diff --git a/test/api/unit/libs/analyticsService.test.js b/test/api/unit/libs/analyticsService.test.js index e5c7819478..055ac95028 100644 --- a/test/api/unit/libs/analyticsService.test.js +++ b/test/api/unit/libs/analyticsService.test.js @@ -1,5 +1,5 @@ /* eslint-disable camelcase */ -import analyticsService from '../../../../website/server/libs/analyticsService'; +import * as analyticsService from '../../../../website/server/libs/analyticsService'; import Amplitude from 'amplitude'; import { Visitor } from 'universal-analytics'; diff --git a/test/api/unit/libs/cron.test.js b/test/api/unit/libs/cron.test.js index 61e7499393..30e6d6adb4 100644 --- a/test/api/unit/libs/cron.test.js +++ b/test/api/unit/libs/cron.test.js @@ -6,7 +6,7 @@ import { recoverCron, cron } from '../../../../website/server/libs/cron'; import { model as User } from '../../../../website/server/models/user'; import * as Tasks from '../../../../website/server/models/task'; import common from '../../../../website/common'; -import analytics from '../../../../website/server/libs/analyticsService'; +import * as analytics from '../../../../website/server/libs/analyticsService'; // const scoreTask = common.ops.scoreTask; diff --git a/test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js b/test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js index 65d78399eb..d89b3cc32d 100644 --- a/test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js +++ b/test/api/unit/libs/payments/group-plans/group-payments-cancel.test.js @@ -1,7 +1,7 @@ import moment from 'moment'; import * as sender from '../../../../../../website/server/libs/email'; -import * as api from '../../../../../../website/server/libs/payments/payments'; +import api from '../../../../../../website/server/libs/payments/payments'; import { model as User } from '../../../../../../website/server/models/user'; import { model as Group } from '../../../../../../website/server/models/group'; import { diff --git a/test/api/unit/libs/payments/group-plans/group-payments-create.test.js b/test/api/unit/libs/payments/group-plans/group-payments-create.test.js index 3e57126ef0..b16716cd2e 100644 --- a/test/api/unit/libs/payments/group-plans/group-payments-create.test.js +++ b/test/api/unit/libs/payments/group-plans/group-payments-create.test.js @@ -3,7 +3,7 @@ import stripeModule from 'stripe'; import nconf from 'nconf'; import * as sender from '../../../../../../website/server/libs/email'; -import * as api from '../../../../../../website/server/libs/payments/payments'; +import api from '../../../../../../website/server/libs/payments/payments'; import amzLib from '../../../../../../website/server/libs/payments/amazon'; import paypalPayments from '../../../../../../website/server/libs/payments/paypal'; import stripePayments from '../../../../../../website/server/libs/payments/stripe'; diff --git a/test/api/unit/libs/payments/payments.test.js b/test/api/unit/libs/payments/payments.test.js index f37c5c511b..48b05d4cd5 100644 --- a/test/api/unit/libs/payments/payments.test.js +++ b/test/api/unit/libs/payments/payments.test.js @@ -1,9 +1,9 @@ import moment from 'moment'; import * as sender from '../../../../../website/server/libs/email'; -import * as api from '../../../../../website/server/libs/payments/payments'; -import analytics from '../../../../../website/server/libs/analyticsService'; -import notifications from '../../../../../website/server/libs/pushNotifications'; +import api from '../../../../../website/server/libs/payments/payments'; +import * as analytics from '../../../../../website/server/libs/analyticsService'; +import * as notifications from '../../../../../website/server/libs/pushNotifications'; import { model as User } from '../../../../../website/server/models/user'; import { translate as t } from '../../../../helpers/api-integration/v3'; import { diff --git a/test/api/unit/libs/slack.js b/test/api/unit/libs/slack.js index 4b6acdf695..3780eb399a 100644 --- a/test/api/unit/libs/slack.js +++ b/test/api/unit/libs/slack.js @@ -1,7 +1,7 @@ /* eslint-disable camelcase */ import { IncomingWebhook } from '@slack/client'; import requireAgain from 'require-again'; -import slack from '../../../../website/server/libs/slack'; +import * as slack from '../../../../website/server/libs/slack'; import logger from '../../../../website/server/libs/logger'; import { TAVERN_ID } from '../../../../website/server/models/group'; import nconf from 'nconf'; diff --git a/test/api/unit/middlewares/analytics.test.js b/test/api/unit/middlewares/analytics.test.js index dce6bab20d..8865c11d0b 100644 --- a/test/api/unit/middlewares/analytics.test.js +++ b/test/api/unit/middlewares/analytics.test.js @@ -4,7 +4,7 @@ import { generateReq, generateNext, } from '../../../helpers/api-unit.helper'; -import analyticsService from '../../../../website/server/libs/analyticsService'; +import * as analyticsService from '../../../../website/server/libs/analyticsService'; import nconf from 'nconf'; import requireAgain from 'require-again'; @@ -19,7 +19,7 @@ describe('analytics middleware', () => { }); it('attaches analytics object res.locals', () => { - let attachAnalytics = requireAgain(pathToAnalyticsMiddleware); + let attachAnalytics = requireAgain(pathToAnalyticsMiddleware).default; attachAnalytics(req, res, next); @@ -28,7 +28,7 @@ describe('analytics middleware', () => { it('attaches stubbed methods for non-prod environments', () => { sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(false); - let attachAnalytics = requireAgain(pathToAnalyticsMiddleware); + let attachAnalytics = requireAgain(pathToAnalyticsMiddleware).default; attachAnalytics(req, res, next); @@ -39,7 +39,7 @@ describe('analytics middleware', () => { it('attaches real methods for prod environments', () => { sandbox.stub(nconf, 'get').withArgs('IS_PROD').returns(true); - let attachAnalytics = requireAgain(pathToAnalyticsMiddleware); + let attachAnalytics = requireAgain(pathToAnalyticsMiddleware).default; attachAnalytics(req, res, next); diff --git a/test/api/unit/middlewares/cronMiddleware.js b/test/api/unit/middlewares/cronMiddleware.js index 28d4135e25..ca48110393 100644 --- a/test/api/unit/middlewares/cronMiddleware.js +++ b/test/api/unit/middlewares/cronMiddleware.js @@ -9,7 +9,7 @@ import moment from 'moment'; import { model as User } from '../../../../website/server/models/user'; import { model as Group } from '../../../../website/server/models/group'; import * as Tasks from '../../../../website/server/models/task'; -import analyticsService from '../../../../website/server/libs/analyticsService'; +import * as analyticsService from '../../../../website/server/libs/analyticsService'; import * as cronLib from '../../../../website/server/libs/cron'; import { v4 as generateUUID } from 'uuid'; diff --git a/test/api/unit/middlewares/maintenanceMode.test.js b/test/api/unit/middlewares/maintenanceMode.test.js index df5736bd38..130573c046 100644 --- a/test/api/unit/middlewares/maintenanceMode.test.js +++ b/test/api/unit/middlewares/maintenanceMode.test.js @@ -18,7 +18,7 @@ describe('maintenance mode middleware', () => { it('does not return 503 error when maintenance mode is off', () => { req = generateReq(); sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('false'); - let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware); + let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default; attachMaintenanceMode(req, res, next); @@ -29,7 +29,7 @@ describe('maintenance mode middleware', () => { it('returns 503 error when maintenance mode is on', () => { req = generateReq(); sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('true'); - let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware); + let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default; attachMaintenanceMode(req, res, next); @@ -41,7 +41,7 @@ describe('maintenance mode middleware', () => { it('renders maintenance page when request type is HTML', () => { req = generateReq({headers: {accept: 'text/html'}}); sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('true'); - let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware); + let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default; attachMaintenanceMode(req, res, next); expect(res.render).to.have.been.calledOnce; @@ -50,7 +50,7 @@ describe('maintenance mode middleware', () => { it('sends error message when request type is JSON', () => { req = generateReq({headers: {accept: 'application/json'}}); sandbox.stub(nconf, 'get').withArgs('MAINTENANCE_MODE').returns('true'); - let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware); + let attachMaintenanceMode = requireAgain(pathToMaintenanceModeMiddleware).default; attachMaintenanceMode(req, res, next); expect(res.send).to.have.been.calledOnce; diff --git a/test/api/unit/models/group.test.js b/test/api/unit/models/group.test.js index 0a2b45b571..318e569868 100644 --- a/test/api/unit/models/group.test.js +++ b/test/api/unit/models/group.test.js @@ -10,13 +10,13 @@ import { model as Group, } from '../../../../website/server/models/group'; import { model as User } from '../../../../website/server/models/user'; -import { quests as questScrolls } from '../../../../website/common/script/content'; +import { quests as questScrolls } from '../../../../website/common/script/content/quests'; import { groupChatReceivedWebhook, questActivityWebhook, } from '../../../../website/server/libs/webhook'; import * as email from '../../../../website/server/libs/email'; -import { TAVERN_ID } from '../../../../website/common/script/'; +import { TAVERN_ID } from '../../../../website/common/script/constants'; import shared from '../../../../website/common'; describe('Group Model', () => { diff --git a/website/client/vue.config.js b/website/client/vue.config.js index 5a7d2fd00b..6de846a95c 100644 --- a/website/client/vue.config.js +++ b/website/client/vue.config.js @@ -3,6 +3,7 @@ const webpack = require('webpack'); const nconf = require('nconf'); const setupNconf = require('../../website/server/libs/setupNconf'); const { DuplicatesPlugin } = require("inspectpack/plugin"); +const pkg = require('../../package.json'); let configFile = path.join(path.resolve(__dirname, '../../config.json')); diff --git a/website/server/controllers/api-v3/chat.js b/website/server/controllers/api-v3/chat.js index e72ae98d4c..1d4a9d7b7d 100644 --- a/website/server/controllers/api-v3/chat.js +++ b/website/server/controllers/api-v3/chat.js @@ -10,7 +10,7 @@ import { } from '../../libs/errors'; import { removeFromArray } from '../../libs/collectionManipulators'; import { getUserInfo, getGroupUrl, sendTxn } from '../../libs/email'; -import slack from '../../libs/slack'; +import * as slack from '../../libs/slack'; import { chatReporterFactory } from '../../libs/chatReporting/chatReporterFactory'; import { getAuthorEmailFromMessage} from '../../libs/chat'; import nconf from 'nconf'; diff --git a/website/server/controllers/api-v3/debug.js b/website/server/controllers/api-v3/debug.js index d6ffe3252f..46297f14ea 100644 --- a/website/server/controllers/api-v3/debug.js +++ b/website/server/controllers/api-v3/debug.js @@ -1,9 +1,11 @@ import { authWithHeaders } from '../../middlewares/auth'; import ensureDevelpmentMode from '../../middlewares/ensureDevelpmentMode'; import { BadRequest } from '../../libs/errors'; -import { content } from '../../../common'; +import common from '../../../common'; import _ from 'lodash'; +const content = common.content; + /** * @apiDefine Development Development * These routes only exist while Habitica is in development mode. (Such as running a local instance on your computer) diff --git a/website/server/controllers/api-v3/members.js b/website/server/controllers/api-v3/members.js index 3a010090ab..2c90a12a47 100644 --- a/website/server/controllers/api-v3/members.js +++ b/website/server/controllers/api-v3/members.js @@ -19,9 +19,11 @@ import { sendTxn as sendTxnEmail, } from '../../libs/email'; import { sendNotification as sendPushNotification } from '../../libs/pushNotifications'; -import { achievements } from '../../../../website/common/'; +import common from '../../../../website/common/'; import {sentMessage} from '../../libs/inbox'; +const achievements = common.achievements; + let api = {}; /** diff --git a/website/server/controllers/api-v3/quests.js b/website/server/controllers/api-v3/quests.js index ee6da8afcf..0fd401354d 100644 --- a/website/server/controllers/api-v3/quests.js +++ b/website/server/controllers/api-v3/quests.js @@ -1,6 +1,6 @@ import _ from 'lodash'; import { authWithHeaders } from '../../middlewares/auth'; -import analytics from '../../libs/analyticsService'; +import * as analytics from '../../libs/analyticsService'; import { model as Group, basicFields as basicGroupFields, diff --git a/website/server/controllers/api-v3/shops.js b/website/server/controllers/api-v3/shops.js index 16dbb497ec..b4e3c6d568 100644 --- a/website/server/controllers/api-v3/shops.js +++ b/website/server/controllers/api-v3/shops.js @@ -1,5 +1,7 @@ import { authWithHeaders } from '../../middlewares/auth'; -import { shops } from '../../../common/'; +import common from '../../../common/'; + +const shops = common.shops; let api = {}; diff --git a/website/server/libs/analyticsService.js b/website/server/libs/analyticsService.js index 1e13f5277c..0f3b1f8ff7 100644 --- a/website/server/libs/analyticsService.js +++ b/website/server/libs/analyticsService.js @@ -8,7 +8,7 @@ import { omit, toArray, } from 'lodash'; -import { content as Content } from '../../common'; +import common from '../../common'; import logger from './logger'; const AMPLITUDE_TOKEN = nconf.get('AMPLITUDE_KEY'); @@ -28,6 +28,8 @@ if (AMPLITUDE_TOKEN) amplitude = new Amplitude(AMPLITUDE_TOKEN); let ga = googleAnalytics(GA_TOKEN); +const Content = common.content; + function _lookUpItemName (itemKey) { if (!itemKey) return; diff --git a/website/server/libs/chatReporting/groupChatReporter.js b/website/server/libs/chatReporting/groupChatReporter.js index b41f142579..ab7e23f7fc 100644 --- a/website/server/libs/chatReporting/groupChatReporter.js +++ b/website/server/libs/chatReporting/groupChatReporter.js @@ -7,7 +7,7 @@ import { NotFound, } from '../errors'; import { sendTxn } from '../email'; -import slack from '../slack'; +import * as slack from '../slack'; import { model as Group } from '../../models/group'; import { chatModel as Chat } from '../../models/message'; import apiError from '../apiError'; diff --git a/website/server/libs/chatReporting/inboxChatReporter.js b/website/server/libs/chatReporting/inboxChatReporter.js index 207b570fd3..059d200db2 100644 --- a/website/server/libs/chatReporting/inboxChatReporter.js +++ b/website/server/libs/chatReporting/inboxChatReporter.js @@ -6,7 +6,7 @@ import { BadRequest, } from '../errors'; import { getUserInfo, sendTxn} from '../email'; -import slack from '../slack'; +import * as slack from '../slack'; import apiError from '../apiError'; import * as inboxLib from '../inbox'; diff --git a/website/server/libs/payments/gems.js b/website/server/libs/payments/gems.js index 1751effcba..9ee9546e41 100644 --- a/website/server/libs/payments/gems.js +++ b/website/server/libs/payments/gems.js @@ -1,4 +1,4 @@ -import analytics from '../analyticsService'; +import * as analytics from '../analyticsService'; import { getUserInfo, sendTxn as txnEmail, diff --git a/website/server/libs/payments/subscriptions.js b/website/server/libs/payments/subscriptions.js index b209e6b0b6..1e606c1a47 100644 --- a/website/server/libs/payments/subscriptions.js +++ b/website/server/libs/payments/subscriptions.js @@ -1,8 +1,8 @@ import _ from 'lodash'; import moment from 'moment'; -import analytics from '../analyticsService'; -import slack from '../slack'; +import * as analytics from '../analyticsService'; +import * as slack from '../slack'; import { getUserInfo, sendTxn as txnEmail,