@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
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import { getRoutes } from '@hubspot/local-dev-lib/api/functions';
|
|
3
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
4
|
+
import { logError, ApiErrorContext } from '../../../lib/errorHandlers/index.js';
|
|
5
|
+
import { getTableContents, getTableHeader } from '../../../lib/ui/table.js';
|
|
6
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
7
|
+
import { commands } from '../../../lang/en.js';
|
|
8
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
9
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
10
|
+
const command = ['list', 'ls'];
|
|
11
|
+
const describe = commands.cms.subcommands.function.subcommands.list.describe;
|
|
12
|
+
async function handler(args) {
|
|
13
|
+
const { derivedAccountId } = args;
|
|
14
|
+
trackCommandUsage('function-list', undefined, derivedAccountId);
|
|
15
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.list.debug.gettingFunctions);
|
|
16
|
+
const { data: routesResp } = await getRoutes(derivedAccountId).catch(async (e) => {
|
|
17
|
+
logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
18
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
19
|
+
});
|
|
20
|
+
if (!routesResp.objects.length) {
|
|
21
|
+
return uiLogger.info(commands.cms.subcommands.function.subcommands.list.info.noFunctions);
|
|
22
|
+
}
|
|
23
|
+
if (args.json) {
|
|
24
|
+
return uiLogger.json(routesResp.objects);
|
|
25
|
+
}
|
|
26
|
+
const functionsAsArrays = routesResp.objects.map(func => {
|
|
27
|
+
const { route, method, created, updated, secretNames } = func;
|
|
28
|
+
return [
|
|
29
|
+
route,
|
|
30
|
+
method,
|
|
31
|
+
secretNames.join(', '),
|
|
32
|
+
moment(created).format(),
|
|
33
|
+
moment(updated).format(),
|
|
34
|
+
];
|
|
35
|
+
});
|
|
36
|
+
functionsAsArrays.unshift(getTableHeader(['Route', 'Method', 'Secrets', 'Created', 'Updated']));
|
|
37
|
+
return uiLogger.log(getTableContents(functionsAsArrays));
|
|
38
|
+
}
|
|
39
|
+
function functionListBuilder(yargs) {
|
|
40
|
+
yargs.options({
|
|
41
|
+
json: {
|
|
42
|
+
describe: commands.cms.subcommands.function.subcommands.list.options.json
|
|
43
|
+
.describe,
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return yargs;
|
|
48
|
+
}
|
|
49
|
+
const builder = makeYargsBuilder(functionListBuilder, command, describe, {
|
|
50
|
+
useConfigOptions: true,
|
|
51
|
+
useAccountOptions: true,
|
|
52
|
+
useEnvironmentOptions: true,
|
|
53
|
+
});
|
|
54
|
+
const functionListCommand = {
|
|
55
|
+
command,
|
|
56
|
+
describe,
|
|
57
|
+
handler,
|
|
58
|
+
builder,
|
|
59
|
+
};
|
|
60
|
+
export default functionListCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, YargsCommandModule, EnvironmentArgs } from '../../../types/Yargs.js';
|
|
2
|
+
export type LogsArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
endpoint?: string;
|
|
4
|
+
latest?: boolean;
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
follow?: boolean;
|
|
7
|
+
limit?: number;
|
|
8
|
+
};
|
|
9
|
+
declare const logsCommand: YargsCommandModule<unknown, LogsArgs>;
|
|
10
|
+
export default logsCommand;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
2
|
+
import { outputLogs } from '../../../lib/ui/serverlessFunctionLogs.js';
|
|
3
|
+
import { getFunctionLogs, getLatestFunctionLog, } from '@hubspot/local-dev-lib/api/functions';
|
|
4
|
+
import { tailLogs } from '../../../lib/serverlessLogs.js';
|
|
5
|
+
import { promptUser } from '../../../lib/prompts/promptUtils.js';
|
|
6
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
7
|
+
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
8
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
9
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
10
|
+
import { commands } from '../../../lang/en.js';
|
|
11
|
+
const handleLogsError = (e, accountId, functionPath) => {
|
|
12
|
+
if (isHubSpotHttpError(e) && (e.status === 404 || e.status == 400)) {
|
|
13
|
+
uiLogger.error(commands.cms.subcommands.function.subcommands.logs.errors.noLogsFound(functionPath, accountId));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const endpointLog = async (accountId, functionPath, options) => {
|
|
17
|
+
const { limit, latest, follow, compact } = options;
|
|
18
|
+
const requestParams = {
|
|
19
|
+
limit,
|
|
20
|
+
latest,
|
|
21
|
+
follow,
|
|
22
|
+
endpoint: functionPath,
|
|
23
|
+
};
|
|
24
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.logs.gettingLogs(latest, functionPath));
|
|
25
|
+
let logsResp;
|
|
26
|
+
if (follow) {
|
|
27
|
+
const tailCall = (after) => getFunctionLogs(accountId, functionPath, { after });
|
|
28
|
+
const fetchLatest = () => {
|
|
29
|
+
try {
|
|
30
|
+
return getLatestFunctionLog(accountId, functionPath);
|
|
31
|
+
}
|
|
32
|
+
catch (e) {
|
|
33
|
+
handleLogsError(e, accountId, functionPath);
|
|
34
|
+
return Promise.reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
await tailLogs(accountId, functionPath, fetchLatest, tailCall, compact);
|
|
38
|
+
}
|
|
39
|
+
else if (latest) {
|
|
40
|
+
try {
|
|
41
|
+
const { data } = await getLatestFunctionLog(accountId, functionPath);
|
|
42
|
+
logsResp = data;
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
handleLogsError(e, accountId, functionPath);
|
|
46
|
+
process.exit(EXIT_CODES.ERROR);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
try {
|
|
51
|
+
const { data } = await getFunctionLogs(accountId, functionPath, requestParams);
|
|
52
|
+
logsResp = data;
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
handleLogsError(e, accountId, functionPath);
|
|
56
|
+
process.exit(EXIT_CODES.ERROR);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (logsResp) {
|
|
60
|
+
return outputLogs(logsResp, { compact });
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const command = 'logs [endpoint]';
|
|
64
|
+
const describe = commands.cms.subcommands.function.subcommands.logs.describe;
|
|
65
|
+
const handler = async (options) => {
|
|
66
|
+
const { endpoint: endpointArgValue, latest, derivedAccountId } = options;
|
|
67
|
+
trackCommandUsage('logs', latest ? { action: 'latest' } : {}, derivedAccountId);
|
|
68
|
+
const { endpointPromptValue } = await promptUser({
|
|
69
|
+
name: 'endpointPromptValue',
|
|
70
|
+
message: commands.cms.subcommands.function.subcommands.logs.endpointPrompt,
|
|
71
|
+
when: !endpointArgValue,
|
|
72
|
+
});
|
|
73
|
+
await endpointLog(derivedAccountId, endpointArgValue || endpointPromptValue, options);
|
|
74
|
+
};
|
|
75
|
+
function logsBuilder(yargs) {
|
|
76
|
+
yargs.positional('endpoint', {
|
|
77
|
+
describe: commands.cms.subcommands.function.subcommands.logs.positionals.endpoint
|
|
78
|
+
.describe,
|
|
79
|
+
type: 'string',
|
|
80
|
+
});
|
|
81
|
+
yargs
|
|
82
|
+
.options({
|
|
83
|
+
latest: {
|
|
84
|
+
alias: 'l',
|
|
85
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.latest
|
|
86
|
+
.describe,
|
|
87
|
+
type: 'boolean',
|
|
88
|
+
},
|
|
89
|
+
compact: {
|
|
90
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.compact
|
|
91
|
+
.describe,
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
},
|
|
94
|
+
follow: {
|
|
95
|
+
alias: ['f'],
|
|
96
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.follow
|
|
97
|
+
.describe,
|
|
98
|
+
type: 'boolean',
|
|
99
|
+
},
|
|
100
|
+
limit: {
|
|
101
|
+
describe: commands.cms.subcommands.function.subcommands.logs.options.limit
|
|
102
|
+
.describe,
|
|
103
|
+
type: 'number',
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
.conflicts('follow', 'limit');
|
|
107
|
+
yargs.example([
|
|
108
|
+
[
|
|
109
|
+
'$0 logs my-endpoint',
|
|
110
|
+
commands.cms.subcommands.function.subcommands.logs.examples.default,
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
'$0 logs my-endpoint --limit=10',
|
|
114
|
+
commands.cms.subcommands.function.subcommands.logs.examples.limit,
|
|
115
|
+
],
|
|
116
|
+
[
|
|
117
|
+
'$0 logs my-endpoint --follow',
|
|
118
|
+
commands.cms.subcommands.function.subcommands.logs.examples.follow,
|
|
119
|
+
],
|
|
120
|
+
]);
|
|
121
|
+
return yargs;
|
|
122
|
+
}
|
|
123
|
+
const builder = makeYargsBuilder(logsBuilder, command, describe, {
|
|
124
|
+
useGlobalOptions: true,
|
|
125
|
+
useConfigOptions: true,
|
|
126
|
+
useAccountOptions: true,
|
|
127
|
+
useEnvironmentOptions: true,
|
|
128
|
+
});
|
|
129
|
+
const logsCommand = {
|
|
130
|
+
command,
|
|
131
|
+
describe,
|
|
132
|
+
builder,
|
|
133
|
+
handler,
|
|
134
|
+
};
|
|
135
|
+
export default logsCommand;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type FunctionServerArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
port?: string;
|
|
5
|
+
contact?: boolean;
|
|
6
|
+
watch?: boolean;
|
|
7
|
+
'log-output'?: boolean;
|
|
8
|
+
};
|
|
9
|
+
declare const functionServerCommand: YargsCommandModule<unknown, FunctionServerArgs>;
|
|
10
|
+
export default functionServerCommand;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
2
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
3
|
+
// This package is not typed, so we need to use require
|
|
4
|
+
import { start as startTestServer } from '@hubspot/serverless-dev-runtime';
|
|
5
|
+
import { commands } from '../../../lang/en.js';
|
|
6
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
7
|
+
const command = 'server <path>';
|
|
8
|
+
const describe = undefined;
|
|
9
|
+
async function handler(args) {
|
|
10
|
+
const { path: functionPath, derivedAccountId } = args;
|
|
11
|
+
trackCommandUsage('functions-server', undefined, derivedAccountId);
|
|
12
|
+
uiLogger.debug(commands.cms.subcommands.function.subcommands.server.debug.startingServer(functionPath));
|
|
13
|
+
startTestServer({
|
|
14
|
+
accountId: derivedAccountId,
|
|
15
|
+
...args,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function functionServerBuilder(yargs) {
|
|
19
|
+
yargs.positional('path', {
|
|
20
|
+
describe: commands.cms.subcommands.function.subcommands.server.positionals.path
|
|
21
|
+
.describe,
|
|
22
|
+
type: 'string',
|
|
23
|
+
});
|
|
24
|
+
yargs.options({
|
|
25
|
+
port: {
|
|
26
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.port
|
|
27
|
+
.describe,
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: 5432,
|
|
30
|
+
},
|
|
31
|
+
contact: {
|
|
32
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.contact
|
|
33
|
+
.describe,
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
default: true,
|
|
36
|
+
},
|
|
37
|
+
watch: {
|
|
38
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.watch
|
|
39
|
+
.describe,
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
default: true,
|
|
42
|
+
},
|
|
43
|
+
'log-output': {
|
|
44
|
+
describe: commands.cms.subcommands.function.subcommands.server.options.logOutput
|
|
45
|
+
.describe,
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
yargs.example([
|
|
51
|
+
[
|
|
52
|
+
'$0 functions server ./tmp/myFunctionFolder.functions',
|
|
53
|
+
commands.cms.subcommands.function.subcommands.server.examples.default,
|
|
54
|
+
],
|
|
55
|
+
]);
|
|
56
|
+
return yargs;
|
|
57
|
+
}
|
|
58
|
+
const builder = makeYargsBuilder(functionServerBuilder, command, describe, {
|
|
59
|
+
useConfigOptions: true,
|
|
60
|
+
useAccountOptions: true,
|
|
61
|
+
useEnvironmentOptions: true,
|
|
62
|
+
});
|
|
63
|
+
const functionServerCommand = {
|
|
64
|
+
command,
|
|
65
|
+
describe,
|
|
66
|
+
handler,
|
|
67
|
+
builder,
|
|
68
|
+
};
|
|
69
|
+
export default functionServerCommand;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import createCommand from './function/create.js';
|
|
2
|
+
import listCommand from './function/list.js';
|
|
3
|
+
import deployCommand from './function/deploy.js';
|
|
4
|
+
import serverCommand from './function/server.js';
|
|
5
|
+
import logsCommand from './function/logs.js';
|
|
6
|
+
import { commands } from '../../lang/en.js';
|
|
7
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
|
+
const command = ['function', 'functions'];
|
|
9
|
+
const describe = commands.cms.subcommands.function.describe;
|
|
10
|
+
function functionBuilder(yargs) {
|
|
11
|
+
yargs
|
|
12
|
+
.command(createCommand)
|
|
13
|
+
.command(listCommand)
|
|
14
|
+
.command(deployCommand)
|
|
15
|
+
.command(serverCommand)
|
|
16
|
+
.command(logsCommand)
|
|
17
|
+
.demandCommand(1, '');
|
|
18
|
+
return yargs;
|
|
19
|
+
}
|
|
20
|
+
const builder = makeYargsBuilder(functionBuilder, command, describe);
|
|
21
|
+
const functionCommand = {
|
|
22
|
+
command,
|
|
23
|
+
describe,
|
|
24
|
+
builder,
|
|
25
|
+
handler: () => { },
|
|
26
|
+
};
|
|
27
|
+
export default functionCommand;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getCwd } from '@hubspot/local-dev-lib/path';
|
|
4
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
5
4
|
import { retrieveDefaultModule } from '@hubspot/local-dev-lib/cms/modules';
|
|
6
|
-
import {
|
|
5
|
+
import { commands } from '../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
7
7
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
8
8
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
9
9
|
import { listPrompt } from '../../lib/prompts/promptUtils.js';
|
|
10
10
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
11
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
12
12
|
const command = 'get-react-module [name] [dest]';
|
|
13
|
-
const describe =
|
|
13
|
+
const describe = commands.cms.subcommands.getReactModule.describe;
|
|
14
14
|
async function handler(args) {
|
|
15
15
|
const { name, dest } = args;
|
|
16
16
|
trackCommandUsage('get-react-modules');
|
|
@@ -26,7 +26,7 @@ async function handler(args) {
|
|
|
26
26
|
if (!availableModules) {
|
|
27
27
|
process.exit(EXIT_CODES.ERROR);
|
|
28
28
|
}
|
|
29
|
-
const moduleChoice = await listPrompt(
|
|
29
|
+
const moduleChoice = await listPrompt(commands.cms.subcommands.getReactModule.selectModulePrompt, {
|
|
30
30
|
choices: availableModules.map(module => module.name),
|
|
31
31
|
});
|
|
32
32
|
moduleToRetrieve = moduleChoice;
|
|
@@ -35,22 +35,17 @@ async function handler(args) {
|
|
|
35
35
|
? path.join(path.resolve(getCwd(), dest), `${moduleToRetrieve}`)
|
|
36
36
|
: path.join(getCwd(), `${moduleToRetrieve}`);
|
|
37
37
|
if (fs.existsSync(destPath)) {
|
|
38
|
-
|
|
39
|
-
path: destPath,
|
|
40
|
-
}));
|
|
38
|
+
uiLogger.error(commands.cms.subcommands.getReactModule.errors.pathExists(destPath));
|
|
41
39
|
process.exit(EXIT_CODES.ERROR);
|
|
42
40
|
}
|
|
43
41
|
try {
|
|
44
42
|
await retrieveDefaultModule(moduleToRetrieve, destPath);
|
|
45
|
-
|
|
46
|
-
moduleName: moduleToRetrieve,
|
|
47
|
-
path: destPath,
|
|
48
|
-
}));
|
|
43
|
+
uiLogger.success(commands.cms.subcommands.getReactModule.success.moduleDownloaded(moduleToRetrieve, destPath));
|
|
49
44
|
}
|
|
50
45
|
catch (e) {
|
|
51
46
|
const isBadRequestError = e?.cause?.code === 'ERR_BAD_REQUEST';
|
|
52
47
|
if (isBadRequestError) {
|
|
53
|
-
|
|
48
|
+
uiLogger.error(commands.cms.subcommands.getReactModule.errors.invalidName);
|
|
54
49
|
}
|
|
55
50
|
else {
|
|
56
51
|
logError(e);
|
|
@@ -61,11 +56,11 @@ async function handler(args) {
|
|
|
61
56
|
}
|
|
62
57
|
function cmsGetReactModuleBuilder(yargs) {
|
|
63
58
|
yargs.positional('name', {
|
|
64
|
-
describe:
|
|
59
|
+
describe: commands.cms.subcommands.getReactModule.positionals.name.describe,
|
|
65
60
|
type: 'string',
|
|
66
61
|
});
|
|
67
62
|
yargs.positional('dest', {
|
|
68
|
-
describe:
|
|
63
|
+
describe: commands.cms.subcommands.getReactModule.positionals.dest.describe,
|
|
69
64
|
type: 'string',
|
|
70
65
|
});
|
|
71
66
|
return yargs;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import SpinniesManager from '../../lib/ui/SpinniesManager.js';
|
|
2
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
2
|
import { getTableContents, getTableHeader } from '../../lib/ui/table.js';
|
|
4
3
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
5
|
-
import {
|
|
4
|
+
import { commands } from '../../lang/en.js';
|
|
5
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
6
6
|
import { fetchThemes } from '@hubspot/local-dev-lib/api/designManager';
|
|
7
7
|
import { requestLighthouseScore, getLighthouseScoreStatus, getLighthouseScore, } from '@hubspot/local-dev-lib/api/lighthouseScore';
|
|
8
8
|
import { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } from '../../lib/constants.js';
|
|
@@ -45,14 +45,14 @@ async function selectTheme(accountId) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
catch (err) {
|
|
48
|
-
|
|
48
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToFetchThemes);
|
|
49
49
|
process.exit(EXIT_CODES.ERROR);
|
|
50
50
|
}
|
|
51
51
|
const { theme: selectedTheme } = await promptUser([
|
|
52
52
|
{
|
|
53
53
|
type: 'list',
|
|
54
54
|
name: 'theme',
|
|
55
|
-
message:
|
|
55
|
+
message: commands.cms.subcommands.lighthouseScore.info.promptMessage,
|
|
56
56
|
choices: themes,
|
|
57
57
|
},
|
|
58
58
|
]);
|
|
@@ -75,15 +75,13 @@ async function handler(args) {
|
|
|
75
75
|
isValidTheme = false;
|
|
76
76
|
}
|
|
77
77
|
if (!isValidTheme) {
|
|
78
|
-
|
|
79
|
-
theme: themeToCheck,
|
|
80
|
-
}));
|
|
78
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.themeNotFound(themeToCheck));
|
|
81
79
|
process.exit(EXIT_CODES.ERROR);
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
else {
|
|
85
83
|
themeToCheck = await selectTheme(derivedAccountId);
|
|
86
|
-
|
|
84
|
+
uiLogger.log('');
|
|
87
85
|
}
|
|
88
86
|
// Kick off the scoring
|
|
89
87
|
let requestResult;
|
|
@@ -94,17 +92,17 @@ async function handler(args) {
|
|
|
94
92
|
requestResult = data;
|
|
95
93
|
}
|
|
96
94
|
catch (err) {
|
|
97
|
-
|
|
95
|
+
uiLogger.debug(err);
|
|
98
96
|
}
|
|
99
97
|
if (!requestResult || !requestResult.mobileId || !requestResult.desktopId) {
|
|
100
|
-
|
|
98
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToGetLighthouseScore);
|
|
101
99
|
process.exit(EXIT_CODES.ERROR);
|
|
102
100
|
}
|
|
103
101
|
// Poll till scoring is finished
|
|
104
102
|
try {
|
|
105
103
|
SpinniesManager.init();
|
|
106
104
|
SpinniesManager.add('lighthouseScore', {
|
|
107
|
-
text:
|
|
105
|
+
text: commands.cms.subcommands.lighthouseScore.info.generatingScore(themeToCheck),
|
|
108
106
|
});
|
|
109
107
|
async function checkScoreStatus() {
|
|
110
108
|
let desktopScoreStatus = 'COMPLETED';
|
|
@@ -131,7 +129,7 @@ async function handler(args) {
|
|
|
131
129
|
SpinniesManager.remove('lighthouseScore');
|
|
132
130
|
}
|
|
133
131
|
catch (err) {
|
|
134
|
-
|
|
132
|
+
uiLogger.debug(err);
|
|
135
133
|
process.exit(EXIT_CODES.ERROR);
|
|
136
134
|
}
|
|
137
135
|
// Fetch the scoring results
|
|
@@ -166,16 +164,17 @@ async function handler(args) {
|
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
catch (err) {
|
|
169
|
-
|
|
167
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors.failedToGetLighthouseScore);
|
|
170
168
|
process.exit(EXIT_CODES.ERROR);
|
|
171
169
|
}
|
|
172
170
|
if (verbose) {
|
|
173
171
|
const scoreResult = target === 'desktop' ? desktopScoreResult : mobileScoreResult;
|
|
174
172
|
if (!verboseViewAverageScoreResult || !scoreResult) {
|
|
175
|
-
|
|
173
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.errors
|
|
174
|
+
.failedToGetLighthouseScore);
|
|
176
175
|
process.exit(EXIT_CODES.ERROR);
|
|
177
176
|
}
|
|
178
|
-
|
|
177
|
+
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.themeToCheckTitle(themeToCheck, target));
|
|
179
178
|
const tableHeader = getTableHeader(DEFAULT_TABLE_HEADER);
|
|
180
179
|
const scores = verboseViewAverageScoreResult.scores
|
|
181
180
|
? verboseViewAverageScoreResult.scores[0]
|
|
@@ -187,10 +186,10 @@ async function handler(args) {
|
|
|
187
186
|
scores.pwaScore,
|
|
188
187
|
scores.seoScore,
|
|
189
188
|
];
|
|
190
|
-
|
|
189
|
+
uiLogger.log(getTableContents([tableHeader, averageTableData], {
|
|
191
190
|
border: { bodyLeft: ' ' },
|
|
192
191
|
}));
|
|
193
|
-
|
|
192
|
+
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.pageTemplateScoreTitle);
|
|
194
193
|
const table2Header = getTableHeader([
|
|
195
194
|
'Template path',
|
|
196
195
|
...DEFAULT_TABLE_HEADER,
|
|
@@ -205,29 +204,27 @@ async function handler(args) {
|
|
|
205
204
|
score.seoScore,
|
|
206
205
|
];
|
|
207
206
|
});
|
|
208
|
-
|
|
207
|
+
uiLogger.log(getTableContents([table2Header, ...templateTableData], {
|
|
209
208
|
border: { bodyLeft: ' ' },
|
|
210
209
|
}));
|
|
211
|
-
|
|
210
|
+
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.lighthouseLinksTitle);
|
|
212
211
|
scoreResult.scores.forEach(score => {
|
|
213
212
|
if (score.templatePath && score.link) {
|
|
214
|
-
|
|
213
|
+
uiLogger.log(` ${uiLink(score.templatePath, score.link)}`);
|
|
215
214
|
}
|
|
216
215
|
});
|
|
217
216
|
if (scoreResult.failedTemplatePaths.length) {
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
uiLogger.log('');
|
|
218
|
+
uiLogger.error(commands.cms.subcommands.lighthouseScore.info.failedTemplatePathsTitle);
|
|
220
219
|
scoreResult.failedTemplatePaths.forEach(failedTemplatePath => {
|
|
221
|
-
|
|
220
|
+
uiLogger.log(` ${failedTemplatePath}`);
|
|
222
221
|
});
|
|
223
222
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
target,
|
|
227
|
-
}));
|
|
223
|
+
uiLogger.log('');
|
|
224
|
+
uiLogger.info(commands.cms.subcommands.lighthouseScore.info.targetDeviceNote(target));
|
|
228
225
|
}
|
|
229
226
|
else {
|
|
230
|
-
|
|
227
|
+
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.themeTitle(themeToCheck));
|
|
231
228
|
const tableHeader = getTableHeader(['Target', ...DEFAULT_TABLE_HEADER]);
|
|
232
229
|
const getTableData = (target, scoreResult) => {
|
|
233
230
|
const scores = scoreResult?.scores ? scoreResult.scores[0] : EMPTY_SCORE;
|
|
@@ -244,35 +241,35 @@ async function handler(args) {
|
|
|
244
241
|
getTableData('desktop', desktopScoreResult),
|
|
245
242
|
getTableData('mobile', mobileScoreResult),
|
|
246
243
|
];
|
|
247
|
-
|
|
244
|
+
uiLogger.log(getTableContents([tableHeader, ...tableData], {
|
|
248
245
|
border: { bodyLeft: ' ' },
|
|
249
246
|
}));
|
|
250
|
-
|
|
247
|
+
uiLogger.info(commands.cms.subcommands.lighthouseScore.info.verboseOptionNote);
|
|
251
248
|
}
|
|
252
|
-
|
|
253
|
-
|
|
249
|
+
uiLogger.log('');
|
|
250
|
+
uiLogger.log(commands.cms.subcommands.lighthouseScore.info.poweredByLink);
|
|
254
251
|
process.exit(EXIT_CODES.SUCCESS);
|
|
255
252
|
}
|
|
256
253
|
function cmslighthouseScoreBuilder(yargs) {
|
|
257
254
|
yargs.option('theme', {
|
|
258
|
-
describe:
|
|
255
|
+
describe: commands.cms.subcommands.lighthouseScore.options.theme.describe,
|
|
259
256
|
type: 'string',
|
|
260
257
|
});
|
|
261
258
|
yargs.option('target', {
|
|
262
|
-
describe:
|
|
259
|
+
describe: commands.cms.subcommands.lighthouseScore.options.target.describe,
|
|
263
260
|
type: 'string',
|
|
264
261
|
choices: ['desktop', 'mobile'],
|
|
265
262
|
default: 'desktop',
|
|
266
263
|
});
|
|
267
264
|
yargs.option('verbose', {
|
|
268
|
-
describe:
|
|
265
|
+
describe: commands.cms.subcommands.lighthouseScore.options.verbose.describe,
|
|
269
266
|
boolean: true,
|
|
270
267
|
default: false,
|
|
271
268
|
});
|
|
272
269
|
yargs.example([
|
|
273
270
|
[
|
|
274
271
|
'$0 cms lighthouse-score --theme=my-theme',
|
|
275
|
-
|
|
272
|
+
commands.cms.subcommands.lighthouseScore.examples.default,
|
|
276
273
|
],
|
|
277
274
|
]);
|
|
278
275
|
return yargs;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccountArgs, CommonArgs, ConfigArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
|
+
export type LintArgs = CommonArgs & ConfigArgs & AccountArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const lintCommand: YargsCommandModule<unknown, LintArgs>;
|
|
6
|
+
export default lintCommand;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { lint } from '@hubspot/local-dev-lib/cms/validate';
|
|
2
|
+
import { logError } from '../../lib/errorHandlers/index.js';
|
|
3
|
+
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
4
|
+
import { commands } from '../../lang/en.js';
|
|
5
|
+
import { resolveLocalPath } from '../../lib/filesystem.js';
|
|
6
|
+
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
7
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
9
|
+
const command = 'lint <path>';
|
|
10
|
+
// Hiding since this command is still experimental
|
|
11
|
+
const describe = undefined; //'Lint a file or folder for HubL syntax';
|
|
12
|
+
function getErrorsFromHublValidationObject(validation) {
|
|
13
|
+
return ((validation && validation.meta && validation.meta.template_errors) || []);
|
|
14
|
+
}
|
|
15
|
+
function printHublValidationError(err) {
|
|
16
|
+
const { severity, message, lineno, startPosition } = err;
|
|
17
|
+
if (severity === 'FATAL') {
|
|
18
|
+
uiLogger.error(`[${lineno}, ${startPosition}]: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
uiLogger.warn(`[${lineno}, ${startPosition}]: ${message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function printHublValidationResult({ file, validation }) {
|
|
25
|
+
let count = 0;
|
|
26
|
+
if (!validation) {
|
|
27
|
+
return count;
|
|
28
|
+
}
|
|
29
|
+
const errors = getErrorsFromHublValidationObject(validation);
|
|
30
|
+
if (!errors.length) {
|
|
31
|
+
return count;
|
|
32
|
+
}
|
|
33
|
+
uiLogger.group(file);
|
|
34
|
+
errors.forEach(err => {
|
|
35
|
+
if (err.reason !== 'SYNTAX_ERROR') {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
++count;
|
|
39
|
+
printHublValidationError(err);
|
|
40
|
+
});
|
|
41
|
+
uiLogger.groupEnd();
|
|
42
|
+
return count;
|
|
43
|
+
}
|
|
44
|
+
async function handler(args) {
|
|
45
|
+
const { path: lintPath, derivedAccountId } = args;
|
|
46
|
+
const localPath = resolveLocalPath(lintPath);
|
|
47
|
+
const groupName = commands.cms.subcommands.lint.groupName(localPath);
|
|
48
|
+
trackCommandUsage('lint', undefined, derivedAccountId);
|
|
49
|
+
uiLogger.group(groupName);
|
|
50
|
+
let count = 0;
|
|
51
|
+
try {
|
|
52
|
+
await lint(derivedAccountId, localPath, (result) => {
|
|
53
|
+
return (count += printHublValidationResult(result));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
uiLogger.groupEnd();
|
|
58
|
+
logError(err, { accountId: derivedAccountId });
|
|
59
|
+
process.exit(EXIT_CODES.ERROR);
|
|
60
|
+
}
|
|
61
|
+
uiLogger.groupEnd();
|
|
62
|
+
uiLogger.log(commands.cms.subcommands.lint.issuesFound(count));
|
|
63
|
+
}
|
|
64
|
+
function lintBuilder(yargs) {
|
|
65
|
+
yargs.positional('path', {
|
|
66
|
+
describe: commands.cms.subcommands.lint.positionals.path.describe,
|
|
67
|
+
required: true,
|
|
68
|
+
type: 'string',
|
|
69
|
+
});
|
|
70
|
+
return yargs;
|
|
71
|
+
}
|
|
72
|
+
const builder = makeYargsBuilder(lintBuilder, command, describe, {
|
|
73
|
+
useGlobalOptions: true,
|
|
74
|
+
useConfigOptions: true,
|
|
75
|
+
useAccountOptions: true,
|
|
76
|
+
});
|
|
77
|
+
const lintCommand = {
|
|
78
|
+
command,
|
|
79
|
+
describe,
|
|
80
|
+
handler,
|
|
81
|
+
builder,
|
|
82
|
+
};
|
|
83
|
+
export default lintCommand;
|