@hubspot/cli 7.5.3-experimental.0 → 7.5.4-beta.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/migrate.d.ts +12 -3
- package/api/migrate.js +9 -2
- package/bin/cli.js +100 -93
- package/commands/account/auth.d.ts +8 -0
- package/commands/account/auth.js +175 -0
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +54 -14
- package/commands/account/createOverride.d.ts +6 -0
- package/commands/account/createOverride.js +121 -0
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +36 -5
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +38 -15
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +49 -9
- package/commands/account/removeOverride.d.ts +6 -0
- package/commands/account/removeOverride.js +93 -0
- package/commands/account/rename.d.ts +3 -7
- package/commands/account/rename.js +16 -9
- package/commands/account/use.d.ts +5 -9
- package/commands/account/use.js +27 -6
- package/commands/account.d.ts +3 -4
- package/commands/account.js +33 -53
- package/commands/app/migrate.d.ts +5 -6
- package/commands/app/migrate.js +60 -44
- package/commands/app/secret/add.d.ts +7 -0
- package/commands/app/secret/add.js +64 -0
- package/commands/app/secret/delete.d.ts +8 -0
- package/commands/app/secret/delete.js +87 -0
- package/commands/app/secret/list.d.ts +6 -0
- package/commands/app/secret/list.js +64 -0
- package/commands/app/secret/update.d.ts +7 -0
- package/commands/app/secret/update.js +77 -0
- package/commands/app/secret.d.ts +3 -0
- package/commands/app/secret.js +30 -0
- package/commands/app.d.ts +2 -5
- package/commands/app.js +10 -10
- package/commands/auth.d.ts +5 -7
- package/commands/auth.js +37 -33
- package/commands/cms/convertFields.d.ts +7 -1
- package/commands/cms/convertFields.js +57 -41
- package/commands/cms/getReactModule.d.ts +7 -1
- package/commands/cms/getReactModule.js +52 -34
- package/commands/cms/lighthouseScore.d.ts +8 -1
- package/commands/cms/lighthouseScore.js +129 -100
- package/commands/cms.d.ts +3 -1
- package/commands/cms.js +22 -16
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +23 -13
- package/commands/config/migrate.d.ts +6 -0
- package/commands/config/migrate.js +75 -0
- package/commands/config/set.d.ts +10 -1
- package/commands/config/set.js +56 -32
- package/commands/config.d.ts +3 -1
- package/commands/config.js +19 -11
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -38
- package/commands/create/app.d.ts +3 -1
- package/commands/create/app.js +9 -7
- package/commands/create/function.d.ts +3 -1
- package/commands/create/function.js +11 -10
- package/commands/create/index.d.ts +5 -1
- package/commands/create/index.js +23 -11
- package/commands/create/module.d.ts +3 -1
- package/commands/create/module.js +14 -13
- package/commands/create/react-app.d.ts +3 -1
- package/commands/create/react-app.js +10 -7
- package/commands/create/template.d.ts +3 -1
- package/commands/create/template.js +14 -14
- package/commands/create/vue-app.d.ts +3 -1
- package/commands/create/vue-app.js +10 -7
- package/commands/create/webpack-serverless.d.ts +3 -1
- package/commands/create/webpack-serverless.js +10 -7
- package/commands/create/website-theme.d.ts +3 -1
- package/commands/create/website-theme.js +10 -9
- package/commands/create.d.ts +4 -24
- package/commands/create.js +62 -75
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +17 -10
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +17 -10
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +17 -10
- package/commands/customObject/schema/list.d.ts +4 -8
- package/commands/customObject/schema/list.js +17 -10
- package/commands/customObject/schema/update.d.ts +4 -9
- package/commands/customObject/schema/update.js +18 -11
- package/commands/customObject/schema.d.ts +3 -5
- package/commands/customObject/schema.js +27 -54
- package/commands/customObject.d.ts +3 -4
- package/commands/customObject.js +20 -48
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +30 -22
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +38 -48
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -34
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +18 -42
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +22 -11
- package/commands/getStarted.d.ts +9 -0
- package/commands/getStarted.js +227 -0
- package/commands/hubdb/clear.d.ts +4 -9
- package/commands/hubdb/clear.js +21 -15
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +23 -17
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +24 -16
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +20 -14
- package/commands/hubdb/list.d.ts +4 -0
- package/commands/hubdb/list.js +83 -0
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +24 -47
- package/commands/init.d.ts +3 -7
- package/commands/init.js +31 -24
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +42 -44
- package/commands/list.d.ts +3 -7
- package/commands/list.js +21 -16
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -45
- package/commands/mcp/setup.d.ts +7 -0
- package/commands/mcp/setup.js +50 -0
- package/commands/mcp/start.d.ts +3 -0
- package/commands/mcp/start.js +75 -0
- package/commands/mcp.d.ts +3 -0
- package/commands/mcp.js +26 -0
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -30
- package/commands/module.d.ts +3 -1
- package/commands/module.js +23 -12
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +20 -15
- package/commands/open.d.ts +3 -7
- package/commands/open.js +20 -15
- package/commands/project/add.d.ts +8 -9
- package/commands/project/add.js +53 -85
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +51 -47
- package/commands/project/create.d.ts +4 -1
- package/commands/project/create.js +132 -81
- package/commands/project/deploy.d.ts +5 -6
- package/commands/project/deploy.js +93 -37
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +41 -26
- package/commands/project/dev/index.d.ts +4 -5
- package/commands/project/dev/index.js +103 -33
- package/commands/project/dev/unifiedFlow.d.ts +11 -2
- package/commands/project/dev/unifiedFlow.js +85 -46
- package/commands/project/download.d.ts +3 -7
- package/commands/project/download.js +18 -19
- package/commands/project/installDeps.d.ts +6 -1
- package/commands/project/installDeps.js +48 -32
- package/commands/project/listBuilds.d.ts +3 -7
- package/commands/project/listBuilds.js +32 -30
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +7 -8
- package/commands/project/migrate.js +49 -26
- package/commands/project/migrateApp.d.ts +3 -8
- package/commands/project/migrateApp.js +23 -20
- package/commands/project/open.d.ts +3 -7
- package/commands/project/open.js +29 -21
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +209 -0
- package/commands/project/profile/delete.d.ts +6 -0
- package/commands/project/profile/delete.js +123 -0
- package/commands/project/profile.d.ts +3 -0
- package/commands/project/profile.js +25 -0
- package/commands/project/upload.d.ts +10 -1
- package/commands/project/upload.js +94 -56
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +85 -0
- package/commands/project/watch.d.ts +6 -1
- package/commands/project/watch.js +95 -61
- package/commands/project.d.ts +3 -1
- package/commands/project.js +49 -37
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +22 -20
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +27 -21
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +35 -29
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +18 -44
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +21 -15
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +28 -18
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +19 -13
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +25 -17
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +23 -49
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +20 -16
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +22 -18
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +36 -30
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +22 -48
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +116 -135
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +74 -76
- package/lang/en.d.ts +3217 -0
- package/lang/en.js +3074 -3313
- package/lang/en.lyaml +96 -228
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +11 -0
- package/lib/app/migrate.d.ts +33 -4
- package/lib/app/migrate.js +179 -88
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +12 -11
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +11 -10
- package/lib/commonOpts.d.ts +4 -7
- package/lib/commonOpts.js +47 -19
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +83 -0
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -45
- package/lib/constants.d.ts +33 -0
- package/lib/constants.js +34 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +14 -40
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +19 -16
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -9
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +60 -46
- package/lib/errorHandlers/index.js +13 -7
- package/lib/errorHandlers/suppressError.js +18 -26
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +3 -6
- package/lib/hasFeature.d.ts +3 -1
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/marketplaceValidate.d.ts +12 -2
- package/lib/marketplaceValidate.js +22 -29
- package/lib/mcp/setup.d.ts +21 -0
- package/lib/mcp/setup.js +215 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +3 -3
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +37 -3
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +125 -0
- package/lib/middleware/yargsChecksMiddleware.js +2 -2
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/oauth.js +1 -2
- package/lib/process.js +1 -2
- package/lib/projectProfiles.d.ts +7 -0
- package/lib/projectProfiles.js +83 -0
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +16 -21
- package/lib/projects/add/legacyAddComponent.d.ts +5 -0
- package/lib/projects/add/legacyAddComponent.js +48 -0
- package/lib/projects/add/v3AddComponent.d.ts +8 -0
- package/lib/projects/add/v3AddComponent.js +85 -0
- package/lib/projects/buildAndDeploy.js +46 -42
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -0
- package/lib/projects/create/index.d.ts +23 -0
- package/lib/projects/create/index.js +33 -0
- package/lib/projects/create/legacy.d.ts +6 -0
- package/lib/projects/{create.js → create/legacy.js} +23 -15
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
- package/lib/projects/localDev/AppDevModeInterface.js +215 -0
- package/lib/{DevServerManager.d.ts → projects/localDev/DevServerManager.d.ts} +1 -1
- package/lib/{DevServerManager.js → projects/localDev/DevServerManager.js} +6 -6
- package/lib/projects/localDev/DevServerManagerV2.d.ts +22 -0
- package/lib/{DevServerManagerV2.js → projects/localDev/DevServerManagerV2.js} +22 -19
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +159 -0
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +57 -83
- package/lib/projects/localDev/LocalDevProcess.d.ts +34 -0
- package/lib/projects/localDev/LocalDevProcess.js +201 -0
- package/lib/projects/localDev/LocalDevState.d.ts +50 -0
- package/lib/projects/localDev/LocalDevState.js +119 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +53 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +20 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +131 -0
- package/lib/{localDev.d.ts → projects/localDev/helpers.d.ts} +6 -4
- package/lib/{localDev.js → projects/localDev/helpers.js} +127 -114
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +17 -2
- package/lib/projects/upload.js +74 -50
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +23 -1
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +21 -18
- package/lib/prompts/accountNamePrompt.js +16 -13
- package/lib/prompts/accountsPrompt.js +1 -2
- package/lib/prompts/cmsFieldPrompt.js +1 -2
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createApiSamplePrompt.js +4 -5
- package/lib/prompts/createFunctionPrompt.js +13 -14
- package/lib/prompts/createModulePrompt.js +8 -9
- package/lib/prompts/createProjectPrompt.d.ts +20 -4
- package/lib/prompts/createProjectPrompt.js +43 -13
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/createTemplatePrompt.js +1 -2
- package/lib/prompts/downloadProjectPrompt.js +3 -4
- package/lib/prompts/installAppPrompt.d.ts +2 -0
- package/lib/prompts/installAppPrompt.js +45 -0
- package/lib/prompts/personalAccessKeyPrompt.js +35 -25
- package/lib/prompts/previewPrompt.js +5 -6
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -8
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +15 -16
- package/lib/prompts/projectNamePrompt.js +5 -6
- package/lib/prompts/projectsLogsPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +4 -2
- package/lib/prompts/promptUtils.js +3 -1
- package/lib/prompts/sandboxesPrompt.js +5 -6
- package/lib/prompts/secretPrompt.js +2 -3
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/selectHubDBTablePrompt.js +11 -8
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -9
- package/lib/prompts/setAsDefaultAccountPrompt.js +11 -2
- package/lib/prompts/uploadPrompt.js +4 -5
- package/lib/sandboxSync.js +15 -14
- package/lib/sandboxes.js +12 -13
- package/lib/serverlessLogs.js +4 -6
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/boxen.d.ts +5 -0
- package/lib/ui/boxen.js +30 -0
- package/lib/ui/git.js +8 -9
- package/lib/ui/index.d.ts +4 -2
- package/lib/ui/index.js +20 -17
- package/lib/ui/logger.d.ts +10 -0
- package/lib/ui/logger.js +15 -0
- package/lib/ui/serverlessFunctionLogs.js +2 -3
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +5 -1
- package/lib/yargsUtils.js +6 -0
- package/mcp-server/server.d.ts +1 -0
- package/mcp-server/server.js +18 -0
- package/mcp-server/tools/index.d.ts +2 -0
- package/mcp-server/tools/index.js +19 -0
- package/mcp-server/tools/project/AddFeatureToProject.d.ts +29 -0
- package/mcp-server/tools/project/AddFeatureToProject.js +85 -0
- package/mcp-server/tools/project/CreateProjectTool.d.ts +35 -0
- package/mcp-server/tools/project/CreateProjectTool.js +104 -0
- package/mcp-server/tools/project/DeployProject.d.ts +20 -0
- package/mcp-server/tools/project/DeployProject.js +50 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +17 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +58 -0
- package/mcp-server/tools/project/UploadProjectTools.d.ts +17 -0
- package/mcp-server/tools/project/UploadProjectTools.js +35 -0
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +17 -0
- package/mcp-server/tools/project/ValidateProjectTool.js +35 -0
- package/mcp-server/tools/project/constants.d.ts +3 -0
- package/mcp-server/tools/project/constants.js +13 -0
- package/mcp-server/types.d.ts +14 -0
- package/mcp-server/types.js +17 -0
- package/mcp-server/utils/command.d.ts +3 -0
- package/mcp-server/utils/command.js +16 -0
- package/mcp-server/utils/content.d.ts +3 -0
- package/mcp-server/utils/content.js +21 -0
- package/mcp-server/utils/project.d.ts +5 -0
- package/mcp-server/utils/project.js +17 -0
- package/package.json +26 -17
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +35 -0
- package/types/LocalDev.js +2 -0
- package/types/Projects.d.ts +19 -2
- package/types/Prompts.d.ts +0 -7
- package/types/Yargs.d.ts +14 -14
- package/lib/DevServerManagerV2.d.ts +0 -33
- package/lib/LocalDevManagerV2.d.ts +0 -64
- package/lib/LocalDevManagerV2.js +0 -377
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/index.d.ts +0 -21
- package/lib/projects/index.js +0 -194
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -40
package/lib/app/migrate.js
CHANGED
|
@@ -3,9 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getUnmigratableReason = getUnmigratableReason;
|
|
7
|
+
exports.generateFilterAppsByProjectNameFunction = generateFilterAppsByProjectNameFunction;
|
|
8
|
+
exports.buildErrorMessageFromMigrationStatus = buildErrorMessageFromMigrationStatus;
|
|
9
|
+
exports.fetchMigrationApps = fetchMigrationApps;
|
|
10
|
+
exports.promptForAppToMigrate = promptForAppToMigrate;
|
|
11
|
+
exports.selectAppToMigrate = selectAppToMigrate;
|
|
12
|
+
exports.handleMigrationSetup = handleMigrationSetup;
|
|
13
|
+
exports.beginMigration = beginMigration;
|
|
14
|
+
exports.pollMigrationStatus = pollMigrationStatus;
|
|
15
|
+
exports.finalizeMigration = finalizeMigration;
|
|
16
|
+
exports.downloadProjectFiles = downloadProjectFiles;
|
|
6
17
|
exports.migrateApp2025_2 = migrateApp2025_2;
|
|
7
18
|
exports.logInvalidAccountError = logInvalidAccountError;
|
|
8
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
19
|
const path_1 = __importDefault(require("path"));
|
|
10
20
|
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
11
21
|
const archive_1 = require("@hubspot/local-dev-lib/archive");
|
|
@@ -15,63 +25,88 @@ const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
|
15
25
|
const transform_1 = require("@hubspot/project-parsing-lib/src/lib/transform");
|
|
16
26
|
const Migration_1 = require("@hubspot/local-dev-lib/types/Migration");
|
|
17
27
|
const projects_2 = require("@hubspot/local-dev-lib/api/projects");
|
|
28
|
+
const inquirer = require('inquirer');
|
|
18
29
|
const promptUtils_1 = require("../prompts/promptUtils");
|
|
19
30
|
const ui_1 = require("../ui");
|
|
20
|
-
const
|
|
21
|
-
const projects_3 = require("../projects");
|
|
31
|
+
const ensureProjectExists_1 = require("../projects/ensureProjectExists");
|
|
22
32
|
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
23
33
|
const polling_1 = require("../polling");
|
|
24
34
|
const migrate_1 = require("../../api/migrate");
|
|
25
35
|
const fs_1 = __importDefault(require("fs"));
|
|
26
|
-
|
|
36
|
+
const en_1 = require("../../lang/en");
|
|
37
|
+
const hasFeature_1 = require("../hasFeature");
|
|
38
|
+
const constants_1 = require("../constants");
|
|
39
|
+
const urls_1 = require("../projects/urls");
|
|
40
|
+
const logger_1 = require("../ui/logger");
|
|
41
|
+
function getUnmigratableReason(reasonCode, projectName, accountId) {
|
|
27
42
|
switch (reasonCode) {
|
|
28
43
|
case projects_1.UNMIGRATABLE_REASONS.UP_TO_DATE:
|
|
29
|
-
return
|
|
44
|
+
return en_1.lib.migrate.errors.unmigratableReasons.upToDate;
|
|
30
45
|
case projects_1.UNMIGRATABLE_REASONS.IS_A_PRIVATE_APP:
|
|
31
|
-
return
|
|
46
|
+
return en_1.lib.migrate.errors.unmigratableReasons.isPrivateApp;
|
|
32
47
|
case projects_1.UNMIGRATABLE_REASONS.LISTED_IN_MARKETPLACE:
|
|
33
|
-
return
|
|
48
|
+
return en_1.lib.migrate.errors.unmigratableReasons.listedInMarketplace;
|
|
49
|
+
case projects_1.UNMIGRATABLE_REASONS.PROJECT_CONNECTED_TO_GITHUB:
|
|
50
|
+
return en_1.lib.migrate.errors.unmigratableReasons.projectConnectedToGitHub(projectName, accountId);
|
|
51
|
+
case migrate_1.CLI_UNMIGRATABLE_REASONS.PART_OF_PROJECT_ALREADY:
|
|
52
|
+
return en_1.lib.migrate.errors.unmigratableReasons.partOfProjectAlready;
|
|
34
53
|
default:
|
|
35
|
-
return
|
|
36
|
-
reasonCode,
|
|
37
|
-
});
|
|
54
|
+
return en_1.lib.migrate.errors.unmigratableReasons.generic(reasonCode);
|
|
38
55
|
}
|
|
39
56
|
}
|
|
40
|
-
function
|
|
57
|
+
function generateFilterAppsByProjectNameFunction(projectConfig) {
|
|
41
58
|
return (app) => {
|
|
42
59
|
if (projectConfig) {
|
|
43
60
|
return app.projectName === projectConfig?.projectConfig?.name;
|
|
44
61
|
}
|
|
45
|
-
return
|
|
62
|
+
return true;
|
|
46
63
|
};
|
|
47
64
|
}
|
|
48
|
-
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
function buildErrorMessageFromMigrationStatus(error) {
|
|
66
|
+
const { componentErrors, projectErrorDetail } = error;
|
|
67
|
+
if (!componentErrors || !componentErrors.length) {
|
|
68
|
+
return projectErrorDetail;
|
|
69
|
+
}
|
|
70
|
+
return `${projectErrorDetail}: \n\t- ${componentErrors
|
|
71
|
+
.map(componentError => {
|
|
72
|
+
const { componentType, errorMessage, developerSymbol: uid, } = componentError;
|
|
73
|
+
return `${componentType}${uid ? ` (${uid})` : ''}: ${errorMessage}`;
|
|
74
|
+
})
|
|
75
|
+
.join('\n\t- ')}`;
|
|
76
|
+
}
|
|
77
|
+
async function fetchMigrationApps(appId, derivedAccountId, platformVersion, projectConfig) {
|
|
78
|
+
const { data: { migratableApps, unmigratableApps }, } = await (0, migrate_1.listAppsForMigration)(derivedAccountId, platformVersion);
|
|
79
|
+
const filteredMigratableApps = migratableApps.filter(generateFilterAppsByProjectNameFunction(projectConfig));
|
|
80
|
+
const filteredUnmigratableApps = unmigratableApps.filter(generateFilterAppsByProjectNameFunction(projectConfig));
|
|
53
81
|
const allApps = [...filteredMigratableApps, ...filteredUnmigratableApps];
|
|
54
82
|
if (allApps.length > 1 && projectConfig) {
|
|
55
|
-
throw new Error(
|
|
83
|
+
throw new Error(en_1.lib.migrate.errors.project.multipleApps);
|
|
56
84
|
}
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
85
|
+
if (!projectConfig?.projectConfig) {
|
|
86
|
+
allApps.forEach(app => {
|
|
87
|
+
if (app.projectName) {
|
|
88
|
+
app.isMigratable = false;
|
|
89
|
+
app.unmigratableReason =
|
|
90
|
+
migrate_1.CLI_UNMIGRATABLE_REASONS.PART_OF_PROJECT_ALREADY;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (allApps.length === 0 && projectConfig) {
|
|
95
|
+
throw new Error(en_1.lib.migrate.errors.noAppsForProject(projectConfig?.projectConfig?.name || ''));
|
|
96
|
+
}
|
|
97
|
+
if (allApps.length === 0 || !allApps.some(app => app.isMigratable)) {
|
|
98
|
+
const reasons = filteredUnmigratableApps.map(app => `${chalk_1.default.bold(app.appName)}: ${getUnmigratableReason(app.unmigratableReason, app.projectName, derivedAccountId)}`);
|
|
99
|
+
throw new Error(en_1.lib.migrate.errors.noAppsEligible((0, ui_1.uiAccountDescription)(derivedAccountId), reasons));
|
|
66
100
|
}
|
|
67
101
|
if (appId &&
|
|
68
102
|
!allApps.some(app => {
|
|
69
103
|
return app.appId === appId;
|
|
70
104
|
})) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
appId,
|
|
73
|
-
}));
|
|
105
|
+
throw new Error(en_1.lib.migrate.errors.appWithAppIdNotFound(appId));
|
|
74
106
|
}
|
|
107
|
+
return allApps;
|
|
108
|
+
}
|
|
109
|
+
async function promptForAppToMigrate(allApps, derivedAccountId) {
|
|
75
110
|
const appChoices = allApps.map(app => ({
|
|
76
111
|
name: app.isMigratable
|
|
77
112
|
? app.appName
|
|
@@ -79,38 +114,60 @@ async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
|
|
|
79
114
|
value: app,
|
|
80
115
|
disabled: app.isMigratable
|
|
81
116
|
? false
|
|
82
|
-
: getUnmigratableReason(app.unmigratableReason),
|
|
117
|
+
: getUnmigratableReason(app.unmigratableReason, app.projectName, derivedAccountId),
|
|
83
118
|
}));
|
|
119
|
+
const enabledChoices = appChoices.filter(app => !app.disabled);
|
|
120
|
+
const disabledChoices = appChoices.filter(app => app.disabled);
|
|
121
|
+
const { appId: selectedAppId } = await (0, promptUtils_1.listPrompt)(en_1.lib.migrate.prompt.chooseApp, {
|
|
122
|
+
choices: [
|
|
123
|
+
...enabledChoices,
|
|
124
|
+
new inquirer.Separator(),
|
|
125
|
+
...disabledChoices,
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
return selectedAppId;
|
|
129
|
+
}
|
|
130
|
+
async function selectAppToMigrate(allApps, derivedAccountId, appId) {
|
|
131
|
+
if (appId &&
|
|
132
|
+
!allApps.some(app => {
|
|
133
|
+
return app.appId === appId;
|
|
134
|
+
})) {
|
|
135
|
+
throw new Error(en_1.lib.migrate.errors.appWithAppIdNotFound(appId));
|
|
136
|
+
}
|
|
84
137
|
let appIdToMigrate = appId;
|
|
85
138
|
if (!appIdToMigrate) {
|
|
86
|
-
|
|
87
|
-
choices: appChoices,
|
|
88
|
-
});
|
|
89
|
-
appIdToMigrate = selectedAppId;
|
|
139
|
+
appIdToMigrate = await promptForAppToMigrate(allApps, derivedAccountId);
|
|
90
140
|
}
|
|
91
141
|
const selectedApp = allApps.find(app => app.appId === appIdToMigrate);
|
|
92
|
-
const migratableComponents =
|
|
93
|
-
const unmigratableComponents =
|
|
142
|
+
const migratableComponents = new Set();
|
|
143
|
+
const unmigratableComponents = new Set();
|
|
94
144
|
selectedApp?.migrationComponents.forEach(component => {
|
|
95
145
|
if (component.isSupported) {
|
|
96
|
-
migratableComponents.
|
|
146
|
+
migratableComponents.add((0, transform_1.mapToUserFacingType)(component.componentType));
|
|
97
147
|
}
|
|
98
148
|
else {
|
|
99
|
-
unmigratableComponents.
|
|
149
|
+
unmigratableComponents.add((0, transform_1.mapToUserFacingType)(component.componentType));
|
|
100
150
|
}
|
|
101
151
|
});
|
|
102
|
-
if (migratableComponents.
|
|
103
|
-
logger_1.
|
|
104
|
-
components: `\n - ${migratableComponents.join('\n - ')}`,
|
|
105
|
-
}));
|
|
152
|
+
if (migratableComponents.size !== 0) {
|
|
153
|
+
logger_1.uiLogger.log(en_1.lib.migrate.componentsToBeMigrated(`\n - ${[...migratableComponents].join('\n - ')}`));
|
|
106
154
|
}
|
|
107
|
-
if (unmigratableComponents.
|
|
108
|
-
logger_1.
|
|
109
|
-
components: `\n - ${unmigratableComponents.join('\n - ')}`,
|
|
110
|
-
}));
|
|
155
|
+
if (unmigratableComponents.size !== 0) {
|
|
156
|
+
logger_1.uiLogger.log(en_1.lib.migrate.componentsThatWillNotBeMigrated(`\n - ${[...unmigratableComponents].join('\n - ')}`));
|
|
111
157
|
}
|
|
112
|
-
logger_1.
|
|
113
|
-
const proceed = await (0, promptUtils_1.confirmPrompt)(
|
|
158
|
+
logger_1.uiLogger.log('');
|
|
159
|
+
const proceed = await (0, promptUtils_1.confirmPrompt)(en_1.lib.migrate.prompt.proceed, {
|
|
160
|
+
defaultAnswer: false,
|
|
161
|
+
});
|
|
162
|
+
return {
|
|
163
|
+
proceed,
|
|
164
|
+
appIdToMigrate,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
|
|
168
|
+
const { name, dest, appId } = options;
|
|
169
|
+
const allApps = await fetchMigrationApps(appId, derivedAccountId, options.platformVersion, projectConfig);
|
|
170
|
+
const { proceed, appIdToMigrate } = await selectAppToMigrate(allApps, derivedAccountId, appId);
|
|
114
171
|
if (!proceed) {
|
|
115
172
|
return {};
|
|
116
173
|
}
|
|
@@ -124,32 +181,53 @@ async function handleMigrationSetup(derivedAccountId, options, projectConfig) {
|
|
|
124
181
|
projectDest: projectConfig.projectDir,
|
|
125
182
|
};
|
|
126
183
|
}
|
|
127
|
-
const projectName =
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
184
|
+
const projectName = name ||
|
|
185
|
+
(await (0, promptUtils_1.inputPrompt)(en_1.lib.migrate.prompt.inputName, {
|
|
186
|
+
validate: async (input) => {
|
|
187
|
+
const { projectExists } = await (0, ensureProjectExists_1.ensureProjectExists)(derivedAccountId, input, { allowCreate: false, noLogs: true });
|
|
188
|
+
if (projectExists) {
|
|
189
|
+
return en_1.lib.migrate.errors.project.alreadyExists(input);
|
|
190
|
+
}
|
|
191
|
+
return true;
|
|
192
|
+
},
|
|
134
193
|
}));
|
|
194
|
+
const { projectExists } = await (0, ensureProjectExists_1.ensureProjectExists)(derivedAccountId, projectName, { allowCreate: false, noLogs: true });
|
|
195
|
+
if (projectExists) {
|
|
196
|
+
throw new Error(en_1.lib.migrate.errors.project.alreadyExists(projectName));
|
|
135
197
|
}
|
|
136
198
|
const projectDest = dest ||
|
|
137
|
-
(await (0, promptUtils_1.inputPrompt)(
|
|
199
|
+
(await (0, promptUtils_1.inputPrompt)(en_1.lib.migrate.prompt.inputDest, {
|
|
138
200
|
defaultAnswer: path_1.default.resolve((0, path_2.getCwd)(), (0, path_2.sanitizeFileName)(projectName)),
|
|
139
201
|
}));
|
|
140
202
|
return { appIdToMigrate, projectName, projectDest };
|
|
141
203
|
}
|
|
142
204
|
async function beginMigration(derivedAccountId, appId, platformVersion) {
|
|
143
205
|
SpinniesManager_1.default.add('beginningMigration', {
|
|
144
|
-
text:
|
|
206
|
+
text: en_1.lib.migrate.spinners.beginningMigration,
|
|
145
207
|
});
|
|
146
208
|
const uidMap = {};
|
|
147
209
|
const { data } = await (0, migrate_1.initializeMigration)(derivedAccountId, appId, platformVersion);
|
|
148
210
|
const { migrationId } = data;
|
|
149
|
-
|
|
211
|
+
let pollResponse;
|
|
212
|
+
try {
|
|
213
|
+
pollResponse = await pollMigrationStatus(derivedAccountId, migrationId, [
|
|
214
|
+
Migration_1.MIGRATION_STATUS.INPUT_REQUIRED,
|
|
215
|
+
]);
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
SpinniesManager_1.default.fail('beginningMigration', {
|
|
219
|
+
text: en_1.lib.migrate.spinners.unableToStartMigration,
|
|
220
|
+
});
|
|
221
|
+
if ((0, migrate_1.isMigrationStatus)(error) && error.status === Migration_1.MIGRATION_STATUS.FAILURE) {
|
|
222
|
+
throw new Error(buildErrorMessageFromMigrationStatus(error));
|
|
223
|
+
}
|
|
224
|
+
throw new Error(en_1.lib.migrate.errors.migrationFailed, {
|
|
225
|
+
cause: error,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
150
228
|
if (pollResponse.status !== Migration_1.MIGRATION_STATUS.INPUT_REQUIRED) {
|
|
151
229
|
SpinniesManager_1.default.fail('beginningMigration', {
|
|
152
|
-
text:
|
|
230
|
+
text: en_1.lib.migrate.spinners.unableToStartMigration,
|
|
153
231
|
});
|
|
154
232
|
return;
|
|
155
233
|
}
|
|
@@ -158,18 +236,28 @@ async function beginMigration(derivedAccountId, appId, platformVersion) {
|
|
|
158
236
|
if (Object.values(componentsRequiringUids).length !== 0) {
|
|
159
237
|
for (const [componentId, component] of Object.entries(componentsRequiringUids)) {
|
|
160
238
|
const { componentHint, componentType } = component;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
239
|
+
// Extract the internal ID from the base64-encoded ComponentExternalId
|
|
240
|
+
let internalId;
|
|
241
|
+
try {
|
|
242
|
+
const decoded = Buffer.from(componentId, 'base64').toString('utf8');
|
|
243
|
+
const parts = decoded.split('$$');
|
|
244
|
+
internalId = parts[1] || componentId;
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
// If decoding fails, use the componentId as the internalId
|
|
248
|
+
internalId = componentId;
|
|
249
|
+
}
|
|
250
|
+
const promptText = componentHint
|
|
251
|
+
? `${(0, transform_1.mapToUserFacingType)(componentType)} '${componentHint}' (ID: ${internalId})`
|
|
252
|
+
: `${(0, transform_1.mapToUserFacingType)(componentType)} (ID: ${internalId})`;
|
|
253
|
+
uidMap[componentId] = await (0, promptUtils_1.inputPrompt)(en_1.lib.migrate.prompt.uidForComponent(promptText), {
|
|
166
254
|
validate: (uid) => {
|
|
167
255
|
const result = (0, project_parsing_lib_1.validateUid)(uid);
|
|
168
256
|
return result === undefined ? true : result;
|
|
169
257
|
},
|
|
170
|
-
defaultAnswer:
|
|
171
|
-
.
|
|
172
|
-
|
|
258
|
+
defaultAnswer: componentHint
|
|
259
|
+
? componentHint.replace(/[^A-Za-z0-9_\-.]/g, '')
|
|
260
|
+
: undefined,
|
|
173
261
|
});
|
|
174
262
|
}
|
|
175
263
|
}
|
|
@@ -185,7 +273,7 @@ async function finalizeMigration(derivedAccountId, migrationId, uidMap, projectN
|
|
|
185
273
|
let pollResponse;
|
|
186
274
|
try {
|
|
187
275
|
SpinniesManager_1.default.add('finishingMigration', {
|
|
188
|
-
text:
|
|
276
|
+
text: en_1.lib.migrate.spinners.finishingMigration,
|
|
189
277
|
});
|
|
190
278
|
await (0, migrate_1.continueMigration)(derivedAccountId, migrationId, uidMap, projectName);
|
|
191
279
|
pollResponse = await pollMigrationStatus(derivedAccountId, migrationId, [
|
|
@@ -194,21 +282,21 @@ async function finalizeMigration(derivedAccountId, migrationId, uidMap, projectN
|
|
|
194
282
|
}
|
|
195
283
|
catch (error) {
|
|
196
284
|
SpinniesManager_1.default.fail('finishingMigration', {
|
|
197
|
-
text:
|
|
285
|
+
text: en_1.lib.migrate.spinners.migrationFailed,
|
|
198
286
|
});
|
|
199
287
|
if ((0, migrate_1.isMigrationStatus)(error) && error.status === Migration_1.MIGRATION_STATUS.FAILURE) {
|
|
200
|
-
throw new Error(error
|
|
288
|
+
throw new Error(buildErrorMessageFromMigrationStatus(error));
|
|
201
289
|
}
|
|
202
|
-
throw new Error(
|
|
290
|
+
throw new Error(en_1.lib.migrate.errors.migrationFailed, {
|
|
203
291
|
cause: error,
|
|
204
292
|
});
|
|
205
293
|
}
|
|
206
294
|
if (pollResponse.status !== Migration_1.MIGRATION_STATUS.SUCCESS) {
|
|
207
|
-
throw new Error(
|
|
295
|
+
throw new Error(en_1.lib.migrate.errors.migrationFailed);
|
|
208
296
|
}
|
|
209
297
|
if (pollResponse.status === Migration_1.MIGRATION_STATUS.SUCCESS) {
|
|
210
298
|
SpinniesManager_1.default.succeed('finishingMigration', {
|
|
211
|
-
text:
|
|
299
|
+
text: en_1.lib.migrate.spinners.migrationComplete,
|
|
212
300
|
});
|
|
213
301
|
}
|
|
214
302
|
return pollResponse.buildId;
|
|
@@ -216,7 +304,7 @@ async function finalizeMigration(derivedAccountId, migrationId, uidMap, projectN
|
|
|
216
304
|
async function downloadProjectFiles(derivedAccountId, projectName, buildId, projectDest, projectConfig) {
|
|
217
305
|
try {
|
|
218
306
|
SpinniesManager_1.default.add('fetchingMigratedProject', {
|
|
219
|
-
text:
|
|
307
|
+
text: en_1.lib.migrate.spinners.downloadingProjectContents,
|
|
220
308
|
});
|
|
221
309
|
const { data: zippedProject } = await (0, projects_2.downloadProject)(derivedAccountId, projectName, buildId);
|
|
222
310
|
let absoluteDestPath;
|
|
@@ -227,6 +315,7 @@ async function downloadProjectFiles(derivedAccountId, projectName, buildId, proj
|
|
|
227
315
|
const archiveDest = path_1.default.join(projectDir, 'archive');
|
|
228
316
|
// Move the existing source directory to archive
|
|
229
317
|
fs_1.default.renameSync(path_1.default.join(projectDir, srcDir), archiveDest);
|
|
318
|
+
logger_1.uiLogger.info(en_1.lib.migrate.sourceContentsMoved(archiveDest));
|
|
230
319
|
}
|
|
231
320
|
else {
|
|
232
321
|
absoluteDestPath = projectDest
|
|
@@ -238,27 +327,30 @@ async function downloadProjectFiles(derivedAccountId, projectName, buildId, proj
|
|
|
238
327
|
hideLogs: true,
|
|
239
328
|
});
|
|
240
329
|
SpinniesManager_1.default.succeed('fetchingMigratedProject', {
|
|
241
|
-
text:
|
|
330
|
+
text: en_1.lib.migrate.spinners.downloadingProjectContentsComplete,
|
|
242
331
|
});
|
|
243
|
-
logger_1.
|
|
332
|
+
logger_1.uiLogger.success(`Saved ${projectName} to ${projectDest}`);
|
|
244
333
|
}
|
|
245
334
|
catch (error) {
|
|
246
335
|
SpinniesManager_1.default.fail('fetchingMigratedProject', {
|
|
247
|
-
text:
|
|
336
|
+
text: en_1.lib.migrate.spinners.downloadingProjectContentsFailed,
|
|
248
337
|
});
|
|
249
338
|
throw error;
|
|
250
339
|
}
|
|
251
340
|
}
|
|
252
341
|
async function migrateApp2025_2(derivedAccountId, options, projectConfig) {
|
|
253
342
|
SpinniesManager_1.default.init();
|
|
343
|
+
const ungatedForUnifiedApps = await (0, hasFeature_1.hasFeature)(derivedAccountId, constants_1.FEATURES.UNIFIED_APPS);
|
|
344
|
+
if (!ungatedForUnifiedApps) {
|
|
345
|
+
throw new Error(en_1.lib.migrate.errors.notUngatedForUnifiedApps((0, ui_1.uiAccountDescription)(derivedAccountId)));
|
|
346
|
+
}
|
|
254
347
|
if (projectConfig) {
|
|
255
348
|
if (!projectConfig?.projectConfig || !projectConfig?.projectDir) {
|
|
256
|
-
throw new Error(
|
|
349
|
+
throw new Error(en_1.lib.migrate.errors.project.invalidConfig);
|
|
257
350
|
}
|
|
258
|
-
|
|
259
|
-
const { projectExists } = await (0, projects_3.ensureProjectExists)(derivedAccountId, projectConfig.projectConfig.name, { allowCreate: false, noLogs: true });
|
|
351
|
+
const { projectExists } = await (0, ensureProjectExists_1.ensureProjectExists)(derivedAccountId, projectConfig.projectConfig.name, { allowCreate: false, noLogs: true });
|
|
260
352
|
if (!projectExists) {
|
|
261
|
-
throw new Error(
|
|
353
|
+
throw new Error(en_1.lib.migrate.errors.project.doesNotExist(derivedAccountId));
|
|
262
354
|
}
|
|
263
355
|
}
|
|
264
356
|
const { appIdToMigrate, projectName, projectDest } = await handleMigrationSetup(derivedAccountId, options, projectConfig);
|
|
@@ -272,13 +364,12 @@ async function migrateApp2025_2(derivedAccountId, options, projectConfig) {
|
|
|
272
364
|
const { migrationId, uidMap } = migrationInProgress;
|
|
273
365
|
const buildId = await finalizeMigration(derivedAccountId, migrationId, uidMap, projectConfig?.projectConfig?.name || projectName);
|
|
274
366
|
await downloadProjectFiles(derivedAccountId, projectName, buildId, projectDest, projectConfig);
|
|
367
|
+
logger_1.uiLogger.log((0, ui_1.uiLink)('Project Details', (0, urls_1.getProjectDetailUrl)(projectName, derivedAccountId)));
|
|
368
|
+
logger_1.uiLogger.log((0, ui_1.uiLink)('Build Details', (0, urls_1.getProjectBuildDetailUrl)(projectName, buildId, derivedAccountId)));
|
|
275
369
|
}
|
|
276
|
-
function logInvalidAccountError(
|
|
370
|
+
function logInvalidAccountError() {
|
|
277
371
|
(0, ui_1.uiLine)();
|
|
278
|
-
logger_1.
|
|
279
|
-
logger_1.
|
|
280
|
-
useCommand: (0, ui_1.uiCommandReference)('hs accounts use'),
|
|
281
|
-
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
282
|
-
}));
|
|
372
|
+
logger_1.uiLogger.error(en_1.lib.migrate.errors.invalidAccountTypeTitle);
|
|
373
|
+
logger_1.uiLogger.log(en_1.lib.migrate.errors.invalidAccountTypeDescription((0, ui_1.uiCommandReference)('hs account use'), (0, ui_1.uiCommandReference)('hs auth')));
|
|
283
374
|
(0, ui_1.uiLine)();
|
|
284
375
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
2
|
import { ArgumentsCamelCase } from 'yargs';
|
|
3
|
-
import {
|
|
4
|
-
export declare function migrateApp2023_2(derivedAccountId: number, options: ArgumentsCamelCase<
|
|
3
|
+
import { MigrateAppArgs } from './migrate';
|
|
4
|
+
export declare function migrateApp2023_2(derivedAccountId: number, options: ArgumentsCamelCase<MigrateAppArgs>, accountConfig: CLIAccount): Promise<void>;
|
|
@@ -17,9 +17,9 @@ const exitCodes_1 = require("../enums/exitCodes");
|
|
|
17
17
|
const ui_1 = require("../ui");
|
|
18
18
|
const lang_1 = require("../lang");
|
|
19
19
|
const accountTypes_1 = require("../accountTypes");
|
|
20
|
-
const
|
|
20
|
+
const selectPublicAppForMigrationPrompt_1 = require("../prompts/selectPublicAppForMigrationPrompt");
|
|
21
21
|
const createProjectPrompt_1 = require("../prompts/createProjectPrompt");
|
|
22
|
-
const
|
|
22
|
+
const ensureProjectExists_1 = require("../projects/ensureProjectExists");
|
|
23
23
|
const usageTracking_1 = require("../usageTracking");
|
|
24
24
|
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
25
25
|
const process_1 = require("../process");
|
|
@@ -27,13 +27,14 @@ const polling_1 = require("../polling");
|
|
|
27
27
|
const migrate_1 = require("./migrate");
|
|
28
28
|
async function migrateApp2023_2(derivedAccountId, options, accountConfig) {
|
|
29
29
|
const accountName = (0, ui_1.uiAccountDescription)(derivedAccountId);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const defaultAccountIsUnified = await (0, accountTypes_1.isUnifiedAccount)(accountConfig);
|
|
31
|
+
if (!(0, accountTypes_1.isAppDeveloperAccount)(accountConfig) && !defaultAccountIsUnified) {
|
|
32
|
+
(0, migrate_1.logInvalidAccountError)();
|
|
33
|
+
return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
33
34
|
}
|
|
34
35
|
let appId = options.appId;
|
|
35
36
|
if (!appId) {
|
|
36
|
-
const { appId: selectAppId } = await (0,
|
|
37
|
+
const { appId: selectAppId } = await (0, selectPublicAppForMigrationPrompt_1.selectPublicAppForMigrationPrompt)({
|
|
37
38
|
accountId: derivedAccountId,
|
|
38
39
|
accountName,
|
|
39
40
|
isMigratingApp: true,
|
|
@@ -50,16 +51,16 @@ async function migrateApp2023_2(derivedAccountId, options, accountConfig) {
|
|
|
50
51
|
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.errors.invalidApp`, {
|
|
51
52
|
appId,
|
|
52
53
|
}));
|
|
53
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
54
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
catch (error) {
|
|
57
58
|
(0, errorHandlers_1.logError)(error, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId }));
|
|
58
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
59
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
59
60
|
}
|
|
60
61
|
const createProjectPromptResponse = await (0, createProjectPrompt_1.createProjectPrompt)(options);
|
|
61
62
|
const { name: projectName, dest: projectDest } = createProjectPromptResponse;
|
|
62
|
-
const { projectExists } = await (0,
|
|
63
|
+
const { projectExists } = await (0, ensureProjectExists_1.ensureProjectExists)(derivedAccountId, projectName, {
|
|
63
64
|
allowCreate: false,
|
|
64
65
|
noLogs: true,
|
|
65
66
|
});
|
|
@@ -85,7 +86,7 @@ async function migrateApp2023_2(derivedAccountId, options, accountConfig) {
|
|
|
85
86
|
});
|
|
86
87
|
process.stdin.resume();
|
|
87
88
|
if (!shouldCreateApp) {
|
|
88
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
89
|
+
return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
89
90
|
}
|
|
90
91
|
try {
|
|
91
92
|
SpinniesManager_1.default.init();
|
|
@@ -96,7 +97,7 @@ async function migrateApp2023_2(derivedAccountId, options, accountConfig) {
|
|
|
96
97
|
if ((key.ctrl && key.name === 'c') || key.name === 'q') {
|
|
97
98
|
SpinniesManager_1.default.remove('migrateApp');
|
|
98
99
|
logger_1.logger.log((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.migrationInterrupted`));
|
|
99
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
100
|
+
return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
100
101
|
}
|
|
101
102
|
});
|
|
102
103
|
const { data: migrateResponse } = await (0, projects_1.migrateApp)(derivedAccountId, appId, projectName);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
2
|
+
type PrivateAppInstallUrlArgs = {
|
|
3
|
+
targetAccountId: number;
|
|
4
|
+
env: Environment;
|
|
5
|
+
appId: string;
|
|
6
|
+
};
|
|
7
|
+
type PublicAppInstallUrlArgs = {
|
|
8
|
+
targetAccountId: number;
|
|
9
|
+
env: Environment;
|
|
10
|
+
clientId: string;
|
|
11
|
+
scopes: string[];
|
|
12
|
+
redirectUrls: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare function getOauthAppInstallUrl({ targetAccountId, env, clientId, scopes, redirectUrls, }: PublicAppInstallUrlArgs): string;
|
|
15
|
+
export declare function getStaticAuthAppInstallUrl({ targetAccountId, env, appId, }: PrivateAppInstallUrlArgs): string;
|
|
16
|
+
export {};
|
package/lib/app/urls.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOauthAppInstallUrl = getOauthAppInstallUrl;
|
|
4
|
+
exports.getStaticAuthAppInstallUrl = getStaticAuthAppInstallUrl;
|
|
5
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
6
|
+
function getOauthAppInstallUrl({ targetAccountId, env, clientId, scopes, redirectUrls, }) {
|
|
7
|
+
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
8
|
+
return (`${websiteOrigin}/oauth/${targetAccountId}/authorize` +
|
|
9
|
+
`?client_id=${encodeURIComponent(clientId)}` +
|
|
10
|
+
`&scope=${encodeURIComponent(scopes.join(' '))}` +
|
|
11
|
+
`&redirect_uri=${encodeURIComponent(redirectUrls[0])}`);
|
|
12
|
+
}
|
|
13
|
+
function getStaticAuthAppInstallUrl({ targetAccountId, env, appId, }) {
|
|
14
|
+
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
15
|
+
return `${websiteOrigin}/static-token/${targetAccountId}/authorize?appId=${appId}`;
|
|
16
|
+
}
|
package/lib/buildAccount.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
2
2
|
import { CLIAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
3
|
-
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
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 buildDeveloperTestAccount(testAccountName: string, parentAccountConfig: CLIAccount, env: Environment, portalLimit: number): Promise<
|
|
6
|
+
export declare function buildDeveloperTestAccount(testAccountName: string, parentAccountConfig: CLIAccount, env: Environment, portalLimit: number): Promise<number>;
|
|
8
7
|
type SandboxAccount = SandboxResponse & {
|
|
9
8
|
name: string;
|
|
10
9
|
};
|
package/lib/buildAccount.js
CHANGED
|
@@ -61,49 +61,50 @@ async function saveAccountToConfig(accountId, accountName, env, personalAccessKe
|
|
|
61
61
|
return validName;
|
|
62
62
|
}
|
|
63
63
|
async function buildDeveloperTestAccount(testAccountName, parentAccountConfig, env, portalLimit) {
|
|
64
|
-
const i18nKey = 'lib.developerTestAccount.create.loading';
|
|
65
64
|
const id = (0, getAccountIdentifier_1.getAccountIdentifier)(parentAccountConfig);
|
|
66
65
|
const parentAccountId = (0, config_1.getAccountId)(id);
|
|
67
66
|
if (!parentAccountId) {
|
|
68
|
-
throw new Error((0, lang_1.i18n)(
|
|
67
|
+
throw new Error((0, lang_1.i18n)(`lib.developerTestAccount.create.loading.fail`));
|
|
69
68
|
}
|
|
70
69
|
SpinniesManager_1.default.init({
|
|
71
70
|
succeedColor: 'white',
|
|
72
71
|
});
|
|
73
72
|
logger_1.logger.log('');
|
|
74
73
|
SpinniesManager_1.default.add('buildDeveloperTestAccount', {
|
|
75
|
-
text: (0, lang_1.i18n)(
|
|
74
|
+
text: (0, lang_1.i18n)(`lib.developerTestAccount.create.loading.add`, {
|
|
76
75
|
accountName: testAccountName,
|
|
77
76
|
}),
|
|
78
77
|
});
|
|
79
|
-
let
|
|
78
|
+
let developerTestAccountId;
|
|
79
|
+
let developerTestAccountPersonalAccessKey;
|
|
80
80
|
try {
|
|
81
81
|
const { data } = await (0, developerTestAccounts_1.createDeveloperTestAccount)(parentAccountId, testAccountName);
|
|
82
|
-
|
|
82
|
+
developerTestAccountId = data.id;
|
|
83
|
+
developerTestAccountPersonalAccessKey = data.personalAccessKey;
|
|
83
84
|
SpinniesManager_1.default.succeed('buildDeveloperTestAccount', {
|
|
84
|
-
text: (0, lang_1.i18n)(
|
|
85
|
+
text: (0, lang_1.i18n)(`lib.developerTestAccount.create.loading.succeed`, {
|
|
85
86
|
accountName: testAccountName,
|
|
86
|
-
accountId:
|
|
87
|
+
accountId: developerTestAccountId,
|
|
87
88
|
}),
|
|
88
89
|
});
|
|
89
90
|
}
|
|
90
91
|
catch (e) {
|
|
91
92
|
(0, index_1.debugError)(e);
|
|
92
93
|
SpinniesManager_1.default.fail('buildDeveloperTestAccount', {
|
|
93
|
-
text: (0, lang_1.i18n)(
|
|
94
|
+
text: (0, lang_1.i18n)(`lib.developerTestAccount.create.loading.fail`, {
|
|
94
95
|
accountName: testAccountName,
|
|
95
96
|
}),
|
|
96
97
|
});
|
|
97
98
|
(0, developerTestAccounts_2.handleDeveloperTestAccountCreateError)(e, parentAccountId, env, portalLimit);
|
|
98
99
|
}
|
|
99
100
|
try {
|
|
100
|
-
await saveAccountToConfig(
|
|
101
|
+
await saveAccountToConfig(developerTestAccountId, testAccountName, env, developerTestAccountPersonalAccessKey);
|
|
101
102
|
}
|
|
102
103
|
catch (err) {
|
|
103
104
|
(0, index_1.logError)(err);
|
|
104
105
|
throw err;
|
|
105
106
|
}
|
|
106
|
-
return
|
|
107
|
+
return developerTestAccountId;
|
|
107
108
|
}
|
|
108
109
|
async function buildSandbox(sandboxName, parentAccountConfig, sandboxType, env, force = false) {
|
|
109
110
|
let i18nKey;
|