@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,171 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { commands } from '../../../lang/en.js';
|
|
3
|
+
import { findFieldsJsonPath, combineThemeCss, setPreviewSelectors, generateInheritedSelectors, generateSelectorsMap, getMaxFieldsDepth, } from '../../../lib/generateSelectors.js';
|
|
4
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
5
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
6
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
7
|
+
const HUBL_EXPRESSION_REGEX = new RegExp(/{%\s*(.*)\s*%}/, 'g');
|
|
8
|
+
const HUBL_VARIABLE_NAME_REGEX = new RegExp(/{%\s*set\s*(\w*)/, 'i');
|
|
9
|
+
const HUBL_STATEMENT_REGEX = new RegExp(/{{\s*[\w.(,\d\-\s)|/~]*.*}}/, 'g');
|
|
10
|
+
const HUBL_STATEMENT_PLACEHOLDER_REGEX = new RegExp(/hubl_statement_\d*/, 'g');
|
|
11
|
+
const CSS_VARS_REGEX = new RegExp(/--([\w.(,\d\-)]*):(.*);/, 'g');
|
|
12
|
+
const CSS_VARS_NAME_REGEX = new RegExp(/(--[\w.(,\d\-)]*)/, 'g');
|
|
13
|
+
const CSS_SELECTORS_REGEX = new RegExp(/([\s\w:.,\0-[\]]*){/, 'i');
|
|
14
|
+
const CSS_EXPRESSION_REGEX = new RegExp(/(?!\s)([^}])*(?![.#\s,>])[^}]*}/, 'g');
|
|
15
|
+
const THEME_PATH_REGEX = new RegExp(/=\s*.*(theme\.(\w|\.)*)/, 'i');
|
|
16
|
+
const command = 'generate-selectors <path>';
|
|
17
|
+
const describe = commands.cms.subcommands.theme.subcommands.generateSelectors.describe;
|
|
18
|
+
async function handler(args) {
|
|
19
|
+
const { path } = args;
|
|
20
|
+
const fieldsJsonPath = findFieldsJsonPath(path);
|
|
21
|
+
if (!fieldsJsonPath) {
|
|
22
|
+
uiLogger.error(commands.cms.subcommands.theme.subcommands.generateSelectors.errors
|
|
23
|
+
.fieldsNotFound);
|
|
24
|
+
process.exit(EXIT_CODES.ERROR);
|
|
25
|
+
}
|
|
26
|
+
let fieldsJson = JSON.parse(fs.readFileSync(fieldsJsonPath, 'utf-8'));
|
|
27
|
+
let cssString = combineThemeCss(path) ?? '';
|
|
28
|
+
/**
|
|
29
|
+
* Creates map of HubL variable names to theme field paths
|
|
30
|
+
*/
|
|
31
|
+
const HubLExpressions = cssString.match(HUBL_EXPRESSION_REGEX);
|
|
32
|
+
const hublVariableMap = HubLExpressions
|
|
33
|
+
? HubLExpressions.reduce((_hublVariableMap, expression) => {
|
|
34
|
+
const variableName = expression.match(HUBL_VARIABLE_NAME_REGEX);
|
|
35
|
+
const themeFieldKey = expression.match(THEME_PATH_REGEX);
|
|
36
|
+
if (!themeFieldKey || !variableName)
|
|
37
|
+
return _hublVariableMap;
|
|
38
|
+
_hublVariableMap[variableName[1]] = themeFieldKey[1];
|
|
39
|
+
return _hublVariableMap;
|
|
40
|
+
}, {})
|
|
41
|
+
: {};
|
|
42
|
+
/**
|
|
43
|
+
* Removes HubL variable expressions
|
|
44
|
+
*/
|
|
45
|
+
cssString = cssString.replace(HUBL_EXPRESSION_REGEX, '');
|
|
46
|
+
/**
|
|
47
|
+
* Regex for HubL variable names
|
|
48
|
+
*/
|
|
49
|
+
const HUBL_EXPRESSIONS = new RegExp(`.*(${Object.keys(hublVariableMap).join('|')}).*`, 'g');
|
|
50
|
+
/**
|
|
51
|
+
* Matches all HubL statements in the CSS and replaces them with a placeholder string
|
|
52
|
+
* This is to prevent the the css expression regex from capturing all the HubL as well
|
|
53
|
+
*/
|
|
54
|
+
const hublStatements = cssString.match(HUBL_STATEMENT_REGEX) || [];
|
|
55
|
+
const hublStatementsMap = {};
|
|
56
|
+
hublStatements.forEach((statement, index) => {
|
|
57
|
+
const statementKey = `hubl_statement_${index}`;
|
|
58
|
+
hublStatementsMap[statementKey] = statement;
|
|
59
|
+
cssString = cssString.replace(statement, statementKey);
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Matchs all css variables and determines if there are hubl within those vars.
|
|
63
|
+
*/
|
|
64
|
+
const cssVars = cssString.match(CSS_VARS_REGEX) || [];
|
|
65
|
+
const cssVarsMap = cssVars.reduce((acc, expression) => {
|
|
66
|
+
const cssVarName = expression.match(CSS_VARS_NAME_REGEX);
|
|
67
|
+
const hublVariables = expression.match(HUBL_STATEMENT_PLACEHOLDER_REGEX);
|
|
68
|
+
if (!cssVarName || !hublVariables)
|
|
69
|
+
return acc;
|
|
70
|
+
cssString = cssString.replace(expression, '');
|
|
71
|
+
return { ...acc, [cssVarName[0]]: hublVariables };
|
|
72
|
+
}, {});
|
|
73
|
+
// replace all css variable references with corresponding hubl placeholder
|
|
74
|
+
Object.keys(cssVarsMap).forEach(cssVarName => {
|
|
75
|
+
const hublPlaceholders = cssVarsMap[cssVarName];
|
|
76
|
+
cssString = cssString.replace(cssVarName, hublPlaceholders.join(' '));
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* Parses each css string for a HubL statement and tries to map theme field paths to CSS selectors
|
|
80
|
+
*/
|
|
81
|
+
const cssExpressions = (cssString.match(CSS_EXPRESSION_REGEX) || []).map(exp => exp.replace(/\r?\n/g, ' '));
|
|
82
|
+
const finalMap = cssExpressions.reduce((themeFieldsSelectorMap, cssExpression) => {
|
|
83
|
+
const hublStatementsPlaceholderKey = cssExpression.match(HUBL_STATEMENT_PLACEHOLDER_REGEX) || [];
|
|
84
|
+
hublStatementsPlaceholderKey.forEach(placeholderKey => {
|
|
85
|
+
let hublStatement;
|
|
86
|
+
let themeFieldPath;
|
|
87
|
+
if (placeholderKey in hublStatementsMap) {
|
|
88
|
+
hublStatement =
|
|
89
|
+
hublStatementsMap[placeholderKey].match(HUBL_EXPRESSIONS);
|
|
90
|
+
themeFieldPath =
|
|
91
|
+
hublStatementsMap[placeholderKey].match(/theme\.[\w|.]*/);
|
|
92
|
+
}
|
|
93
|
+
const cssSelectors = cssExpression.match(CSS_SELECTORS_REGEX);
|
|
94
|
+
/**
|
|
95
|
+
* Try to match a HubL statement to any HubL Variables being used
|
|
96
|
+
*/
|
|
97
|
+
if (cssSelectors && themeFieldPath) {
|
|
98
|
+
const cssSelector = cssSelectors[1].replace(/\n/g, ' ');
|
|
99
|
+
const hublThemePath = themeFieldPath?.[0] ?? '';
|
|
100
|
+
if (!themeFieldsSelectorMap[hublThemePath]) {
|
|
101
|
+
themeFieldsSelectorMap[hublThemePath] = [];
|
|
102
|
+
}
|
|
103
|
+
if (!themeFieldsSelectorMap[hublThemePath].includes(cssSelector)) {
|
|
104
|
+
themeFieldsSelectorMap[hublThemePath] =
|
|
105
|
+
themeFieldsSelectorMap[hublThemePath].concat(cssSelector);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (cssSelectors && hublStatement) {
|
|
109
|
+
const cssSelector = cssSelectors?.[1]?.replace(/\n/g, ' ') ?? '';
|
|
110
|
+
const hublVariableName = Object.keys(hublVariableMap).find(_hubl => {
|
|
111
|
+
return hublStatement && hublStatement[0].includes(_hubl);
|
|
112
|
+
}) || '';
|
|
113
|
+
const themeFieldKey = hublVariableName
|
|
114
|
+
? hublVariableMap[hublVariableName]
|
|
115
|
+
: undefined;
|
|
116
|
+
/**
|
|
117
|
+
* If the theme path is referenced directly add selectors
|
|
118
|
+
*/
|
|
119
|
+
if (themeFieldKey) {
|
|
120
|
+
if (!themeFieldsSelectorMap[themeFieldKey]) {
|
|
121
|
+
themeFieldsSelectorMap[themeFieldKey] = [];
|
|
122
|
+
}
|
|
123
|
+
if (!themeFieldsSelectorMap[themeFieldKey].includes(cssSelector)) {
|
|
124
|
+
themeFieldsSelectorMap[themeFieldKey] =
|
|
125
|
+
themeFieldsSelectorMap[themeFieldKey].concat(cssSelector);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
return themeFieldsSelectorMap;
|
|
131
|
+
}, {});
|
|
132
|
+
if (!Object.keys(finalMap).length) {
|
|
133
|
+
uiLogger.error(commands.cms.subcommands.theme.subcommands.generateSelectors.errors
|
|
134
|
+
.noSelectorsFound);
|
|
135
|
+
process.exit(EXIT_CODES.ERROR);
|
|
136
|
+
}
|
|
137
|
+
Object.keys(finalMap).forEach(themeFieldKey => {
|
|
138
|
+
const fieldKey = themeFieldKey.split('.');
|
|
139
|
+
const selectors = finalMap[themeFieldKey];
|
|
140
|
+
fieldsJson = setPreviewSelectors(fieldsJson, fieldKey.splice(1), selectors);
|
|
141
|
+
});
|
|
142
|
+
// Because fields can have nested inheritance we generated inherited selectors
|
|
143
|
+
// multiple times to make sure all inherted selectors are bubbled up.
|
|
144
|
+
const maxFieldsDepth = getMaxFieldsDepth();
|
|
145
|
+
for (let i = 0; i < maxFieldsDepth; i += 1) {
|
|
146
|
+
fieldsJson = generateInheritedSelectors(fieldsJson);
|
|
147
|
+
}
|
|
148
|
+
const selectorsMap = generateSelectorsMap(fieldsJson);
|
|
149
|
+
const selectorsPath = `${path}/editor-preview.json`;
|
|
150
|
+
fs.writeFileSync(selectorsPath, `${JSON.stringify({ selectors: selectorsMap }, null, 2)}\n`);
|
|
151
|
+
uiLogger.success(commands.cms.subcommands.theme.subcommands.generateSelectors.success(path, selectorsPath));
|
|
152
|
+
}
|
|
153
|
+
function themeSelectorBuilder(yargs) {
|
|
154
|
+
yargs.positional('path', {
|
|
155
|
+
describe: commands.cms.subcommands.theme.subcommands.generateSelectors.positionals
|
|
156
|
+
.path,
|
|
157
|
+
type: 'string',
|
|
158
|
+
required: true,
|
|
159
|
+
});
|
|
160
|
+
return yargs;
|
|
161
|
+
}
|
|
162
|
+
const builder = makeYargsBuilder(themeSelectorBuilder, command, describe, {
|
|
163
|
+
useGlobalOptions: true,
|
|
164
|
+
});
|
|
165
|
+
const themeSelectorsCommand = {
|
|
166
|
+
command,
|
|
167
|
+
describe,
|
|
168
|
+
handler,
|
|
169
|
+
builder,
|
|
170
|
+
};
|
|
171
|
+
export default themeSelectorsCommand;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type ThemeValidateArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
3
|
+
path: string;
|
|
4
|
+
};
|
|
5
|
+
declare const themeValidateCommand: YargsCommandModule<unknown, ThemeValidateArgs>;
|
|
6
|
+
export default themeValidateCommand;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import SpinniesManager from '../../../lib/ui/SpinniesManager.js';
|
|
2
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
3
|
+
import { kickOffValidation, pollForValidationFinish, fetchValidationResults, processValidationErrors, displayValidationResults, } from '../../../lib/marketplaceValidate.js';
|
|
4
|
+
import { commands } from '../../../lang/en.js';
|
|
5
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
6
|
+
const command = 'marketplace-validate <path>';
|
|
7
|
+
const describe = commands.cms.subcommands.theme.subcommands.marketplaceValidate.describe;
|
|
8
|
+
async function handler(args) {
|
|
9
|
+
const { path, derivedAccountId } = args;
|
|
10
|
+
trackCommandUsage('validate', {}, derivedAccountId);
|
|
11
|
+
SpinniesManager.init();
|
|
12
|
+
SpinniesManager.add('marketplaceValidation', {
|
|
13
|
+
text: commands.cms.subcommands.theme.subcommands.marketplaceValidate.logs.validatingTheme(path),
|
|
14
|
+
});
|
|
15
|
+
const assetType = 'THEME';
|
|
16
|
+
const validationId = await kickOffValidation(derivedAccountId, assetType, path);
|
|
17
|
+
await pollForValidationFinish(derivedAccountId, validationId);
|
|
18
|
+
SpinniesManager.remove('marketplaceValidation');
|
|
19
|
+
const validationResults = await fetchValidationResults(derivedAccountId, validationId);
|
|
20
|
+
processValidationErrors(commands.cms.subcommands.theme.subcommands.marketplaceValidate.errors
|
|
21
|
+
.invalidPath, validationResults);
|
|
22
|
+
displayValidationResults(commands.cms.subcommands.theme.subcommands.marketplaceValidate.results, validationResults);
|
|
23
|
+
process.exit();
|
|
24
|
+
}
|
|
25
|
+
function themeValidateBuilder(yargs) {
|
|
26
|
+
yargs.positional('path', {
|
|
27
|
+
describe: commands.cms.subcommands.theme.subcommands.marketplaceValidate.positionals
|
|
28
|
+
.path.describe,
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true,
|
|
31
|
+
});
|
|
32
|
+
return yargs;
|
|
33
|
+
}
|
|
34
|
+
const builder = makeYargsBuilder(themeValidateBuilder, command, describe, {
|
|
35
|
+
useGlobalOptions: true,
|
|
36
|
+
useConfigOptions: true,
|
|
37
|
+
useAccountOptions: true,
|
|
38
|
+
useEnvironmentOptions: true,
|
|
39
|
+
});
|
|
40
|
+
const themeValidateCommand = {
|
|
41
|
+
command,
|
|
42
|
+
describe,
|
|
43
|
+
handler,
|
|
44
|
+
builder,
|
|
45
|
+
};
|
|
46
|
+
export default themeValidateCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, YargsCommandModule } from '../../../types/Yargs.js';
|
|
2
|
+
export type ThemePreviewArgs = CommonArgs & ConfigArgs & AccountArgs & {
|
|
3
|
+
src: string;
|
|
4
|
+
dest: string;
|
|
5
|
+
notify: string;
|
|
6
|
+
'no-ssl'?: boolean;
|
|
7
|
+
port?: number;
|
|
8
|
+
resetSession?: boolean;
|
|
9
|
+
generateFieldsTypes?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const themePreviewCommand: YargsCommandModule<unknown, ThemePreviewArgs>;
|
|
12
|
+
export default themePreviewCommand;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import cliProgress from 'cli-progress';
|
|
4
|
+
import { commands } from '../../../lang/en.js';
|
|
5
|
+
import { getCwd } from '@hubspot/local-dev-lib/path';
|
|
6
|
+
import { FILE_UPLOAD_RESULT_TYPES } from '@hubspot/local-dev-lib/constants/files';
|
|
7
|
+
import { getThemeJSONPath } from '@hubspot/local-dev-lib/cms/themes';
|
|
8
|
+
import { preview } from '@hubspot/theme-preview-dev-server';
|
|
9
|
+
import { getUploadableFileList } from '../../../lib/upload.js';
|
|
10
|
+
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
11
|
+
import { previewPrompt, previewProjectPrompt, } from '../../../lib/prompts/previewPrompt.js';
|
|
12
|
+
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
13
|
+
import { ApiErrorContext, logError } from '../../../lib/errorHandlers/index.js';
|
|
14
|
+
import { handleExit, handleKeypress } from '../../../lib/process.js';
|
|
15
|
+
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
16
|
+
import { findProjectComponents } from '../../../lib/projects/structure.js';
|
|
17
|
+
import { ComponentTypes } from '../../../types/Projects.js';
|
|
18
|
+
import { makeYargsBuilder } from '../../../lib/yargsUtils.js';
|
|
19
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
20
|
+
const command = 'preview [--src] [--dest]';
|
|
21
|
+
const describe = commands.cms.subcommands.theme.subcommands.preview.describe;
|
|
22
|
+
function validateSrcPath(src) {
|
|
23
|
+
const logInvalidPath = () => {
|
|
24
|
+
uiLogger.error(commands.cms.subcommands.theme.subcommands.preview.errors.invalidPath(src));
|
|
25
|
+
};
|
|
26
|
+
try {
|
|
27
|
+
const stats = fs.statSync(src);
|
|
28
|
+
if (!stats.isDirectory()) {
|
|
29
|
+
logInvalidPath();
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
logInvalidPath();
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
function handleUserInput() {
|
|
40
|
+
const onTerminate = () => {
|
|
41
|
+
uiLogger.log(commands.cms.subcommands.theme.subcommands.preview.logs.processExited);
|
|
42
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
43
|
+
};
|
|
44
|
+
handleExit(onTerminate);
|
|
45
|
+
handleKeypress(key => {
|
|
46
|
+
if ((key.ctrl && key.name === 'c') || key.name === 'q') {
|
|
47
|
+
onTerminate();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async function determineSrcAndDest(args) {
|
|
52
|
+
let absoluteSrc;
|
|
53
|
+
let dest;
|
|
54
|
+
const { projectDir, projectConfig } = await getProjectConfig();
|
|
55
|
+
if (!(projectDir && projectConfig)) {
|
|
56
|
+
// Not in a project, prompt for src and dest of traditional theme
|
|
57
|
+
const previewPromptAnswers = await previewPrompt(args);
|
|
58
|
+
const src = args.src || previewPromptAnswers.src;
|
|
59
|
+
dest = args.dest || previewPromptAnswers.dest;
|
|
60
|
+
absoluteSrc = path.resolve(getCwd(), src);
|
|
61
|
+
if (!dest || !validateSrcPath(absoluteSrc)) {
|
|
62
|
+
process.exit(EXIT_CODES.ERROR);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
// In a project
|
|
67
|
+
let themeJsonPath = getThemeJSONPath(getCwd());
|
|
68
|
+
if (!themeJsonPath) {
|
|
69
|
+
const projectComponents = await findProjectComponents(projectDir);
|
|
70
|
+
const themeComponents = projectComponents.filter(c => c.type === ComponentTypes.HublTheme);
|
|
71
|
+
if (themeComponents.length === 0) {
|
|
72
|
+
uiLogger.error(commands.cms.subcommands.theme.subcommands.preview.errors
|
|
73
|
+
.noThemeComponents);
|
|
74
|
+
process.exit(EXIT_CODES.ERROR);
|
|
75
|
+
}
|
|
76
|
+
const answer = await previewProjectPrompt(themeComponents);
|
|
77
|
+
themeJsonPath = `${answer.themeComponentPath}/theme.json`;
|
|
78
|
+
}
|
|
79
|
+
const { dir: themeDir } = path.parse(themeJsonPath);
|
|
80
|
+
absoluteSrc = themeDir;
|
|
81
|
+
const { base: themeName } = path.parse(themeDir);
|
|
82
|
+
dest = `@projects/${projectConfig.name}/${themeName}`;
|
|
83
|
+
}
|
|
84
|
+
return { absoluteSrc, dest };
|
|
85
|
+
}
|
|
86
|
+
async function handler(args) {
|
|
87
|
+
const { derivedAccountId, notify, noSsl, resetSession, port, generateFieldsTypes, } = args;
|
|
88
|
+
const { absoluteSrc, dest } = await determineSrcAndDest(args);
|
|
89
|
+
const filePaths = await getUploadableFileList(absoluteSrc, false);
|
|
90
|
+
function startProgressBar(numFiles) {
|
|
91
|
+
const initialUploadProgressBar = new cliProgress.SingleBar({
|
|
92
|
+
gracefulExit: true,
|
|
93
|
+
format: '[{bar}] {percentage}% | {value}/{total} | {label}',
|
|
94
|
+
hideCursor: true,
|
|
95
|
+
}, cliProgress.Presets.rect);
|
|
96
|
+
initialUploadProgressBar.start(numFiles, 0, {
|
|
97
|
+
label: commands.cms.subcommands.theme.subcommands.preview
|
|
98
|
+
.initialUploadProgressBar.start,
|
|
99
|
+
});
|
|
100
|
+
let uploadsHaveStarted = false;
|
|
101
|
+
const uploadOptions = {
|
|
102
|
+
onAttemptCallback: () => {
|
|
103
|
+
/* Intentionally blank */
|
|
104
|
+
},
|
|
105
|
+
onSuccessCallback: () => {
|
|
106
|
+
initialUploadProgressBar.increment();
|
|
107
|
+
if (!uploadsHaveStarted) {
|
|
108
|
+
uploadsHaveStarted = true;
|
|
109
|
+
initialUploadProgressBar.update(0, {
|
|
110
|
+
label: commands.cms.subcommands.theme.subcommands.preview
|
|
111
|
+
.initialUploadProgressBar.uploading,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
onFirstErrorCallback: () => {
|
|
116
|
+
/* Intentionally blank */
|
|
117
|
+
},
|
|
118
|
+
onRetryCallback: () => {
|
|
119
|
+
/* Intentionally blank */
|
|
120
|
+
},
|
|
121
|
+
onFinalErrorCallback: () => initialUploadProgressBar.increment(),
|
|
122
|
+
onFinishCallback: (results) => {
|
|
123
|
+
initialUploadProgressBar.update(numFiles, {
|
|
124
|
+
label: commands.cms.subcommands.theme.subcommands.preview
|
|
125
|
+
.initialUploadProgressBar.finish,
|
|
126
|
+
});
|
|
127
|
+
initialUploadProgressBar.stop();
|
|
128
|
+
results.forEach(result => {
|
|
129
|
+
if (result.resultType == FILE_UPLOAD_RESULT_TYPES.FAILURE) {
|
|
130
|
+
uiLogger.error(commands.cms.subcommands.theme.subcommands.preview.errors.uploadFailed(result.file, dest));
|
|
131
|
+
logError(result.error, new ApiErrorContext({
|
|
132
|
+
accountId: derivedAccountId,
|
|
133
|
+
request: dest,
|
|
134
|
+
payload: result.file,
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
return uploadOptions;
|
|
141
|
+
}
|
|
142
|
+
trackCommandUsage('preview', {}, derivedAccountId);
|
|
143
|
+
let createUnifiedDevServer;
|
|
144
|
+
try {
|
|
145
|
+
// @ts-ignore TODO: Remove when we deprecate Node 18
|
|
146
|
+
require.resolve('@hubspot/cms-dev-server');
|
|
147
|
+
// @ts-ignore TODO: Remove when we deprecate Node 18
|
|
148
|
+
const { createDevServer } = await import('@hubspot/cms-dev-server');
|
|
149
|
+
createUnifiedDevServer = createDevServer;
|
|
150
|
+
}
|
|
151
|
+
catch (e) {
|
|
152
|
+
uiLogger.warn('Unified dev server requires node 20 to run. Defaulting to legacy preview.');
|
|
153
|
+
}
|
|
154
|
+
if (createUnifiedDevServer) {
|
|
155
|
+
if (port) {
|
|
156
|
+
process.env['PORT'] = port.toString();
|
|
157
|
+
}
|
|
158
|
+
createUnifiedDevServer(absoluteSrc, false, '', '', !noSsl, generateFieldsTypes, {
|
|
159
|
+
filePaths,
|
|
160
|
+
resetSession: resetSession || false,
|
|
161
|
+
startProgressBar,
|
|
162
|
+
dest,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
preview(derivedAccountId, absoluteSrc, dest, {
|
|
167
|
+
notify,
|
|
168
|
+
filePaths,
|
|
169
|
+
noSsl,
|
|
170
|
+
port,
|
|
171
|
+
resetSession: resetSession || false,
|
|
172
|
+
startProgressBar,
|
|
173
|
+
handleUserInput,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function themePreviewBuilder(yargs) {
|
|
178
|
+
yargs
|
|
179
|
+
.option('src', {
|
|
180
|
+
describe: commands.cms.subcommands.theme.subcommands.preview.positionals.src,
|
|
181
|
+
type: 'string',
|
|
182
|
+
requiresArg: true,
|
|
183
|
+
})
|
|
184
|
+
.option('dest', {
|
|
185
|
+
describe: commands.cms.subcommands.theme.subcommands.preview.positionals.dest,
|
|
186
|
+
type: 'string',
|
|
187
|
+
requiresArg: true,
|
|
188
|
+
})
|
|
189
|
+
.option('notify', {
|
|
190
|
+
alias: 'n',
|
|
191
|
+
describe: commands.cms.subcommands.theme.subcommands.preview.options.notify,
|
|
192
|
+
type: 'string',
|
|
193
|
+
requiresArg: true,
|
|
194
|
+
})
|
|
195
|
+
.option('no-ssl', {
|
|
196
|
+
describe: commands.cms.subcommands.theme.subcommands.preview.options.noSsl,
|
|
197
|
+
type: 'boolean',
|
|
198
|
+
})
|
|
199
|
+
.option('port', {
|
|
200
|
+
describe: commands.cms.subcommands.theme.subcommands.preview.options.port,
|
|
201
|
+
type: 'number',
|
|
202
|
+
})
|
|
203
|
+
.option('resetSession', {
|
|
204
|
+
hidden: true,
|
|
205
|
+
type: 'boolean',
|
|
206
|
+
})
|
|
207
|
+
.option('generateFieldsTypes', {
|
|
208
|
+
hidden: true,
|
|
209
|
+
type: 'boolean',
|
|
210
|
+
});
|
|
211
|
+
return yargs;
|
|
212
|
+
}
|
|
213
|
+
const builder = makeYargsBuilder(themePreviewBuilder, command, describe, {
|
|
214
|
+
useGlobalOptions: true,
|
|
215
|
+
useConfigOptions: true,
|
|
216
|
+
useAccountOptions: true,
|
|
217
|
+
});
|
|
218
|
+
const themePreviewCommand = {
|
|
219
|
+
command,
|
|
220
|
+
describe,
|
|
221
|
+
handler,
|
|
222
|
+
builder,
|
|
223
|
+
};
|
|
224
|
+
export default themePreviewCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import marketplaceValidate from './theme/marketplace-validate.js';
|
|
2
|
+
import generateSelectors from './theme/generate-selectors.js';
|
|
3
|
+
import previewCommand from './theme/preview.js';
|
|
4
|
+
import createCommand from './theme/create.js';
|
|
5
|
+
import { commands } from '../../lang/en.js';
|
|
6
|
+
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
7
|
+
const command = ['theme', 'themes'];
|
|
8
|
+
const describe = commands.cms.subcommands.theme.describe;
|
|
9
|
+
function themeBuilder(yargs) {
|
|
10
|
+
yargs
|
|
11
|
+
.command(previewCommand)
|
|
12
|
+
.command(createCommand)
|
|
13
|
+
.command(marketplaceValidate)
|
|
14
|
+
.command(generateSelectors)
|
|
15
|
+
.demandCommand(1, '');
|
|
16
|
+
return yargs;
|
|
17
|
+
}
|
|
18
|
+
const builder = makeYargsBuilder(themeBuilder, command, describe);
|
|
19
|
+
const themeCommand = {
|
|
20
|
+
command,
|
|
21
|
+
describe,
|
|
22
|
+
builder,
|
|
23
|
+
handler: () => { },
|
|
24
|
+
};
|
|
25
|
+
export default themeCommand;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, CmsPublishModeArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
|
+
export type UploadArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & CmsPublishModeArgs & {
|
|
3
|
+
src?: string;
|
|
4
|
+
dest?: string;
|
|
5
|
+
fieldOptions?: string | string[];
|
|
6
|
+
saveOutput?: boolean;
|
|
7
|
+
convertFields?: boolean;
|
|
8
|
+
clean?: boolean;
|
|
9
|
+
force?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const uploadCommand: YargsCommandModule<unknown, UploadArgs>;
|
|
12
|
+
export default uploadCommand;
|