@hubspot/cli 8.3.0 → 8.4.0-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/bin/cli.js +2 -0
- package/commands/account/auth.js +12 -22
- package/commands/account/clean.js +5 -6
- package/commands/account/createOverride.js +7 -7
- package/commands/account/info.js +2 -1
- package/commands/account/list.js +3 -5
- package/commands/account/remove.js +2 -3
- package/commands/account/removeOverride.js +8 -10
- package/commands/account/rename.js +5 -6
- package/commands/account/use.js +8 -19
- package/commands/api.d.ts +10 -0
- package/commands/api.js +164 -0
- package/commands/app/migrate.js +8 -8
- package/commands/app/secret/add.js +6 -7
- package/commands/app/secret/delete.js +9 -10
- package/commands/app/secret/list.js +6 -7
- package/commands/app/secret/update.js +8 -9
- package/commands/auth.js +12 -12
- package/commands/cms/app/create.js +9 -5
- package/commands/cms/convertFields.js +8 -8
- package/commands/cms/delete.js +2 -3
- package/commands/cms/fetch.js +7 -7
- package/commands/cms/function/create.js +9 -5
- package/commands/cms/function/deploy.js +2 -3
- package/commands/cms/function/list.js +11 -7
- package/commands/cms/function/logs.js +17 -23
- package/commands/cms/function/server.js +2 -3
- package/commands/cms/getReactModule.js +7 -8
- package/commands/cms/lighthouseScore.js +25 -24
- package/commands/cms/lint.js +4 -5
- package/commands/cms/list.js +5 -6
- package/commands/cms/module/create.js +9 -5
- package/commands/cms/module/marketplace-validate.js +7 -8
- package/commands/cms/mv.js +2 -3
- package/commands/cms/template/create.js +10 -6
- package/commands/cms/theme/create.js +5 -5
- package/commands/cms/theme/generate-selectors.js +5 -4
- package/commands/cms/theme/marketplace-validate.js +8 -9
- package/commands/cms/theme/preview.js +16 -8
- package/commands/cms/upload.js +15 -12
- package/commands/cms/watch.js +5 -5
- package/commands/cms/webpack/create.js +5 -5
- package/commands/completion.js +3 -5
- package/commands/config/migrate.js +6 -7
- package/commands/config/set.js +5 -6
- package/commands/customObject/create.js +4 -5
- package/commands/customObject/createSchema.js +4 -5
- package/commands/customObject/deleteSchema.js +4 -5
- package/commands/customObject/fetchAllSchemas.js +2 -3
- package/commands/customObject/fetchSchema.js +2 -3
- package/commands/customObject/listSchemas.js +2 -3
- package/commands/customObject/updateSchema.js +4 -5
- package/commands/doctor.js +8 -8
- package/commands/feedback.js +6 -4
- package/commands/filemanager/fetch.js +5 -6
- package/commands/filemanager/upload.js +5 -5
- package/commands/getStarted.js +14 -16
- package/commands/hubdb/clear.js +5 -6
- package/commands/hubdb/create.js +4 -5
- package/commands/hubdb/delete.js +8 -9
- package/commands/hubdb/fetch.js +5 -6
- package/commands/hubdb/list.js +16 -14
- package/commands/init.js +14 -17
- package/commands/mcp/setup.js +5 -6
- package/commands/mcp/start.js +2 -3
- package/commands/open.js +4 -5
- package/commands/project/add.js +10 -5
- package/commands/project/create.js +10 -10
- package/commands/project/delete.d.ts +7 -0
- package/commands/project/delete.js +74 -0
- package/commands/project/deploy.js +36 -34
- package/commands/project/dev/deprecatedFlow.js +42 -15
- package/commands/project/dev/index.d.ts +3 -3
- package/commands/project/dev/index.js +24 -30
- package/commands/project/dev/unifiedFlow.js +37 -14
- package/commands/project/download.js +10 -11
- package/commands/project/info.d.ts +4 -0
- package/commands/project/info.js +67 -0
- package/commands/project/installDeps.js +9 -6
- package/commands/project/lint.js +11 -8
- package/commands/project/list.js +14 -14
- package/commands/project/listBuilds.js +8 -6
- package/commands/project/logs.js +5 -6
- package/commands/project/migrate.js +8 -8
- package/commands/project/open.js +5 -6
- package/commands/project/profile/add.js +12 -8
- package/commands/project/profile/delete.js +15 -11
- package/commands/project/updateDeps.js +9 -6
- package/commands/project/upload.js +31 -17
- package/commands/project/validate.js +11 -11
- package/commands/project/watch.js +20 -20
- package/commands/project.js +4 -0
- package/commands/sandbox/create.js +15 -15
- package/commands/sandbox/delete.js +13 -14
- package/commands/secret/addSecret.js +6 -7
- package/commands/secret/deleteSecret.js +5 -6
- package/commands/secret/listSecret.js +2 -3
- package/commands/secret/updateSecret.js +4 -5
- package/commands/testAccount/create.d.ts +1 -1
- package/commands/testAccount/create.js +20 -16
- package/commands/testAccount/createConfig.js +7 -8
- package/commands/testAccount/delete.js +27 -18
- package/commands/testAccount/importData.js +6 -7
- package/commands/upgrade.js +9 -10
- package/lang/en.d.ts +114 -5
- package/lang/en.js +111 -5
- package/lib/accountAuth.js +2 -2
- package/lib/buildAccount.js +3 -3
- package/lib/doctor/Diagnosis.js +5 -5
- package/lib/errorHandlers/index.js +4 -3
- package/lib/errorHandlers/suppressError.js +4 -0
- package/lib/errors/PromptExitError.d.ts +4 -2
- package/lib/errors/PromptExitError.js +3 -0
- package/lib/process.d.ts +1 -1
- package/lib/process.js +10 -3
- package/lib/projects/delete.d.ts +13 -0
- package/lib/projects/delete.js +193 -0
- package/lib/projects/localDev/AppDevModeInterface.js +11 -11
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +3 -1
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
- package/lib/projects/localDev/DevSessionManager.d.ts +6 -3
- package/lib/projects/localDev/DevSessionManager.js +31 -19
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.d.ts +3 -0
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +16 -12
- package/lib/projects/localDev/LocalDevProcess.js +6 -5
- package/lib/projects/localDev/LocalDevState.d.ts +3 -2
- package/lib/projects/localDev/LocalDevState.js +3 -1
- package/lib/projects/localDev/helpers/account.d.ts +4 -3
- package/lib/projects/localDev/helpers/account.js +16 -19
- package/lib/projects/localDev/helpers/process.d.ts +1 -1
- package/lib/projects/localDev/helpers/process.js +4 -10
- package/lib/projects/localDev/helpers/project.d.ts +4 -3
- package/lib/projects/localDev/helpers/project.js +31 -15
- package/lib/projects/projectInfo.d.ts +5 -0
- package/lib/projects/projectInfo.js +82 -0
- package/lib/projects/projectProfiles.d.ts +1 -2
- package/lib/projects/projectProfiles.js +5 -17
- package/lib/prompts/createApiSamplePrompt.js +4 -0
- package/lib/prompts/projectProfilePrompt.d.ts +2 -0
- package/lib/prompts/projectProfilePrompt.js +46 -0
- package/lib/prompts/promptUtils.js +3 -2
- package/lib/prompts/selectHubDBTablePrompt.js +2 -2
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +2 -2
- package/lib/theme/cmsDevServerProcess.d.ts +2 -0
- package/lib/theme/cmsDevServerProcess.js +7 -6
- package/lib/ui/SpinniesManager.d.ts +1 -0
- package/lib/ui/SpinniesManager.js +20 -6
- package/lib/ui/spinniesUtils.d.ts +0 -1
- package/lib/ui/spinniesUtils.js +6 -16
- package/lib/usageTracking.d.ts +3 -4
- package/lib/yargs/makeYargsBuilder.d.ts +13 -0
- package/lib/yargs/makeYargsBuilder.js +33 -0
- package/lib/yargs/makeYargsHandlerWithUsageTracking.d.ts +3 -0
- package/lib/yargs/makeYargsHandlerWithUsageTracking.js +95 -0
- package/lib/yargs/strictEnforceBoolean.d.ts +1 -0
- package/lib/yargs/strictEnforceBoolean.js +13 -0
- package/lib/yargsUtils.d.ts +3 -16
- package/lib/yargsUtils.js +3 -48
- package/package.json +9 -4
- package/types/LocalDev.d.ts +5 -0
- package/types/Projects.d.ts +19 -0
- package/types/Yargs.d.ts +18 -1
- package/api/__tests__/migrate.test.d.ts +0 -1
- package/api/__tests__/migrate.test.js +0 -199
- package/commands/__tests__/account.test.d.ts +0 -1
- package/commands/__tests__/account.test.js +0 -69
- package/commands/__tests__/auth.test.d.ts +0 -1
- package/commands/__tests__/auth.test.js +0 -43
- package/commands/__tests__/cms.test.d.ts +0 -1
- package/commands/__tests__/cms.test.js +0 -87
- package/commands/__tests__/config.test.d.ts +0 -1
- package/commands/__tests__/config.test.js +0 -44
- package/commands/__tests__/customObject.test.d.ts +0 -1
- package/commands/__tests__/customObject.test.js +0 -68
- package/commands/__tests__/doctor.test.d.ts +0 -1
- package/commands/__tests__/doctor.test.js +0 -132
- package/commands/__tests__/feedback.test.d.ts +0 -1
- package/commands/__tests__/feedback.test.js +0 -24
- package/commands/__tests__/filemanager.test.d.ts +0 -1
- package/commands/__tests__/filemanager.test.js +0 -45
- package/commands/__tests__/getStarted.test.d.ts +0 -1
- package/commands/__tests__/getStarted.test.js +0 -173
- package/commands/__tests__/hubdb.test.d.ts +0 -1
- package/commands/__tests__/hubdb.test.js +0 -50
- package/commands/__tests__/init.test.d.ts +0 -1
- package/commands/__tests__/init.test.js +0 -42
- package/commands/__tests__/mcp.test.d.ts +0 -1
- package/commands/__tests__/mcp.test.js +0 -46
- package/commands/__tests__/open.test.d.ts +0 -1
- package/commands/__tests__/open.test.js +0 -58
- package/commands/__tests__/project.test.d.ts +0 -1
- package/commands/__tests__/project.test.js +0 -125
- package/commands/__tests__/sandbox.test.d.ts +0 -1
- package/commands/__tests__/sandbox.test.js +0 -44
- package/commands/__tests__/secret.test.d.ts +0 -1
- package/commands/__tests__/secret.test.js +0 -49
- package/commands/__tests__/testAccount.test.d.ts +0 -1
- package/commands/__tests__/testAccount.test.js +0 -57
- package/commands/__tests__/upgrade.test.d.ts +0 -1
- package/commands/__tests__/upgrade.test.js +0 -309
- package/commands/account/__tests__/auth.test.d.ts +0 -1
- package/commands/account/__tests__/auth.test.js +0 -206
- package/commands/account/__tests__/clean.test.d.ts +0 -1
- package/commands/account/__tests__/clean.test.js +0 -28
- package/commands/account/__tests__/createOverride.test.d.ts +0 -1
- package/commands/account/__tests__/createOverride.test.js +0 -32
- package/commands/account/__tests__/info.test.d.ts +0 -1
- package/commands/account/__tests__/info.test.js +0 -28
- package/commands/account/__tests__/list.test.d.ts +0 -1
- package/commands/account/__tests__/list.test.js +0 -153
- package/commands/account/__tests__/remove.test.d.ts +0 -1
- package/commands/account/__tests__/remove.test.js +0 -36
- package/commands/account/__tests__/removeOverride.d.ts +0 -1
- package/commands/account/__tests__/removeOverride.js +0 -25
- package/commands/account/__tests__/rename.test.d.ts +0 -1
- package/commands/account/__tests__/rename.test.js +0 -82
- package/commands/account/__tests__/use.test.d.ts +0 -1
- package/commands/account/__tests__/use.test.js +0 -170
- package/commands/app/__tests__/migrate.test.d.ts +0 -1
- package/commands/app/__tests__/migrate.test.js +0 -111
- package/commands/app/secret/__tests__/add.test.d.ts +0 -1
- package/commands/app/secret/__tests__/add.test.js +0 -140
- package/commands/app/secret/__tests__/delete.test.d.ts +0 -1
- package/commands/app/secret/__tests__/delete.test.js +0 -28
- package/commands/app/secret/__tests__/list.test.d.ts +0 -1
- package/commands/app/secret/__tests__/list.test.js +0 -25
- package/commands/app/secret/__tests__/update.test.d.ts +0 -1
- package/commands/app/secret/__tests__/update.test.js +0 -28
- package/commands/cms/__tests__/delete.test.d.ts +0 -1
- package/commands/cms/__tests__/delete.test.js +0 -39
- package/commands/cms/__tests__/fetch.test.d.ts +0 -1
- package/commands/cms/__tests__/fetch.test.js +0 -156
- package/commands/cms/__tests__/function.test.d.ts +0 -1
- package/commands/cms/__tests__/function.test.js +0 -50
- package/commands/cms/__tests__/lint.test.d.ts +0 -1
- package/commands/cms/__tests__/lint.test.js +0 -33
- package/commands/cms/__tests__/list.test.d.ts +0 -1
- package/commands/cms/__tests__/list.test.js +0 -42
- package/commands/cms/__tests__/module.test.d.ts +0 -1
- package/commands/cms/__tests__/module.test.js +0 -45
- package/commands/cms/__tests__/mv.test.d.ts +0 -1
- package/commands/cms/__tests__/mv.test.js +0 -46
- package/commands/cms/__tests__/theme.test.d.ts +0 -1
- package/commands/cms/__tests__/theme.test.js +0 -54
- package/commands/cms/__tests__/upload.test.d.ts +0 -1
- package/commands/cms/__tests__/upload.test.js +0 -312
- package/commands/cms/__tests__/watch.test.d.ts +0 -1
- package/commands/cms/__tests__/watch.test.js +0 -204
- package/commands/cms/function/__tests__/logs.test.d.ts +0 -1
- package/commands/cms/function/__tests__/logs.test.js +0 -70
- package/commands/cms/theme/__tests__/generate-selectors.test.d.ts +0 -1
- package/commands/cms/theme/__tests__/generate-selectors.test.js +0 -28
- package/commands/cms/theme/__tests__/marketplace-validate.test.d.ts +0 -1
- package/commands/cms/theme/__tests__/marketplace-validate.test.js +0 -36
- package/commands/cms/theme/__tests__/preview.test.d.ts +0 -1
- package/commands/cms/theme/__tests__/preview.test.js +0 -54
- package/commands/customObject/__tests__/create.test.d.ts +0 -1
- package/commands/customObject/__tests__/create.test.js +0 -40
- package/commands/customObject/__tests__/createSchema.test.d.ts +0 -1
- package/commands/customObject/__tests__/createSchema.test.js +0 -28
- package/commands/customObject/__tests__/deleteSchema.test.d.ts +0 -1
- package/commands/customObject/__tests__/deleteSchema.test.js +0 -42
- package/commands/customObject/__tests__/fetch-all-schemas.test.d.ts +0 -1
- package/commands/customObject/__tests__/fetch-all-schemas.test.js +0 -41
- package/commands/customObject/__tests__/fetchSchema.test.d.ts +0 -1
- package/commands/customObject/__tests__/fetchSchema.test.js +0 -45
- package/commands/customObject/__tests__/listSchemas.test.d.ts +0 -1
- package/commands/customObject/__tests__/listSchemas.test.js +0 -29
- package/commands/customObject/__tests__/updateSchema.test.d.ts +0 -1
- package/commands/customObject/__tests__/updateSchema.test.js +0 -40
- package/commands/filemanager/__tests__/fetch.test.d.ts +0 -1
- package/commands/filemanager/__tests__/fetch.test.js +0 -32
- package/commands/filemanager/__tests__/upload.test.d.ts +0 -1
- package/commands/filemanager/__tests__/upload.test.js +0 -191
- package/commands/hubdb/__tests__/clear.test.d.ts +0 -1
- package/commands/hubdb/__tests__/clear.test.js +0 -28
- package/commands/hubdb/__tests__/create.test.d.ts +0 -1
- package/commands/hubdb/__tests__/create.test.js +0 -28
- package/commands/hubdb/__tests__/delete.test.d.ts +0 -1
- package/commands/hubdb/__tests__/delete.test.js +0 -28
- package/commands/hubdb/__tests__/fetch.test.d.ts +0 -1
- package/commands/hubdb/__tests__/fetch.test.js +0 -28
- package/commands/hubdb/__tests__/list.test.d.ts +0 -1
- package/commands/hubdb/__tests__/list.test.js +0 -88
- package/commands/mcp/__tests__/setup.test.d.ts +0 -1
- package/commands/mcp/__tests__/setup.test.js +0 -26
- package/commands/mcp/__tests__/start.test.d.ts +0 -1
- package/commands/mcp/__tests__/start.test.js +0 -144
- package/commands/project/__tests__/add.test.d.ts +0 -1
- package/commands/project/__tests__/add.test.js +0 -107
- package/commands/project/__tests__/create.test.d.ts +0 -1
- package/commands/project/__tests__/create.test.js +0 -97
- package/commands/project/__tests__/deploy.test.d.ts +0 -1
- package/commands/project/__tests__/deploy.test.js +0 -307
- package/commands/project/__tests__/dev.test.d.ts +0 -1
- package/commands/project/__tests__/dev.test.js +0 -273
- package/commands/project/__tests__/devUnifiedFlow.test.d.ts +0 -1
- package/commands/project/__tests__/devUnifiedFlow.test.js +0 -434
- package/commands/project/__tests__/download.test.d.ts +0 -1
- package/commands/project/__tests__/download.test.js +0 -39
- package/commands/project/__tests__/installDeps.test.d.ts +0 -1
- package/commands/project/__tests__/installDeps.test.js +0 -140
- package/commands/project/__tests__/lint.test.d.ts +0 -1
- package/commands/project/__tests__/lint.test.js +0 -704
- package/commands/project/__tests__/list.test.d.ts +0 -1
- package/commands/project/__tests__/list.test.js +0 -31
- package/commands/project/__tests__/listBuilds.test.d.ts +0 -1
- package/commands/project/__tests__/listBuilds.test.js +0 -38
- package/commands/project/__tests__/logs.test.d.ts +0 -1
- package/commands/project/__tests__/logs.test.js +0 -202
- package/commands/project/__tests__/migrate.test.d.ts +0 -1
- package/commands/project/__tests__/migrate.test.js +0 -106
- package/commands/project/__tests__/open.test.d.ts +0 -1
- package/commands/project/__tests__/open.test.js +0 -39
- package/commands/project/__tests__/profile.test.d.ts +0 -1
- package/commands/project/__tests__/profile.test.js +0 -42
- package/commands/project/__tests__/updateDeps.test.d.ts +0 -1
- package/commands/project/__tests__/updateDeps.test.js +0 -140
- package/commands/project/__tests__/upload.test.d.ts +0 -1
- package/commands/project/__tests__/upload.test.js +0 -234
- package/commands/project/__tests__/validate.test.d.ts +0 -1
- package/commands/project/__tests__/validate.test.js +0 -381
- package/commands/project/__tests__/watch.test.d.ts +0 -1
- package/commands/project/__tests__/watch.test.js +0 -35
- package/commands/sandbox/__tests__/create.test.d.ts +0 -1
- package/commands/sandbox/__tests__/create.test.js +0 -198
- package/commands/sandbox/__tests__/delete.test.d.ts +0 -1
- package/commands/sandbox/__tests__/delete.test.js +0 -31
- package/commands/secret/__tests__/addSecret.test.d.ts +0 -1
- package/commands/secret/__tests__/addSecret.test.js +0 -162
- package/commands/secret/__tests__/deleteSecret.test.d.ts +0 -1
- package/commands/secret/__tests__/deleteSecret.test.js +0 -41
- package/commands/secret/__tests__/listSecret.test.d.ts +0 -1
- package/commands/secret/__tests__/listSecret.test.js +0 -29
- package/commands/secret/__tests__/updateSecret.test.d.ts +0 -1
- package/commands/secret/__tests__/updateSecret.test.js +0 -29
- package/commands/testAccount/__tests__/create.test.d.ts +0 -1
- package/commands/testAccount/__tests__/create.test.js +0 -106
- package/commands/testAccount/__tests__/createConfig.test.d.ts +0 -1
- package/commands/testAccount/__tests__/createConfig.test.js +0 -32
- package/commands/testAccount/__tests__/delete.test.d.ts +0 -1
- package/commands/testAccount/__tests__/delete.test.js +0 -29
- package/commands/testAccount/__tests__/importData.test.d.ts +0 -1
- package/commands/testAccount/__tests__/importData.test.js +0 -92
- package/lib/__tests__/CLIWebSocketServer.test.d.ts +0 -1
- package/lib/__tests__/CLIWebSocketServer.test.js +0 -252
- package/lib/__tests__/accountAuth.test.d.ts +0 -1
- package/lib/__tests__/accountAuth.test.js +0 -258
- package/lib/__tests__/accountTypes.test.d.ts +0 -1
- package/lib/__tests__/accountTypes.test.js +0 -98
- package/lib/__tests__/buildAccount.test.d.ts +0 -1
- package/lib/__tests__/buildAccount.test.js +0 -211
- package/lib/__tests__/cliUpgradeUtils.test.d.ts +0 -1
- package/lib/__tests__/cliUpgradeUtils.test.js +0 -131
- package/lib/__tests__/commandSuggestion.test.d.ts +0 -1
- package/lib/__tests__/commandSuggestion.test.js +0 -121
- package/lib/__tests__/commonOpts.test.d.ts +0 -1
- package/lib/__tests__/commonOpts.test.js +0 -80
- package/lib/__tests__/dependencyManagement.test.d.ts +0 -1
- package/lib/__tests__/dependencyManagement.test.js +0 -1067
- package/lib/__tests__/developerTestAccounts.test.d.ts +0 -1
- package/lib/__tests__/developerTestAccounts.test.js +0 -156
- package/lib/__tests__/hasFeature.test.d.ts +0 -1
- package/lib/__tests__/hasFeature.test.js +0 -167
- package/lib/__tests__/http.test.d.ts +0 -1
- package/lib/__tests__/http.test.js +0 -40
- package/lib/__tests__/importData.test.d.ts +0 -1
- package/lib/__tests__/importData.test.js +0 -98
- package/lib/__tests__/npmCli.test.d.ts +0 -1
- package/lib/__tests__/npmCli.test.js +0 -84
- package/lib/__tests__/oauth.test.d.ts +0 -1
- package/lib/__tests__/oauth.test.js +0 -109
- package/lib/__tests__/parsing.test.d.ts +0 -1
- package/lib/__tests__/parsing.test.js +0 -34
- package/lib/__tests__/polling.test.d.ts +0 -1
- package/lib/__tests__/polling.test.js +0 -76
- package/lib/__tests__/process.test.d.ts +0 -1
- package/lib/__tests__/process.test.js +0 -89
- package/lib/__tests__/sandboxes.test.d.ts +0 -1
- package/lib/__tests__/sandboxes.test.js +0 -128
- package/lib/__tests__/serverlessLogs.test.d.ts +0 -1
- package/lib/__tests__/serverlessLogs.test.js +0 -163
- package/lib/__tests__/usageTracking.test.d.ts +0 -1
- package/lib/__tests__/usageTracking.test.js +0 -197
- package/lib/__tests__/validation.test.d.ts +0 -1
- package/lib/__tests__/validation.test.js +0 -143
- package/lib/__tests__/yargsUtils.test.d.ts +0 -1
- package/lib/__tests__/yargsUtils.test.js +0 -124
- package/lib/app/__tests__/migrate.test.d.ts +0 -1
- package/lib/app/__tests__/migrate.test.js +0 -638
- package/lib/doctor/__tests__/Diagnosis.test.d.ts +0 -1
- package/lib/doctor/__tests__/Diagnosis.test.js +0 -84
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +0 -1
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +0 -177
- package/lib/doctor/__tests__/Doctor.test.d.ts +0 -1
- package/lib/doctor/__tests__/Doctor.test.js +0 -560
- package/lib/errorHandlers/__tests__/index.test.d.ts +0 -1
- package/lib/errorHandlers/__tests__/index.test.js +0 -278
- package/lib/mcp/__tests__/setup.test.d.ts +0 -1
- package/lib/mcp/__tests__/setup.test.js +0 -523
- package/lib/middleware/__tests__/commandTargetingUtils.test.d.ts +0 -1
- package/lib/middleware/__tests__/commandTargetingUtils.test.js +0 -99
- package/lib/middleware/__tests__/configMiddleware.test.d.ts +0 -1
- package/lib/middleware/__tests__/configMiddleware.test.js +0 -118
- package/lib/middleware/__tests__/gitMiddleware.test.d.ts +0 -1
- package/lib/middleware/__tests__/gitMiddleware.test.js +0 -43
- package/lib/middleware/__tests__/requestMiddleware.test.d.ts +0 -1
- package/lib/middleware/__tests__/requestMiddleware.test.js +0 -15
- package/lib/middleware/__tests__/usageTrackingMiddleware.test.d.ts +0 -1
- package/lib/middleware/__tests__/usageTrackingMiddleware.test.js +0 -44
- package/lib/middleware/__tests__/yargsChecksMiddleware.test.d.ts +0 -1
- package/lib/middleware/__tests__/yargsChecksMiddleware.test.js +0 -39
- package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +0 -1
- package/lib/projects/__tests__/AppDevModeInterface.test.js +0 -541
- package/lib/projects/__tests__/DevServerManager.test.d.ts +0 -1
- package/lib/projects/__tests__/DevServerManager.test.js +0 -185
- package/lib/projects/__tests__/DevSessionManager.test.d.ts +0 -1
- package/lib/projects/__tests__/DevSessionManager.test.js +0 -250
- package/lib/projects/__tests__/LocalDevProcess.test.d.ts +0 -1
- package/lib/projects/__tests__/LocalDevProcess.test.js +0 -481
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +0 -1
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +0 -231
- package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +0 -1
- package/lib/projects/__tests__/ProjectLogsManager.test.js +0 -302
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.d.ts +0 -1
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.js +0 -160
- package/lib/projects/__tests__/components.test.d.ts +0 -1
- package/lib/projects/__tests__/components.test.js +0 -440
- package/lib/projects/__tests__/deploy.test.d.ts +0 -1
- package/lib/projects/__tests__/deploy.test.js +0 -231
- package/lib/projects/__tests__/localDevProjectHelpers.test.d.ts +0 -1
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +0 -120
- package/lib/projects/__tests__/platformVersion.test.d.ts +0 -1
- package/lib/projects/__tests__/platformVersion.test.js +0 -63
- package/lib/projects/__tests__/pollProjectBuildAndDeploy.test.d.ts +0 -1
- package/lib/projects/__tests__/pollProjectBuildAndDeploy.test.js +0 -328
- package/lib/projects/__tests__/projectProfiles.test.d.ts +0 -1
- package/lib/projects/__tests__/projectProfiles.test.js +0 -441
- package/lib/projects/__tests__/projects.test.d.ts +0 -1
- package/lib/projects/__tests__/projects.test.js +0 -58
- package/lib/projects/__tests__/structure.test.d.ts +0 -1
- package/lib/projects/__tests__/structure.test.js +0 -210
- package/lib/projects/__tests__/uieLinting.test.d.ts +0 -1
- package/lib/projects/__tests__/uieLinting.test.js +0 -631
- package/lib/projects/__tests__/upload.test.d.ts +0 -1
- package/lib/projects/__tests__/upload.test.js +0 -183
- package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +0 -1
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +0 -245
- package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +0 -1
- package/lib/projects/add/__tests__/v2AddComponent.test.js +0 -343
- package/lib/projects/create/__tests__/legacy.test.d.ts +0 -1
- package/lib/projects/create/__tests__/legacy.test.js +0 -72
- package/lib/projects/create/__tests__/v2.test.d.ts +0 -1
- package/lib/projects/create/__tests__/v2.test.js +0 -257
- package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.js +0 -157
- package/lib/prompts/__tests__/createFunctionPrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/createFunctionPrompt.test.js +0 -129
- package/lib/prompts/__tests__/createModulePrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/createModulePrompt.test.js +0 -187
- package/lib/prompts/__tests__/createTemplatePrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/createTemplatePrompt.test.js +0 -102
- package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +0 -31
- package/lib/prompts/__tests__/projectAddPrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/projectAddPrompt.test.js +0 -143
- package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/projectsLogsPrompt.test.js +0 -37
- package/lib/prompts/__tests__/selectProjectTemplatePrompt.test.d.ts +0 -1
- package/lib/prompts/__tests__/selectProjectTemplatePrompt.test.js +0 -160
- package/lib/theme/__tests__/migrate.test.d.ts +0 -1
- package/lib/theme/__tests__/migrate.test.js +0 -247
- package/lib/ui/__tests__/SpinniesManager.test.d.ts +0 -1
- package/lib/ui/__tests__/SpinniesManager.test.js +0 -488
- package/lib/ui/__tests__/removeAnsiCodes.test.d.ts +0 -1
- package/lib/ui/__tests__/removeAnsiCodes.test.js +0 -84
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.d.ts +0 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +0 -254
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.d.ts +0 -1
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +0 -227
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.d.ts +0 -1
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +0 -208
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.d.ts +0 -1
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +0 -186
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.d.ts +0 -1
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +0 -124
- package/mcp-server/tools/cms/__tests__/HsListTool.test.d.ts +0 -1
- package/mcp-server/tools/cms/__tests__/HsListTool.test.js +0 -124
- package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +0 -157
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +0 -131
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +0 -461
- package/mcp-server/tools/project/__tests__/DeployProjectTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +0 -125
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +0 -125
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +0 -210
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +0 -146
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +0 -124
- package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +0 -307
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +0 -242
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +0 -209
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +0 -158
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +0 -187
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +0 -1
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +0 -118
- package/mcp-server/utils/__tests__/command.test.d.ts +0 -1
- package/mcp-server/utils/__tests__/command.test.js +0 -275
- package/mcp-server/utils/__tests__/content.test.d.ts +0 -1
- package/mcp-server/utils/__tests__/content.test.js +0 -164
- package/mcp-server/utils/__tests__/feedbackTracking.test.d.ts +0 -1
- package/mcp-server/utils/__tests__/feedbackTracking.test.js +0 -69
|
@@ -1,638 +0,0 @@
|
|
|
1
|
-
import { uiLogger } from '../../ui/logger.js';
|
|
2
|
-
import { getCwd, sanitizeFileName } from '@hubspot/local-dev-lib/path';
|
|
3
|
-
import { extractZipArchive } from '@hubspot/local-dev-lib/archive';
|
|
4
|
-
import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
|
|
5
|
-
import { validateUid } from '@hubspot/project-parsing-lib/uid';
|
|
6
|
-
import { UNMIGRATABLE_REASONS } from '@hubspot/local-dev-lib/constants/projects';
|
|
7
|
-
import { MIGRATION_STATUS } from '@hubspot/local-dev-lib/types/Migration';
|
|
8
|
-
import { downloadProject, fetchProjectComponentsMetadata, } from '@hubspot/local-dev-lib/api/projects';
|
|
9
|
-
import fs from 'fs';
|
|
10
|
-
import { confirmPrompt, inputPrompt, listPrompt, } from '../../prompts/promptUtils.js';
|
|
11
|
-
import { ensureProjectExists } from '../../projects/ensureProjectExists.js';
|
|
12
|
-
import { poll } from '../../polling.js';
|
|
13
|
-
import { CLI_UNMIGRATABLE_REASONS, continueAppMigration, initializeAppMigration, listAppsForMigration, } from '../../../api/migrate.js';
|
|
14
|
-
import { lib } from '../../../lang/en.js';
|
|
15
|
-
import { hasUnfiedAppsAccess } from '../../hasFeature.js';
|
|
16
|
-
import { getUnmigratableReason, generateFilterAppsByProjectNameFunction, buildErrorMessageFromMigrationStatus, fetchMigrationApps, promptForAppToMigrate, selectAppToMigrate, handleMigrationSetup, beginAppMigration, pollMigrationStatus, finalizeAppMigration, downloadProjectFiles, migrateApp, logInvalidAccountError, validateMigrationApps, } from '../migrate.js';
|
|
17
|
-
vi.mock('@hubspot/local-dev-lib/path');
|
|
18
|
-
vi.mock('@hubspot/local-dev-lib/archive');
|
|
19
|
-
vi.mock('@hubspot/project-parsing-lib/uid');
|
|
20
|
-
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
21
|
-
vi.mock('../../prompts/promptUtils');
|
|
22
|
-
vi.mock('../../projects/config');
|
|
23
|
-
vi.mock('../../projects/ensureProjectExists');
|
|
24
|
-
vi.mock('../../ui/SpinniesManager');
|
|
25
|
-
vi.mock('../../polling');
|
|
26
|
-
vi.mock('../../../api/migrate');
|
|
27
|
-
vi.mock('../../hasFeature');
|
|
28
|
-
vi.mock('@hubspot/local-dev-lib/config');
|
|
29
|
-
vi.mock('../../projects/urls');
|
|
30
|
-
vi.mock('fs');
|
|
31
|
-
const mockedUiLogger = uiLogger;
|
|
32
|
-
const mockedGetCwd = getCwd;
|
|
33
|
-
const mockedSanitizeFileName = sanitizeFileName;
|
|
34
|
-
const mockedExtractZipArchive = extractZipArchive;
|
|
35
|
-
const mockedValidateUid = validateUid;
|
|
36
|
-
const mockedDownloadProject = downloadProject;
|
|
37
|
-
const mockedFetchProjectComponentsMetadata = fetchProjectComponentsMetadata;
|
|
38
|
-
const mockedGetConfigAccountById = getConfigAccountById;
|
|
39
|
-
const mockedConfirmPrompt = confirmPrompt;
|
|
40
|
-
const mockedInputPrompt = inputPrompt;
|
|
41
|
-
const mockedListPrompt = listPrompt;
|
|
42
|
-
const mockedEnsureProjectExists = ensureProjectExists;
|
|
43
|
-
const mockedPoll = poll;
|
|
44
|
-
const mockedListAppsForMigration = listAppsForMigration;
|
|
45
|
-
const mockedInitializeAppMigration = initializeAppMigration;
|
|
46
|
-
const mockedContinueAppMigration = continueAppMigration;
|
|
47
|
-
const mockedHasUnfiedAppsAccess = hasUnfiedAppsAccess;
|
|
48
|
-
const mockedFs = fs;
|
|
49
|
-
const createMockMigratableApp = (id, name, projectName) => ({
|
|
50
|
-
appId: id,
|
|
51
|
-
appName: name,
|
|
52
|
-
isMigratable: true,
|
|
53
|
-
migrationComponents: [],
|
|
54
|
-
...(projectName && { projectName }),
|
|
55
|
-
});
|
|
56
|
-
const createMockUnmigratableApp = (id, name, reason) => ({
|
|
57
|
-
appId: id,
|
|
58
|
-
appName: name,
|
|
59
|
-
isMigratable: false,
|
|
60
|
-
// @ts-expect-error
|
|
61
|
-
unmigratableReason: reason,
|
|
62
|
-
migrationComponents: [],
|
|
63
|
-
});
|
|
64
|
-
const createLoadedProjectConfig = (name) => ({
|
|
65
|
-
projectConfig: { name, srcDir: 'src' },
|
|
66
|
-
projectDir: MOCK_PROJECT_DIR,
|
|
67
|
-
});
|
|
68
|
-
const ACCOUNT_ID = 123;
|
|
69
|
-
const PROJECT_NAME = 'Test Project';
|
|
70
|
-
const APP_ID = 1;
|
|
71
|
-
const PLATFORM_VERSION = '2025.2';
|
|
72
|
-
const MIGRATION_ID = 456;
|
|
73
|
-
const BUILD_ID = 789;
|
|
74
|
-
const PROJECT_DEST = '/mock/dest';
|
|
75
|
-
const MOCK_CWD = '/mock/cwd';
|
|
76
|
-
const MOCK_PROJECT_DIR = '/mock/project/dir';
|
|
77
|
-
const mockUnmigratableApps = [
|
|
78
|
-
createMockUnmigratableApp(3, 'App 3', UNMIGRATABLE_REASONS.UP_TO_DATE),
|
|
79
|
-
createMockUnmigratableApp(4, 'App 4', UNMIGRATABLE_REASONS.IS_A_PRIVATE_APP),
|
|
80
|
-
];
|
|
81
|
-
describe('lib/app/migrate', () => {
|
|
82
|
-
beforeEach(() => {
|
|
83
|
-
mockedGetCwd.mockReturnValue(MOCK_CWD);
|
|
84
|
-
mockedSanitizeFileName.mockImplementation(name => name);
|
|
85
|
-
mockedValidateUid.mockReturnValue(undefined);
|
|
86
|
-
mockedHasUnfiedAppsAccess.mockResolvedValue(true);
|
|
87
|
-
mockedFs.renameSync.mockImplementation(() => { });
|
|
88
|
-
// Mock account config for the test account ID
|
|
89
|
-
mockedGetConfigAccountById.mockReturnValue({
|
|
90
|
-
accountId: ACCOUNT_ID,
|
|
91
|
-
name: 'Test Account',
|
|
92
|
-
authType: 'personalaccesskey',
|
|
93
|
-
auth: {
|
|
94
|
-
tokenInfo: {
|
|
95
|
-
accessToken: 'test-token',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
env: 'prod',
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe('getUnmigratableReason', () => {
|
|
102
|
-
const testCases = [
|
|
103
|
-
{
|
|
104
|
-
name: 'UP_TO_DATE',
|
|
105
|
-
reason: UNMIGRATABLE_REASONS.UP_TO_DATE,
|
|
106
|
-
expected: lib.migrate.errors.unmigratableReasons.upToDate,
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
name: 'IS_A_PRIVATE_APP',
|
|
110
|
-
reason: UNMIGRATABLE_REASONS.IS_A_PRIVATE_APP,
|
|
111
|
-
expected: lib.migrate.errors.unmigratableReasons.isPrivateApp,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'LISTED_IN_MARKETPLACE',
|
|
115
|
-
reason: UNMIGRATABLE_REASONS.LISTED_IN_MARKETPLACE,
|
|
116
|
-
expected: lib.migrate.errors.unmigratableReasons.listedInMarketplace,
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'PROJECT_CONNECTED_TO_GITHUB',
|
|
120
|
-
reason: UNMIGRATABLE_REASONS.PROJECT_CONNECTED_TO_GITHUB,
|
|
121
|
-
expected: lib.migrate.errors.unmigratableReasons.projectConnectedToGitHub(PROJECT_NAME, ACCOUNT_ID),
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'PART_OF_PROJECT_ALREADY',
|
|
125
|
-
reason: CLI_UNMIGRATABLE_REASONS.PART_OF_PROJECT_ALREADY,
|
|
126
|
-
expected: lib.migrate.errors.unmigratableReasons.partOfProjectAlready,
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'UNKNOWN_REASON',
|
|
130
|
-
reason: 'UNKNOWN_REASON',
|
|
131
|
-
expected: lib.migrate.errors.unmigratableReasons.generic('UNKNOWN_REASON'),
|
|
132
|
-
},
|
|
133
|
-
];
|
|
134
|
-
testCases.forEach(testCase => {
|
|
135
|
-
it(`should return the correct message for ${testCase.name}`, () => {
|
|
136
|
-
const result = getUnmigratableReason(testCase.reason, PROJECT_NAME, ACCOUNT_ID);
|
|
137
|
-
expect(result).toBe(testCase.expected);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe('generateFilterAppsByProjectNameFunction', () => {
|
|
142
|
-
it('should return a function that filters by project name when projectConfig is provided', () => {
|
|
143
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
144
|
-
const filterFn = generateFilterAppsByProjectNameFunction(projectConfig);
|
|
145
|
-
const matchingApp = createMockMigratableApp(1, 'App 1', PROJECT_NAME);
|
|
146
|
-
const nonMatchingApp = createMockMigratableApp(2, 'App 2', 'Other Project');
|
|
147
|
-
expect(filterFn(matchingApp)).toBe(true);
|
|
148
|
-
expect(filterFn(nonMatchingApp)).toBe(false);
|
|
149
|
-
});
|
|
150
|
-
it('should return a function that always returns true when projectConfig is not provided', () => {
|
|
151
|
-
const filterFn = generateFilterAppsByProjectNameFunction(undefined);
|
|
152
|
-
const app1 = createMockMigratableApp(1, 'App 1', PROJECT_NAME);
|
|
153
|
-
const app2 = createMockMigratableApp(2, 'App 2', 'Other Project');
|
|
154
|
-
expect(filterFn(app1)).toBe(true);
|
|
155
|
-
expect(filterFn(app2)).toBe(true);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
describe('buildErrorMessageFromMigrationStatus', () => {
|
|
159
|
-
it('should return projectErrorDetail when there are no component errors', () => {
|
|
160
|
-
const error = {
|
|
161
|
-
id: 123,
|
|
162
|
-
status: MIGRATION_STATUS.FAILURE,
|
|
163
|
-
projectErrorDetail: 'Project error',
|
|
164
|
-
componentErrors: [],
|
|
165
|
-
};
|
|
166
|
-
const result = buildErrorMessageFromMigrationStatus(error);
|
|
167
|
-
expect(result).toBe('Project error');
|
|
168
|
-
});
|
|
169
|
-
it('should return formatted error message with component errors', () => {
|
|
170
|
-
const error = {
|
|
171
|
-
id: 123,
|
|
172
|
-
status: MIGRATION_STATUS.FAILURE,
|
|
173
|
-
projectErrorDetail: 'Project error',
|
|
174
|
-
componentErrors: [
|
|
175
|
-
{
|
|
176
|
-
componentType: 'CARD',
|
|
177
|
-
developerSymbol: 'card1',
|
|
178
|
-
errorMessage: 'Card error',
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
componentType: 'FUNCTION',
|
|
182
|
-
errorMessage: 'Function error',
|
|
183
|
-
},
|
|
184
|
-
],
|
|
185
|
-
};
|
|
186
|
-
const result = buildErrorMessageFromMigrationStatus(error);
|
|
187
|
-
expect(result).toBe('Project error: \n\t- CARD (card1): Card error\n\t- FUNCTION: Function error');
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
describe('fetchMigrationApps', () => {
|
|
191
|
-
const setupMockApps = (migratableApps = [], unmigratableApps = []) => {
|
|
192
|
-
// @ts-expect-error
|
|
193
|
-
mockedListAppsForMigration.mockResolvedValue({
|
|
194
|
-
data: {
|
|
195
|
-
migratableApps,
|
|
196
|
-
unmigratableApps,
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
};
|
|
200
|
-
beforeEach(() => {
|
|
201
|
-
setupMockApps([
|
|
202
|
-
createMockMigratableApp(1, 'App 1', PROJECT_NAME),
|
|
203
|
-
createMockMigratableApp(2, 'App 2', PROJECT_NAME),
|
|
204
|
-
], [createMockUnmigratableApp(3, 'App 3', UNMIGRATABLE_REASONS.UP_TO_DATE)]);
|
|
205
|
-
});
|
|
206
|
-
it('should return all apps when no projectConfig is provided', async () => {
|
|
207
|
-
setupMockApps([createMockMigratableApp(1, 'App 1')]);
|
|
208
|
-
const result = await fetchMigrationApps(ACCOUNT_ID, PLATFORM_VERSION, {});
|
|
209
|
-
expect(result.migratableApps).toHaveLength(1);
|
|
210
|
-
expect(result.migratableApps[0].appId).toBe(1);
|
|
211
|
-
expect(result.unmigratableApps).toHaveLength(0);
|
|
212
|
-
});
|
|
213
|
-
it('should filter apps by project name when projectConfig is provided', async () => {
|
|
214
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
215
|
-
setupMockApps([createMockMigratableApp(1, 'App 1', PROJECT_NAME)]);
|
|
216
|
-
const result = await fetchMigrationApps(ACCOUNT_ID, PLATFORM_VERSION, {
|
|
217
|
-
projectConfig,
|
|
218
|
-
});
|
|
219
|
-
expect(result.migratableApps).toHaveLength(1);
|
|
220
|
-
expect(result.migratableApps[0].projectName).toBe(PROJECT_NAME);
|
|
221
|
-
});
|
|
222
|
-
it('should pass appId to listAppsForMigration when provided', async () => {
|
|
223
|
-
setupMockApps([createMockMigratableApp(1, 'App 1')]);
|
|
224
|
-
await fetchMigrationApps(ACCOUNT_ID, PLATFORM_VERSION, {
|
|
225
|
-
appId: APP_ID,
|
|
226
|
-
});
|
|
227
|
-
expect(mockedListAppsForMigration).toHaveBeenCalledWith(ACCOUNT_ID, PLATFORM_VERSION, APP_ID);
|
|
228
|
-
});
|
|
229
|
-
it('should pass undefined appId to listAppsForMigration when not provided', async () => {
|
|
230
|
-
setupMockApps([createMockMigratableApp(1, 'App 1')]);
|
|
231
|
-
await fetchMigrationApps(ACCOUNT_ID, PLATFORM_VERSION, {});
|
|
232
|
-
expect(mockedListAppsForMigration).toHaveBeenCalledWith(ACCOUNT_ID, PLATFORM_VERSION, undefined);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
describe('validateMigrationApps', () => {
|
|
236
|
-
const mockMigratableApp1 = createMockMigratableApp(1, 'App 1', PROJECT_NAME);
|
|
237
|
-
const mockMigratableApp2 = createMockMigratableApp(2, 'App 2', PROJECT_NAME);
|
|
238
|
-
it('should throw an error when multiple apps are found for a project', async () => {
|
|
239
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
240
|
-
await expect(validateMigrationApps(APP_ID, ACCOUNT_ID, {
|
|
241
|
-
migratableApps: [mockMigratableApp1, mockMigratableApp2],
|
|
242
|
-
unmigratableApps: [],
|
|
243
|
-
}, projectConfig)).rejects.toThrow(lib.migrate.errors.project.multipleApps);
|
|
244
|
-
});
|
|
245
|
-
it('should throw an error when no apps are found for a project', async () => {
|
|
246
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
247
|
-
await expect(validateMigrationApps(APP_ID, ACCOUNT_ID, { migratableApps: [], unmigratableApps: [] }, projectConfig)).rejects.toThrow(lib.migrate.errors.noAppsForProject(PROJECT_NAME));
|
|
248
|
-
});
|
|
249
|
-
it('should throw an error when no migratable apps are found', async () => {
|
|
250
|
-
await expect(validateMigrationApps(APP_ID, ACCOUNT_ID, {
|
|
251
|
-
migratableApps: [],
|
|
252
|
-
unmigratableApps: mockUnmigratableApps,
|
|
253
|
-
})).rejects.toThrow(/No apps in account/);
|
|
254
|
-
});
|
|
255
|
-
it('should throw an error when appId is provided but not found', async () => {
|
|
256
|
-
await expect(validateMigrationApps(APP_ID, ACCOUNT_ID, {
|
|
257
|
-
migratableApps: [],
|
|
258
|
-
unmigratableApps: [],
|
|
259
|
-
})).rejects.toThrow(/No apps in account/);
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
describe('promptForAppToMigrate', () => {
|
|
263
|
-
const mockApps = [
|
|
264
|
-
createMockMigratableApp(1, 'App 1'),
|
|
265
|
-
createMockUnmigratableApp(2, 'App 2', UNMIGRATABLE_REASONS.UP_TO_DATE),
|
|
266
|
-
];
|
|
267
|
-
beforeEach(() => {
|
|
268
|
-
mockedListPrompt.mockResolvedValue(mockApps[0]);
|
|
269
|
-
});
|
|
270
|
-
it('should prompt the user to select an app', async () => {
|
|
271
|
-
await promptForAppToMigrate(mockApps, ACCOUNT_ID);
|
|
272
|
-
expect(mockedListPrompt).toHaveBeenCalledWith(lib.migrate.prompt.chooseApp, expect.any(Object));
|
|
273
|
-
});
|
|
274
|
-
it('should return the selected app', async () => {
|
|
275
|
-
mockedListPrompt.mockResolvedValue({ appId: mockApps[0].appId });
|
|
276
|
-
const result = await promptForAppToMigrate(mockApps, ACCOUNT_ID);
|
|
277
|
-
expect(result).toBe(mockApps[0].appId);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
describe('selectAppToMigrate', () => {
|
|
281
|
-
const mockApps = [
|
|
282
|
-
{
|
|
283
|
-
appId: 1,
|
|
284
|
-
appName: 'App 1',
|
|
285
|
-
isMigratable: true,
|
|
286
|
-
migrationComponents: [
|
|
287
|
-
{ id: '1', componentType: 'CARD', isSupported: true },
|
|
288
|
-
{ id: '2', componentType: 'FUNCTION', isSupported: false },
|
|
289
|
-
],
|
|
290
|
-
},
|
|
291
|
-
createMockUnmigratableApp(2, 'App 2', UNMIGRATABLE_REASONS.UP_TO_DATE),
|
|
292
|
-
];
|
|
293
|
-
beforeEach(() => {
|
|
294
|
-
mockedListPrompt.mockResolvedValue({ appId: 1 });
|
|
295
|
-
mockedConfirmPrompt.mockResolvedValue(true);
|
|
296
|
-
});
|
|
297
|
-
it('should throw an error when appId is provided but not found', async () => {
|
|
298
|
-
await expect(selectAppToMigrate(mockApps, ACCOUNT_ID, 999)).rejects.toThrow(lib.migrate.errors.appWithAppIdNotFound(999));
|
|
299
|
-
});
|
|
300
|
-
it('should call listPrompt when appId is not provided', async () => {
|
|
301
|
-
await selectAppToMigrate(mockApps, ACCOUNT_ID);
|
|
302
|
-
expect(mockedListPrompt).toHaveBeenCalledWith(lib.migrate.prompt.chooseApp, expect.any(Object));
|
|
303
|
-
});
|
|
304
|
-
it('should return proceed: false and appIdToMigrate when user cancels', async () => {
|
|
305
|
-
mockedConfirmPrompt.mockResolvedValue(false);
|
|
306
|
-
const result = await selectAppToMigrate(mockApps, ACCOUNT_ID);
|
|
307
|
-
expect(result).toEqual({ proceed: false, appIdToMigrate: 1 });
|
|
308
|
-
});
|
|
309
|
-
it('should return proceed: true and appIdToMigrate when user confirms', async () => {
|
|
310
|
-
const result = await selectAppToMigrate(mockApps, ACCOUNT_ID);
|
|
311
|
-
expect(result).toEqual({ proceed: true, appIdToMigrate: 1 });
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
describe('handleMigrationSetup', () => {
|
|
315
|
-
const defaultOptions = {
|
|
316
|
-
name: PROJECT_NAME,
|
|
317
|
-
dest: PROJECT_DEST,
|
|
318
|
-
appId: APP_ID,
|
|
319
|
-
platformVersion: PLATFORM_VERSION,
|
|
320
|
-
unstable: false,
|
|
321
|
-
};
|
|
322
|
-
beforeEach(() => {
|
|
323
|
-
setupMockForHandleMigrationSetup();
|
|
324
|
-
});
|
|
325
|
-
function setupMockForHandleMigrationSetup() {
|
|
326
|
-
// @ts-expect-error
|
|
327
|
-
mockedListAppsForMigration.mockResolvedValue({
|
|
328
|
-
data: {
|
|
329
|
-
migratableApps: [createMockMigratableApp(1, 'App 1')],
|
|
330
|
-
unmigratableApps: [],
|
|
331
|
-
},
|
|
332
|
-
});
|
|
333
|
-
mockedListPrompt.mockResolvedValue({ appId: 1 });
|
|
334
|
-
mockedConfirmPrompt.mockResolvedValue(true);
|
|
335
|
-
mockedEnsureProjectExists.mockResolvedValue({ projectExists: false });
|
|
336
|
-
}
|
|
337
|
-
it('should return early when user cancels', async () => {
|
|
338
|
-
mockedConfirmPrompt.mockResolvedValueOnce(false);
|
|
339
|
-
const result = await handleMigrationSetup(ACCOUNT_ID, defaultOptions);
|
|
340
|
-
expect(result).toEqual({});
|
|
341
|
-
});
|
|
342
|
-
it('should return project details when projectConfig is provided', async () => {
|
|
343
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
344
|
-
// @ts-expect-error
|
|
345
|
-
mockedListAppsForMigration.mockResolvedValueOnce({
|
|
346
|
-
data: {
|
|
347
|
-
migratableApps: [createMockMigratableApp(1, 'App 1', PROJECT_NAME)],
|
|
348
|
-
unmigratableApps: [],
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
const result = await handleMigrationSetup(ACCOUNT_ID, defaultOptions, projectConfig);
|
|
352
|
-
expect(result).toEqual({
|
|
353
|
-
appIdToMigrate: 1,
|
|
354
|
-
projectName: PROJECT_NAME,
|
|
355
|
-
projectDest: MOCK_PROJECT_DIR,
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
it('should prompt for project name when not provided', async () => {
|
|
359
|
-
const optionsWithoutName = { ...defaultOptions, name: undefined };
|
|
360
|
-
mockedInputPrompt.mockResolvedValue('New Project');
|
|
361
|
-
await handleMigrationSetup(ACCOUNT_ID, optionsWithoutName);
|
|
362
|
-
expect(mockedInputPrompt).toHaveBeenCalledWith(lib.migrate.prompt.inputName, expect.any(Object));
|
|
363
|
-
});
|
|
364
|
-
it('should prompt for project destination when not provided', async () => {
|
|
365
|
-
const optionsWithoutDest = { ...defaultOptions, dest: undefined };
|
|
366
|
-
mockedInputPrompt.mockResolvedValue('/mock/new/dest');
|
|
367
|
-
await handleMigrationSetup(ACCOUNT_ID, optionsWithoutDest);
|
|
368
|
-
expect(mockedInputPrompt).toHaveBeenCalledWith(lib.migrate.prompt.inputDest, expect.any(Object));
|
|
369
|
-
});
|
|
370
|
-
it('should throw an error when project already exists', async () => {
|
|
371
|
-
mockedEnsureProjectExists.mockResolvedValue({ projectExists: true });
|
|
372
|
-
await expect(handleMigrationSetup(ACCOUNT_ID, defaultOptions)).rejects.toThrow(lib.migrate.errors.project.alreadyExists(PROJECT_NAME));
|
|
373
|
-
});
|
|
374
|
-
});
|
|
375
|
-
describe('beginAppMigration', () => {
|
|
376
|
-
beforeEach(() => {
|
|
377
|
-
// @ts-expect-error
|
|
378
|
-
mockedInitializeAppMigration.mockResolvedValue({
|
|
379
|
-
data: { migrationId: MIGRATION_ID },
|
|
380
|
-
});
|
|
381
|
-
mockedPoll.mockResolvedValue({
|
|
382
|
-
status: MIGRATION_STATUS.INPUT_REQUIRED,
|
|
383
|
-
// @ts-expect-error
|
|
384
|
-
componentsRequiringUids: {},
|
|
385
|
-
});
|
|
386
|
-
mockedInputPrompt.mockResolvedValue('test-uid');
|
|
387
|
-
});
|
|
388
|
-
it('should initialize migration and return migrationId and uidMap', async () => {
|
|
389
|
-
const result = await beginAppMigration(ACCOUNT_ID, APP_ID, PLATFORM_VERSION);
|
|
390
|
-
expect(result).toEqual({
|
|
391
|
-
migrationId: MIGRATION_ID,
|
|
392
|
-
uidMap: {},
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
it('should prompt for UIDs when components require them', async () => {
|
|
396
|
-
const componentHint = 'test-card';
|
|
397
|
-
mockedPoll.mockResolvedValue({
|
|
398
|
-
status: MIGRATION_STATUS.INPUT_REQUIRED,
|
|
399
|
-
// @ts-expect-error
|
|
400
|
-
componentsRequiringUids: {
|
|
401
|
-
'1': {
|
|
402
|
-
componentType: 'CARD',
|
|
403
|
-
componentHint,
|
|
404
|
-
},
|
|
405
|
-
},
|
|
406
|
-
});
|
|
407
|
-
await beginAppMigration(ACCOUNT_ID, APP_ID, PLATFORM_VERSION);
|
|
408
|
-
expect(mockedInputPrompt).toHaveBeenCalledWith(lib.migrate.prompt.uidForComponent("card 'test-card' (ID: 1)"), {
|
|
409
|
-
defaultAnswer: componentHint,
|
|
410
|
-
validate: expect.any(Function),
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
it('should throw an error when migration fails', async () => {
|
|
414
|
-
mockedPoll.mockRejectedValue(new Error('Failed'));
|
|
415
|
-
await expect(beginAppMigration(ACCOUNT_ID, APP_ID, PLATFORM_VERSION)).rejects.toThrow(/Migration Failed/);
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
describe('pollMigrationStatus', () => {
|
|
419
|
-
it('should call poll with checkMigrationStatusV2', async () => {
|
|
420
|
-
const mockStatus = {
|
|
421
|
-
id: MIGRATION_ID,
|
|
422
|
-
status: MIGRATION_STATUS.SUCCESS,
|
|
423
|
-
buildId: BUILD_ID,
|
|
424
|
-
};
|
|
425
|
-
mockedPoll.mockResolvedValue(mockStatus);
|
|
426
|
-
const result = await pollMigrationStatus(ACCOUNT_ID, MIGRATION_ID);
|
|
427
|
-
expect(mockedPoll).toHaveBeenCalledWith(expect.any(Function), expect.any(Object), 300_000);
|
|
428
|
-
expect(result).toBe(mockStatus);
|
|
429
|
-
});
|
|
430
|
-
});
|
|
431
|
-
describe('finalizeAppMigration', () => {
|
|
432
|
-
const uidMap = { '1': 'test-uid' };
|
|
433
|
-
beforeEach(() => {
|
|
434
|
-
// @ts-expect-error
|
|
435
|
-
mockedContinueAppMigration.mockResolvedValue({
|
|
436
|
-
data: { migrationId: MIGRATION_ID },
|
|
437
|
-
});
|
|
438
|
-
mockedPoll.mockResolvedValue({
|
|
439
|
-
status: MIGRATION_STATUS.SUCCESS,
|
|
440
|
-
// @ts-expect-error
|
|
441
|
-
buildId: BUILD_ID,
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
it('should continue migration and return buildId', async () => {
|
|
445
|
-
const result = await finalizeAppMigration(ACCOUNT_ID, MIGRATION_ID, uidMap, PROJECT_NAME);
|
|
446
|
-
expect(result).toBe(BUILD_ID);
|
|
447
|
-
});
|
|
448
|
-
it('should throw an error when migration fails', async () => {
|
|
449
|
-
mockedPoll.mockRejectedValue(new Error('Test error'));
|
|
450
|
-
await expect(finalizeAppMigration(ACCOUNT_ID, MIGRATION_ID, uidMap, PROJECT_NAME)).rejects.toThrow(/Migration Failed/);
|
|
451
|
-
});
|
|
452
|
-
});
|
|
453
|
-
describe('downloadProjectFiles', () => {
|
|
454
|
-
beforeEach(() => {
|
|
455
|
-
// @ts-expect-error
|
|
456
|
-
mockedDownloadProject.mockResolvedValue({
|
|
457
|
-
data: Buffer.from('mock-zip-data'),
|
|
458
|
-
});
|
|
459
|
-
mockedExtractZipArchive.mockResolvedValue(true);
|
|
460
|
-
mockedGetCwd.mockReturnValue(MOCK_CWD);
|
|
461
|
-
mockedSanitizeFileName.mockReturnValue(PROJECT_NAME);
|
|
462
|
-
});
|
|
463
|
-
it('should download and extract project files', async () => {
|
|
464
|
-
await downloadProjectFiles(ACCOUNT_ID, PROJECT_NAME, BUILD_ID, PROJECT_DEST);
|
|
465
|
-
expect(mockedDownloadProject).toHaveBeenCalledWith(ACCOUNT_ID, PROJECT_NAME, BUILD_ID);
|
|
466
|
-
expect(mockedExtractZipArchive).toHaveBeenCalledWith(expect.any(Buffer), PROJECT_NAME, expect.stringContaining(PROJECT_DEST), {
|
|
467
|
-
includesRootDir: true,
|
|
468
|
-
hideLogs: true,
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
it('should handle projectConfig correctly', async () => {
|
|
472
|
-
const projectConfig = {
|
|
473
|
-
projectConfig: { name: PROJECT_NAME, srcDir: 'src' },
|
|
474
|
-
projectDir: MOCK_PROJECT_DIR,
|
|
475
|
-
};
|
|
476
|
-
await downloadProjectFiles(ACCOUNT_ID, PROJECT_NAME, BUILD_ID, PROJECT_DEST, projectConfig);
|
|
477
|
-
expect(mockedFs.renameSync).toHaveBeenCalledWith(`${MOCK_PROJECT_DIR}/src`, `${MOCK_PROJECT_DIR}/archive`);
|
|
478
|
-
expect(mockedExtractZipArchive).toHaveBeenCalledWith(expect.any(Buffer), PROJECT_NAME, MOCK_PROJECT_DIR, {
|
|
479
|
-
includesRootDir: true,
|
|
480
|
-
hideLogs: true,
|
|
481
|
-
});
|
|
482
|
-
});
|
|
483
|
-
it('should throw an error when download fails', async () => {
|
|
484
|
-
const error = new Error('Download failed');
|
|
485
|
-
mockedDownloadProject.mockRejectedValue(error);
|
|
486
|
-
await expect(downloadProjectFiles(ACCOUNT_ID, PROJECT_NAME, BUILD_ID, PROJECT_DEST)).rejects.toThrow(error);
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
describe('migrateApp', () => {
|
|
490
|
-
const options = {
|
|
491
|
-
name: PROJECT_NAME,
|
|
492
|
-
dest: PROJECT_DEST,
|
|
493
|
-
appId: APP_ID,
|
|
494
|
-
platformVersion: PLATFORM_VERSION,
|
|
495
|
-
unstable: false,
|
|
496
|
-
};
|
|
497
|
-
beforeEach(() => {
|
|
498
|
-
mockedHasUnfiedAppsAccess.mockResolvedValue(true);
|
|
499
|
-
});
|
|
500
|
-
it('should throw an error when account is not ungated for unified apps', async () => {
|
|
501
|
-
mockedHasUnfiedAppsAccess.mockResolvedValueOnce(false);
|
|
502
|
-
await expect(migrateApp(ACCOUNT_ID, options)).rejects.toThrowError(/isn't enrolled in the required product beta to access this command./);
|
|
503
|
-
});
|
|
504
|
-
it('should throw an error when projectConfig is invalid', async () => {
|
|
505
|
-
const invalidProjectConfig = {
|
|
506
|
-
projectConfig: undefined,
|
|
507
|
-
projectDir: '/mock/project/dir',
|
|
508
|
-
};
|
|
509
|
-
await expect(migrateApp(ACCOUNT_ID, options, invalidProjectConfig)).rejects.toThrow(/The project configuration file is invalid/);
|
|
510
|
-
});
|
|
511
|
-
it('should throw an error when project does not exist', async () => {
|
|
512
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
513
|
-
mockedEnsureProjectExists.mockResolvedValueOnce({
|
|
514
|
-
projectExists: false,
|
|
515
|
-
});
|
|
516
|
-
await expect(migrateApp(ACCOUNT_ID, options, projectConfig)).rejects.toThrow(/Migrations are only supported for existing projects/);
|
|
517
|
-
});
|
|
518
|
-
it('should extract appId from project components when project exists', async () => {
|
|
519
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
520
|
-
const extractedAppId = 27031427;
|
|
521
|
-
mockedEnsureProjectExists.mockResolvedValueOnce({
|
|
522
|
-
projectExists: true,
|
|
523
|
-
project: { id: 123, name: PROJECT_NAME },
|
|
524
|
-
});
|
|
525
|
-
mockedFetchProjectComponentsMetadata.mockResolvedValueOnce({
|
|
526
|
-
data: {
|
|
527
|
-
topLevelComponentMetadata: [
|
|
528
|
-
{
|
|
529
|
-
componentName: 'My Public App',
|
|
530
|
-
type: { name: 'PUBLIC_APP' },
|
|
531
|
-
deployOutput: { appId: extractedAppId },
|
|
532
|
-
featureComponents: [],
|
|
533
|
-
},
|
|
534
|
-
],
|
|
535
|
-
},
|
|
536
|
-
});
|
|
537
|
-
// @ts-expect-error Mock
|
|
538
|
-
mockedListAppsForMigration.mockResolvedValueOnce({
|
|
539
|
-
data: {
|
|
540
|
-
migratableApps: [
|
|
541
|
-
createMockMigratableApp(extractedAppId, 'App 1', PROJECT_NAME),
|
|
542
|
-
],
|
|
543
|
-
unmigratableApps: [],
|
|
544
|
-
},
|
|
545
|
-
});
|
|
546
|
-
mockedListPrompt.mockResolvedValue({ appId: extractedAppId });
|
|
547
|
-
mockedConfirmPrompt.mockResolvedValueOnce(false);
|
|
548
|
-
await migrateApp(ACCOUNT_ID, options, projectConfig);
|
|
549
|
-
expect(mockedFetchProjectComponentsMetadata).toHaveBeenCalledWith(ACCOUNT_ID, 123);
|
|
550
|
-
expect(mockedListAppsForMigration).toHaveBeenCalledWith(ACCOUNT_ID, PLATFORM_VERSION, extractedAppId);
|
|
551
|
-
});
|
|
552
|
-
it('should not set appId when project has no PUBLIC_APP component', async () => {
|
|
553
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
554
|
-
const optionsWithoutAppId = {
|
|
555
|
-
...options,
|
|
556
|
-
appId: undefined,
|
|
557
|
-
};
|
|
558
|
-
mockedEnsureProjectExists.mockResolvedValueOnce({
|
|
559
|
-
projectExists: true,
|
|
560
|
-
project: { id: 123, name: PROJECT_NAME },
|
|
561
|
-
});
|
|
562
|
-
mockedFetchProjectComponentsMetadata.mockResolvedValueOnce({
|
|
563
|
-
data: {
|
|
564
|
-
topLevelComponentMetadata: [
|
|
565
|
-
{
|
|
566
|
-
componentName: 'Some Other Component',
|
|
567
|
-
type: { name: 'THEME' },
|
|
568
|
-
deployOutput: {},
|
|
569
|
-
featureComponents: [],
|
|
570
|
-
},
|
|
571
|
-
],
|
|
572
|
-
},
|
|
573
|
-
});
|
|
574
|
-
// @ts-expect-error Mock
|
|
575
|
-
mockedListAppsForMigration.mockResolvedValueOnce({
|
|
576
|
-
data: {
|
|
577
|
-
migratableApps: [createMockMigratableApp(1, 'App 1', PROJECT_NAME)],
|
|
578
|
-
unmigratableApps: [],
|
|
579
|
-
},
|
|
580
|
-
});
|
|
581
|
-
mockedListPrompt.mockResolvedValue({ appId: 1 });
|
|
582
|
-
mockedConfirmPrompt.mockResolvedValueOnce(false);
|
|
583
|
-
await migrateApp(ACCOUNT_ID, optionsWithoutAppId, projectConfig);
|
|
584
|
-
expect(mockedListAppsForMigration).toHaveBeenCalledWith(ACCOUNT_ID, PLATFORM_VERSION, undefined);
|
|
585
|
-
});
|
|
586
|
-
it('should not set appId when deployOutput has no appId', async () => {
|
|
587
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
588
|
-
const optionsWithoutAppId = {
|
|
589
|
-
...options,
|
|
590
|
-
appId: undefined,
|
|
591
|
-
};
|
|
592
|
-
mockedEnsureProjectExists.mockResolvedValueOnce({
|
|
593
|
-
projectExists: true,
|
|
594
|
-
project: { id: 123, name: PROJECT_NAME },
|
|
595
|
-
});
|
|
596
|
-
mockedFetchProjectComponentsMetadata.mockResolvedValueOnce({
|
|
597
|
-
data: {
|
|
598
|
-
topLevelComponentMetadata: [
|
|
599
|
-
{
|
|
600
|
-
componentName: 'My Public App',
|
|
601
|
-
type: { name: 'PUBLIC_APP' },
|
|
602
|
-
deployOutput: null,
|
|
603
|
-
featureComponents: [],
|
|
604
|
-
},
|
|
605
|
-
],
|
|
606
|
-
},
|
|
607
|
-
});
|
|
608
|
-
// @ts-expect-error Mock
|
|
609
|
-
mockedListAppsForMigration.mockResolvedValueOnce({
|
|
610
|
-
data: {
|
|
611
|
-
migratableApps: [createMockMigratableApp(1, 'App 1', PROJECT_NAME)],
|
|
612
|
-
unmigratableApps: [],
|
|
613
|
-
},
|
|
614
|
-
});
|
|
615
|
-
mockedListPrompt.mockResolvedValue({ appId: 1 });
|
|
616
|
-
mockedConfirmPrompt.mockResolvedValueOnce(false);
|
|
617
|
-
await migrateApp(ACCOUNT_ID, optionsWithoutAppId, projectConfig);
|
|
618
|
-
expect(mockedListAppsForMigration).toHaveBeenCalledWith(ACCOUNT_ID, PLATFORM_VERSION, undefined);
|
|
619
|
-
});
|
|
620
|
-
it('should propagate error when fetchProjectComponentsMetadata fails', async () => {
|
|
621
|
-
const projectConfig = createLoadedProjectConfig(PROJECT_NAME);
|
|
622
|
-
mockedEnsureProjectExists.mockResolvedValueOnce({
|
|
623
|
-
projectExists: true,
|
|
624
|
-
project: { id: 123, name: PROJECT_NAME },
|
|
625
|
-
});
|
|
626
|
-
const apiError = new Error('API request failed');
|
|
627
|
-
mockedFetchProjectComponentsMetadata.mockRejectedValueOnce(apiError);
|
|
628
|
-
await expect(migrateApp(ACCOUNT_ID, options, projectConfig)).rejects.toThrow('API request failed');
|
|
629
|
-
});
|
|
630
|
-
});
|
|
631
|
-
describe('logInvalidAccountError', () => {
|
|
632
|
-
it('should log the invalid account error message', () => {
|
|
633
|
-
logInvalidAccountError();
|
|
634
|
-
expect(mockedUiLogger.error).toHaveBeenCalledWith(lib.migrate.errors.invalidAccountTypeTitle);
|
|
635
|
-
expect(mockedUiLogger.log).toHaveBeenCalledWith(expect.stringContaining('Only public apps created in a developer account can be converted to a project component'));
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|