@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,343 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { v2AddComponent } from '../v2AddComponent.js';
|
|
3
|
-
import { getConfigForPlatformVersion } from '../../create/legacy.js';
|
|
4
|
-
import { createV2App } from '../../create/v2.js';
|
|
5
|
-
import { confirmPrompt } from '../../../prompts/promptUtils.js';
|
|
6
|
-
import { projectAddPromptV2 } from '../../../prompts/projectAddPrompt.js';
|
|
7
|
-
import { cloneGithubRepo } from '@hubspot/local-dev-lib/github';
|
|
8
|
-
import { getProjectMetadata } from '@hubspot/project-parsing-lib/projects';
|
|
9
|
-
import { trackCommandUsage } from '../../../usageTracking.js';
|
|
10
|
-
import { updateHsMetaFilesWithAutoGeneratedFields } from '../../components.js';
|
|
11
|
-
import { commands } from '../../../../lang/en.js';
|
|
12
|
-
vi.mock('fs');
|
|
13
|
-
vi.mock('../../../prompts/promptUtils');
|
|
14
|
-
vi.mock('../../create/legacy');
|
|
15
|
-
vi.mock('../../create/v2');
|
|
16
|
-
vi.mock('../../../prompts/projectAddPrompt');
|
|
17
|
-
vi.mock('@hubspot/local-dev-lib/github');
|
|
18
|
-
vi.mock('../../../ui/SpinniesManager.js');
|
|
19
|
-
vi.mock('@hubspot/project-parsing-lib/projects');
|
|
20
|
-
vi.mock('../../components.js');
|
|
21
|
-
const mockedFs = vi.mocked(fs);
|
|
22
|
-
const mockedGetConfigForPlatformVersion = vi.mocked(getConfigForPlatformVersion);
|
|
23
|
-
const mockedConfirmPrompt = vi.mocked(confirmPrompt);
|
|
24
|
-
const mockedCreateV2App = vi.mocked(createV2App);
|
|
25
|
-
const mockedProjectAddPromptV2 = vi.mocked(projectAddPromptV2);
|
|
26
|
-
const mockedCloneGithubRepo = vi.mocked(cloneGithubRepo);
|
|
27
|
-
const mockedGetProjectMetadata = vi.mocked(getProjectMetadata);
|
|
28
|
-
const mockedTrackCommandUsage = vi.mocked(trackCommandUsage);
|
|
29
|
-
const mockedUpdateHsMetaFilesWithAutoGeneratedFields = vi.mocked(updateHsMetaFilesWithAutoGeneratedFields);
|
|
30
|
-
describe('lib/projects/add/v2AddComponent', () => {
|
|
31
|
-
const mockProjectConfig = {
|
|
32
|
-
name: 'test-project',
|
|
33
|
-
srcDir: 'src',
|
|
34
|
-
platformVersion: '2025.2',
|
|
35
|
-
};
|
|
36
|
-
const mockArgs = {
|
|
37
|
-
name: 'test-component',
|
|
38
|
-
type: 'module',
|
|
39
|
-
derivedAccountId: 1234,
|
|
40
|
-
};
|
|
41
|
-
const projectDir = '/path/to/project';
|
|
42
|
-
const mockAccountId = 123;
|
|
43
|
-
const mockComponentTemplate = {
|
|
44
|
-
label: 'Test Component',
|
|
45
|
-
path: 'test-component',
|
|
46
|
-
type: 'module',
|
|
47
|
-
supportedAuthTypes: ['oauth'],
|
|
48
|
-
supportedDistributions: ['private'],
|
|
49
|
-
};
|
|
50
|
-
const mockParentComponent = {
|
|
51
|
-
label: 'Test App',
|
|
52
|
-
type: 'app',
|
|
53
|
-
authType: 'oauth',
|
|
54
|
-
distribution: 'private',
|
|
55
|
-
path: 'app-template',
|
|
56
|
-
};
|
|
57
|
-
const mockConfig = {
|
|
58
|
-
components: [mockComponentTemplate],
|
|
59
|
-
parentComponents: [mockParentComponent],
|
|
60
|
-
};
|
|
61
|
-
const mockProjectMetadata = {
|
|
62
|
-
hsMetaFiles: [],
|
|
63
|
-
components: {
|
|
64
|
-
app: { count: 1, maxCount: 1, hsMetaFiles: ['/path/to/app.meta.json'] },
|
|
65
|
-
module: { count: 0, maxCount: 5, hsMetaFiles: [] },
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
beforeEach(() => {
|
|
69
|
-
mockedCreateV2App.mockResolvedValue({
|
|
70
|
-
authType: 'oauth',
|
|
71
|
-
distribution: 'private',
|
|
72
|
-
});
|
|
73
|
-
mockedTrackCommandUsage.mockResolvedValue();
|
|
74
|
-
});
|
|
75
|
-
describe('v2AddComponent()', () => {
|
|
76
|
-
it('successfully adds a component when app already exists', async () => {
|
|
77
|
-
const mockAppMeta = {
|
|
78
|
-
name: 'Test App',
|
|
79
|
-
config: {
|
|
80
|
-
distribution: 'private',
|
|
81
|
-
auth: { type: 'oauth' },
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
const mockPromptResponse = {
|
|
85
|
-
componentTemplate: [mockComponentTemplate],
|
|
86
|
-
};
|
|
87
|
-
const mockUpdatedProjectMetadata = {
|
|
88
|
-
hsMetaFiles: ['/path/to/new-module.meta.json'],
|
|
89
|
-
components: {
|
|
90
|
-
app: {
|
|
91
|
-
count: 1,
|
|
92
|
-
maxCount: 1,
|
|
93
|
-
hsMetaFiles: ['/path/to/app.meta.json'],
|
|
94
|
-
},
|
|
95
|
-
module: {
|
|
96
|
-
count: 1,
|
|
97
|
-
maxCount: 5,
|
|
98
|
-
hsMetaFiles: ['/path/to/new-module.meta.json'],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
103
|
-
mockedGetProjectMetadata
|
|
104
|
-
.mockResolvedValueOnce(mockProjectMetadata)
|
|
105
|
-
.mockResolvedValueOnce(mockUpdatedProjectMetadata);
|
|
106
|
-
mockedFs.readFileSync.mockReturnValue(JSON.stringify(mockAppMeta));
|
|
107
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
108
|
-
mockedCloneGithubRepo.mockResolvedValue(true);
|
|
109
|
-
mockedUpdateHsMetaFilesWithAutoGeneratedFields.mockResolvedValue(undefined);
|
|
110
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
111
|
-
expect(mockedGetConfigForPlatformVersion).toHaveBeenCalledWith('2025.2');
|
|
112
|
-
expect(mockedGetProjectMetadata).toHaveBeenCalledWith('/path/to/project/src');
|
|
113
|
-
expect(mockedGetProjectMetadata).toHaveBeenCalledTimes(2);
|
|
114
|
-
expect(mockedProjectAddPromptV2).toHaveBeenCalled();
|
|
115
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
116
|
-
type: 'module',
|
|
117
|
-
}, mockAccountId);
|
|
118
|
-
expect(mockedCloneGithubRepo).toHaveBeenCalledWith(expect.any(String), projectDir, expect.objectContaining({
|
|
119
|
-
sourceDir: ['2025.2/test-component'],
|
|
120
|
-
hideLogs: true,
|
|
121
|
-
branch: 'main',
|
|
122
|
-
}));
|
|
123
|
-
expect(mockedUpdateHsMetaFilesWithAutoGeneratedFields).toHaveBeenCalledWith('test-project', ['/path/to/new-module.meta.json'], [], expect.objectContaining({
|
|
124
|
-
currentProjectMetadata: mockProjectMetadata,
|
|
125
|
-
updatedProjectMetadata: mockUpdatedProjectMetadata,
|
|
126
|
-
showSuccessMessage: true,
|
|
127
|
-
}));
|
|
128
|
-
});
|
|
129
|
-
it('creates an app when no app exists and user confirms', async () => {
|
|
130
|
-
const mockProjectMetadataNoApps = {
|
|
131
|
-
hsMetaFiles: [],
|
|
132
|
-
components: {
|
|
133
|
-
app: { count: 0, maxCount: 1, hsMetaFiles: [] },
|
|
134
|
-
module: { count: 0, maxCount: 5, hsMetaFiles: [] },
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
const mockPromptResponse = {
|
|
138
|
-
componentTemplate: [mockComponentTemplate],
|
|
139
|
-
};
|
|
140
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
141
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadataNoApps);
|
|
142
|
-
mockedConfirmPrompt.mockResolvedValue(true);
|
|
143
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
144
|
-
mockedCloneGithubRepo.mockResolvedValue(true);
|
|
145
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
146
|
-
expect(mockedCreateV2App).toHaveBeenCalled();
|
|
147
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
148
|
-
type: 'module',
|
|
149
|
-
}, mockAccountId);
|
|
150
|
-
expect(mockedCloneGithubRepo).toHaveBeenCalledWith(expect.any(String), projectDir, expect.objectContaining({
|
|
151
|
-
sourceDir: ['2025.2/test-component', '2025.2/app-template'],
|
|
152
|
-
}));
|
|
153
|
-
});
|
|
154
|
-
it('should not call clone', async () => {
|
|
155
|
-
const mockProjectMetadataNoApps = {
|
|
156
|
-
hsMetaFiles: [],
|
|
157
|
-
components: {
|
|
158
|
-
app: {
|
|
159
|
-
count: 1,
|
|
160
|
-
maxCount: 1,
|
|
161
|
-
hsMetaFiles: ['/path/to/app.meta.json'],
|
|
162
|
-
},
|
|
163
|
-
module: { count: 0, maxCount: 5, hsMetaFiles: [] },
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
const mockPromptResponse = {
|
|
167
|
-
componentTemplate: [],
|
|
168
|
-
};
|
|
169
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
170
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadataNoApps);
|
|
171
|
-
mockedConfirmPrompt.mockResolvedValue(true);
|
|
172
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
173
|
-
mockedCloneGithubRepo.mockResolvedValue(true);
|
|
174
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
175
|
-
expect(mockedCreateV2App).not.toHaveBeenCalled();
|
|
176
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
177
|
-
type: '',
|
|
178
|
-
}, mockAccountId);
|
|
179
|
-
expect(mockedCloneGithubRepo).not.toHaveBeenCalled();
|
|
180
|
-
});
|
|
181
|
-
it('throws an error when app count exceeds maximum', async () => {
|
|
182
|
-
const mockProjectMetadataMaxApps = {
|
|
183
|
-
hsMetaFiles: [],
|
|
184
|
-
components: {
|
|
185
|
-
app: { count: 2, maxCount: 1, hsMetaFiles: [] },
|
|
186
|
-
module: { count: 0, maxCount: 5, hsMetaFiles: [] },
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
190
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadataMaxApps);
|
|
191
|
-
await expect(v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId)).rejects.toThrow('This project currently has the maximum number of apps: 1');
|
|
192
|
-
});
|
|
193
|
-
it('throws an error when components list is empty', async () => {
|
|
194
|
-
const mockEmptyConfig = {
|
|
195
|
-
components: [],
|
|
196
|
-
parentComponents: [],
|
|
197
|
-
};
|
|
198
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockEmptyConfig);
|
|
199
|
-
await expect(v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId)).rejects.toThrow(commands.project.add.error.failedToFetchComponentList);
|
|
200
|
-
});
|
|
201
|
-
it('throws an error when app meta file cannot be parsed', async () => {
|
|
202
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
203
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadata);
|
|
204
|
-
mockedFs.readFileSync.mockImplementation(() => {
|
|
205
|
-
throw new Error('File read error');
|
|
206
|
-
});
|
|
207
|
-
await expect(v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId)).rejects.toThrow('Unable to parse app file');
|
|
208
|
-
});
|
|
209
|
-
it('throws an error when cloning fails', async () => {
|
|
210
|
-
const mockAppMeta = {
|
|
211
|
-
config: {
|
|
212
|
-
distribution: 'private',
|
|
213
|
-
auth: { type: 'oauth' },
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
const mockPromptResponse = {
|
|
217
|
-
componentTemplate: [mockComponentTemplate],
|
|
218
|
-
};
|
|
219
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
220
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadata);
|
|
221
|
-
mockedFs.readFileSync.mockReturnValue(JSON.stringify(mockAppMeta));
|
|
222
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
223
|
-
mockedCloneGithubRepo.mockRejectedValue(new Error('Clone failed'));
|
|
224
|
-
await expect(v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId)).rejects.toThrow(commands.project.add.error.failedToDownloadComponent);
|
|
225
|
-
});
|
|
226
|
-
it('should track usage with multiple component types', async () => {
|
|
227
|
-
const mockAppMeta = {
|
|
228
|
-
config: {
|
|
229
|
-
distribution: 'private',
|
|
230
|
-
auth: { type: 'oauth' },
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
const mockSecondComponentTemplate = {
|
|
234
|
-
label: 'Test Card',
|
|
235
|
-
path: 'test-card',
|
|
236
|
-
type: 'card',
|
|
237
|
-
supportedAuthTypes: ['oauth'],
|
|
238
|
-
supportedDistributions: ['private'],
|
|
239
|
-
};
|
|
240
|
-
const mockPromptResponse = {
|
|
241
|
-
componentTemplate: [mockComponentTemplate, mockSecondComponentTemplate],
|
|
242
|
-
};
|
|
243
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
244
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadata);
|
|
245
|
-
mockedFs.readFileSync.mockReturnValue(JSON.stringify(mockAppMeta));
|
|
246
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
247
|
-
mockedCloneGithubRepo.mockResolvedValue(true);
|
|
248
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
249
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
250
|
-
type: 'module,card',
|
|
251
|
-
}, mockAccountId);
|
|
252
|
-
});
|
|
253
|
-
it('should track usage with empty type when no components are selected', async () => {
|
|
254
|
-
const mockProjectMetadataNoApps = {
|
|
255
|
-
hsMetaFiles: [],
|
|
256
|
-
components: {
|
|
257
|
-
app: {
|
|
258
|
-
count: 1,
|
|
259
|
-
maxCount: 1,
|
|
260
|
-
hsMetaFiles: ['/path/to/app.meta.json'],
|
|
261
|
-
},
|
|
262
|
-
module: { count: 0, maxCount: 5, hsMetaFiles: [] },
|
|
263
|
-
},
|
|
264
|
-
};
|
|
265
|
-
const mockPromptResponse = {
|
|
266
|
-
componentTemplate: [],
|
|
267
|
-
};
|
|
268
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
269
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadataNoApps);
|
|
270
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
271
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
272
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
273
|
-
type: '',
|
|
274
|
-
}, mockAccountId);
|
|
275
|
-
});
|
|
276
|
-
it('should track usage with cliSelector when available', async () => {
|
|
277
|
-
const mockAppMeta = {
|
|
278
|
-
config: {
|
|
279
|
-
distribution: 'private',
|
|
280
|
-
auth: { type: 'oauth' },
|
|
281
|
-
},
|
|
282
|
-
};
|
|
283
|
-
const mockComponentTemplateWithCliSelector = {
|
|
284
|
-
label: 'Workflow Action Tool',
|
|
285
|
-
path: 'workflow-action-tool',
|
|
286
|
-
type: 'workflow-action',
|
|
287
|
-
cliSelector: 'workflow-action-tool',
|
|
288
|
-
supportedAuthTypes: ['oauth'],
|
|
289
|
-
supportedDistributions: ['private'],
|
|
290
|
-
};
|
|
291
|
-
const mockPromptResponse = {
|
|
292
|
-
componentTemplate: [mockComponentTemplateWithCliSelector],
|
|
293
|
-
};
|
|
294
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
295
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadata);
|
|
296
|
-
mockedFs.readFileSync.mockReturnValue(JSON.stringify(mockAppMeta));
|
|
297
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
298
|
-
mockedCloneGithubRepo.mockResolvedValue(true);
|
|
299
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
300
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
301
|
-
type: 'workflow-action-tool',
|
|
302
|
-
}, mockAccountId);
|
|
303
|
-
});
|
|
304
|
-
it('should track usage with cliSelector for multiple components', async () => {
|
|
305
|
-
const mockAppMeta = {
|
|
306
|
-
config: {
|
|
307
|
-
distribution: 'private',
|
|
308
|
-
auth: { type: 'oauth' },
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
const mockComponentWithCliSelector = {
|
|
312
|
-
label: 'Workflow Action Tool',
|
|
313
|
-
path: 'workflow-action-tool',
|
|
314
|
-
type: 'workflow-action',
|
|
315
|
-
cliSelector: 'workflow-action-tool',
|
|
316
|
-
supportedAuthTypes: ['oauth'],
|
|
317
|
-
supportedDistributions: ['private'],
|
|
318
|
-
};
|
|
319
|
-
const mockComponentWithoutCliSelector = {
|
|
320
|
-
label: 'Regular Module',
|
|
321
|
-
path: 'module',
|
|
322
|
-
type: 'module',
|
|
323
|
-
supportedAuthTypes: ['oauth'],
|
|
324
|
-
supportedDistributions: ['private'],
|
|
325
|
-
};
|
|
326
|
-
const mockPromptResponse = {
|
|
327
|
-
componentTemplate: [
|
|
328
|
-
mockComponentWithCliSelector,
|
|
329
|
-
mockComponentWithoutCliSelector,
|
|
330
|
-
],
|
|
331
|
-
};
|
|
332
|
-
mockedGetConfigForPlatformVersion.mockResolvedValue(mockConfig);
|
|
333
|
-
mockedGetProjectMetadata.mockResolvedValue(mockProjectMetadata);
|
|
334
|
-
mockedFs.readFileSync.mockReturnValue(JSON.stringify(mockAppMeta));
|
|
335
|
-
mockedProjectAddPromptV2.mockResolvedValue(mockPromptResponse);
|
|
336
|
-
mockedCloneGithubRepo.mockResolvedValue(true);
|
|
337
|
-
await v2AddComponent(mockArgs, projectDir, mockProjectConfig, mockAccountId);
|
|
338
|
-
expect(mockedTrackCommandUsage).toHaveBeenCalledWith('project-add', {
|
|
339
|
-
type: 'workflow-action-tool,module',
|
|
340
|
-
}, mockAccountId);
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import * as github from '@hubspot/local-dev-lib/api/github';
|
|
2
|
-
import { getProjectComponentListFromRepo, getProjectTemplateListFromRepo, } from '../legacy.js';
|
|
3
|
-
import { PROJECT_COMPONENT_TYPES, HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, } from '../../../constants.js';
|
|
4
|
-
vi.mock('@hubspot/local-dev-lib/api/github');
|
|
5
|
-
const mockedFetchRepoFile = vi.mocked(github.fetchRepoFile);
|
|
6
|
-
const repoConfig = {
|
|
7
|
-
[PROJECT_COMPONENT_TYPES.COMPONENTS]: [
|
|
8
|
-
{
|
|
9
|
-
label: 'Component 1',
|
|
10
|
-
path: 'component1',
|
|
11
|
-
type: 'Component',
|
|
12
|
-
},
|
|
13
|
-
],
|
|
14
|
-
[PROJECT_COMPONENT_TYPES.PROJECTS]: [
|
|
15
|
-
{
|
|
16
|
-
name: 'project1',
|
|
17
|
-
label: 'Project 1',
|
|
18
|
-
path: 'project1',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
describe('lib/projects/create/legacy', () => {
|
|
23
|
-
describe('getProjectComponentListFromRepo()', () => {
|
|
24
|
-
it('returns a list of components', async () => {
|
|
25
|
-
// @ts-expect-error - Mocking AxiosResponse
|
|
26
|
-
mockedFetchRepoFile.mockResolvedValue({
|
|
27
|
-
data: repoConfig,
|
|
28
|
-
});
|
|
29
|
-
const components = await getProjectComponentListFromRepo('gh-ref');
|
|
30
|
-
expect(components).toEqual(repoConfig[PROJECT_COMPONENT_TYPES.COMPONENTS]);
|
|
31
|
-
});
|
|
32
|
-
it('returns an empty list if no components are found', async () => {
|
|
33
|
-
mockedFetchRepoFile.mockRejectedValue(new Error('Not found'));
|
|
34
|
-
const components = await getProjectComponentListFromRepo('gh-ref');
|
|
35
|
-
expect(components).toEqual([]);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
describe('getProjectTemplateListFromRepo()', () => {
|
|
39
|
-
it('returns a list of project templates', async () => {
|
|
40
|
-
// @ts-expect-error - Mocking AxiosResponse
|
|
41
|
-
mockedFetchRepoFile.mockResolvedValue({
|
|
42
|
-
data: repoConfig,
|
|
43
|
-
});
|
|
44
|
-
const templates = await getProjectTemplateListFromRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'gh-ref');
|
|
45
|
-
expect(templates).toEqual(repoConfig[PROJECT_COMPONENT_TYPES.PROJECTS]);
|
|
46
|
-
});
|
|
47
|
-
it('throws an error if the request for the template list fails', async () => {
|
|
48
|
-
mockedFetchRepoFile.mockRejectedValue(new Error('Not found'));
|
|
49
|
-
await expect(getProjectTemplateListFromRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'gh-ref')).rejects.toThrow('Failed to fetch the config.json file from the target repository');
|
|
50
|
-
});
|
|
51
|
-
it('throws an error if there are no projects listed in the repo config', async () => {
|
|
52
|
-
// @ts-expect-error - Mocking AxiosResponse
|
|
53
|
-
mockedFetchRepoFile.mockResolvedValue({});
|
|
54
|
-
await expect(getProjectTemplateListFromRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'gh-ref')).rejects.toThrow('Unable to find any projects in the target repository');
|
|
55
|
-
});
|
|
56
|
-
it('throws an error if any of the projects in the repo config are missing required properties', async () => {
|
|
57
|
-
// @ts-expect-error - Mocking AxiosResponse
|
|
58
|
-
mockedFetchRepoFile.mockResolvedValue({
|
|
59
|
-
data: {
|
|
60
|
-
...repoConfig,
|
|
61
|
-
[PROJECT_COMPONENT_TYPES.PROJECTS]: [
|
|
62
|
-
{
|
|
63
|
-
name: 'project1',
|
|
64
|
-
label: 'Project 1',
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
await expect(getProjectTemplateListFromRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, 'gh-ref')).rejects.toThrow('Found misconfigured projects in the target repository');
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { calculateComponentTemplateChoices } from '../v2.js';
|
|
2
|
-
import { hasFeature } from '../../../hasFeature.js';
|
|
3
|
-
import { getConfigAccountById as __getConfigAccountById } from '@hubspot/local-dev-lib/config';
|
|
4
|
-
const getConfigAccountById = __getConfigAccountById;
|
|
5
|
-
vi.mock('@hubspot/local-dev-lib/api/github');
|
|
6
|
-
vi.mock('../../../hasFeature.js');
|
|
7
|
-
vi.mock('@hubspot/local-dev-lib/config');
|
|
8
|
-
const mockHasFeature = vi.mocked(hasFeature);
|
|
9
|
-
describe('lib/projects/create/v2', () => {
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
mockHasFeature.mockResolvedValue(true);
|
|
12
|
-
// Mock account config
|
|
13
|
-
getConfigAccountById.mockReturnValue({
|
|
14
|
-
accountId: 123,
|
|
15
|
-
name: 'Test Account',
|
|
16
|
-
authType: 'personalaccesskey',
|
|
17
|
-
personalAccessKey: 'test-key',
|
|
18
|
-
env: 'prod',
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('calculateComponentTemplateChoices()', () => {
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
mockHasFeature.mockClear();
|
|
24
|
-
});
|
|
25
|
-
const mockComponents = [
|
|
26
|
-
{
|
|
27
|
-
label: 'Module Component',
|
|
28
|
-
path: 'module',
|
|
29
|
-
type: 'module',
|
|
30
|
-
supportedAuthTypes: ['oauth'],
|
|
31
|
-
supportedDistributions: ['private'],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
label: 'Card Component',
|
|
35
|
-
path: 'card',
|
|
36
|
-
type: 'card',
|
|
37
|
-
supportedAuthTypes: ['oauth', 'static'],
|
|
38
|
-
supportedDistributions: ['private', 'marketplace'],
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
const mockProjectMetadataForChoices = {
|
|
42
|
-
hsMetaFiles: [],
|
|
43
|
-
components: {
|
|
44
|
-
module: { count: 0, maxCount: 5, hsMetaFiles: [] },
|
|
45
|
-
card: { count: 3, maxCount: 3, hsMetaFiles: [] },
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
it('returns enabled components when they meet all requirements', async () => {
|
|
49
|
-
const choices = await calculateComponentTemplateChoices(mockComponents, 'oauth', 'private', 123, mockProjectMetadataForChoices);
|
|
50
|
-
expect(choices).toHaveLength(2);
|
|
51
|
-
expect(choices[0]).toEqual({
|
|
52
|
-
name: 'Module Component [module]',
|
|
53
|
-
value: mockComponents[0],
|
|
54
|
-
});
|
|
55
|
-
expect(choices[1]).toEqual({
|
|
56
|
-
name: expect.stringContaining('Card Component'),
|
|
57
|
-
value: mockComponents[1],
|
|
58
|
-
disabled: expect.stringContaining('maximum'),
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
it('disables components when auth type is not supported', async () => {
|
|
62
|
-
const choices = await calculateComponentTemplateChoices(mockComponents, 'privatekey', 'private', 123, mockProjectMetadataForChoices);
|
|
63
|
-
// All components should be disabled
|
|
64
|
-
expect(choices[0]).toEqual({
|
|
65
|
-
name: expect.stringContaining('Module Component'),
|
|
66
|
-
value: mockComponents[0],
|
|
67
|
-
disabled: expect.stringContaining('oauth'),
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
it('disables components when distribution is not supported', async () => {
|
|
71
|
-
const choices = await calculateComponentTemplateChoices(mockComponents, 'oauth', 'enterprise', 123, mockProjectMetadataForChoices);
|
|
72
|
-
// All components should be disabled
|
|
73
|
-
expect(choices[0]).toEqual({
|
|
74
|
-
name: expect.stringContaining('Module Component'),
|
|
75
|
-
value: mockComponents[0],
|
|
76
|
-
disabled: expect.stringContaining('private'),
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
it('handles components without auth type or distribution restrictions', async () => {
|
|
80
|
-
const componentsWithoutRestrictions = [
|
|
81
|
-
{
|
|
82
|
-
label: 'Unrestricted Component',
|
|
83
|
-
path: 'unrestricted',
|
|
84
|
-
type: 'module',
|
|
85
|
-
},
|
|
86
|
-
];
|
|
87
|
-
const choices = await calculateComponentTemplateChoices(componentsWithoutRestrictions, 'oauth', 'private', 123, {
|
|
88
|
-
hsMetaFiles: [],
|
|
89
|
-
components: { module: { count: 0, maxCount: 5, hsMetaFiles: [] } },
|
|
90
|
-
});
|
|
91
|
-
expect(choices[0]).toEqual({
|
|
92
|
-
name: 'Unrestricted Component [module]',
|
|
93
|
-
value: componentsWithoutRestrictions[0],
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
it('handles components with cliSelector field (metadata compatibility)', async () => {
|
|
97
|
-
const componentWithCliSelector = [
|
|
98
|
-
{
|
|
99
|
-
label: 'Workflow Action Tool',
|
|
100
|
-
path: 'workflow-action-tool',
|
|
101
|
-
type: 'workflow-action',
|
|
102
|
-
cliSelector: 'workflow-action-tool',
|
|
103
|
-
supportedAuthTypes: ['oauth'],
|
|
104
|
-
supportedDistributions: ['private'],
|
|
105
|
-
},
|
|
106
|
-
];
|
|
107
|
-
const projectMetadataWithWorkflowAction = {
|
|
108
|
-
hsMetaFiles: [],
|
|
109
|
-
components: {
|
|
110
|
-
'workflow-action': { count: 2, maxCount: 3, hsMetaFiles: [] },
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
const choices = await calculateComponentTemplateChoices(componentWithCliSelector, 'oauth', 'private', 213, projectMetadataWithWorkflowAction);
|
|
114
|
-
expect(choices).toHaveLength(1); // no disabled components
|
|
115
|
-
expect(choices[0]).toEqual({
|
|
116
|
-
name: 'Workflow Action Tool [workflow-action-tool]',
|
|
117
|
-
value: componentWithCliSelector[0],
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
it('disables component when project metadata count exceeds maximum', async () => {
|
|
121
|
-
const componentWithCliSelector = [
|
|
122
|
-
{
|
|
123
|
-
label: 'Workflow Action Tool',
|
|
124
|
-
path: 'workflow-action-tool',
|
|
125
|
-
type: 'workflow-action',
|
|
126
|
-
cliSelector: 'workflow-action-tool',
|
|
127
|
-
supportedAuthTypes: ['oauth'],
|
|
128
|
-
supportedDistributions: ['private'],
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
const projectMetadataAtMaxWorkflowAction = {
|
|
132
|
-
hsMetaFiles: [],
|
|
133
|
-
components: {
|
|
134
|
-
'workflow-action': { count: 3, maxCount: 3, hsMetaFiles: [] },
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
const choices = await calculateComponentTemplateChoices(componentWithCliSelector, 'oauth', 'private', 123, projectMetadataAtMaxWorkflowAction);
|
|
138
|
-
expect(choices).toHaveLength(1);
|
|
139
|
-
expect(choices[0]).toEqual({
|
|
140
|
-
name: expect.stringContaining('Workflow Action Tool'),
|
|
141
|
-
value: componentWithCliSelector[0],
|
|
142
|
-
disabled: expect.stringContaining('maximum'),
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
it('handles undefined projectMetadata without throwing errors', async () => {
|
|
146
|
-
const componentWithCliSelector = [
|
|
147
|
-
{
|
|
148
|
-
label: 'Workflow Action Tool',
|
|
149
|
-
path: 'workflow-action-tool',
|
|
150
|
-
type: 'workflow-action',
|
|
151
|
-
cliSelector: 'workflow-action-tool',
|
|
152
|
-
supportedAuthTypes: ['oauth'],
|
|
153
|
-
supportedDistributions: ['private'],
|
|
154
|
-
},
|
|
155
|
-
];
|
|
156
|
-
const choices = await calculateComponentTemplateChoices(componentWithCliSelector, 'oauth', 'private', 123, undefined);
|
|
157
|
-
expect(choices).toHaveLength(1); // no disabled components
|
|
158
|
-
expect(choices[0]).toEqual({
|
|
159
|
-
name: 'Workflow Action Tool [workflow-action-tool]',
|
|
160
|
-
value: componentWithCliSelector[0],
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
it('handles projectMetadata with undefined components property (after fix)', async () => {
|
|
164
|
-
const componentWithCliSelector = [
|
|
165
|
-
{
|
|
166
|
-
label: 'Workflow Action Tool',
|
|
167
|
-
path: 'workflow-action-tool',
|
|
168
|
-
type: 'workflow-action',
|
|
169
|
-
cliSelector: 'workflow-action-tool',
|
|
170
|
-
supportedAuthTypes: ['oauth'],
|
|
171
|
-
supportedDistributions: ['private'],
|
|
172
|
-
},
|
|
173
|
-
];
|
|
174
|
-
const projectMetadataWithoutComponents = {
|
|
175
|
-
hsMetaFiles: [],
|
|
176
|
-
components: undefined,
|
|
177
|
-
};
|
|
178
|
-
// This test verifies the null check fix works
|
|
179
|
-
// Currently this will fail because the fix checks for projectMetadata.components
|
|
180
|
-
await expect(async () => calculateComponentTemplateChoices(componentWithCliSelector, 'oauth', 'private', 123,
|
|
181
|
-
// @ts-expect-error breaking stuff on purpose
|
|
182
|
-
projectMetadataWithoutComponents)).rejects.toThrow();
|
|
183
|
-
});
|
|
184
|
-
it('disables gated components when hasFeature returns false', async () => {
|
|
185
|
-
mockHasFeature.mockResolvedValue(false);
|
|
186
|
-
const gatedComponent = [
|
|
187
|
-
{
|
|
188
|
-
label: 'Workflow Action Tool',
|
|
189
|
-
path: 'workflow-action-tool',
|
|
190
|
-
type: 'workflow-action',
|
|
191
|
-
cliSelector: 'workflow-action-tool',
|
|
192
|
-
supportedAuthTypes: ['oauth'],
|
|
193
|
-
supportedDistributions: ['private'],
|
|
194
|
-
},
|
|
195
|
-
];
|
|
196
|
-
const projectMetadataWithWorkflowAction = {
|
|
197
|
-
hsMetaFiles: [],
|
|
198
|
-
components: {
|
|
199
|
-
'workflow-action': { count: 0, maxCount: 3, hsMetaFiles: [] },
|
|
200
|
-
},
|
|
201
|
-
};
|
|
202
|
-
const choices = await calculateComponentTemplateChoices(gatedComponent, 'oauth', 'private', 123, projectMetadataWithWorkflowAction);
|
|
203
|
-
expect(choices).toHaveLength(1);
|
|
204
|
-
expect(choices[0]).toEqual({
|
|
205
|
-
name: expect.stringContaining('Workflow Action Tool'),
|
|
206
|
-
value: gatedComponent[0],
|
|
207
|
-
disabled: expect.stringContaining("doesn't have access to this feature"),
|
|
208
|
-
});
|
|
209
|
-
expect(mockHasFeature).toHaveBeenCalledWith(123, expect.any(String));
|
|
210
|
-
});
|
|
211
|
-
it('enables gated components when hasFeature returns true', async () => {
|
|
212
|
-
mockHasFeature.mockResolvedValue(true);
|
|
213
|
-
const gatedComponent = [
|
|
214
|
-
{
|
|
215
|
-
label: 'Workflow Action Tool',
|
|
216
|
-
path: 'workflow-action-tool',
|
|
217
|
-
type: 'workflow-action',
|
|
218
|
-
cliSelector: 'workflow-action-tool',
|
|
219
|
-
supportedAuthTypes: ['oauth'],
|
|
220
|
-
supportedDistributions: ['private'],
|
|
221
|
-
},
|
|
222
|
-
];
|
|
223
|
-
const projectMetadataWithWorkflowAction = {
|
|
224
|
-
hsMetaFiles: [],
|
|
225
|
-
components: {
|
|
226
|
-
'workflow-action': { count: 0, maxCount: 3, hsMetaFiles: [] },
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
const choices = await calculateComponentTemplateChoices(gatedComponent, 'oauth', 'private', 123, projectMetadataWithWorkflowAction);
|
|
230
|
-
expect(choices).toHaveLength(1); // no disabled components
|
|
231
|
-
expect(choices[0]).toEqual({
|
|
232
|
-
name: 'Workflow Action Tool [workflow-action-tool]',
|
|
233
|
-
value: gatedComponent[0],
|
|
234
|
-
});
|
|
235
|
-
expect(mockHasFeature).toHaveBeenCalledWith(123, expect.any(String));
|
|
236
|
-
});
|
|
237
|
-
it('handles non-gated components without calling hasFeature', async () => {
|
|
238
|
-
const nonGatedComponent = [
|
|
239
|
-
{
|
|
240
|
-
label: 'Regular Component',
|
|
241
|
-
path: 'regular',
|
|
242
|
-
type: 'module',
|
|
243
|
-
supportedAuthTypes: ['oauth'],
|
|
244
|
-
supportedDistributions: ['private'],
|
|
245
|
-
},
|
|
246
|
-
];
|
|
247
|
-
const choices = await calculateComponentTemplateChoices(nonGatedComponent, 'oauth', 'private', 123, mockProjectMetadataForChoices);
|
|
248
|
-
expect(choices).toHaveLength(1);
|
|
249
|
-
expect(choices[0]).toEqual({
|
|
250
|
-
name: 'Regular Component [module]',
|
|
251
|
-
value: nonGatedComponent[0],
|
|
252
|
-
});
|
|
253
|
-
// hasFeature should not be called for non-gated components
|
|
254
|
-
expect(mockHasFeature).not.toHaveBeenCalled();
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
});
|