@hubspot/cli 7.7.19-experimental.3 → 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
|
@@ -0,0 +1,495 @@
|
|
|
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 logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const path_1 = require("@hubspot/local-dev-lib/path");
|
|
8
|
+
const archive_1 = require("@hubspot/local-dev-lib/archive");
|
|
9
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
10
|
+
const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
11
|
+
const Migration_1 = require("@hubspot/local-dev-lib/types/Migration");
|
|
12
|
+
const projects_2 = require("@hubspot/local-dev-lib/api/projects");
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
15
|
+
const ensureProjectExists_1 = require("../../projects/ensureProjectExists");
|
|
16
|
+
const polling_1 = require("../../polling");
|
|
17
|
+
const migrate_1 = require("../../../api/migrate");
|
|
18
|
+
const en_1 = require("../../../lang/en");
|
|
19
|
+
const hasFeature_1 = require("../../hasFeature");
|
|
20
|
+
const migrate_2 = require("../migrate");
|
|
21
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
22
|
+
vi.mock('@hubspot/local-dev-lib/path');
|
|
23
|
+
vi.mock('@hubspot/local-dev-lib/archive');
|
|
24
|
+
vi.mock('@hubspot/project-parsing-lib');
|
|
25
|
+
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
26
|
+
vi.mock('inquirer');
|
|
27
|
+
vi.mock('../../prompts/promptUtils');
|
|
28
|
+
vi.mock('../../projects/config');
|
|
29
|
+
vi.mock('../../projects/ensureProjectExists');
|
|
30
|
+
vi.mock('../../ui/SpinniesManager');
|
|
31
|
+
vi.mock('../../polling');
|
|
32
|
+
vi.mock('../../../api/migrate');
|
|
33
|
+
vi.mock('../../hasFeature');
|
|
34
|
+
vi.mock('../../projects/urls');
|
|
35
|
+
vi.mock('fs');
|
|
36
|
+
const mockedLogger = logger_1.logger;
|
|
37
|
+
const mockedGetCwd = path_1.getCwd;
|
|
38
|
+
const mockedSanitizeFileName = path_1.sanitizeFileName;
|
|
39
|
+
const mockedExtractZipArchive = archive_1.extractZipArchive;
|
|
40
|
+
const mockedValidateUid = project_parsing_lib_1.validateUid;
|
|
41
|
+
const mockedDownloadProject = projects_2.downloadProject;
|
|
42
|
+
const mockedConfirmPrompt = promptUtils_1.confirmPrompt;
|
|
43
|
+
const mockedInputPrompt = promptUtils_1.inputPrompt;
|
|
44
|
+
const mockedListPrompt = promptUtils_1.listPrompt;
|
|
45
|
+
const mockedEnsureProjectExists = ensureProjectExists_1.ensureProjectExists;
|
|
46
|
+
const mockedPoll = polling_1.poll;
|
|
47
|
+
const mockedListAppsForMigration = migrate_1.listAppsForMigration;
|
|
48
|
+
const mockedInitializeMigration = migrate_1.initializeMigration;
|
|
49
|
+
const mockedContinueMigration = migrate_1.continueMigration;
|
|
50
|
+
const mockedHasFeature = hasFeature_1.hasFeature;
|
|
51
|
+
const mockedFs = fs_1.default;
|
|
52
|
+
const createMockMigratableApp = (id, name, projectName) => ({
|
|
53
|
+
appId: id,
|
|
54
|
+
appName: name,
|
|
55
|
+
isMigratable: true,
|
|
56
|
+
migrationComponents: [],
|
|
57
|
+
...(projectName && { projectName }),
|
|
58
|
+
});
|
|
59
|
+
const createMockUnmigratableApp = (id, name, reason) => ({
|
|
60
|
+
appId: id,
|
|
61
|
+
appName: name,
|
|
62
|
+
isMigratable: false,
|
|
63
|
+
// @ts-expect-error
|
|
64
|
+
unmigratableReason: reason,
|
|
65
|
+
migrationComponents: [],
|
|
66
|
+
});
|
|
67
|
+
const createLoadedProjectConfig = (name) => ({
|
|
68
|
+
projectConfig: { name },
|
|
69
|
+
projectDir: MOCK_PROJECT_DIR,
|
|
70
|
+
});
|
|
71
|
+
const ACCOUNT_ID = 123;
|
|
72
|
+
const PROJECT_NAME = 'Test Project';
|
|
73
|
+
const APP_ID = 1;
|
|
74
|
+
const PLATFORM_VERSION = '2025.2';
|
|
75
|
+
const MIGRATION_ID = 456;
|
|
76
|
+
const BUILD_ID = 789;
|
|
77
|
+
const PROJECT_DEST = '/mock/dest';
|
|
78
|
+
const MOCK_CWD = '/mock/cwd';
|
|
79
|
+
const MOCK_PROJECT_DIR = '/mock/project/dir';
|
|
80
|
+
const mockUnmigratableApps = [
|
|
81
|
+
createMockUnmigratableApp(3, 'App 3', projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE),
|
|
82
|
+
createMockUnmigratableApp(4, 'App 4', projects_1.UNMIGRATABLE_REASONS.IS_A_PRIVATE_APP),
|
|
83
|
+
];
|
|
84
|
+
describe('lib/app/migrate', () => {
|
|
85
|
+
beforeEach(() => {
|
|
86
|
+
mockedGetCwd.mockReturnValue(MOCK_CWD);
|
|
87
|
+
mockedSanitizeFileName.mockImplementation(name => name);
|
|
88
|
+
mockedValidateUid.mockReturnValue(undefined);
|
|
89
|
+
mockedHasFeature.mockResolvedValue(true);
|
|
90
|
+
mockedFs.renameSync.mockImplementation(() => { });
|
|
91
|
+
});
|
|
92
|
+
describe('getUnmigratableReason', () => {
|
|
93
|
+
const testCases = [
|
|
94
|
+
{
|
|
95
|
+
name: 'UP_TO_DATE',
|
|
96
|
+
reason: projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE,
|
|
97
|
+
expected: en_1.lib.migrate.errors.unmigratableReasons.upToDate,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'IS_A_PRIVATE_APP',
|
|
101
|
+
reason: projects_1.UNMIGRATABLE_REASONS.IS_A_PRIVATE_APP,
|
|
102
|
+
expected: en_1.lib.migrate.errors.unmigratableReasons.isPrivateApp,
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'LISTED_IN_MARKETPLACE',
|
|
106
|
+
reason: projects_1.UNMIGRATABLE_REASONS.LISTED_IN_MARKETPLACE,
|
|
107
|
+
expected: en_1.lib.migrate.errors.unmigratableReasons.listedInMarketplace,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'PROJECT_CONNECTED_TO_GITHUB',
|
|
111
|
+
reason: projects_1.UNMIGRATABLE_REASONS.PROJECT_CONNECTED_TO_GITHUB,
|
|
112
|
+
expected: en_1.lib.migrate.errors.unmigratableReasons.projectConnectedToGitHub(PROJECT_NAME, ACCOUNT_ID),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'PART_OF_PROJECT_ALREADY',
|
|
116
|
+
reason: migrate_1.CLI_UNMIGRATABLE_REASONS.PART_OF_PROJECT_ALREADY,
|
|
117
|
+
expected: en_1.lib.migrate.errors.unmigratableReasons.partOfProjectAlready,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'UNKNOWN_REASON',
|
|
121
|
+
reason: 'UNKNOWN_REASON',
|
|
122
|
+
expected: en_1.lib.migrate.errors.unmigratableReasons.generic('UNKNOWN_REASON'),
|
|
123
|
+
},
|
|
124
|
+
];
|
|
125
|
+
testCases.forEach(testCase => {
|
|
126
|
+
it(`should return the correct message for ${testCase.name}`, () => {
|
|
127
|
+
const result = (0, migrate_2.getUnmigratableReason)(testCase.reason, PROJECT_NAME, ACCOUNT_ID);
|
|
128
|
+
expect(result).toBe(testCase.expected);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe('generateFilterAppsByProjectNameFunction', () => {
|
|
133
|
+
it('should return a function that filters by project name when projectConfig is provided', () => {
|
|
134
|
+
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
135
|
+
const filterFn = (0, migrate_2.generateFilterAppsByProjectNameFunction)(projectConfig);
|
|
136
|
+
const matchingApp = createMockMigratableApp(1, 'App 1', PROJECT_NAME);
|
|
137
|
+
const nonMatchingApp = createMockMigratableApp(2, 'App 2', 'Other Project');
|
|
138
|
+
expect(filterFn(matchingApp)).toBe(true);
|
|
139
|
+
expect(filterFn(nonMatchingApp)).toBe(false);
|
|
140
|
+
});
|
|
141
|
+
it('should return a function that always returns true when projectConfig is not provided', () => {
|
|
142
|
+
const filterFn = (0, migrate_2.generateFilterAppsByProjectNameFunction)(undefined);
|
|
143
|
+
const app1 = createMockMigratableApp(1, 'App 1', PROJECT_NAME);
|
|
144
|
+
const app2 = createMockMigratableApp(2, 'App 2', 'Other Project');
|
|
145
|
+
expect(filterFn(app1)).toBe(true);
|
|
146
|
+
expect(filterFn(app2)).toBe(true);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
describe('buildErrorMessageFromMigrationStatus', () => {
|
|
150
|
+
it('should return projectErrorDetail when there are no component errors', () => {
|
|
151
|
+
const error = {
|
|
152
|
+
id: 123,
|
|
153
|
+
status: Migration_1.MIGRATION_STATUS.FAILURE,
|
|
154
|
+
projectErrorDetail: 'Project error',
|
|
155
|
+
componentErrors: [],
|
|
156
|
+
};
|
|
157
|
+
const result = (0, migrate_2.buildErrorMessageFromMigrationStatus)(error);
|
|
158
|
+
expect(result).toBe('Project error');
|
|
159
|
+
});
|
|
160
|
+
it('should return formatted error message with component errors', () => {
|
|
161
|
+
const error = {
|
|
162
|
+
id: 123,
|
|
163
|
+
status: Migration_1.MIGRATION_STATUS.FAILURE,
|
|
164
|
+
projectErrorDetail: 'Project error',
|
|
165
|
+
componentErrors: [
|
|
166
|
+
{
|
|
167
|
+
componentType: 'CARD',
|
|
168
|
+
developerSymbol: 'card1',
|
|
169
|
+
errorMessage: 'Card error',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
componentType: 'FUNCTION',
|
|
173
|
+
errorMessage: 'Function error',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
const result = (0, migrate_2.buildErrorMessageFromMigrationStatus)(error);
|
|
178
|
+
expect(result).toBe('Project error: \n\t- CARD (card1): Card error\n\t- FUNCTION: Function error');
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
describe('fetchMigrationApps', () => {
|
|
182
|
+
const setupMockApps = (migratableApps = [], unmigratableApps = []) => {
|
|
183
|
+
// @ts-expect-error
|
|
184
|
+
mockedListAppsForMigration.mockResolvedValue({
|
|
185
|
+
data: {
|
|
186
|
+
migratableApps,
|
|
187
|
+
unmigratableApps,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
beforeEach(() => {
|
|
192
|
+
setupMockApps([
|
|
193
|
+
createMockMigratableApp(1, 'App 1', PROJECT_NAME),
|
|
194
|
+
createMockMigratableApp(2, 'App 2', PROJECT_NAME),
|
|
195
|
+
], [createMockUnmigratableApp(3, 'App 3', projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE)]);
|
|
196
|
+
});
|
|
197
|
+
it('should return all apps when no projectConfig is provided', async () => {
|
|
198
|
+
setupMockApps([createMockMigratableApp(1, 'App 1')]);
|
|
199
|
+
const result = await (0, migrate_2.fetchMigrationApps)(undefined, ACCOUNT_ID, PLATFORM_VERSION);
|
|
200
|
+
expect(result).toHaveLength(1);
|
|
201
|
+
expect(result[0].appId).toBe(1);
|
|
202
|
+
});
|
|
203
|
+
it('should filter apps by project name when projectConfig is provided', async () => {
|
|
204
|
+
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
205
|
+
setupMockApps([createMockMigratableApp(1, 'App 1', PROJECT_NAME)]);
|
|
206
|
+
const result = await (0, migrate_2.fetchMigrationApps)(undefined, ACCOUNT_ID, PLATFORM_VERSION, projectConfig);
|
|
207
|
+
expect(result).toHaveLength(1);
|
|
208
|
+
expect(result[0].projectName).toBe(PROJECT_NAME);
|
|
209
|
+
});
|
|
210
|
+
it('should throw an error when multiple apps are found for a project', async () => {
|
|
211
|
+
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
212
|
+
setupMockApps([
|
|
213
|
+
createMockMigratableApp(1, 'App 1', PROJECT_NAME),
|
|
214
|
+
createMockMigratableApp(2, 'App 2', PROJECT_NAME),
|
|
215
|
+
]);
|
|
216
|
+
await expect((0, migrate_2.fetchMigrationApps)(undefined, ACCOUNT_ID, PLATFORM_VERSION, projectConfig)).rejects.toThrow(en_1.lib.migrate.errors.project.multipleApps);
|
|
217
|
+
});
|
|
218
|
+
it('should throw an error when no apps are found for a project', async () => {
|
|
219
|
+
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
220
|
+
setupMockApps([], []);
|
|
221
|
+
await expect((0, migrate_2.fetchMigrationApps)(undefined, ACCOUNT_ID, PLATFORM_VERSION, projectConfig)).rejects.toThrow(en_1.lib.migrate.errors.noAppsForProject(PROJECT_NAME));
|
|
222
|
+
});
|
|
223
|
+
it('should throw an error when no migratable apps are found', async () => {
|
|
224
|
+
setupMockApps([], mockUnmigratableApps);
|
|
225
|
+
await expect((0, migrate_2.fetchMigrationApps)(undefined, ACCOUNT_ID, PLATFORM_VERSION)).rejects.toThrow(/No apps in account/);
|
|
226
|
+
});
|
|
227
|
+
it('should throw an error when appId is provided but not found', async () => {
|
|
228
|
+
await expect((0, migrate_2.fetchMigrationApps)(999, ACCOUNT_ID, PLATFORM_VERSION)).rejects.toThrow(/No apps in account/);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
describe('promptForAppToMigrate', () => {
|
|
232
|
+
const mockApps = [
|
|
233
|
+
createMockMigratableApp(1, 'App 1'),
|
|
234
|
+
createMockUnmigratableApp(2, 'App 2', projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE),
|
|
235
|
+
];
|
|
236
|
+
beforeEach(() => {
|
|
237
|
+
mockedListPrompt.mockResolvedValue(mockApps[0]);
|
|
238
|
+
});
|
|
239
|
+
it('should prompt the user to select an app', async () => {
|
|
240
|
+
await (0, migrate_2.promptForAppToMigrate)(mockApps, ACCOUNT_ID);
|
|
241
|
+
expect(mockedListPrompt).toHaveBeenCalledWith(en_1.lib.migrate.prompt.chooseApp, expect.any(Object));
|
|
242
|
+
});
|
|
243
|
+
it('should return the selected app', async () => {
|
|
244
|
+
mockedListPrompt.mockResolvedValue({ appId: mockApps[0].appId });
|
|
245
|
+
const result = await (0, migrate_2.promptForAppToMigrate)(mockApps, ACCOUNT_ID);
|
|
246
|
+
expect(result).toBe(mockApps[0].appId);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
describe('selectAppToMigrate', () => {
|
|
250
|
+
const mockApps = [
|
|
251
|
+
{
|
|
252
|
+
appId: 1,
|
|
253
|
+
appName: 'App 1',
|
|
254
|
+
isMigratable: true,
|
|
255
|
+
migrationComponents: [
|
|
256
|
+
{ id: '1', componentType: 'CARD', isSupported: true },
|
|
257
|
+
{ id: '2', componentType: 'FUNCTION', isSupported: false },
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
createMockUnmigratableApp(2, 'App 2', projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE),
|
|
261
|
+
];
|
|
262
|
+
beforeEach(() => {
|
|
263
|
+
mockedListPrompt.mockResolvedValue({ appId: 1 });
|
|
264
|
+
mockedConfirmPrompt.mockResolvedValue(true);
|
|
265
|
+
});
|
|
266
|
+
it('should throw an error when appId is provided but not found', async () => {
|
|
267
|
+
await expect((0, migrate_2.selectAppToMigrate)(mockApps, ACCOUNT_ID, 999)).rejects.toThrow(en_1.lib.migrate.errors.appWithAppIdNotFound(999));
|
|
268
|
+
});
|
|
269
|
+
it('should call listPrompt when appId is not provided', async () => {
|
|
270
|
+
await (0, migrate_2.selectAppToMigrate)(mockApps, ACCOUNT_ID);
|
|
271
|
+
expect(mockedListPrompt).toHaveBeenCalledWith(en_1.lib.migrate.prompt.chooseApp, expect.any(Object));
|
|
272
|
+
});
|
|
273
|
+
it('should return proceed: false and appIdToMigrate when user cancels', async () => {
|
|
274
|
+
mockedConfirmPrompt.mockResolvedValue(false);
|
|
275
|
+
const result = await (0, migrate_2.selectAppToMigrate)(mockApps, ACCOUNT_ID);
|
|
276
|
+
expect(result).toEqual({ proceed: false, appIdToMigrate: 1 });
|
|
277
|
+
});
|
|
278
|
+
it('should return proceed: true and appIdToMigrate when user confirms', async () => {
|
|
279
|
+
const result = await (0, migrate_2.selectAppToMigrate)(mockApps, ACCOUNT_ID);
|
|
280
|
+
expect(result).toEqual({ proceed: true, appIdToMigrate: 1 });
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
describe('handleMigrationSetup', () => {
|
|
284
|
+
const defaultOptions = {
|
|
285
|
+
name: PROJECT_NAME,
|
|
286
|
+
dest: PROJECT_DEST,
|
|
287
|
+
appId: APP_ID,
|
|
288
|
+
platformVersion: PLATFORM_VERSION,
|
|
289
|
+
unstable: false,
|
|
290
|
+
};
|
|
291
|
+
beforeEach(() => {
|
|
292
|
+
setupMockForHandleMigrationSetup();
|
|
293
|
+
});
|
|
294
|
+
function setupMockForHandleMigrationSetup() {
|
|
295
|
+
// @ts-expect-error
|
|
296
|
+
mockedListAppsForMigration.mockResolvedValue({
|
|
297
|
+
data: {
|
|
298
|
+
migratableApps: [createMockMigratableApp(1, 'App 1')],
|
|
299
|
+
unmigratableApps: [],
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
mockedListPrompt.mockResolvedValue({ appId: 1 });
|
|
303
|
+
mockedConfirmPrompt.mockResolvedValue(true);
|
|
304
|
+
mockedEnsureProjectExists.mockResolvedValue({ projectExists: false });
|
|
305
|
+
}
|
|
306
|
+
it('should return early when user cancels', async () => {
|
|
307
|
+
mockedConfirmPrompt.mockResolvedValueOnce(false);
|
|
308
|
+
const result = await (0, migrate_2.handleMigrationSetup)(ACCOUNT_ID, defaultOptions);
|
|
309
|
+
expect(result).toEqual({});
|
|
310
|
+
});
|
|
311
|
+
it('should return project details when projectConfig is provided', async () => {
|
|
312
|
+
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
313
|
+
// @ts-expect-error
|
|
314
|
+
mockedListAppsForMigration.mockResolvedValueOnce({
|
|
315
|
+
data: {
|
|
316
|
+
migratableApps: [createMockMigratableApp(1, 'App 1', PROJECT_NAME)],
|
|
317
|
+
unmigratableApps: [],
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
const result = await (0, migrate_2.handleMigrationSetup)(ACCOUNT_ID, defaultOptions, projectConfig);
|
|
321
|
+
expect(result).toEqual({
|
|
322
|
+
appIdToMigrate: 1,
|
|
323
|
+
projectName: PROJECT_NAME,
|
|
324
|
+
projectDest: MOCK_PROJECT_DIR,
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
it('should prompt for project name when not provided', async () => {
|
|
328
|
+
const optionsWithoutName = { ...defaultOptions, name: undefined };
|
|
329
|
+
mockedInputPrompt.mockResolvedValue('New Project');
|
|
330
|
+
await (0, migrate_2.handleMigrationSetup)(ACCOUNT_ID, optionsWithoutName);
|
|
331
|
+
expect(mockedInputPrompt).toHaveBeenCalledWith(en_1.lib.migrate.prompt.inputName, expect.any(Object));
|
|
332
|
+
});
|
|
333
|
+
it('should prompt for project destination when not provided', async () => {
|
|
334
|
+
const optionsWithoutDest = { ...defaultOptions, dest: undefined };
|
|
335
|
+
mockedInputPrompt.mockResolvedValue('/mock/new/dest');
|
|
336
|
+
await (0, migrate_2.handleMigrationSetup)(ACCOUNT_ID, optionsWithoutDest);
|
|
337
|
+
expect(mockedInputPrompt).toHaveBeenCalledWith(en_1.lib.migrate.prompt.inputDest, expect.any(Object));
|
|
338
|
+
});
|
|
339
|
+
it('should throw an error when project already exists', async () => {
|
|
340
|
+
mockedEnsureProjectExists.mockResolvedValue({ projectExists: true });
|
|
341
|
+
await expect((0, migrate_2.handleMigrationSetup)(ACCOUNT_ID, defaultOptions)).rejects.toThrow(en_1.lib.migrate.errors.project.alreadyExists(PROJECT_NAME));
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
describe('beginMigration', () => {
|
|
345
|
+
beforeEach(() => {
|
|
346
|
+
// @ts-expect-error
|
|
347
|
+
mockedInitializeMigration.mockResolvedValue({
|
|
348
|
+
data: { migrationId: MIGRATION_ID },
|
|
349
|
+
});
|
|
350
|
+
mockedPoll.mockResolvedValue({
|
|
351
|
+
status: Migration_1.MIGRATION_STATUS.INPUT_REQUIRED,
|
|
352
|
+
// @ts-expect-error
|
|
353
|
+
componentsRequiringUids: {},
|
|
354
|
+
});
|
|
355
|
+
mockedInputPrompt.mockResolvedValue('test-uid');
|
|
356
|
+
});
|
|
357
|
+
it('should initialize migration and return migrationId and uidMap', async () => {
|
|
358
|
+
const result = await (0, migrate_2.beginMigration)(ACCOUNT_ID, APP_ID, PLATFORM_VERSION);
|
|
359
|
+
expect(result).toEqual({
|
|
360
|
+
migrationId: MIGRATION_ID,
|
|
361
|
+
uidMap: {},
|
|
362
|
+
});
|
|
363
|
+
});
|
|
364
|
+
it('should prompt for UIDs when components require them', async () => {
|
|
365
|
+
const componentHint = 'test-card';
|
|
366
|
+
mockedPoll.mockResolvedValue({
|
|
367
|
+
status: Migration_1.MIGRATION_STATUS.INPUT_REQUIRED,
|
|
368
|
+
// @ts-expect-error
|
|
369
|
+
componentsRequiringUids: {
|
|
370
|
+
'1': {
|
|
371
|
+
componentType: 'CARD',
|
|
372
|
+
componentHint,
|
|
373
|
+
},
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
await (0, migrate_2.beginMigration)(ACCOUNT_ID, APP_ID, PLATFORM_VERSION);
|
|
377
|
+
expect(mockedInputPrompt).toHaveBeenCalledWith(en_1.lib.migrate.prompt.uidForComponent("card 'test-card' (ID: 1)"), {
|
|
378
|
+
defaultAnswer: componentHint,
|
|
379
|
+
validate: expect.any(Function),
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
it('should throw an error when migration fails', async () => {
|
|
383
|
+
mockedPoll.mockRejectedValue(new Error('Failed'));
|
|
384
|
+
await expect((0, migrate_2.beginMigration)(ACCOUNT_ID, APP_ID, PLATFORM_VERSION)).rejects.toThrow(/Migration Failed/);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
describe('pollMigrationStatus', () => {
|
|
388
|
+
it('should call poll with checkMigrationStatusV2', async () => {
|
|
389
|
+
const mockStatus = {
|
|
390
|
+
id: MIGRATION_ID,
|
|
391
|
+
status: Migration_1.MIGRATION_STATUS.SUCCESS,
|
|
392
|
+
buildId: BUILD_ID,
|
|
393
|
+
};
|
|
394
|
+
mockedPoll.mockResolvedValue(mockStatus);
|
|
395
|
+
const result = await (0, migrate_2.pollMigrationStatus)(ACCOUNT_ID, MIGRATION_ID);
|
|
396
|
+
expect(mockedPoll).toHaveBeenCalledWith(expect.any(Function), expect.any(Object));
|
|
397
|
+
expect(result).toBe(mockStatus);
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
describe('finalizeMigration', () => {
|
|
401
|
+
const uidMap = { '1': 'test-uid' };
|
|
402
|
+
beforeEach(() => {
|
|
403
|
+
// @ts-expect-error
|
|
404
|
+
mockedContinueMigration.mockResolvedValue({
|
|
405
|
+
data: { migrationId: MIGRATION_ID },
|
|
406
|
+
});
|
|
407
|
+
mockedPoll.mockResolvedValue({
|
|
408
|
+
status: Migration_1.MIGRATION_STATUS.SUCCESS,
|
|
409
|
+
// @ts-expect-error
|
|
410
|
+
buildId: BUILD_ID,
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
it('should continue migration and return buildId', async () => {
|
|
414
|
+
const result = await (0, migrate_2.finalizeMigration)(ACCOUNT_ID, MIGRATION_ID, uidMap, PROJECT_NAME);
|
|
415
|
+
expect(result).toBe(BUILD_ID);
|
|
416
|
+
});
|
|
417
|
+
it('should throw an error when migration fails', async () => {
|
|
418
|
+
mockedPoll.mockRejectedValue(new Error('Test error'));
|
|
419
|
+
await expect((0, migrate_2.finalizeMigration)(ACCOUNT_ID, MIGRATION_ID, uidMap, PROJECT_NAME)).rejects.toThrow(/Migration Failed/);
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
describe('downloadProjectFiles', () => {
|
|
423
|
+
beforeEach(() => {
|
|
424
|
+
// @ts-expect-error
|
|
425
|
+
mockedDownloadProject.mockResolvedValue({
|
|
426
|
+
data: Buffer.from('mock-zip-data'),
|
|
427
|
+
});
|
|
428
|
+
mockedExtractZipArchive.mockResolvedValue(true);
|
|
429
|
+
mockedGetCwd.mockReturnValue(MOCK_CWD);
|
|
430
|
+
mockedSanitizeFileName.mockReturnValue(PROJECT_NAME);
|
|
431
|
+
});
|
|
432
|
+
it('should download and extract project files', async () => {
|
|
433
|
+
await (0, migrate_2.downloadProjectFiles)(ACCOUNT_ID, PROJECT_NAME, BUILD_ID, PROJECT_DEST);
|
|
434
|
+
expect(mockedDownloadProject).toHaveBeenCalledWith(ACCOUNT_ID, PROJECT_NAME, BUILD_ID);
|
|
435
|
+
expect(mockedExtractZipArchive).toHaveBeenCalledWith(expect.any(Buffer), PROJECT_NAME, expect.stringContaining(PROJECT_DEST), {
|
|
436
|
+
includesRootDir: true,
|
|
437
|
+
hideLogs: true,
|
|
438
|
+
});
|
|
439
|
+
});
|
|
440
|
+
it('should handle projectConfig correctly', async () => {
|
|
441
|
+
const projectConfig = {
|
|
442
|
+
projectConfig: { name: PROJECT_NAME, srcDir: 'src' },
|
|
443
|
+
projectDir: MOCK_PROJECT_DIR,
|
|
444
|
+
};
|
|
445
|
+
await (0, migrate_2.downloadProjectFiles)(ACCOUNT_ID, PROJECT_NAME, BUILD_ID, PROJECT_DEST, projectConfig);
|
|
446
|
+
expect(mockedFs.renameSync).toHaveBeenCalledWith(`${MOCK_PROJECT_DIR}/src`, `${MOCK_PROJECT_DIR}/archive`);
|
|
447
|
+
expect(mockedExtractZipArchive).toHaveBeenCalledWith(expect.any(Buffer), PROJECT_NAME, MOCK_PROJECT_DIR, {
|
|
448
|
+
includesRootDir: true,
|
|
449
|
+
hideLogs: true,
|
|
450
|
+
});
|
|
451
|
+
});
|
|
452
|
+
it('should throw an error when download fails', async () => {
|
|
453
|
+
const error = new Error('Download failed');
|
|
454
|
+
mockedDownloadProject.mockRejectedValue(error);
|
|
455
|
+
await expect((0, migrate_2.downloadProjectFiles)(ACCOUNT_ID, PROJECT_NAME, BUILD_ID, PROJECT_DEST)).rejects.toThrow(error);
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
describe('migrateApp2025_2', () => {
|
|
459
|
+
const options = {
|
|
460
|
+
name: PROJECT_NAME,
|
|
461
|
+
dest: PROJECT_DEST,
|
|
462
|
+
appId: APP_ID,
|
|
463
|
+
platformVersion: PLATFORM_VERSION,
|
|
464
|
+
unstable: false,
|
|
465
|
+
};
|
|
466
|
+
beforeEach(() => {
|
|
467
|
+
mockedHasFeature.mockResolvedValue(true);
|
|
468
|
+
});
|
|
469
|
+
it('should throw an error when account is not ungated for unified apps', async () => {
|
|
470
|
+
mockedHasFeature.mockResolvedValueOnce(false);
|
|
471
|
+
await expect((0, migrate_2.migrateApp2025_2)(ACCOUNT_ID, options)).rejects.toThrowError(/isn't enrolled in the required product beta to access this command./);
|
|
472
|
+
});
|
|
473
|
+
it('should throw an error when projectConfig is invalid', async () => {
|
|
474
|
+
const invalidProjectConfig = {
|
|
475
|
+
projectConfig: undefined,
|
|
476
|
+
projectDir: '/mock/project/dir',
|
|
477
|
+
};
|
|
478
|
+
await expect((0, migrate_2.migrateApp2025_2)(ACCOUNT_ID, options, invalidProjectConfig)).rejects.toThrow(/The project configuration file is invalid/);
|
|
479
|
+
});
|
|
480
|
+
it('should throw an error when project does not exist', async () => {
|
|
481
|
+
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
482
|
+
mockedEnsureProjectExists.mockResolvedValueOnce({
|
|
483
|
+
projectExists: false,
|
|
484
|
+
});
|
|
485
|
+
await expect((0, migrate_2.migrateApp2025_2)(ACCOUNT_ID, options, projectConfig)).rejects.toThrow(/Migrations are only supported for existing projects/);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
describe('logInvalidAccountError', () => {
|
|
489
|
+
it('should log the invalid account error message', () => {
|
|
490
|
+
(0, migrate_2.logInvalidAccountError)();
|
|
491
|
+
expect(mockedLogger.error).toHaveBeenCalledWith(en_1.lib.migrate.errors.invalidAccountTypeTitle);
|
|
492
|
+
expect(mockedLogger.log).toHaveBeenCalledWith(expect.stringContaining('Only public apps created in a developer account can be converted to a project component'));
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const appsDev_1 = require("@hubspot/local-dev-lib/api/appsDev");
|
|
4
|
+
const projects_1 = require("@hubspot/local-dev-lib/api/projects");
|
|
5
|
+
const archive_1 = require("@hubspot/local-dev-lib/archive");
|
|
6
|
+
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
7
|
+
const exitCodes_1 = require("../../enums/exitCodes");
|
|
8
|
+
const accountTypes_1 = require("../../accountTypes");
|
|
9
|
+
const selectPublicAppForMigrationPrompt_1 = require("../../prompts/selectPublicAppForMigrationPrompt");
|
|
10
|
+
const projectNameAndDestPrompt_1 = require("../../prompts/projectNameAndDestPrompt");
|
|
11
|
+
const ensureProjectExists_1 = require("../../projects/ensureProjectExists");
|
|
12
|
+
const polling_1 = require("../../polling");
|
|
13
|
+
const migrate_legacy_1 = require("../migrate_legacy");
|
|
14
|
+
// Mock all external dependencies
|
|
15
|
+
vi.mock('@hubspot/local-dev-lib/api/appsDev');
|
|
16
|
+
vi.mock('@hubspot/local-dev-lib/logger');
|
|
17
|
+
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
18
|
+
vi.mock('@hubspot/local-dev-lib/path');
|
|
19
|
+
vi.mock('@hubspot/local-dev-lib/urls');
|
|
20
|
+
vi.mock('@hubspot/local-dev-lib/archive');
|
|
21
|
+
vi.mock('../../prompts/promptUtils');
|
|
22
|
+
vi.mock('../../errorHandlers');
|
|
23
|
+
vi.mock('../../accountTypes');
|
|
24
|
+
vi.mock('../../prompts/selectPublicAppForMigrationPrompt');
|
|
25
|
+
vi.mock('../../prompts/projectNameAndDestPrompt');
|
|
26
|
+
vi.mock('../../projects/ensureProjectExists');
|
|
27
|
+
vi.mock('../../usageTracking');
|
|
28
|
+
vi.mock('../../ui/SpinniesManager');
|
|
29
|
+
vi.mock('../../process');
|
|
30
|
+
vi.mock('../../polling');
|
|
31
|
+
const isAppDeveloperAccount = accountTypes_1.isAppDeveloperAccount;
|
|
32
|
+
const isUnifiedAccount = accountTypes_1.isUnifiedAccount;
|
|
33
|
+
const selectPublicAppForMigrationPrompt = selectPublicAppForMigrationPrompt_1.selectPublicAppForMigrationPrompt;
|
|
34
|
+
const projectNameAndDestPrompt = projectNameAndDestPrompt_1.projectNameAndDestPrompt;
|
|
35
|
+
const ensureProjectExists = ensureProjectExists_1.ensureProjectExists;
|
|
36
|
+
const poll = polling_1.poll;
|
|
37
|
+
const fetchPublicAppMetadata = appsDev_1.fetchPublicAppMetadata;
|
|
38
|
+
const migrateNonProjectApp_v2023_2 = projects_1.migrateApp;
|
|
39
|
+
const downloadProject = projects_1.downloadProject;
|
|
40
|
+
const promptUser = promptUtils_1.promptUser;
|
|
41
|
+
describe('migrateApp2023_2', () => {
|
|
42
|
+
const mockDerivedAccountId = 123;
|
|
43
|
+
const mockOptions = {
|
|
44
|
+
_: [],
|
|
45
|
+
$0: 'test',
|
|
46
|
+
derivedAccountId: 123,
|
|
47
|
+
d: false,
|
|
48
|
+
debug: false,
|
|
49
|
+
platformVersion: '2023.2',
|
|
50
|
+
unstable: false,
|
|
51
|
+
};
|
|
52
|
+
const mockAccountConfig = {
|
|
53
|
+
accountId: 123,
|
|
54
|
+
name: 'Test Account',
|
|
55
|
+
env: 'prod',
|
|
56
|
+
};
|
|
57
|
+
const appId = 12345;
|
|
58
|
+
const projectName = 'test-project';
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
// @ts-expect-error function mismatch
|
|
61
|
+
vi.spyOn(process, 'exit').mockImplementation(() => { });
|
|
62
|
+
selectPublicAppForMigrationPrompt.mockResolvedValue({
|
|
63
|
+
appId,
|
|
64
|
+
});
|
|
65
|
+
isAppDeveloperAccount.mockReturnValue(true);
|
|
66
|
+
isUnifiedAccount.mockResolvedValue(false);
|
|
67
|
+
fetchPublicAppMetadata.mockResolvedValue({
|
|
68
|
+
// @ts-expect-error Mocking the return type
|
|
69
|
+
data: { preventProjectMigrations: false },
|
|
70
|
+
});
|
|
71
|
+
projectNameAndDestPrompt.mockResolvedValue({
|
|
72
|
+
name: projectName,
|
|
73
|
+
dest: '/test/dest',
|
|
74
|
+
});
|
|
75
|
+
promptUser.mockResolvedValue({
|
|
76
|
+
shouldCreateApp: true,
|
|
77
|
+
});
|
|
78
|
+
ensureProjectExists.mockResolvedValue({
|
|
79
|
+
projectExists: false,
|
|
80
|
+
});
|
|
81
|
+
migrateNonProjectApp_v2023_2.mockResolvedValue({
|
|
82
|
+
// @ts-expect-error Mocking the return type
|
|
83
|
+
data: { id: 'migration-id' },
|
|
84
|
+
});
|
|
85
|
+
poll.mockResolvedValue({
|
|
86
|
+
status: 'SUCCESS',
|
|
87
|
+
// @ts-expect-error
|
|
88
|
+
project: {
|
|
89
|
+
name: projectName,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
downloadProject.mockResolvedValue({
|
|
93
|
+
// @ts-expect-error Mocking the return type
|
|
94
|
+
data: 'zipped-project-data',
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
it('should exit if account is not an app developer account and not unified', async () => {
|
|
98
|
+
isAppDeveloperAccount.mockReturnValue(false);
|
|
99
|
+
await (0, migrate_legacy_1.migrateApp2023_2)(mockDerivedAccountId, mockOptions, mockAccountConfig);
|
|
100
|
+
expect(migrateNonProjectApp_v2023_2).not.toHaveBeenCalled();
|
|
101
|
+
expect(process.exit).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
102
|
+
});
|
|
103
|
+
it('should proceed with migration for valid app developer account', async () => {
|
|
104
|
+
await (0, migrate_legacy_1.migrateApp2023_2)(mockDerivedAccountId, mockOptions, mockAccountConfig);
|
|
105
|
+
expect(selectPublicAppForMigrationPrompt).toHaveBeenCalled();
|
|
106
|
+
expect(fetchPublicAppMetadata).toHaveBeenCalledWith(appId, mockDerivedAccountId);
|
|
107
|
+
expect(projectNameAndDestPrompt).toHaveBeenCalled();
|
|
108
|
+
expect(ensureProjectExists).toHaveBeenCalled();
|
|
109
|
+
expect(migrateNonProjectApp_v2023_2).toHaveBeenCalled();
|
|
110
|
+
expect(poll).toHaveBeenCalled();
|
|
111
|
+
expect(downloadProject).toHaveBeenCalled();
|
|
112
|
+
expect(archive_1.extractZipArchive).toHaveBeenCalled();
|
|
113
|
+
});
|
|
114
|
+
it('should handle migration failure gracefully', async () => {
|
|
115
|
+
const errorMessage = 'Migration failed';
|
|
116
|
+
migrateNonProjectApp_v2023_2.mockRejectedValue(new Error(errorMessage));
|
|
117
|
+
await expect((0, migrate_legacy_1.migrateApp2023_2)(mockDerivedAccountId, mockOptions, mockAccountConfig)).rejects.toThrow(errorMessage);
|
|
118
|
+
});
|
|
119
|
+
it('should handle non-migratable apps', async () => {
|
|
120
|
+
fetchPublicAppMetadata.mockResolvedValue({
|
|
121
|
+
data: {
|
|
122
|
+
preventProjectMigrations: true,
|
|
123
|
+
// @ts-expect-error
|
|
124
|
+
listingInfo: { someInfo: 'test' },
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
await (0, migrate_legacy_1.migrateApp2023_2)(mockDerivedAccountId, mockOptions, mockAccountConfig);
|
|
128
|
+
expect(process.exit).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
|
|
129
|
+
});
|
|
130
|
+
it('should handle existing project error', async () => {
|
|
131
|
+
ensureProjectExists.mockResolvedValue({
|
|
132
|
+
projectExists: true,
|
|
133
|
+
});
|
|
134
|
+
await expect((0, migrate_legacy_1.migrateApp2023_2)(mockDerivedAccountId, mockOptions, mockAccountConfig)).rejects.toThrow('A project with name test-project already exists');
|
|
135
|
+
});
|
|
136
|
+
});
|
package/lib/buildAccount.d.ts
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { DeveloperTestAccountConfig } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
2
1
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
3
2
|
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
4
3
|
import { SandboxResponse } from '@hubspot/local-dev-lib/types/Sandbox';
|
|
5
4
|
import { SandboxAccountType } from '../types/Sandboxes';
|
|
6
5
|
export declare function saveAccountToConfig(accountId: number | undefined, accountName: string, env: Environment, personalAccessKey?: string, force?: boolean): Promise<string>;
|
|
7
|
-
export declare function
|
|
8
|
-
accountName: string;
|
|
9
|
-
accountId?: number;
|
|
10
|
-
personalAccessKey?: string;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function buildDeveloperTestAccount(testAccountName: string, parentAccountConfig: CLIAccount, env: Environment, portalLimit: number, useV3?: boolean): Promise<number>;
|
|
6
|
+
export declare function buildDeveloperTestAccount(testAccountName: string, parentAccountConfig: CLIAccount, env: Environment, portalLimit: number): Promise<number>;
|
|
13
7
|
type SandboxAccount = SandboxResponse & {
|
|
14
8
|
name: string;
|
|
15
9
|
};
|