@hubspot/cli 7.8.12-experimental.0 → 7.9.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 +31 -25
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/cms.test.js +44 -1
- package/commands/__tests__/customObject.test.js +22 -1
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/__tests__/project.test.js +2 -0
- package/commands/account/auth.js +1 -0
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -5
- package/commands/app/migrate.js +13 -18
- package/commands/app.js +1 -6
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +17 -7
- package/commands/{__tests__/remove.test.js → cms/__tests__/delete.test.js} +8 -8
- package/commands/{__tests__ → cms/__tests__}/fetch.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/function.test.js +7 -3
- package/commands/{__tests__ → cms/__tests__}/lint.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/list.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/mv.test.js +3 -3
- package/commands/{__tests__ → cms/__tests__}/theme.test.js +9 -2
- package/commands/cms/app/create.d.ts +9 -0
- package/commands/cms/app/create.js +82 -0
- package/commands/cms/app.d.ts +3 -0
- package/commands/cms/app.js +17 -0
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/delete.d.ts +6 -0
- package/commands/cms/delete.js +43 -0
- package/commands/cms/fetch.d.ts +12 -0
- package/commands/cms/fetch.js +79 -0
- package/commands/{__tests__ → cms/function/__tests__}/logs.test.js +4 -5
- package/commands/cms/function/create.d.ts +12 -0
- package/commands/cms/function/create.js +84 -0
- package/commands/cms/function/deploy.d.ts +6 -0
- package/commands/cms/function/deploy.js +89 -0
- package/commands/cms/function/list.d.ts +6 -0
- package/commands/cms/function/list.js +60 -0
- package/commands/cms/function/logs.d.ts +10 -0
- package/commands/cms/function/logs.js +135 -0
- package/commands/cms/function/server.d.ts +10 -0
- package/commands/cms/function/server.js +69 -0
- package/commands/cms/function.d.ts +3 -0
- package/commands/cms/function.js +27 -0
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms/lint.d.ts +6 -0
- package/commands/cms/lint.js +83 -0
- package/commands/cms/list.d.ts +6 -0
- package/commands/cms/list.js +96 -0
- package/commands/cms/module/create.d.ts +11 -0
- package/commands/cms/module/create.js +84 -0
- package/commands/cms/module/marketplace-validate.d.ts +6 -0
- package/commands/cms/module/marketplace-validate.js +45 -0
- package/commands/cms/module.d.ts +3 -0
- package/commands/cms/module.js +17 -0
- package/commands/cms/mv.d.ts +7 -0
- package/commands/cms/mv.js +60 -0
- package/commands/cms/template/create.d.ts +9 -0
- package/commands/cms/template/create.js +72 -0
- package/commands/cms/template.d.ts +3 -0
- package/commands/cms/template.js +17 -0
- package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.js +2 -2
- package/commands/{theme → cms/theme}/__tests__/preview.test.js +2 -2
- package/commands/cms/theme/create.d.ts +6 -0
- package/commands/cms/theme/create.js +58 -0
- package/commands/cms/theme/generate-selectors.d.ts +6 -0
- package/commands/cms/theme/generate-selectors.js +171 -0
- package/commands/cms/theme/marketplace-validate.d.ts +6 -0
- package/commands/cms/theme/marketplace-validate.js +46 -0
- package/commands/cms/theme/preview.d.ts +12 -0
- package/commands/cms/theme/preview.js +224 -0
- package/commands/cms/theme.d.ts +3 -0
- package/commands/cms/theme.js +25 -0
- package/commands/cms/upload.d.ts +12 -0
- package/commands/cms/upload.js +212 -0
- package/commands/cms/watch.d.ts +14 -0
- package/commands/cms/watch.js +138 -0
- package/commands/cms/webpack/create.d.ts +6 -0
- package/commands/cms/webpack/create.js +58 -0
- package/commands/cms/webpack.d.ts +3 -0
- package/commands/cms/webpack.js +17 -0
- package/commands/cms.js +28 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -36
- package/commands/config.js +2 -2
- package/commands/create.js +6 -4
- package/commands/customObject/{schema/__tests__/create.test.js → __tests__/createSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/delete.test.js → __tests__/deleteSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/fetch-all.test.js → __tests__/fetch-all-schemas.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/fetch.test.js → __tests__/fetchSchema.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/list.test.js → __tests__/listSchemas.test.js} +5 -5
- package/commands/customObject/{schema/__tests__/update.test.js → __tests__/updateSchema.test.js} +5 -5
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/createSchema.d.ts +6 -0
- package/commands/customObject/createSchema.js +56 -0
- package/commands/customObject/deleteSchema.d.ts +7 -0
- package/commands/customObject/deleteSchema.js +69 -0
- package/commands/customObject/fetchAllSchemas.d.ts +6 -0
- package/commands/customObject/fetchAllSchemas.js +57 -0
- package/commands/customObject/fetchSchema.d.ts +7 -0
- package/commands/customObject/fetchSchema.js +67 -0
- package/commands/customObject/listSchemas.d.ts +4 -0
- package/commands/customObject/listSchemas.js +35 -0
- package/commands/customObject/schema/create.d.ts +4 -6
- package/commands/customObject/schema/create.js +13 -38
- package/commands/customObject/schema/delete.d.ts +4 -7
- package/commands/customObject/schema/delete.js +15 -50
- package/commands/customObject/schema/fetch-all.d.ts +4 -6
- package/commands/customObject/schema/fetch-all.js +14 -40
- package/commands/customObject/schema/fetch.d.ts +4 -7
- package/commands/customObject/schema/fetch.js +14 -49
- package/commands/customObject/schema/list.d.ts +4 -4
- package/commands/customObject/schema/list.js +10 -19
- package/commands/customObject/schema/update.d.ts +4 -7
- package/commands/customObject/schema/update.js +15 -50
- package/commands/customObject/schema.js +5 -3
- package/commands/customObject/updateSchema.d.ts +7 -0
- package/commands/customObject/updateSchema.js +71 -0
- package/commands/customObject.js +22 -8
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +7 -12
- package/commands/fetch.d.ts +4 -12
- package/commands/fetch.js +20 -47
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.d.ts +4 -6
- package/commands/function/deploy.js +14 -89
- package/commands/function/list.d.ts +4 -6
- package/commands/function/list.js +14 -40
- package/commands/function/server.d.ts +4 -10
- package/commands/function/server.js +22 -31
- package/commands/function.d.ts +2 -4
- package/commands/function.js +25 -14
- package/commands/getStarted.js +2 -2
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.d.ts +4 -6
- package/commands/lint.js +13 -65
- package/commands/list.d.ts +4 -6
- package/commands/list.js +14 -81
- package/commands/logs.d.ts +4 -10
- package/commands/logs.js +25 -94
- package/commands/module/marketplace-validate.d.ts +4 -6
- package/commands/module/marketplace-validate.js +15 -27
- package/commands/module.d.ts +2 -2
- package/commands/module.js +17 -15
- package/commands/mv.d.ts +4 -7
- package/commands/mv.js +14 -51
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +15 -13
- package/commands/project/__tests__/deploy.test.js +3 -4
- package/commands/project/__tests__/devUnifiedFlow.test.js +32 -0
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/list.test.js +31 -0
- package/commands/project/__tests__/logs.test.js +1 -1
- package/commands/project/__tests__/migrate.test.js +6 -5
- package/commands/project/__tests__/migrateApp.test.js +2 -5
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +6 -5
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +1 -2
- package/commands/project/deploy.js +3 -3
- package/commands/project/dev/deprecatedFlow.js +9 -18
- package/commands/project/dev/index.js +19 -17
- package/commands/project/dev/unifiedFlow.js +11 -4
- package/commands/project/download.js +15 -15
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +9 -8
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/listBuilds.js +11 -20
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +5 -2
- package/commands/project/migrateApp.js +9 -15
- package/commands/project/open.js +6 -13
- package/commands/project/upload.d.ts +2 -2
- package/commands/project/upload.js +17 -26
- package/commands/project/validate.js +6 -6
- package/commands/project/watch.js +13 -22
- package/commands/project.js +4 -2
- package/commands/remove.d.ts +4 -6
- package/commands/remove.js +12 -24
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +38 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/create.js +2 -5
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/theme/generate-selectors.d.ts +4 -6
- package/commands/theme/generate-selectors.js +14 -152
- package/commands/theme/marketplace-validate.d.ts +4 -6
- package/commands/theme/marketplace-validate.js +14 -25
- package/commands/theme/preview.d.ts +4 -12
- package/commands/theme/preview.js +18 -183
- package/commands/theme.d.ts +2 -2
- package/commands/theme.js +19 -13
- package/commands/upload.d.ts +4 -12
- package/commands/upload.js +19 -169
- package/commands/watch.d.ts +4 -14
- package/commands/watch.js +23 -88
- package/lang/en.d.ts +863 -542
- package/lang/en.js +912 -595
- package/lang/en.lyaml +4 -4
- package/lib/__tests__/buildAccount.test.js +4 -3
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +5 -5
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.js +1 -1
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.d.ts +2 -2
- package/lib/buildAccount.js +32 -64
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configMigrate.js +88 -9
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +15 -1
- package/lib/constants.js +19 -1
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +11 -18
- package/lib/generateSelectors.js +1 -1
- package/lib/lang.js +6 -5
- package/lib/links.js +4 -4
- package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
- package/lib/middleware/__test__/configMiddleware.test.js +11 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
- package/lib/middleware/autoUpdateMiddleware.d.ts +2 -1
- package/lib/middleware/autoUpdateMiddleware.js +12 -2
- package/lib/middleware/commandTargetingUtils.d.ts +8 -0
- package/lib/middleware/commandTargetingUtils.js +74 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/gitMiddleware.js +5 -1
- package/lib/middleware/notificationsMiddleware.js +5 -11
- package/lib/middleware/yargsChecksMiddleware.js +6 -9
- package/lib/npm.js +2 -2
- package/lib/oauth.js +5 -5
- package/lib/process.js +5 -4
- package/lib/projectProfiles.d.ts +1 -1
- package/lib/projectProfiles.js +2 -10
- package/lib/projects/__tests__/AppDevModeInterface.test.js +101 -135
- package/lib/projects/__tests__/DevServerManager.test.js +183 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +6 -5
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +76 -45
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.d.ts +1 -0
- package/lib/projects/__tests__/UIExtensionsDevModeInterface.test.js +161 -0
- package/lib/projects/__tests__/deploy.test.js +9 -9
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v2AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +39 -39
- package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
- package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
- package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +3 -3
- package/lib/projects/create/index.js +4 -4
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
- package/lib/projects/create/{v3.js → v2.js} +5 -5
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +11 -3
- package/lib/projects/localDev/AppDevModeInterface.js +128 -115
- package/lib/projects/localDev/DevServerManager.d.ts +10 -29
- package/lib/projects/localDev/DevServerManager.js +20 -76
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
- package/lib/projects/localDev/LocalDevLogger.js +10 -11
- package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
- package/lib/projects/localDev/LocalDevProcess.js +3 -2
- package/lib/projects/localDev/LocalDevState.d.ts +3 -0
- package/lib/projects/localDev/LocalDevState.js +9 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +4 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +46 -16
- package/lib/projects/localDev/UIExtensionsDevModeInterface.d.ts +13 -0
- package/lib/projects/localDev/UIExtensionsDevModeInterface.js +37 -0
- package/lib/projects/localDev/helpers/account.d.ts +1 -1
- package/lib/projects/localDev/helpers/account.js +2 -2
- package/lib/projects/localDev/helpers/process.d.ts +1 -0
- package/lib/projects/localDev/helpers/process.js +15 -0
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +39 -3
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +3 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +9 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +2 -3
- package/lib/projects/upload.js +17 -9
- package/lib/projects/urls.d.ts +0 -1
- package/lib/projects/urls.js +0 -3
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/installAppPrompt.d.ts +1 -6
- package/lib/prompts/installAppPrompt.js +1 -6
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.d.ts +2 -2
- package/lib/prompts/projectAddPrompt.js +7 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +27 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.js +6 -6
- package/lib/theme/migrate.js +2 -2
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +6 -0
- package/lib/ui/index.js +55 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +73 -0
- package/lib/ui/uiMessages.js +76 -0
- package/lib/usageTracking.js +7 -7
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +4 -4
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +8 -7
- package/types/Cms.d.ts +6 -6
- package/types/Yargs.d.ts +1 -1
- package/commands/app/__tests__/install.test.js +0 -47
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -122
- package/lib/middleware/__test__/utils.test.js +0 -51
- package/lib/middleware/utils.d.ts +0 -8
- package/lib/middleware/utils.js +0 -14
- package/lib/projects/localDev/DevServerManagerV2.d.ts +0 -22
- package/lib/projects/localDev/DevServerManagerV2.js +0 -81
- /package/commands/{customObject/schema → cms}/__tests__/delete.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/fetch.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/function.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/lint.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/list.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/mv.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/__tests__}/theme.test.d.ts +0 -0
- /package/commands/{__tests__ → cms/function/__tests__}/logs.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/generate-selectors.test.js +0 -0
- /package/commands/{theme → cms/theme}/__tests__/marketplace-validate.test.d.ts +0 -0
- /package/commands/{theme → cms/theme}/__tests__/preview.test.d.ts +0 -0
- /package/commands/{__tests__/remove.test.d.ts → customObject/__tests__/createSchema.test.d.ts} +0 -0
- /package/commands/{app/__tests__/install.test.d.ts → customObject/__tests__/deleteSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/create.test.d.ts → __tests__/fetch-all-schemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch-all.test.d.ts → __tests__/fetchSchema.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/fetch.test.d.ts → __tests__/listSchemas.test.d.ts} +0 -0
- /package/commands/customObject/{schema/__tests__/list.test.d.ts → __tests__/updateSchema.test.d.ts} +0 -0
- /package/commands/{customObject/schema/__tests__/update.test.d.ts → project/__tests__/list.test.d.ts} +0 -0
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
- /package/{commands/create → lib/cmsAssets}/api-sample.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/api-sample.js +0 -0
- /package/{commands/create → lib/cmsAssets}/app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/function.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/function.js +0 -0
- /package/{commands/create → lib/cmsAssets}/index.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/index.js +0 -0
- /package/{commands/create → lib/cmsAssets}/module.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/module.js +0 -0
- /package/{commands/create → lib/cmsAssets}/react-app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/react-app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/template.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/template.js +0 -0
- /package/{commands/create → lib/cmsAssets}/vue-app.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/vue-app.js +0 -0
- /package/{commands/create → lib/cmsAssets}/webpack-serverless.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/webpack-serverless.js +0 -0
- /package/{commands/create → lib/cmsAssets}/website-theme.d.ts +0 -0
- /package/{commands/create → lib/cmsAssets}/website-theme.js +0 -0
- /package/lib/{projects/add/__tests__/v3AddComponent.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/projects/{create/__tests__/v3.test.d.ts → __tests__/DevServerManager.test.d.ts} +0 -0
- /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
|
@@ -2,18 +2,22 @@ import yargs from 'yargs';
|
|
|
2
2
|
import list from '../function/list.js';
|
|
3
3
|
import deploy from '../function/deploy.js';
|
|
4
4
|
import server from '../function/server.js';
|
|
5
|
+
import logs from '../function/logs.js';
|
|
6
|
+
import create from '../function/create.js';
|
|
5
7
|
import functionCommands from '../function.js';
|
|
6
8
|
vi.mock('../function/list');
|
|
7
9
|
vi.mock('../function/deploy');
|
|
8
10
|
vi.mock('../function/server');
|
|
9
|
-
vi.mock('
|
|
11
|
+
vi.mock('../function/logs');
|
|
12
|
+
vi.mock('../function/create');
|
|
13
|
+
vi.mock('../../../lib/commonOpts');
|
|
10
14
|
const commandSpy = vi
|
|
11
15
|
.spyOn(yargs, 'command')
|
|
12
16
|
.mockReturnValue(yargs);
|
|
13
17
|
const demandCommandSpy = vi
|
|
14
18
|
.spyOn(yargs, 'demandCommand')
|
|
15
19
|
.mockReturnValue(yargs);
|
|
16
|
-
describe('commands/function', () => {
|
|
20
|
+
describe('commands/cms/function', () => {
|
|
17
21
|
describe('command', () => {
|
|
18
22
|
it('should have the correct command structure', () => {
|
|
19
23
|
expect(functionCommands.command).toEqual(['function', 'functions']);
|
|
@@ -25,7 +29,7 @@ describe('commands/function', () => {
|
|
|
25
29
|
});
|
|
26
30
|
});
|
|
27
31
|
describe('builder', () => {
|
|
28
|
-
const subcommands = [list, deploy, server];
|
|
32
|
+
const subcommands = [list, deploy, server, logs, create];
|
|
29
33
|
it('should demand the command takes one positional argument', () => {
|
|
30
34
|
functionCommands.builder(yargs);
|
|
31
35
|
expect(demandCommandSpy).toHaveBeenCalledTimes(1);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import { addConfigOptions, addAccountOptions } from '
|
|
2
|
+
import { addConfigOptions, addAccountOptions, } from '../../../lib/commonOpts.js';
|
|
3
3
|
import lintCommand from '../lint.js';
|
|
4
|
-
vi.mock('
|
|
4
|
+
vi.mock('../../../lib/commonOpts');
|
|
5
5
|
const positionalSpy = vi
|
|
6
6
|
.spyOn(yargs, 'positional')
|
|
7
7
|
.mockReturnValue(yargs);
|
|
8
|
-
describe('commands/lint', () => {
|
|
8
|
+
describe('commands/cms/lint', () => {
|
|
9
9
|
describe('command', () => {
|
|
10
10
|
it('should have the correct command structure', () => {
|
|
11
11
|
expect(lintCommand.command).toEqual('lint <path>');
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } from '
|
|
2
|
+
import { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } from '../../../lib/commonOpts.js';
|
|
3
3
|
import listCommand from '../list.js';
|
|
4
|
-
vi.mock('
|
|
4
|
+
vi.mock('../../../lib/commonOpts');
|
|
5
5
|
const positionalSpy = vi
|
|
6
6
|
.spyOn(yargs, 'positional')
|
|
7
7
|
.mockReturnValue(yargs);
|
|
8
8
|
const exampleSpy = vi
|
|
9
9
|
.spyOn(yargs, 'example')
|
|
10
10
|
.mockReturnValue(yargs);
|
|
11
|
-
describe('commands/list', () => {
|
|
11
|
+
describe('commands/cms/list', () => {
|
|
12
12
|
describe('command', () => {
|
|
13
13
|
it('should have the correct command structure', () => {
|
|
14
14
|
expect(listCommand.command).toEqual(['list [path]', 'ls [path]']);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import * as commonOpts from '
|
|
2
|
+
import * as commonOpts from '../../../lib/commonOpts.js';
|
|
3
3
|
import mvCommand from '../mv.js';
|
|
4
|
-
vi.mock('
|
|
4
|
+
vi.mock('../../../lib/commonOpts');
|
|
5
5
|
const positionalSpy = vi
|
|
6
6
|
.spyOn(yargs, 'positional')
|
|
7
7
|
.mockReturnValue(yargs);
|
|
8
|
-
describe('commands/mv', () => {
|
|
8
|
+
describe('commands/cms/mv', () => {
|
|
9
9
|
describe('command', () => {
|
|
10
10
|
it('should have the correct command structure', () => {
|
|
11
11
|
expect(mvCommand.command).toBe('mv <srcPath> <destPath>');
|
|
@@ -2,10 +2,12 @@ import yargs from 'yargs';
|
|
|
2
2
|
import preview from '../theme/preview.js';
|
|
3
3
|
import generateSelectors from '../theme/generate-selectors.js';
|
|
4
4
|
import marketplaceValidate from '../theme/marketplace-validate.js';
|
|
5
|
+
import create from '../theme/create.js';
|
|
5
6
|
import themeCommands from '../theme.js';
|
|
6
7
|
vi.mock('../theme/preview');
|
|
7
8
|
vi.mock('../theme/generate-selectors');
|
|
8
9
|
vi.mock('../theme/marketplace-validate');
|
|
10
|
+
vi.mock('../theme/create');
|
|
9
11
|
vi.mock('../../lib/commonOpts');
|
|
10
12
|
const commandSpy = vi
|
|
11
13
|
.spyOn(yargs, 'command')
|
|
@@ -13,7 +15,7 @@ const commandSpy = vi
|
|
|
13
15
|
const demandCommandSpy = vi
|
|
14
16
|
.spyOn(yargs, 'demandCommand')
|
|
15
17
|
.mockReturnValue(yargs);
|
|
16
|
-
describe('commands/theme', () => {
|
|
18
|
+
describe('commands/cms/theme', () => {
|
|
17
19
|
describe('command', () => {
|
|
18
20
|
it('should have the correct command structure', () => {
|
|
19
21
|
expect(themeCommands.command).toEqual(['theme', 'themes']);
|
|
@@ -29,7 +31,12 @@ describe('commands/theme', () => {
|
|
|
29
31
|
commandSpy.mockClear();
|
|
30
32
|
demandCommandSpy.mockClear();
|
|
31
33
|
});
|
|
32
|
-
const subcommands = [
|
|
34
|
+
const subcommands = [
|
|
35
|
+
preview,
|
|
36
|
+
generateSelectors,
|
|
37
|
+
marketplaceValidate,
|
|
38
|
+
create,
|
|
39
|
+
];
|
|
33
40
|
it('should demand the command takes one positional argument', () => {
|
|
34
41
|
themeCommands.builder(yargs);
|
|
35
42
|
expect(demandCommandSpy).toHaveBeenCalledTimes(1);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
type AppCreateArgs = CommonArgs & ConfigArgs & {
|
|
3
|
+
type: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
dest?: string;
|
|
6
|
+
internal?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const appCreateCommand: YargsCommandModule<unknown, AppCreateArgs>;
|
|
9
|
+
export default appCreateCommand;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
3
|
+
import { resolveLocalPath } from '../../../lib/filesystem.js';
|
|
4
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
5
|
+
import { commands } from '../../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
8
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
9
|
+
import assets from '../../../lib/cmsAssets/index.js';
|
|
10
|
+
const APP_ASSET_TYPES = ['api-sample', 'app', 'react-app', 'vue-app'];
|
|
11
|
+
const SUPPORTED_APP_TYPES = APP_ASSET_TYPES.filter(t => !assets[t].hidden).join(', ');
|
|
12
|
+
const command = 'create <type> [name] [dest]';
|
|
13
|
+
const describe = commands.cms.subcommands.app.subcommands.create.describe;
|
|
14
|
+
async function handler(args) {
|
|
15
|
+
const { derivedAccountId, name, internal: getInternalVersion, type, dest, } = args;
|
|
16
|
+
const assetType = type.toLowerCase();
|
|
17
|
+
if (!assetType || !APP_ASSET_TYPES.includes(assetType)) {
|
|
18
|
+
uiLogger.error(commands.cms.subcommands.app.subcommands.create.errors.unsupportedAssetType(assetType, SUPPORTED_APP_TYPES));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
trackCommandUsage('create', { assetType }, derivedAccountId);
|
|
22
|
+
const asset = assets[assetType];
|
|
23
|
+
const argsToPass = {
|
|
24
|
+
commandArgs: args,
|
|
25
|
+
assetType,
|
|
26
|
+
name,
|
|
27
|
+
dest,
|
|
28
|
+
getInternalVersion: getInternalVersion || false,
|
|
29
|
+
};
|
|
30
|
+
if (!argsToPass.dest) {
|
|
31
|
+
argsToPass.dest = resolveLocalPath(asset.dest(argsToPass));
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await fs.ensureDir(argsToPass.dest);
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
uiLogger.error(commands.cms.subcommands.app.subcommands.create.errors.unusablePath(argsToPass.dest));
|
|
38
|
+
logError(e);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (asset.validate && !asset.validate(argsToPass))
|
|
42
|
+
return;
|
|
43
|
+
try {
|
|
44
|
+
await asset.execute(argsToPass);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
logError(e);
|
|
48
|
+
process.exit(EXIT_CODES.ERROR);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function appCreateBuilder(yargs) {
|
|
52
|
+
yargs.positional('type', {
|
|
53
|
+
describe: commands.cms.subcommands.app.subcommands.create.positionals.type,
|
|
54
|
+
type: 'string',
|
|
55
|
+
choices: APP_ASSET_TYPES.filter(t => !assets[t].hidden),
|
|
56
|
+
});
|
|
57
|
+
yargs.positional('name', {
|
|
58
|
+
describe: commands.cms.subcommands.app.subcommands.create.positionals.name,
|
|
59
|
+
type: 'string',
|
|
60
|
+
});
|
|
61
|
+
yargs.positional('dest', {
|
|
62
|
+
describe: commands.cms.subcommands.app.subcommands.create.positionals.dest,
|
|
63
|
+
type: 'string',
|
|
64
|
+
});
|
|
65
|
+
yargs.option('internal', {
|
|
66
|
+
describe: 'Internal HubSpot version of creation command',
|
|
67
|
+
type: 'boolean',
|
|
68
|
+
hidden: true,
|
|
69
|
+
});
|
|
70
|
+
return yargs;
|
|
71
|
+
}
|
|
72
|
+
const builder = makeYargsBuilder(appCreateBuilder, command, describe, {
|
|
73
|
+
useGlobalOptions: true,
|
|
74
|
+
useConfigOptions: true,
|
|
75
|
+
});
|
|
76
|
+
const appCreateCommand = {
|
|
77
|
+
command,
|
|
78
|
+
describe,
|
|
79
|
+
builder,
|
|
80
|
+
handler,
|
|
81
|
+
};
|
|
82
|
+
export default appCreateCommand;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import createCommand from './app/create.js';
|
|
2
|
+
import { commands } from '../../lang/en.js';
|
|
3
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
4
|
+
const command = ['app', 'apps'];
|
|
5
|
+
const describe = commands.cms.subcommands.app.describe;
|
|
6
|
+
function appBuilder(yargs) {
|
|
7
|
+
yargs.command(createCommand).demandCommand(1, '');
|
|
8
|
+
return yargs;
|
|
9
|
+
}
|
|
10
|
+
const builder = makeYargsBuilder(appBuilder, command, describe);
|
|
11
|
+
const appCommand = {
|
|
12
|
+
command,
|
|
13
|
+
describe,
|
|
14
|
+
builder,
|
|
15
|
+
handler: () => { },
|
|
16
|
+
};
|
|
17
|
+
export default appCommand;
|
|
@@ -2,21 +2,19 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createIgnoreFilter } from '@hubspot/local-dev-lib/ignoreRules';
|
|
4
4
|
import { isAllowedExtension, getCwd } from '@hubspot/local-dev-lib/path';
|
|
5
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
6
5
|
import { walk } from '@hubspot/local-dev-lib/fs';
|
|
7
6
|
import { getThemeJSONPath } from '@hubspot/local-dev-lib/cms/themes';
|
|
8
|
-
import {
|
|
7
|
+
import { commands } from '../../lang/en.js';
|
|
8
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
9
9
|
import { FieldsJs, isConvertableFieldJs, } from '@hubspot/local-dev-lib/cms/handleFieldsJS';
|
|
10
10
|
import { trackConvertFieldsUsage } from '../../lib/usageTracking.js';
|
|
11
11
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
12
12
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
13
13
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
14
14
|
const command = 'convert-fields';
|
|
15
|
-
const describe =
|
|
15
|
+
const describe = commands.convertFields.describe;
|
|
16
16
|
function invalidPath(src) {
|
|
17
|
-
|
|
18
|
-
path: src,
|
|
19
|
-
}));
|
|
17
|
+
uiLogger.error(commands.convertFields.errors.invalidPath(src));
|
|
20
18
|
process.exit(EXIT_CODES.ERROR);
|
|
21
19
|
}
|
|
22
20
|
async function handler(args) {
|
|
@@ -77,13 +75,13 @@ async function handler(args) {
|
|
|
77
75
|
}
|
|
78
76
|
function convertFieldsBuilder(yargs) {
|
|
79
77
|
yargs.option('src', {
|
|
80
|
-
describe:
|
|
78
|
+
describe: commands.convertFields.positionals.src.describe,
|
|
81
79
|
type: 'string',
|
|
82
80
|
required: true,
|
|
83
|
-
demandOption:
|
|
81
|
+
demandOption: commands.convertFields.errors.missingSrc,
|
|
84
82
|
});
|
|
85
83
|
yargs.option('fieldOptions', {
|
|
86
|
-
describe:
|
|
84
|
+
describe: commands.convertFields.options.options.describe,
|
|
87
85
|
type: 'array',
|
|
88
86
|
default: [''],
|
|
89
87
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
|
+
export type DeleteArgs = CommonArgs & ConfigArgs & EnvironmentArgs & AccountArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const cmsDeleteCommand: YargsCommandModule<unknown, DeleteArgs>;
|
|
6
|
+
export default cmsDeleteCommand;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { deleteFile } from '@hubspot/local-dev-lib/api/fileMapper';
|
|
2
|
+
import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
|
|
3
|
+
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
4
|
+
import { commands } from '../../lang/en.js';
|
|
5
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
6
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
7
|
+
const command = 'delete <path>';
|
|
8
|
+
const describe = commands.cms.subcommands.delete.describe;
|
|
9
|
+
async function handler(args) {
|
|
10
|
+
const { path: hsPath, derivedAccountId } = args;
|
|
11
|
+
trackCommandUsage('delete', undefined, derivedAccountId);
|
|
12
|
+
try {
|
|
13
|
+
await deleteFile(derivedAccountId, hsPath);
|
|
14
|
+
uiLogger.log(commands.cms.subcommands.delete.deleted(hsPath, derivedAccountId));
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
uiLogger.error(commands.cms.subcommands.delete.errors.deleteFailed(hsPath, derivedAccountId));
|
|
18
|
+
logError(error, new ApiErrorContext({
|
|
19
|
+
accountId: derivedAccountId,
|
|
20
|
+
request: hsPath,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function cmsDeleteBuilder(yargs) {
|
|
25
|
+
yargs.positional('path', {
|
|
26
|
+
describe: commands.cms.subcommands.delete.positionals.path,
|
|
27
|
+
type: 'string',
|
|
28
|
+
});
|
|
29
|
+
return yargs;
|
|
30
|
+
}
|
|
31
|
+
const builder = makeYargsBuilder(cmsDeleteBuilder, command, describe, {
|
|
32
|
+
useGlobalOptions: true,
|
|
33
|
+
useConfigOptions: true,
|
|
34
|
+
useAccountOptions: true,
|
|
35
|
+
useEnvironmentOptions: true,
|
|
36
|
+
});
|
|
37
|
+
const cmsDeleteCommand = {
|
|
38
|
+
command,
|
|
39
|
+
describe,
|
|
40
|
+
handler,
|
|
41
|
+
builder,
|
|
42
|
+
};
|
|
43
|
+
export default cmsDeleteCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
2
|
+
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
3
|
+
export type FetchCommandArgs = {
|
|
4
|
+
src: string;
|
|
5
|
+
dest?: string;
|
|
6
|
+
cmsPublishMode?: CmsPublishMode;
|
|
7
|
+
staging?: boolean;
|
|
8
|
+
assetVersion?: number;
|
|
9
|
+
overwrite?: boolean;
|
|
10
|
+
} & ConfigArgs & AccountArgs & EnvironmentArgs & CommonArgs;
|
|
11
|
+
declare const fetchCommand: YargsCommandModule<unknown, FetchCommandArgs>;
|
|
12
|
+
export default fetchCommand;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { downloadFileOrFolder } from '@hubspot/local-dev-lib/fileMapper';
|
|
2
|
+
import { addCmsPublishModeOptions, addOverwriteOptions, getCmsPublishMode, } from '../../lib/commonOpts.js';
|
|
3
|
+
import { resolveLocalPath } from '../../lib/filesystem.js';
|
|
4
|
+
import { validateCmsPublishMode } from '../../lib/validation.js';
|
|
5
|
+
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
6
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
7
|
+
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
8
|
+
import { logError } from '../../lib/errorHandlers/index.js';
|
|
9
|
+
import { commands } from '../../lang/en.js';
|
|
10
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
11
|
+
const command = 'fetch <src> [dest]';
|
|
12
|
+
const describe = commands.cms.subcommands.fetch.describe;
|
|
13
|
+
async function handler(options) {
|
|
14
|
+
const { src, dest } = options;
|
|
15
|
+
if (!validateCmsPublishMode(options)) {
|
|
16
|
+
process.exit(EXIT_CODES.ERROR);
|
|
17
|
+
}
|
|
18
|
+
if (typeof src !== 'string') {
|
|
19
|
+
uiLogger.error(commands.cms.subcommands.fetch.errors.sourceRequired);
|
|
20
|
+
process.exit(EXIT_CODES.ERROR);
|
|
21
|
+
}
|
|
22
|
+
const { derivedAccountId } = options;
|
|
23
|
+
const cmsPublishMode = getCmsPublishMode(options);
|
|
24
|
+
trackCommandUsage('fetch', { mode: cmsPublishMode }, derivedAccountId);
|
|
25
|
+
const { assetVersion, staging, overwrite } = options;
|
|
26
|
+
try {
|
|
27
|
+
// Fetch and write file/folder.
|
|
28
|
+
await downloadFileOrFolder(derivedAccountId, src, resolveLocalPath(dest), cmsPublishMode, {
|
|
29
|
+
assetVersion: assetVersion !== undefined ? `${assetVersion}` : assetVersion,
|
|
30
|
+
staging,
|
|
31
|
+
overwrite,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
logError(err);
|
|
36
|
+
process.exit(EXIT_CODES.ERROR);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const fetchBuilder = (yargs) => {
|
|
40
|
+
yargs.positional('src', {
|
|
41
|
+
describe: commands.cms.subcommands.fetch.positionals.src.describe,
|
|
42
|
+
type: 'string',
|
|
43
|
+
});
|
|
44
|
+
yargs.positional('dest', {
|
|
45
|
+
describe: commands.cms.subcommands.fetch.positionals.dest.describe,
|
|
46
|
+
type: 'string',
|
|
47
|
+
});
|
|
48
|
+
yargs.options({
|
|
49
|
+
staging: {
|
|
50
|
+
describe: commands.cms.subcommands.fetch.options.staging.describe,
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
default: false,
|
|
53
|
+
hidden: true,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
yargs.options({
|
|
57
|
+
assetVersion: {
|
|
58
|
+
type: 'number',
|
|
59
|
+
describe: commands.cms.subcommands.fetch.options.assetVersion.describe,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
addCmsPublishModeOptions(yargs, { read: true });
|
|
63
|
+
addOverwriteOptions(yargs);
|
|
64
|
+
return yargs;
|
|
65
|
+
};
|
|
66
|
+
const builder = makeYargsBuilder(fetchBuilder, command, describe, {
|
|
67
|
+
useConfigOptions: true,
|
|
68
|
+
useAccountOptions: true,
|
|
69
|
+
useGlobalOptions: true,
|
|
70
|
+
useEnvironmentOptions: true,
|
|
71
|
+
useTestingOptions: false,
|
|
72
|
+
});
|
|
73
|
+
const fetchCommand = {
|
|
74
|
+
command,
|
|
75
|
+
describe,
|
|
76
|
+
handler,
|
|
77
|
+
builder,
|
|
78
|
+
};
|
|
79
|
+
export default fetchCommand;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } from '
|
|
3
|
-
|
|
2
|
+
import { addConfigOptions, addAccountOptions, addUseEnvironmentOptions, } from '../../../../lib/commonOpts.js';
|
|
3
|
+
import logsCommand from '../logs.js';
|
|
4
|
+
vi.mock('../../../../lib/commonOpts');
|
|
4
5
|
const optionsSpy = vi
|
|
5
6
|
.spyOn(yargs, 'options')
|
|
6
7
|
.mockReturnValue(yargs);
|
|
@@ -13,9 +14,7 @@ const exampleSpy = vi
|
|
|
13
14
|
const positionalSpy = vi
|
|
14
15
|
.spyOn(yargs, 'positional')
|
|
15
16
|
.mockReturnValue(yargs);
|
|
16
|
-
|
|
17
|
-
import logsCommand from '../logs.js';
|
|
18
|
-
describe('commands/logs', () => {
|
|
17
|
+
describe('commands/cms/function/logs', () => {
|
|
19
18
|
describe('command', () => {
|
|
20
19
|
it('should have the correct command structure', () => {
|
|
21
20
|
expect(logsCommand.command).toEqual('logs [endpoint]');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpMethod } from '../../../types/Cms.js';
|
|
2
|
+
import { CommonArgs, ConfigArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
3
|
+
type FunctionCreateArgs = CommonArgs & ConfigArgs & {
|
|
4
|
+
name?: string;
|
|
5
|
+
dest?: string;
|
|
6
|
+
functionsFolder?: string;
|
|
7
|
+
filename?: string;
|
|
8
|
+
endpointMethod?: HttpMethod;
|
|
9
|
+
endpointPath?: string;
|
|
10
|
+
};
|
|
11
|
+
declare const functionCreateCommand: YargsCommandModule<unknown, FunctionCreateArgs>;
|
|
12
|
+
export default functionCreateCommand;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
3
|
+
import { resolveLocalPath } from '../../../lib/filesystem.js';
|
|
4
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
5
|
+
import { commands } from '../../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
|
+
import { HTTP_METHODS } from '../../../types/Cms.js';
|
|
8
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
9
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
10
|
+
import assets from '../../../lib/cmsAssets/index.js';
|
|
11
|
+
const command = 'create [name] [dest]';
|
|
12
|
+
const describe = commands.cms.subcommands.function.subcommands.create.describe;
|
|
13
|
+
async function handler(args) {
|
|
14
|
+
const { derivedAccountId, name, dest } = args;
|
|
15
|
+
const assetType = 'function';
|
|
16
|
+
trackCommandUsage('create', { assetType }, derivedAccountId);
|
|
17
|
+
const asset = assets[assetType];
|
|
18
|
+
const argsToPass = {
|
|
19
|
+
commandArgs: args,
|
|
20
|
+
assetType,
|
|
21
|
+
name,
|
|
22
|
+
dest,
|
|
23
|
+
};
|
|
24
|
+
if (!argsToPass.dest) {
|
|
25
|
+
argsToPass.dest = resolveLocalPath(asset.dest(argsToPass));
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
await fs.ensureDir(argsToPass.dest);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.create.errors.unusablePath(argsToPass.dest));
|
|
32
|
+
logError(e);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await asset.execute(argsToPass);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
logError(e);
|
|
40
|
+
process.exit(EXIT_CODES.ERROR);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function functionCreateBuilder(yargs) {
|
|
44
|
+
yargs.positional('name', {
|
|
45
|
+
describe: commands.cms.subcommands.function.subcommands.create.positionals.name,
|
|
46
|
+
type: 'string',
|
|
47
|
+
});
|
|
48
|
+
yargs.positional('dest', {
|
|
49
|
+
describe: commands.cms.subcommands.function.subcommands.create.positionals.dest,
|
|
50
|
+
type: 'string',
|
|
51
|
+
});
|
|
52
|
+
yargs.option('functions-folder', {
|
|
53
|
+
describe: commands.cms.subcommands.function.subcommands.create.options
|
|
54
|
+
.functionsFolder,
|
|
55
|
+
type: 'string',
|
|
56
|
+
});
|
|
57
|
+
yargs.option('filename', {
|
|
58
|
+
describe: commands.cms.subcommands.function.subcommands.create.options.filename,
|
|
59
|
+
type: 'string',
|
|
60
|
+
});
|
|
61
|
+
yargs.option('endpoint-method', {
|
|
62
|
+
describe: commands.cms.subcommands.function.subcommands.create.options
|
|
63
|
+
.endpointMethod,
|
|
64
|
+
type: 'string',
|
|
65
|
+
choices: [...HTTP_METHODS],
|
|
66
|
+
default: 'GET',
|
|
67
|
+
});
|
|
68
|
+
yargs.option('endpoint-path', {
|
|
69
|
+
describe: commands.cms.subcommands.function.subcommands.create.options.endpointPath,
|
|
70
|
+
type: 'string',
|
|
71
|
+
});
|
|
72
|
+
return yargs;
|
|
73
|
+
}
|
|
74
|
+
const builder = makeYargsBuilder(functionCreateBuilder, command, describe, {
|
|
75
|
+
useGlobalOptions: true,
|
|
76
|
+
useConfigOptions: true,
|
|
77
|
+
});
|
|
78
|
+
const functionCreateCommand = {
|
|
79
|
+
command,
|
|
80
|
+
describe,
|
|
81
|
+
builder,
|
|
82
|
+
handler,
|
|
83
|
+
};
|
|
84
|
+
export default functionCreateCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type FunctionDeployArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const functionDeployCommand: YargsCommandModule<unknown, FunctionDeployArgs>;
|
|
6
|
+
export default functionDeployCommand;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
2
|
+
import { buildPackage, getBuildStatus, } from '@hubspot/local-dev-lib/api/functions';
|
|
3
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
|
+
import SpinniesManager from '../../../lib/ui/SpinniesManager.js';
|
|
5
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
6
|
+
import { logError, ApiErrorContext } from '../../../lib/errorHandlers/index.js';
|
|
7
|
+
import { uiAccountDescription } from '../../../lib/ui/index.js';
|
|
8
|
+
import { poll } from '../../../lib/polling.js';
|
|
9
|
+
import { outputBuildLog } from '../../../lib/serverlessLogs.js';
|
|
10
|
+
import { commands } from '../../../lang/en.js';
|
|
11
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
12
|
+
function isFunctionBuildError(e) {
|
|
13
|
+
return (typeof e === 'object' && e !== null && 'status' in e && e.status === 'ERROR');
|
|
14
|
+
}
|
|
15
|
+
const command = 'deploy <path>';
|
|
16
|
+
const describe = undefined; // Hidden command
|
|
17
|
+
async function handler(args) {
|
|
18
|
+
const { path: functionPath, derivedAccountId } = args;
|
|
19
|
+
const splitFunctionPath = functionPath.split('.');
|
|
20
|
+
trackCommandUsage('function-deploy', undefined, derivedAccountId);
|
|
21
|
+
if (!splitFunctionPath.length ||
|
|
22
|
+
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
|
|
23
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.deploy.errors.notFunctionsFolder(functionPath));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.deploy.debug.startingBuildAndDeploy(functionPath));
|
|
27
|
+
SpinniesManager.init();
|
|
28
|
+
SpinniesManager.add('loading', {
|
|
29
|
+
text: commands.cms.subcommands.function.subcommands.deploy.loading(functionPath, uiAccountDescription(derivedAccountId)),
|
|
30
|
+
});
|
|
31
|
+
try {
|
|
32
|
+
const { data: buildId } = await buildPackage(derivedAccountId, functionPath);
|
|
33
|
+
const successResp = await poll(() => getBuildStatus(derivedAccountId, Number(buildId)));
|
|
34
|
+
if (successResp) {
|
|
35
|
+
const buildTimeSeconds = successResp.buildTime
|
|
36
|
+
? (successResp.buildTime / 1000).toFixed(2)
|
|
37
|
+
: 0;
|
|
38
|
+
SpinniesManager.succeed('loading');
|
|
39
|
+
if (successResp.cdnUrl) {
|
|
40
|
+
await outputBuildLog(successResp.cdnUrl);
|
|
41
|
+
}
|
|
42
|
+
uiLogger.success(commands.cms.subcommands.function.subcommands.deploy.success.deployed(functionPath, derivedAccountId, buildTimeSeconds));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
SpinniesManager.fail('loading', {
|
|
47
|
+
text: commands.cms.subcommands.function.subcommands.deploy.loadingFailed(functionPath, uiAccountDescription(derivedAccountId)),
|
|
48
|
+
});
|
|
49
|
+
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
50
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.deploy.errors.noPackageJson(functionPath));
|
|
51
|
+
}
|
|
52
|
+
else if (isFunctionBuildError(e)) {
|
|
53
|
+
await outputBuildLog(e.cdnUrl);
|
|
54
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.deploy.errors.buildError(String(e.errorReason)));
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
logError(e, new ApiErrorContext({
|
|
58
|
+
accountId: derivedAccountId,
|
|
59
|
+
request: functionPath,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function functionDeployBuilder(yargs) {
|
|
65
|
+
yargs.positional('path', {
|
|
66
|
+
describe: commands.cms.subcommands.function.subcommands.deploy.positionals.path
|
|
67
|
+
.describe,
|
|
68
|
+
type: 'string',
|
|
69
|
+
});
|
|
70
|
+
yargs.example([
|
|
71
|
+
[
|
|
72
|
+
'$0 functions deploy myFunctionFolder.functions',
|
|
73
|
+
commands.cms.subcommands.function.subcommands.deploy.examples.default,
|
|
74
|
+
],
|
|
75
|
+
]);
|
|
76
|
+
return yargs;
|
|
77
|
+
}
|
|
78
|
+
const builder = makeYargsBuilder(functionDeployBuilder, command, describe, {
|
|
79
|
+
useConfigOptions: true,
|
|
80
|
+
useAccountOptions: true,
|
|
81
|
+
useEnvironmentOptions: true,
|
|
82
|
+
});
|
|
83
|
+
const functionDeployCommand = {
|
|
84
|
+
command,
|
|
85
|
+
describe,
|
|
86
|
+
handler,
|
|
87
|
+
builder,
|
|
88
|
+
};
|
|
89
|
+
export default functionDeployCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type FunctionListArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
json?: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const functionListCommand: YargsCommandModule<unknown, FunctionListArgs>;
|
|
6
|
+
export default functionListCommand;
|