From d3adcff0f19ff7688f8a233d9a5954f26d5f5fa5 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 2 Nov 2023 08:18:32 +0000 Subject: [PATCH] Merge pull request #15544 from overleaf/bg-misc-use-literal-paths Replace APP_ROOT and other variables with literal paths in web imports GitOrigin-RevId: 138f03ad9355c8c6c92a206b0e54573234a6f65d --- .../app/src/Features/LinkedFiles/LinkedFilesErrors.js | 2 +- .../Features/ThirdPartyDataStore/TpdsUpdateSender.js | 2 +- .../src/Features/User/ThirdPartyIdentityManager.js | 9 ++++----- services/web/app/src/infrastructure/ExpressLocals.js | 2 +- .../test/acceptance/src/ProjectStructureTests.js | 2 +- .../launchpad/test/acceptance/src/LaunchpadTests.js | 3 +-- .../server-ce-scripts/test/acceptance/src/Init.js | 2 +- services/web/scripts/ukamf/check-certs.js | 2 +- .../acceptance/src/ProjectStructureMongoLockTest.js | 11 +++++------ .../web/test/acceptance/src/ProjectStructureTests.js | 2 +- services/web/test/acceptance/src/TpdsUpdateTests.js | 2 +- .../acceptance/src/helpers/DeletedSubscription.js | 2 +- services/web/test/acceptance/src/helpers/InitApp.js | 2 +- .../web/test/acceptance/src/helpers/Subscription.js | 2 +- .../src/Authorization/AuthorizationMiddlewareTests.js | 2 +- .../test/unit/src/Docstore/DocstoreManagerTests.js | 2 +- 16 files changed, 23 insertions(+), 26 deletions(-) diff --git a/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js b/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js index 7737184d03..f74152f3ce 100644 --- a/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js +++ b/services/web/app/src/Features/LinkedFiles/LinkedFilesErrors.js @@ -1,4 +1,4 @@ -const { BackwardCompatibleError } = require('../Errors/Errors.js') +const { BackwardCompatibleError } = require('../Errors/Errors') class UrlFetchFailedError extends BackwardCompatibleError {} diff --git a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js index d7e18bfe0c..6713d5cfd2 100644 --- a/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js +++ b/services/web/app/src/Features/ThirdPartyDataStore/TpdsUpdateSender.js @@ -9,7 +9,7 @@ const settings = require('@overleaf/settings') const CollaboratorsGetter = require('../Collaborators/CollaboratorsGetter').promises -const UserGetter = require('../User/UserGetter.js').promises +const UserGetter = require('../User/UserGetter').promises const tpdsUrl = _.get(settings, ['apis', 'thirdPartyDataStore', 'url']) diff --git a/services/web/app/src/Features/User/ThirdPartyIdentityManager.js b/services/web/app/src/Features/User/ThirdPartyIdentityManager.js index 4994ac0d2d..d9aebb172b 100644 --- a/services/web/app/src/Features/User/ThirdPartyIdentityManager.js +++ b/services/web/app/src/Features/User/ThirdPartyIdentityManager.js @@ -1,13 +1,12 @@ -const APP_ROOT = '../../../../app/src' -const UserAuditLogHandler = require(`${APP_ROOT}/Features/User/UserAuditLogHandler`) -const EmailHandler = require(`${APP_ROOT}/Features/Email/EmailHandler`) -const EmailOptionsHelper = require(`${APP_ROOT}/Features/Email/EmailOptionsHelper`) +const UserAuditLogHandler = require('../../../../app/src/Features/User/UserAuditLogHandler') +const EmailHandler = require('../../../../app/src/Features/Email/EmailHandler') +const EmailOptionsHelper = require('../../../../app/src/Features/Email/EmailOptionsHelper') const Errors = require('../Errors/Errors') const _ = require('lodash') const logger = require('@overleaf/logger') const OError = require('@overleaf/o-error') const settings = require('@overleaf/settings') -const { User } = require(`${APP_ROOT}/models/User`) +const { User } = require('../../../../app/src/models/User') const { promisifyAll } = require('@overleaf/promise-utils') const oauthProviders = settings.oauthProviders || {} diff --git a/services/web/app/src/infrastructure/ExpressLocals.js b/services/web/app/src/infrastructure/ExpressLocals.js index f758ecb519..9f1759519a 100644 --- a/services/web/app/src/infrastructure/ExpressLocals.js +++ b/services/web/app/src/infrastructure/ExpressLocals.js @@ -28,7 +28,7 @@ let webpackManifest switch (process.env.NODE_ENV) { case 'production': // Only load webpack manifest file in production. - webpackManifest = require(`../../../public/manifest.json`) + webpackManifest = require('../../../public/manifest.json') break case 'development': { // In dev, fetch the manifest from the webpack container. diff --git a/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js b/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js index 798c168eeb..2d9e23c79b 100644 --- a/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js +++ b/services/web/modules/history-v1/test/acceptance/src/ProjectStructureTests.js @@ -5,7 +5,7 @@ const fs = require('fs') const Settings = require('@overleaf/settings') const _ = require('underscore') -const ProjectGetter = require('../../../../../app/src/Features/Project/ProjectGetter.js') +const ProjectGetter = require('../../../../../app/src/Features/Project/ProjectGetter') const User = require('../../../../../test/acceptance/src/helpers/User') const MockDocUpdaterApiClass = require('../../../../../test/acceptance/src/mocks/MockDocUpdaterApi') diff --git a/services/web/modules/launchpad/test/acceptance/src/LaunchpadTests.js b/services/web/modules/launchpad/test/acceptance/src/LaunchpadTests.js index 15d2d82253..75730a97d6 100644 --- a/services/web/modules/launchpad/test/acceptance/src/LaunchpadTests.js +++ b/services/web/modules/launchpad/test/acceptance/src/LaunchpadTests.js @@ -1,7 +1,6 @@ const { expect } = require('chai') const cheerio = require('cheerio') -const WEB_PATH = '../../../../..' -const UserHelper = require(`${WEB_PATH}/test/acceptance/src/helpers/UserHelper`) +const UserHelper = require('../../../../../test/acceptance/src/helpers/UserHelper') describe('Launchpad', function () { const adminEmail = 'admin@example.com' diff --git a/services/web/modules/server-ce-scripts/test/acceptance/src/Init.js b/services/web/modules/server-ce-scripts/test/acceptance/src/Init.js index 00781b805e..3757f183ac 100644 --- a/services/web/modules/server-ce-scripts/test/acceptance/src/Init.js +++ b/services/web/modules/server-ce-scripts/test/acceptance/src/Init.js @@ -1 +1 @@ -require(`../../../../../test/acceptance/src/helpers/InitApp`) +require('../../../../../test/acceptance/src/helpers/InitApp') diff --git a/services/web/scripts/ukamf/check-certs.js b/services/web/scripts/ukamf/check-certs.js index bb7ae4d8db..b9dc11450c 100644 --- a/services/web/scripts/ukamf/check-certs.js +++ b/services/web/scripts/ukamf/check-certs.js @@ -12,7 +12,7 @@ const { Certificate } = require('@fidm/x509') const UKAMFDB = require('./ukamf-db') -const V1Api = require(`../../app/src/Features/V1/V1Api`).promises +const V1Api = require('../../app/src/Features/V1/V1Api').promises const { db, waitForDb } = require('../../app/src/infrastructure/mongodb') const moment = require('moment') diff --git a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js index d1f5ccb8c9..741fa00b44 100644 --- a/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js +++ b/services/web/test/acceptance/src/ProjectStructureMongoLockTest.js @@ -11,13 +11,12 @@ * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -const APP_PATH = '../../../app/src' -const LockManager = require(`${APP_PATH}/infrastructure/LockManager`) -const ProjectCreationHandler = require(`${APP_PATH}/Features/Project/ProjectCreationHandler.js`) -const ProjectGetter = require(`${APP_PATH}/Features/Project/ProjectGetter.js`) -const ProjectEntityMongoUpdateHandler = require(`${APP_PATH}/Features/Project/ProjectEntityMongoUpdateHandler.js`) -const UserCreator = require(`${APP_PATH}/Features/User/UserCreator.js`) +const LockManager = require('../../../app/src/infrastructure/LockManager') +const ProjectCreationHandler = require('../../../app/src/Features/Project/ProjectCreationHandler') +const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter') +const ProjectEntityMongoUpdateHandler = require('../../../app/src/Features/Project/ProjectEntityMongoUpdateHandler') +const UserCreator = require('../../../app/src/Features/User/UserCreator') const { expect } = require('chai') const _ = require('lodash') diff --git a/services/web/test/acceptance/src/ProjectStructureTests.js b/services/web/test/acceptance/src/ProjectStructureTests.js index be01252151..9386e88bde 100644 --- a/services/web/test/acceptance/src/ProjectStructureTests.js +++ b/services/web/test/acceptance/src/ProjectStructureTests.js @@ -4,7 +4,7 @@ const Path = require('path') const fs = require('fs') const { Project } = require('../../../app/src/models/Project') -const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter.js') +const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter') const User = require('./helpers/User') const MockDocStoreApiClass = require('./mocks/MockDocstoreApi') diff --git a/services/web/test/acceptance/src/TpdsUpdateTests.js b/services/web/test/acceptance/src/TpdsUpdateTests.js index 998ef0004a..877df410b8 100644 --- a/services/web/test/acceptance/src/TpdsUpdateTests.js +++ b/services/web/test/acceptance/src/TpdsUpdateTests.js @@ -1,5 +1,5 @@ const { expect } = require('chai') -const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter.js') +const ProjectGetter = require('../../../app/src/Features/Project/ProjectGetter') const request = require('./helpers/request') const User = require('./helpers/User') diff --git a/services/web/test/acceptance/src/helpers/DeletedSubscription.js b/services/web/test/acceptance/src/helpers/DeletedSubscription.js index 9c73801cf5..6ce678f677 100644 --- a/services/web/test/acceptance/src/helpers/DeletedSubscription.js +++ b/services/web/test/acceptance/src/helpers/DeletedSubscription.js @@ -4,7 +4,7 @@ const SubscriptionUpdater = require('../../../../app/src/Features/Subscription/S const SubscriptionModel = require('../../../../app/src/models/Subscription').Subscription const DeletedSubscriptionModel = - require(`../../../../app/src/models/DeletedSubscription`).DeletedSubscription + require('../../../../app/src/models/DeletedSubscription').DeletedSubscription class DeletedSubscription { constructor(options = {}) { diff --git a/services/web/test/acceptance/src/helpers/InitApp.js b/services/web/test/acceptance/src/helpers/InitApp.js index d5e0bcf218..bda55d1504 100644 --- a/services/web/test/acceptance/src/helpers/InitApp.js +++ b/services/web/test/acceptance/src/helpers/InitApp.js @@ -1,4 +1,4 @@ -const App = require('../../../../app.js') +const App = require('../../../../app') const QueueWorkers = require('../../../../app/src/infrastructure/QueueWorkers') const MongoHelper = require('./MongoHelper') const RedisHelper = require('./RedisHelper') diff --git a/services/web/test/acceptance/src/helpers/Subscription.js b/services/web/test/acceptance/src/helpers/Subscription.js index 030e29e664..17c3acffbc 100644 --- a/services/web/test/acceptance/src/helpers/Subscription.js +++ b/services/web/test/acceptance/src/helpers/Subscription.js @@ -7,7 +7,7 @@ const PermissionsManager = require('../../../../app/src/Features/Authorization/P const SubscriptionModel = require('../../../../app/src/models/Subscription').Subscription const DeletedSubscriptionModel = - require(`../../../../app/src/models/DeletedSubscription`).DeletedSubscription + require('../../../../app/src/models/DeletedSubscription').DeletedSubscription class Subscription { constructor(options = {}) { diff --git a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js index 7327fb1993..16d0bd1059 100644 --- a/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js +++ b/services/web/test/unit/src/Authorization/AuthorizationMiddlewareTests.js @@ -2,7 +2,7 @@ const sinon = require('sinon') const { expect } = require('chai') const SandboxedModule = require('sandboxed-module') const { ObjectId } = require('mongodb') -const Errors = require('../../../../app/src/Features/Errors/Errors.js') +const Errors = require('../../../../app/src/Features/Errors/Errors') const MODULE_PATH = '../../../../app/src/Features/Authorization/AuthorizationMiddleware.js' diff --git a/services/web/test/unit/src/Docstore/DocstoreManagerTests.js b/services/web/test/unit/src/Docstore/DocstoreManagerTests.js index e575ce7e0c..20f1e4c1ea 100644 --- a/services/web/test/unit/src/Docstore/DocstoreManagerTests.js +++ b/services/web/test/unit/src/Docstore/DocstoreManagerTests.js @@ -1,7 +1,7 @@ const sinon = require('sinon') const modulePath = '../../../../app/src/Features/Docstore/DocstoreManager' const SandboxedModule = require('sandboxed-module') -const Errors = require('../../../../app/src/Features/Errors/Errors.js') +const Errors = require('../../../../app/src/Features/Errors/Errors') const tk = require('timekeeper') describe('DocstoreManager', function () {