@hubspot/cli 7.7.19-experimental.2 → 7.7.20-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/__tests__/migrate.test.d.ts +1 -0
- package/api/__tests__/migrate.test.js +183 -0
- package/commands/__tests__/account.test.d.ts +1 -0
- package/commands/__tests__/account.test.js +74 -0
- package/commands/__tests__/auth.test.d.ts +1 -0
- package/commands/__tests__/auth.test.js +43 -0
- package/commands/__tests__/cms.test.d.ts +1 -0
- package/commands/__tests__/cms.test.js +49 -0
- package/commands/__tests__/config.test.d.ts +1 -0
- package/commands/__tests__/config.test.js +49 -0
- package/commands/__tests__/create.test.d.ts +1 -0
- package/commands/__tests__/create.test.js +38 -0
- package/commands/__tests__/customObject.test.d.ts +1 -0
- package/commands/__tests__/customObject.test.js +54 -0
- package/commands/__tests__/doctor.test.d.ts +1 -0
- package/commands/__tests__/doctor.test.js +139 -0
- package/commands/__tests__/feedback.test.d.ts +1 -0
- package/commands/__tests__/feedback.test.js +62 -0
- package/commands/__tests__/fetch.test.d.ts +1 -0
- package/commands/__tests__/fetch.test.js +56 -0
- package/commands/__tests__/filemanager.test.d.ts +1 -0
- package/commands/__tests__/filemanager.test.js +50 -0
- package/commands/__tests__/function.test.d.ts +1 -0
- package/commands/__tests__/function.test.js +51 -0
- package/commands/__tests__/getStarted.test.d.ts +1 -0
- package/commands/__tests__/getStarted.test.js +170 -0
- package/commands/__tests__/hubdb.test.d.ts +1 -0
- package/commands/__tests__/hubdb.test.js +55 -0
- package/commands/__tests__/init.test.d.ts +1 -0
- package/commands/__tests__/init.test.js +47 -0
- package/commands/__tests__/lint.test.d.ts +1 -0
- package/commands/__tests__/lint.test.js +38 -0
- package/commands/__tests__/list.test.d.ts +1 -0
- package/commands/__tests__/list.test.js +47 -0
- package/commands/__tests__/logs.test.d.ts +1 -0
- package/commands/__tests__/logs.test.js +70 -0
- package/commands/__tests__/mcp.test.d.ts +1 -0
- package/commands/__tests__/mcp.test.js +51 -0
- package/commands/__tests__/mv.test.d.ts +1 -0
- package/commands/__tests__/mv.test.js +84 -0
- package/commands/__tests__/open.test.d.ts +1 -0
- package/commands/__tests__/open.test.js +96 -0
- package/commands/__tests__/project.test.d.ts +1 -0
- package/commands/__tests__/project.test.js +100 -0
- package/commands/__tests__/remove.test.d.ts +1 -0
- package/commands/__tests__/remove.test.js +77 -0
- package/commands/__tests__/sandbox.test.d.ts +1 -0
- package/commands/__tests__/sandbox.test.js +49 -0
- package/commands/__tests__/secret.test.d.ts +1 -0
- package/commands/__tests__/secret.test.js +54 -0
- package/commands/__tests__/testAccount.test.d.ts +1 -0
- package/commands/__tests__/testAccount.test.js +60 -0
- package/commands/__tests__/theme.test.d.ts +1 -0
- package/commands/__tests__/theme.test.js +52 -0
- package/commands/account/__tests__/auth.test.d.ts +1 -0
- package/commands/account/__tests__/auth.test.js +31 -0
- package/commands/account/__tests__/clean.test.d.ts +1 -0
- package/commands/account/__tests__/clean.test.js +33 -0
- package/commands/account/__tests__/createOverride.test.d.ts +1 -0
- package/commands/account/__tests__/createOverride.test.js +37 -0
- package/commands/account/__tests__/info.test.d.ts +1 -0
- package/commands/account/__tests__/info.test.js +33 -0
- package/commands/account/__tests__/list.test.d.ts +1 -0
- package/commands/account/__tests__/list.test.js +33 -0
- package/commands/account/__tests__/remove.test.d.ts +1 -0
- package/commands/account/__tests__/remove.test.js +41 -0
- package/commands/account/__tests__/removeOverride.d.ts +1 -0
- package/commands/account/__tests__/removeOverride.js +30 -0
- package/commands/account/__tests__/rename.test.d.ts +1 -0
- package/commands/account/__tests__/rename.test.js +47 -0
- package/commands/account/__tests__/use.test.d.ts +1 -0
- package/commands/account/__tests__/use.test.js +37 -0
- package/commands/app/__tests__/migrate.test.d.ts +1 -0
- package/commands/app/__tests__/migrate.test.js +129 -0
- package/commands/app/secret/__tests__/add.test.d.ts +1 -0
- package/commands/app/secret/__tests__/add.test.js +33 -0
- package/commands/app/secret/__tests__/delete.test.d.ts +1 -0
- package/commands/app/secret/__tests__/delete.test.js +33 -0
- package/commands/app/secret/__tests__/list.test.d.ts +1 -0
- package/commands/app/secret/__tests__/list.test.js +30 -0
- package/commands/app/secret/__tests__/update.test.d.ts +1 -0
- package/commands/app/secret/__tests__/update.test.js +33 -0
- package/commands/app.js +1 -6
- package/commands/customObject/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/__tests__/create.test.js +45 -0
- package/commands/customObject/__tests__/schema.test.d.ts +1 -0
- package/commands/customObject/__tests__/schema.test.js +58 -0
- package/commands/customObject/schema/__tests__/create.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/create.test.js +33 -0
- package/commands/customObject/schema/__tests__/delete.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/delete.test.js +47 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch-all.test.js +46 -0
- package/commands/customObject/schema/__tests__/fetch.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/fetch.test.js +50 -0
- package/commands/customObject/schema/__tests__/list.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/list.test.js +34 -0
- package/commands/customObject/schema/__tests__/update.test.d.ts +1 -0
- package/commands/customObject/schema/__tests__/update.test.js +45 -0
- package/commands/fetch.js +0 -1
- package/commands/filemanager/__tests__/fetch.test.d.ts +1 -0
- package/commands/filemanager/__tests__/fetch.test.js +37 -0
- package/commands/filemanager/__tests__/upload.test.d.ts +1 -0
- package/commands/filemanager/__tests__/upload.test.js +35 -0
- package/commands/hubdb/__tests__/clear.test.d.ts +1 -0
- package/commands/hubdb/__tests__/clear.test.js +33 -0
- package/commands/hubdb/__tests__/create.test.d.ts +1 -0
- package/commands/hubdb/__tests__/create.test.js +33 -0
- package/commands/hubdb/__tests__/delete.test.d.ts +1 -0
- package/commands/hubdb/__tests__/delete.test.js +33 -0
- package/commands/hubdb/__tests__/fetch.test.d.ts +1 -0
- package/commands/hubdb/__tests__/fetch.test.js +33 -0
- package/commands/hubdb/__tests__/list.test.d.ts +1 -0
- package/commands/hubdb/__tests__/list.test.js +101 -0
- package/commands/logs.js +0 -1
- package/commands/mcp/__tests__/setup.test.d.ts +1 -0
- package/commands/mcp/__tests__/setup.test.js +31 -0
- package/commands/mcp/__tests__/start.test.d.ts +1 -0
- package/commands/mcp/__tests__/start.test.js +32 -0
- package/commands/project/__tests__/add.test.d.ts +1 -0
- package/commands/project/__tests__/add.test.js +48 -0
- package/commands/project/__tests__/create.test.d.ts +1 -0
- package/commands/project/__tests__/create.test.js +45 -0
- package/commands/project/__tests__/deploy.test.d.ts +1 -0
- package/commands/project/__tests__/deploy.test.js +344 -0
- package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
- package/commands/project/__tests__/devUnifiedFlow.test.js +419 -0
- package/commands/project/__tests__/download.test.d.ts +1 -0
- package/commands/project/__tests__/download.test.js +44 -0
- package/commands/project/__tests__/fixtures/exampleProject.json +33 -0
- package/commands/project/__tests__/installDeps.test.d.ts +1 -0
- package/commands/project/__tests__/installDeps.test.js +180 -0
- package/commands/project/__tests__/listBuilds.test.d.ts +1 -0
- package/commands/project/__tests__/listBuilds.test.js +43 -0
- package/commands/project/__tests__/logs.test.d.ts +1 -0
- package/commands/project/__tests__/logs.test.js +246 -0
- package/commands/project/__tests__/migrate.test.d.ts +1 -0
- package/commands/project/__tests__/migrate.test.js +116 -0
- package/commands/project/__tests__/migrateApp.test.d.ts +1 -0
- package/commands/project/__tests__/migrateApp.test.js +87 -0
- package/commands/project/__tests__/open.test.d.ts +1 -0
- package/commands/project/__tests__/open.test.js +44 -0
- package/commands/project/__tests__/profile.test.d.ts +1 -0
- package/commands/project/__tests__/profile.test.js +47 -0
- package/commands/project/__tests__/upload.test.d.ts +1 -0
- package/commands/project/__tests__/upload.test.js +48 -0
- package/commands/project/__tests__/watch.test.d.ts +1 -0
- package/commands/project/__tests__/watch.test.js +40 -0
- package/commands/project/dev/unifiedFlow.js +1 -1
- package/commands/sandbox/__tests__/create.test.d.ts +1 -0
- package/commands/sandbox/__tests__/create.test.js +36 -0
- package/commands/sandbox/__tests__/delete.test.d.ts +1 -0
- package/commands/sandbox/__tests__/delete.test.js +36 -0
- package/commands/secret/__tests__/addSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/addSecret.test.js +34 -0
- package/commands/secret/__tests__/deleteSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/deleteSecret.test.js +46 -0
- package/commands/secret/__tests__/listSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/listSecret.test.js +34 -0
- package/commands/secret/__tests__/updateSecret.test.d.ts +1 -0
- package/commands/secret/__tests__/updateSecret.test.js +34 -0
- package/commands/testAccount/__tests__/create.test.d.ts +1 -0
- package/commands/testAccount/__tests__/create.test.js +38 -0
- package/commands/testAccount/__tests__/createConfig.test.d.ts +1 -0
- package/commands/testAccount/__tests__/createConfig.test.js +40 -0
- package/commands/testAccount/__tests__/delete.test.d.ts +1 -0
- package/commands/testAccount/__tests__/delete.test.js +36 -0
- package/commands/testAccount/create.js +24 -14
- package/commands/theme/__tests__/generate-selectors.test.d.ts +1 -0
- package/commands/theme/__tests__/generate-selectors.test.js +33 -0
- package/commands/theme/__tests__/marketplace-validate.test.d.ts +1 -0
- package/commands/theme/__tests__/marketplace-validate.test.js +41 -0
- package/commands/theme/__tests__/preview.test.d.ts +1 -0
- package/commands/theme/__tests__/preview.test.js +65 -0
- package/lang/en.d.ts +6 -65
- package/lang/en.js +6 -65
- package/lib/__tests__/accountTypes.test.d.ts +1 -0
- package/lib/__tests__/accountTypes.test.js +100 -0
- package/lib/__tests__/buildAccount.test.d.ts +1 -0
- package/lib/__tests__/buildAccount.test.js +231 -0
- package/lib/__tests__/commonOpts.test.d.ts +1 -0
- package/lib/__tests__/commonOpts.test.js +87 -0
- package/lib/__tests__/dependencyManagement.test.d.ts +1 -0
- package/lib/__tests__/dependencyManagement.test.js +180 -0
- package/lib/__tests__/developerTestAccounts.test.d.ts +1 -0
- package/lib/__tests__/developerTestAccounts.test.js +180 -0
- package/lib/__tests__/hasFeature.test.d.ts +1 -0
- package/lib/__tests__/hasFeature.test.js +37 -0
- package/lib/__tests__/npm.test.d.ts +1 -0
- package/lib/__tests__/npm.test.js +62 -0
- package/lib/__tests__/oauth.test.d.ts +1 -0
- package/lib/__tests__/oauth.test.js +113 -0
- package/lib/__tests__/parsing.test.d.ts +1 -0
- package/lib/__tests__/parsing.test.js +36 -0
- package/lib/__tests__/polling.test.d.ts +1 -0
- package/lib/__tests__/polling.test.js +78 -0
- package/lib/__tests__/process.test.d.ts +1 -0
- package/lib/__tests__/process.test.js +90 -0
- package/lib/__tests__/projectProfiles.test.d.ts +1 -0
- package/lib/__tests__/projectProfiles.test.js +134 -0
- package/lib/__tests__/sandboxSync.test.d.ts +1 -0
- package/lib/__tests__/sandboxSync.test.js +131 -0
- package/lib/__tests__/sandboxes.test.d.ts +1 -0
- package/lib/__tests__/sandboxes.test.js +148 -0
- package/lib/__tests__/serverlessLogs.test.d.ts +1 -0
- package/lib/__tests__/serverlessLogs.test.js +154 -0
- package/lib/__tests__/usageTracking.test.d.ts +1 -0
- package/lib/__tests__/usageTracking.test.js +171 -0
- package/lib/__tests__/validation.test.d.ts +1 -0
- package/lib/__tests__/validation.test.js +145 -0
- package/lib/__tests__/yargsUtils.test.d.ts +1 -0
- package/lib/__tests__/yargsUtils.test.js +74 -0
- package/lib/app/__tests__/migrate.test.d.ts +1 -0
- package/lib/app/__tests__/migrate.test.js +495 -0
- package/lib/app/__tests__/migrate_legacy.test.d.ts +1 -0
- package/lib/app/__tests__/migrate_legacy.test.js +136 -0
- package/lib/buildAccount.d.ts +1 -7
- package/lib/buildAccount.js +4 -54
- package/lib/doctor/Diagnosis.js +11 -11
- package/lib/doctor/Doctor.js +42 -42
- package/lib/doctor/__tests__/Diagnosis.test.d.ts +1 -0
- package/lib/doctor/__tests__/Diagnosis.test.js +87 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +1 -0
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +172 -0
- package/lib/doctor/__tests__/Doctor.test.d.ts +1 -0
- package/lib/doctor/__tests__/Doctor.test.js +398 -0
- package/lib/mcp/setup.js +18 -2
- package/lib/middleware/__test__/configMiddleware.test.js +12 -12
- package/lib/middleware/__test__/gitMiddleware.test.js +4 -4
- package/lib/middleware/__test__/notificationsMiddleware.test.js +2 -2
- package/lib/middleware/__test__/requestMiddleware.test.js +2 -2
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +7 -7
- package/lib/middleware/notificationsMiddleware.js +16 -13
- package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/AppDevModeInterface.test.js +517 -0
- package/lib/projects/__tests__/LocalDevProcess.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +314 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +1 -0
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +175 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +1 -0
- package/lib/projects/__tests__/ProjectLogsManager.test.js +191 -0
- package/lib/projects/__tests__/buildAndDeploy.test.d.ts +1 -0
- package/lib/projects/__tests__/buildAndDeploy.test.js +25 -0
- package/lib/projects/__tests__/components.test.d.ts +1 -0
- package/lib/projects/__tests__/components.test.js +186 -0
- package/lib/projects/__tests__/projects.test.d.ts +1 -0
- package/lib/projects/__tests__/projects.test.js +89 -0
- package/lib/projects/__tests__/structure.test.d.ts +1 -0
- package/lib/projects/__tests__/structure.test.js +249 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +206 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/v3AddComponent.test.js +190 -0
- package/lib/projects/create/__tests__/legacy.test.d.ts +1 -0
- package/lib/projects/create/__tests__/legacy.test.js +126 -0
- package/lib/projects/create/__tests__/v3.test.d.ts +1 -0
- package/lib/projects/create/__tests__/v3.test.js +80 -0
- package/lib/projects/localDev/DevServerManager.js +0 -1
- package/lib/projects/localDev/helpers.d.ts +1 -1
- package/lib/projects/localDev/helpers.js +2 -2
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/upload.d.ts +1 -2
- package/lib/projects/upload.js +0 -1
- package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +30 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +42 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +10 -9
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +43 -81
- package/lib/schema.js +5 -1
- package/lib/ui/SpinniesManager.js +0 -1
- package/lib/ui/supportHyperlinks.js +2 -2
- package/lib/ui/supportsColor.js +2 -2
- package/lib/utils/hasFlag.d.ts +1 -0
- package/lib/utils/hasFlag.js +15 -0
- package/lib/yargsUtils.d.ts +2 -1
- package/lib/yargsUtils.js +3 -13
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +152 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +129 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/DeployProject.test.js +120 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +127 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +108 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +111 -0
- package/mcp-server/utils/__tests__/command.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/command.test.js +47 -0
- package/mcp-server/utils/__tests__/project.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/project.test.js +81 -0
- package/package.json +8 -8
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -127
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const notificationsMiddleware_1 = require("../notificationsMiddleware");
|
|
4
4
|
describe('lib/middleware/notificationsMiddleware', () => {
|
|
5
5
|
describe('notifyAboutUpdates()', () => {
|
|
6
6
|
it('should safely execute without throwing an error', () => {
|
|
7
|
-
expect(() => notifyAboutUpdates()).not.toThrow();
|
|
7
|
+
expect(() => (0, notificationsMiddleware_1.notifyAboutUpdates)()).not.toThrow();
|
|
8
8
|
});
|
|
9
9
|
});
|
|
10
10
|
});
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const http_1 = require("@hubspot/local-dev-lib/http");
|
|
7
7
|
const requestMiddleware_1 = require("../requestMiddleware");
|
|
8
8
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
9
|
-
|
|
10
|
-
addUserAgentHeader:
|
|
9
|
+
vi.mock('@hubspot/local-dev-lib/http', () => ({
|
|
10
|
+
addUserAgentHeader: vi.fn(),
|
|
11
11
|
}));
|
|
12
12
|
describe('lib/middleware/requestMiddleware', () => {
|
|
13
13
|
describe('setRequestHeaders()', () => {
|
|
@@ -37,17 +37,17 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
|
37
37
|
const exitCodes_1 = require("../../enums/exitCodes");
|
|
38
38
|
const projectsConfig = __importStar(require("../../projects/config"));
|
|
39
39
|
const yargsChecksMiddleware_1 = require("../yargsChecksMiddleware");
|
|
40
|
-
|
|
40
|
+
vi.mock('@hubspot/local-dev-lib/logger', () => ({
|
|
41
41
|
logger: {
|
|
42
|
-
error:
|
|
42
|
+
error: vi.fn(),
|
|
43
43
|
},
|
|
44
44
|
}));
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
i18n:
|
|
45
|
+
vi.mock('../../projects/config');
|
|
46
|
+
vi.mock('../../lang', () => ({
|
|
47
|
+
i18n: vi.fn(key => key),
|
|
48
48
|
}));
|
|
49
|
-
const getIsInProjectSpy =
|
|
50
|
-
const processExitSpy =
|
|
49
|
+
const getIsInProjectSpy = vi.spyOn(projectsConfig, 'getIsInProject');
|
|
50
|
+
const processExitSpy = vi.spyOn(process, 'exit');
|
|
51
51
|
describe('lib/middleware/yargsChecksMiddleware', () => {
|
|
52
52
|
beforeEach(() => {
|
|
53
53
|
processExitSpy.mockImplementation(code => {
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.notifyAboutUpdates = notifyAboutUpdates;
|
|
4
7
|
// Update-notifier is CommonJS, so we need to use require
|
|
5
8
|
const updateNotifier = require('update-notifier');
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
+
const ui_1 = require("../ui");
|
|
12
|
+
const lang_1 = require("../lang");
|
|
10
13
|
const notifier = updateNotifier({
|
|
11
|
-
pkg: { ...
|
|
14
|
+
pkg: { ...package_json_1.default, name: '@hubspot/cli' },
|
|
12
15
|
distTag: 'latest',
|
|
13
16
|
shouldNotifyInNpmScript: true,
|
|
14
17
|
});
|
|
15
18
|
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
16
19
|
function notifyAboutUpdates() {
|
|
17
20
|
notifier.notify({
|
|
18
|
-
message:
|
|
19
|
-
? i18n(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
|
|
21
|
+
message: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
|
|
22
|
+
? (0, lang_1.i18n)(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
|
|
20
23
|
packageName: CMS_CLI_PACKAGE_NAME,
|
|
21
|
-
updateCommand: uiCommandReference('{updateCommand}'),
|
|
24
|
+
updateCommand: (0, ui_1.uiCommandReference)('{updateCommand}'),
|
|
22
25
|
})
|
|
23
|
-
: i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
24
|
-
updateCommand: uiCommandReference('{updateCommand}'),
|
|
26
|
+
: (0, lang_1.i18n)(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
27
|
+
updateCommand: (0, ui_1.uiCommandReference)('{updateCommand}'),
|
|
25
28
|
}),
|
|
26
29
|
defer: false,
|
|
27
30
|
boxenOptions: {
|
|
28
|
-
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
31
|
+
borderColor: ui_1.UI_COLORS.MARIGOLD_DARK,
|
|
29
32
|
margin: 1,
|
|
30
33
|
padding: 1,
|
|
31
34
|
textAlignment: 'center',
|
|
32
35
|
borderStyle: 'round',
|
|
33
|
-
title:
|
|
36
|
+
title: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
|
|
34
37
|
? null
|
|
35
|
-
:
|
|
38
|
+
: chalk_1.default.bold((0, lang_1.i18n)(`commands.generalErrors.updateNotify.notifyTitle`)),
|
|
36
39
|
},
|
|
37
40
|
});
|
|
38
41
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const vitest_1 = require("vitest");
|
|
7
|
+
// Mock the ui-extensions-dev-server module
|
|
8
|
+
vitest_1.vi.mock('@hubspot/ui-extensions-dev-server', () => {
|
|
9
|
+
return {
|
|
10
|
+
DevModeUnifiedInterface: {
|
|
11
|
+
setup: vitest_1.vi.fn().mockResolvedValue(undefined),
|
|
12
|
+
start: vitest_1.vi.fn().mockResolvedValue(undefined),
|
|
13
|
+
fileChange: vitest_1.vi.fn().mockResolvedValue(undefined),
|
|
14
|
+
cleanup: vitest_1.vi.fn().mockResolvedValue(undefined),
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
const localDevAuth_1 = require("@hubspot/local-dev-lib/api/localDevAuth");
|
|
19
|
+
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
20
|
+
const ui_extensions_dev_server_1 = require("@hubspot/ui-extensions-dev-server");
|
|
21
|
+
const portManager_1 = require("@hubspot/local-dev-lib/portManager");
|
|
22
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
23
|
+
const AppDevModeInterface_1 = __importDefault(require("../localDev/AppDevModeInterface"));
|
|
24
|
+
const LocalDevState_1 = __importDefault(require("../localDev/LocalDevState"));
|
|
25
|
+
const LocalDevLogger_1 = __importDefault(require("../localDev/LocalDevLogger"));
|
|
26
|
+
const installAppPrompt_1 = require("../../prompts/installAppPrompt");
|
|
27
|
+
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
28
|
+
const urls_1 = require("../../app/urls");
|
|
29
|
+
const accountTypes_1 = require("../../accountTypes");
|
|
30
|
+
const index_1 = require("../../errorHandlers/index");
|
|
31
|
+
const constants_1 = require("../../constants");
|
|
32
|
+
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
33
|
+
vitest_1.vi.mock('@hubspot/local-dev-lib/api/localDevAuth');
|
|
34
|
+
vitest_1.vi.mock('@hubspot/local-dev-lib/api/appsDev');
|
|
35
|
+
vitest_1.vi.mock('@hubspot/local-dev-lib/portManager');
|
|
36
|
+
vitest_1.vi.mock('@hubspot/local-dev-lib/config');
|
|
37
|
+
vitest_1.vi.mock('../../prompts/installAppPrompt');
|
|
38
|
+
vitest_1.vi.mock('../../prompts/promptUtils');
|
|
39
|
+
vitest_1.vi.mock('../../app/urls');
|
|
40
|
+
vitest_1.vi.mock('../../accountTypes');
|
|
41
|
+
vitest_1.vi.mock('../../ui/logger');
|
|
42
|
+
vitest_1.vi.mock('../../errorHandlers/index');
|
|
43
|
+
vitest_1.vi.mock('../localDev/LocalDevState');
|
|
44
|
+
vitest_1.vi.mock('../localDev/LocalDevLogger');
|
|
45
|
+
describe('AppDevModeInterface', () => {
|
|
46
|
+
let appDevModeInterface;
|
|
47
|
+
let mockLocalDevState;
|
|
48
|
+
let mockLocalDevLogger;
|
|
49
|
+
const mockProjectConfig = {
|
|
50
|
+
name: 'test-project',
|
|
51
|
+
srcDir: 'src',
|
|
52
|
+
platformVersion: '1.0.0',
|
|
53
|
+
};
|
|
54
|
+
const mockAppNode = {
|
|
55
|
+
uid: 'test-app-uid',
|
|
56
|
+
componentType: 'APPLICATION',
|
|
57
|
+
config: {
|
|
58
|
+
name: 'Test App',
|
|
59
|
+
description: 'Test app description',
|
|
60
|
+
logo: 'logo.png',
|
|
61
|
+
auth: {
|
|
62
|
+
type: constants_1.APP_AUTH_TYPES.STATIC,
|
|
63
|
+
requiredScopes: ['test-scope'],
|
|
64
|
+
optionalScopes: [],
|
|
65
|
+
conditionallyRequiredScopes: [],
|
|
66
|
+
redirectUrls: ['http://localhost:3000'],
|
|
67
|
+
},
|
|
68
|
+
distribution: constants_1.APP_DISTRIBUTION_TYPES.PRIVATE,
|
|
69
|
+
},
|
|
70
|
+
localDev: {
|
|
71
|
+
componentRoot: '/test/path',
|
|
72
|
+
componentConfigPath: '/test/path/config.json',
|
|
73
|
+
configUpdatedSinceLastUpload: false,
|
|
74
|
+
},
|
|
75
|
+
componentDeps: {},
|
|
76
|
+
metaFilePath: '/test/path',
|
|
77
|
+
files: [],
|
|
78
|
+
};
|
|
79
|
+
const mockAppData = {
|
|
80
|
+
id: 123,
|
|
81
|
+
clientId: 'test-client-id',
|
|
82
|
+
name: 'Test App',
|
|
83
|
+
installationState: constants_1.APP_INSTALLATION_STATES.NOT_INSTALLED,
|
|
84
|
+
scopeGroupIds: [1, 2, 3],
|
|
85
|
+
};
|
|
86
|
+
const mockPublicApp = {
|
|
87
|
+
id: 123,
|
|
88
|
+
clientId: 'test-client-id',
|
|
89
|
+
name: 'Test App',
|
|
90
|
+
sourceId: 'test-app-uid',
|
|
91
|
+
scopeGroupIds: [1, 2, 3],
|
|
92
|
+
};
|
|
93
|
+
beforeEach(() => {
|
|
94
|
+
vitest_1.vi.clearAllMocks();
|
|
95
|
+
mockLocalDevState = {
|
|
96
|
+
targetProjectAccountId: 12345,
|
|
97
|
+
targetTestingAccountId: 67890,
|
|
98
|
+
projectConfig: mockProjectConfig,
|
|
99
|
+
projectDir: '/test/project',
|
|
100
|
+
projectId: 999,
|
|
101
|
+
env: environments_1.ENVIRONMENTS.PROD,
|
|
102
|
+
projectNodes: { [mockAppNode.uid]: mockAppNode },
|
|
103
|
+
getAppDataByUid: vitest_1.vi.fn(),
|
|
104
|
+
setAppDataForUid: vitest_1.vi.fn(),
|
|
105
|
+
addListener: vitest_1.vi.fn(),
|
|
106
|
+
};
|
|
107
|
+
mockLocalDevLogger = {
|
|
108
|
+
addUploadWarning: vitest_1.vi.fn(),
|
|
109
|
+
};
|
|
110
|
+
// Mock constructors
|
|
111
|
+
LocalDevState_1.default.mockImplementation(() => mockLocalDevState);
|
|
112
|
+
LocalDevLogger_1.default.mockImplementation(() => mockLocalDevLogger);
|
|
113
|
+
// Mock external dependencies
|
|
114
|
+
appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
|
|
115
|
+
data: { results: [mockPublicApp] },
|
|
116
|
+
});
|
|
117
|
+
appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
118
|
+
data: { uniquePortalInstallCount: 5 },
|
|
119
|
+
});
|
|
120
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
121
|
+
data: {
|
|
122
|
+
isInstalledWithScopeGroups: true,
|
|
123
|
+
previouslyAuthorizedScopeGroups: [],
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
config_1.getAccountConfig.mockReturnValue({
|
|
127
|
+
parentAccountId: 12345,
|
|
128
|
+
});
|
|
129
|
+
accountTypes_1.isDeveloperTestAccount.mockReturnValue(true);
|
|
130
|
+
accountTypes_1.isSandbox.mockReturnValue(false);
|
|
131
|
+
urls_1.getOauthAppInstallUrl.mockReturnValue('http://oauth-install-url');
|
|
132
|
+
urls_1.getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
|
|
133
|
+
installAppPrompt_1.installAppAutoPrompt.mockResolvedValue(true);
|
|
134
|
+
installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
|
|
135
|
+
promptUtils_1.confirmPrompt.mockResolvedValue(true);
|
|
136
|
+
appsDev_1.installStaticAuthAppOnTestAccount.mockResolvedValue(undefined);
|
|
137
|
+
// Mock process.exit
|
|
138
|
+
vitest_1.vi.spyOn(global.process, 'exit').mockImplementation((code) => {
|
|
139
|
+
throw new Error(`Process.exit called with code ${code}`);
|
|
140
|
+
});
|
|
141
|
+
appDevModeInterface = new AppDevModeInterface_1.default({
|
|
142
|
+
localDevState: mockLocalDevState,
|
|
143
|
+
localDevLogger: mockLocalDevLogger,
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('constructor', () => {
|
|
147
|
+
it('should initialize with valid state', () => {
|
|
148
|
+
expect(appDevModeInterface).toBeInstanceOf(AppDevModeInterface_1.default);
|
|
149
|
+
expect(appDevModeInterface.localDevState).toBe(mockLocalDevState);
|
|
150
|
+
expect(appDevModeInterface.localDevLogger).toBe(mockLocalDevLogger);
|
|
151
|
+
});
|
|
152
|
+
it('should exit if targetProjectAccountId is missing', () => {
|
|
153
|
+
const mockLocalDevStateWithoutAccountId = {
|
|
154
|
+
...mockLocalDevState,
|
|
155
|
+
targetProjectAccountId: null,
|
|
156
|
+
};
|
|
157
|
+
expect(() => {
|
|
158
|
+
new AppDevModeInterface_1.default({
|
|
159
|
+
localDevState: mockLocalDevStateWithoutAccountId,
|
|
160
|
+
localDevLogger: mockLocalDevLogger,
|
|
161
|
+
});
|
|
162
|
+
}).toThrow('Process.exit called with code 1');
|
|
163
|
+
});
|
|
164
|
+
it('should exit if projectConfig is missing', () => {
|
|
165
|
+
const mockLocalDevStateWithoutConfig = {
|
|
166
|
+
...mockLocalDevState,
|
|
167
|
+
projectConfig: null,
|
|
168
|
+
};
|
|
169
|
+
expect(() => {
|
|
170
|
+
new AppDevModeInterface_1.default({
|
|
171
|
+
localDevState: mockLocalDevStateWithoutConfig,
|
|
172
|
+
localDevLogger: mockLocalDevLogger,
|
|
173
|
+
});
|
|
174
|
+
}).toThrow('Process.exit called with code 1');
|
|
175
|
+
});
|
|
176
|
+
it('should exit if projectDir is missing', () => {
|
|
177
|
+
const mockLocalDevStateWithoutDir = {
|
|
178
|
+
...mockLocalDevState,
|
|
179
|
+
projectDir: null,
|
|
180
|
+
};
|
|
181
|
+
expect(() => {
|
|
182
|
+
new AppDevModeInterface_1.default({
|
|
183
|
+
localDevState: mockLocalDevStateWithoutDir,
|
|
184
|
+
localDevLogger: mockLocalDevLogger,
|
|
185
|
+
});
|
|
186
|
+
}).toThrow('Process.exit called with code 1');
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
describe('setup()', () => {
|
|
190
|
+
beforeEach(() => {
|
|
191
|
+
mockLocalDevState.getAppDataByUid.mockReturnValue(mockAppData);
|
|
192
|
+
});
|
|
193
|
+
it('should return early if no app node exists', async () => {
|
|
194
|
+
mockLocalDevState.projectNodes = {};
|
|
195
|
+
await appDevModeInterface.setup({});
|
|
196
|
+
expect(appsDev_1.fetchPublicAppsForPortal).not.toHaveBeenCalled();
|
|
197
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.setup).not.toHaveBeenCalled();
|
|
198
|
+
});
|
|
199
|
+
it('should setup successfully with private app', async () => {
|
|
200
|
+
await appDevModeInterface.setup({});
|
|
201
|
+
expect(appsDev_1.fetchPublicAppsForPortal).toHaveBeenCalledWith(12345);
|
|
202
|
+
expect(appsDev_1.fetchPublicAppProductionInstallCounts).toHaveBeenCalledWith(123, 12345);
|
|
203
|
+
expect(localDevAuth_1.fetchAppInstallationData).toHaveBeenCalledWith(67890, 999, 'test-app-uid', ['test-scope'], []);
|
|
204
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.setup).toHaveBeenCalled();
|
|
205
|
+
});
|
|
206
|
+
it('should show marketplace warning for marketplace apps', async () => {
|
|
207
|
+
const marketplaceAppNode = {
|
|
208
|
+
...mockAppNode,
|
|
209
|
+
config: {
|
|
210
|
+
...mockAppNode.config,
|
|
211
|
+
distribution: constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE,
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
mockLocalDevState.projectNodes = {
|
|
215
|
+
[marketplaceAppNode.uid]: marketplaceAppNode,
|
|
216
|
+
};
|
|
217
|
+
await appDevModeInterface.setup({});
|
|
218
|
+
expect(promptUtils_1.confirmPrompt).toHaveBeenCalled();
|
|
219
|
+
expect(mockLocalDevLogger.addUploadWarning).toHaveBeenCalled();
|
|
220
|
+
});
|
|
221
|
+
it('should exit if user declines marketplace warning', async () => {
|
|
222
|
+
const marketplaceAppNode = {
|
|
223
|
+
...mockAppNode,
|
|
224
|
+
config: {
|
|
225
|
+
...mockAppNode.config,
|
|
226
|
+
distribution: constants_1.APP_DISTRIBUTION_TYPES.MARKETPLACE,
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
mockLocalDevState.projectNodes = {
|
|
230
|
+
[marketplaceAppNode.uid]: marketplaceAppNode,
|
|
231
|
+
};
|
|
232
|
+
// Set up conditions to trigger marketplace warning
|
|
233
|
+
appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
234
|
+
data: { uniquePortalInstallCount: 5 },
|
|
235
|
+
});
|
|
236
|
+
mockLocalDevState.getAppDataByUid.mockReturnValue(mockAppData);
|
|
237
|
+
promptUtils_1.confirmPrompt.mockResolvedValue(false);
|
|
238
|
+
// Create a new instance to trigger the exit during setup
|
|
239
|
+
const newAppDevModeInterface = new AppDevModeInterface_1.default({
|
|
240
|
+
localDevState: mockLocalDevState,
|
|
241
|
+
localDevLogger: mockLocalDevLogger,
|
|
242
|
+
});
|
|
243
|
+
// The setup method catches the error, so we check that process.exit was called
|
|
244
|
+
await newAppDevModeInterface.setup({});
|
|
245
|
+
expect(process.exit).toHaveBeenCalledWith(0);
|
|
246
|
+
});
|
|
247
|
+
it('should auto-install static auth app on test account', async () => {
|
|
248
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
249
|
+
data: {
|
|
250
|
+
isInstalledWithScopeGroups: false,
|
|
251
|
+
previouslyAuthorizedScopeGroups: [],
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
await appDevModeInterface.setup({});
|
|
255
|
+
expect(appsDev_1.installStaticAuthAppOnTestAccount).toHaveBeenCalledWith(123, 67890, [1, 2, 3]);
|
|
256
|
+
});
|
|
257
|
+
it('should open browser for OAuth app installation', async () => {
|
|
258
|
+
const oauthAppNode = {
|
|
259
|
+
...mockAppNode,
|
|
260
|
+
config: {
|
|
261
|
+
...mockAppNode.config,
|
|
262
|
+
auth: {
|
|
263
|
+
...mockAppNode.config.auth,
|
|
264
|
+
type: constants_1.APP_AUTH_TYPES.OAUTH,
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
mockLocalDevState.projectNodes = { [oauthAppNode.uid]: oauthAppNode };
|
|
269
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
270
|
+
data: {
|
|
271
|
+
isInstalledWithScopeGroups: false,
|
|
272
|
+
previouslyAuthorizedScopeGroups: [],
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
await appDevModeInterface.setup({});
|
|
276
|
+
expect(urls_1.getOauthAppInstallUrl).toHaveBeenCalledWith({
|
|
277
|
+
targetAccountId: 67890,
|
|
278
|
+
env: environments_1.ENVIRONMENTS.PROD,
|
|
279
|
+
clientId: 'test-client-id',
|
|
280
|
+
scopes: ['test-scope'],
|
|
281
|
+
redirectUrls: ['http://localhost:3000'],
|
|
282
|
+
});
|
|
283
|
+
expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalled();
|
|
284
|
+
});
|
|
285
|
+
it('should handle app reinstallation', async () => {
|
|
286
|
+
// Set up conditions for non-automatic installation
|
|
287
|
+
config_1.getAccountConfig.mockReturnValue(null);
|
|
288
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
289
|
+
data: {
|
|
290
|
+
isInstalledWithScopeGroups: false,
|
|
291
|
+
previouslyAuthorizedScopeGroups: ['old-scope'],
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
await appDevModeInterface.setup({});
|
|
295
|
+
expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', true);
|
|
296
|
+
});
|
|
297
|
+
it('should handle errors during setup', async () => {
|
|
298
|
+
const error = new Error('Setup failed');
|
|
299
|
+
appsDev_1.fetchPublicAppsForPortal.mockRejectedValue(error);
|
|
300
|
+
await appDevModeInterface.setup({});
|
|
301
|
+
expect(index_1.logError).toHaveBeenCalledWith(error);
|
|
302
|
+
});
|
|
303
|
+
it('should exit if app not found in portal', async () => {
|
|
304
|
+
// Set up conditions for non-automatic installation to force getAppInstallUrl call
|
|
305
|
+
config_1.getAccountConfig.mockReturnValue(null);
|
|
306
|
+
// First call for fetchAppData succeeds
|
|
307
|
+
appsDev_1.fetchPublicAppsForPortal
|
|
308
|
+
.mockResolvedValueOnce({
|
|
309
|
+
data: { results: [mockPublicApp] },
|
|
310
|
+
})
|
|
311
|
+
// Second call for getAppInstallUrl fails (app not found)
|
|
312
|
+
.mockResolvedValueOnce({
|
|
313
|
+
data: { results: [] },
|
|
314
|
+
});
|
|
315
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
316
|
+
data: {
|
|
317
|
+
isInstalledWithScopeGroups: false,
|
|
318
|
+
previouslyAuthorizedScopeGroups: [],
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
// The setup method catches the error, so we check that process.exit was called
|
|
322
|
+
await appDevModeInterface.setup({});
|
|
323
|
+
expect(process.exit).toHaveBeenCalledWith(1);
|
|
324
|
+
});
|
|
325
|
+
it('should exit if user declines auto-install', async () => {
|
|
326
|
+
// Set up conditions for automatic installation
|
|
327
|
+
config_1.getAccountConfig.mockReturnValue({
|
|
328
|
+
parentAccountId: 12345, // matches targetProjectAccountId
|
|
329
|
+
});
|
|
330
|
+
accountTypes_1.isDeveloperTestAccount.mockReturnValue(true);
|
|
331
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
332
|
+
data: {
|
|
333
|
+
isInstalledWithScopeGroups: false,
|
|
334
|
+
previouslyAuthorizedScopeGroups: [],
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
installAppPrompt_1.installAppAutoPrompt.mockResolvedValue(false);
|
|
338
|
+
// Create a new instance to trigger the exit during setup
|
|
339
|
+
const newAppDevModeInterface = new AppDevModeInterface_1.default({
|
|
340
|
+
localDevState: mockLocalDevState,
|
|
341
|
+
localDevLogger: mockLocalDevLogger,
|
|
342
|
+
});
|
|
343
|
+
// The setup method catches the error, so we check that process.exit was called
|
|
344
|
+
await newAppDevModeInterface.setup({});
|
|
345
|
+
expect(process.exit).toHaveBeenCalledWith(0);
|
|
346
|
+
});
|
|
347
|
+
it('should fallback to browser install if auto-install fails', async () => {
|
|
348
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
349
|
+
data: {
|
|
350
|
+
isInstalledWithScopeGroups: false,
|
|
351
|
+
previouslyAuthorizedScopeGroups: [],
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
appsDev_1.installStaticAuthAppOnTestAccount.mockRejectedValue(new Error('Install failed'));
|
|
355
|
+
await appDevModeInterface.setup({});
|
|
356
|
+
expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalledWith('http://static-install-url', false);
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
describe('start()', () => {
|
|
360
|
+
it('should return early if no app node exists', async () => {
|
|
361
|
+
mockLocalDevState.projectNodes = {};
|
|
362
|
+
await appDevModeInterface.start();
|
|
363
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.start).not.toHaveBeenCalled();
|
|
364
|
+
});
|
|
365
|
+
it('should start UIE dev mode interface', async () => {
|
|
366
|
+
await appDevModeInterface.start();
|
|
367
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.start).toHaveBeenCalledWith({
|
|
368
|
+
accountId: 67890,
|
|
369
|
+
projectConfig: mockProjectConfig,
|
|
370
|
+
requestPorts: portManager_1.requestPorts,
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
describe('fileChange()', () => {
|
|
375
|
+
it('should return early if no app node exists', async () => {
|
|
376
|
+
mockLocalDevState.projectNodes = {};
|
|
377
|
+
await appDevModeInterface.fileChange('test.js', 'change');
|
|
378
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.fileChange).not.toHaveBeenCalled();
|
|
379
|
+
});
|
|
380
|
+
it('should forward file change to UIE dev mode interface', async () => {
|
|
381
|
+
await appDevModeInterface.fileChange('test.js', 'change');
|
|
382
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.fileChange).toHaveBeenCalledWith('test.js', 'change');
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
describe('cleanup()', () => {
|
|
386
|
+
it('should return early if no app node exists', async () => {
|
|
387
|
+
mockLocalDevState.projectNodes = {};
|
|
388
|
+
await appDevModeInterface.cleanup();
|
|
389
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.cleanup).not.toHaveBeenCalled();
|
|
390
|
+
});
|
|
391
|
+
it('should cleanup UIE dev mode interface', async () => {
|
|
392
|
+
await appDevModeInterface.cleanup();
|
|
393
|
+
expect(ui_extensions_dev_server_1.DevModeUnifiedInterface.cleanup).toHaveBeenCalled();
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
describe('isAutomaticallyInstallable()', () => {
|
|
397
|
+
it('should return true for static auth app on test account with correct parent', () => {
|
|
398
|
+
// This is testing private method behavior through setup()
|
|
399
|
+
expect(appDevModeInterface).toBeDefined();
|
|
400
|
+
});
|
|
401
|
+
it('should return false if target account config is missing', async () => {
|
|
402
|
+
// Reset mocks to ensure clean state
|
|
403
|
+
vitest_1.vi.clearAllMocks();
|
|
404
|
+
// Set up basic mocks
|
|
405
|
+
appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
|
|
406
|
+
data: { results: [mockPublicApp] },
|
|
407
|
+
});
|
|
408
|
+
appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
409
|
+
data: { uniquePortalInstallCount: 5 },
|
|
410
|
+
});
|
|
411
|
+
urls_1.getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
|
|
412
|
+
installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
|
|
413
|
+
// Reset the mock LocalDevState
|
|
414
|
+
mockLocalDevState.getAppDataByUid = vitest_1.vi.fn().mockReturnValue(mockAppData);
|
|
415
|
+
mockLocalDevState.setAppDataForUid = vitest_1.vi.fn();
|
|
416
|
+
mockLocalDevState.addListener = vitest_1.vi.fn();
|
|
417
|
+
// Target account config is missing
|
|
418
|
+
config_1.getAccountConfig.mockReturnValue(null);
|
|
419
|
+
// App is not installed
|
|
420
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
421
|
+
data: {
|
|
422
|
+
isInstalledWithScopeGroups: false,
|
|
423
|
+
previouslyAuthorizedScopeGroups: [],
|
|
424
|
+
},
|
|
425
|
+
});
|
|
426
|
+
// Create a new instance to avoid interference from previous test setup
|
|
427
|
+
const newAppDevModeInterface = new AppDevModeInterface_1.default({
|
|
428
|
+
localDevState: mockLocalDevState,
|
|
429
|
+
localDevLogger: mockLocalDevLogger,
|
|
430
|
+
});
|
|
431
|
+
await newAppDevModeInterface.setup({});
|
|
432
|
+
expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalled();
|
|
433
|
+
});
|
|
434
|
+
it('should return false for OAuth app', async () => {
|
|
435
|
+
// Reset mocks to ensure clean state
|
|
436
|
+
vitest_1.vi.clearAllMocks();
|
|
437
|
+
// Set up basic mocks
|
|
438
|
+
appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
|
|
439
|
+
data: { results: [mockPublicApp] },
|
|
440
|
+
});
|
|
441
|
+
appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
442
|
+
data: { uniquePortalInstallCount: 5 },
|
|
443
|
+
});
|
|
444
|
+
urls_1.getOauthAppInstallUrl.mockReturnValue('http://oauth-install-url');
|
|
445
|
+
installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
|
|
446
|
+
// Reset the mock LocalDevState
|
|
447
|
+
mockLocalDevState.getAppDataByUid = vitest_1.vi.fn().mockReturnValue(mockAppData);
|
|
448
|
+
mockLocalDevState.setAppDataForUid = vitest_1.vi.fn();
|
|
449
|
+
mockLocalDevState.addListener = vitest_1.vi.fn();
|
|
450
|
+
const oauthAppNode = {
|
|
451
|
+
...mockAppNode,
|
|
452
|
+
config: {
|
|
453
|
+
...mockAppNode.config,
|
|
454
|
+
auth: {
|
|
455
|
+
...mockAppNode.config.auth,
|
|
456
|
+
type: constants_1.APP_AUTH_TYPES.OAUTH,
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
mockLocalDevState.projectNodes = { [oauthAppNode.uid]: oauthAppNode };
|
|
461
|
+
// App is not installed
|
|
462
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
463
|
+
data: {
|
|
464
|
+
isInstalledWithScopeGroups: false,
|
|
465
|
+
previouslyAuthorizedScopeGroups: [],
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
// Create a new instance to avoid interference from previous test setup
|
|
469
|
+
const newAppDevModeInterface = new AppDevModeInterface_1.default({
|
|
470
|
+
localDevState: mockLocalDevState,
|
|
471
|
+
localDevLogger: mockLocalDevLogger,
|
|
472
|
+
});
|
|
473
|
+
await newAppDevModeInterface.setup({});
|
|
474
|
+
expect(installAppPrompt_1.installAppBrowserPrompt).toHaveBeenCalled();
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
describe('websocket server message handling', () => {
|
|
478
|
+
it('should check app installation when websocket server connects', async () => {
|
|
479
|
+
// Reset mocks to ensure clean state
|
|
480
|
+
vitest_1.vi.clearAllMocks();
|
|
481
|
+
// Set up basic mocks
|
|
482
|
+
appsDev_1.fetchPublicAppsForPortal.mockResolvedValue({
|
|
483
|
+
data: { results: [mockPublicApp] },
|
|
484
|
+
});
|
|
485
|
+
appsDev_1.fetchPublicAppProductionInstallCounts.mockResolvedValue({
|
|
486
|
+
data: { uniquePortalInstallCount: 5 },
|
|
487
|
+
});
|
|
488
|
+
urls_1.getStaticAuthAppInstallUrl.mockReturnValue('http://static-install-url');
|
|
489
|
+
installAppPrompt_1.installAppBrowserPrompt.mockResolvedValue(undefined);
|
|
490
|
+
// Reset the mock LocalDevState
|
|
491
|
+
mockLocalDevState.getAppDataByUid = vitest_1.vi.fn().mockReturnValue(mockAppData);
|
|
492
|
+
mockLocalDevState.setAppDataForUid = vitest_1.vi.fn();
|
|
493
|
+
mockLocalDevState.addListener = vitest_1.vi.fn();
|
|
494
|
+
// App is not installed so fetchAppInstallationData will be called
|
|
495
|
+
localDevAuth_1.fetchAppInstallationData.mockResolvedValue({
|
|
496
|
+
data: {
|
|
497
|
+
isInstalledWithScopeGroups: false,
|
|
498
|
+
previouslyAuthorizedScopeGroups: [],
|
|
499
|
+
},
|
|
500
|
+
});
|
|
501
|
+
// Create a new instance to avoid interference from previous test setup
|
|
502
|
+
const newAppDevModeInterface = new AppDevModeInterface_1.default({
|
|
503
|
+
localDevState: mockLocalDevState,
|
|
504
|
+
localDevLogger: mockLocalDevLogger,
|
|
505
|
+
});
|
|
506
|
+
await newAppDevModeInterface.setup({});
|
|
507
|
+
// Simulate websocket server connection
|
|
508
|
+
const addListenerCall = mockLocalDevState.addListener.mock
|
|
509
|
+
.calls[0];
|
|
510
|
+
const [eventType, callback] = addListenerCall;
|
|
511
|
+
expect(eventType).toBe('devServerMessage');
|
|
512
|
+
// Call the callback with websocket connection message
|
|
513
|
+
await callback(constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.WEBSOCKET_SERVER_CONNECTED);
|
|
514
|
+
expect(localDevAuth_1.fetchAppInstallationData).toHaveBeenCalledTimes(2); // Once in setup, once in listener
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|