@hubspot/cli 7.5.3-experimental.0 → 7.5.3
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/api/migrate.d.ts +12 -3
- package/api/migrate.js +9 -2
- package/bin/cli.js +100 -93
- package/commands/account/auth.d.ts +8 -0
- package/commands/account/auth.js +175 -0
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +54 -14
- package/commands/account/createOverride.d.ts +6 -0
- package/commands/account/createOverride.js +121 -0
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +36 -5
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +38 -15
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +49 -9
- package/commands/account/removeOverride.d.ts +6 -0
- package/commands/account/removeOverride.js +93 -0
- package/commands/account/rename.d.ts +3 -7
- package/commands/account/rename.js +16 -9
- package/commands/account/use.d.ts +5 -9
- package/commands/account/use.js +27 -6
- package/commands/account.d.ts +3 -4
- package/commands/account.js +33 -53
- package/commands/app/migrate.d.ts +5 -6
- package/commands/app/migrate.js +60 -44
- package/commands/app/secret/add.d.ts +7 -0
- package/commands/app/secret/add.js +64 -0
- package/commands/app/secret/delete.d.ts +8 -0
- package/commands/app/secret/delete.js +87 -0
- package/commands/app/secret/list.d.ts +6 -0
- package/commands/app/secret/list.js +64 -0
- package/commands/app/secret/update.d.ts +7 -0
- package/commands/app/secret/update.js +77 -0
- package/commands/app/secret.d.ts +3 -0
- package/commands/app/secret.js +30 -0
- package/commands/app.d.ts +2 -5
- package/commands/app.js +10 -10
- package/commands/auth.d.ts +5 -7
- package/commands/auth.js +37 -33
- package/commands/cms/convertFields.d.ts +7 -1
- package/commands/cms/convertFields.js +57 -41
- package/commands/cms/getReactModule.d.ts +7 -1
- package/commands/cms/getReactModule.js +52 -34
- package/commands/cms/lighthouseScore.d.ts +8 -1
- package/commands/cms/lighthouseScore.js +129 -100
- package/commands/cms.d.ts +3 -1
- package/commands/cms.js +22 -16
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +23 -13
- package/commands/config/migrate.d.ts +6 -0
- package/commands/config/migrate.js +75 -0
- package/commands/config/set.d.ts +10 -1
- package/commands/config/set.js +56 -32
- package/commands/config.d.ts +3 -1
- package/commands/config.js +19 -11
- package/commands/create/api-sample.d.ts +3 -1
- package/commands/create/api-sample.js +34 -38
- package/commands/create/app.d.ts +3 -1
- package/commands/create/app.js +9 -7
- package/commands/create/function.d.ts +3 -1
- package/commands/create/function.js +11 -10
- package/commands/create/index.d.ts +5 -1
- package/commands/create/index.js +23 -11
- package/commands/create/module.d.ts +3 -1
- package/commands/create/module.js +14 -13
- package/commands/create/react-app.d.ts +3 -1
- package/commands/create/react-app.js +10 -7
- package/commands/create/template.d.ts +3 -1
- package/commands/create/template.js +14 -14
- package/commands/create/vue-app.d.ts +3 -1
- package/commands/create/vue-app.js +10 -7
- package/commands/create/webpack-serverless.d.ts +3 -1
- package/commands/create/webpack-serverless.js +10 -7
- package/commands/create/website-theme.d.ts +3 -1
- package/commands/create/website-theme.js +10 -9
- package/commands/create.d.ts +4 -24
- package/commands/create.js +62 -75
- package/commands/customObject/create.d.ts +4 -9
- package/commands/customObject/create.js +17 -10
- package/commands/customObject/schema/create.d.ts +4 -9
- package/commands/customObject/schema/create.js +18 -11
- package/commands/customObject/schema/delete.d.ts +4 -9
- package/commands/customObject/schema/delete.js +17 -10
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +17 -10
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +17 -10
- package/commands/customObject/schema/list.d.ts +4 -8
- package/commands/customObject/schema/list.js +17 -10
- package/commands/customObject/schema/update.d.ts +4 -9
- package/commands/customObject/schema/update.js +18 -11
- package/commands/customObject/schema.d.ts +3 -5
- package/commands/customObject/schema.js +27 -54
- package/commands/customObject.d.ts +3 -4
- package/commands/customObject.js +20 -48
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +30 -22
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +38 -48
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -34
- package/commands/filemanager/fetch.d.ts +4 -9
- package/commands/filemanager/fetch.js +18 -11
- package/commands/filemanager/upload.d.ts +4 -9
- package/commands/filemanager/upload.js +17 -11
- package/commands/filemanager.d.ts +3 -4
- package/commands/filemanager.js +18 -42
- package/commands/function/deploy.d.ts +6 -1
- package/commands/function/deploy.js +70 -50
- package/commands/function/list.d.ts +6 -1
- package/commands/function/list.js +44 -32
- package/commands/function/server.d.ts +10 -1
- package/commands/function/server.js +49 -38
- package/commands/function.d.ts +5 -1
- package/commands/function.js +22 -11
- package/commands/getStarted.d.ts +9 -0
- package/commands/getStarted.js +227 -0
- package/commands/hubdb/clear.d.ts +4 -9
- package/commands/hubdb/clear.js +21 -15
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +23 -17
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +24 -16
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +20 -14
- package/commands/hubdb/list.d.ts +4 -0
- package/commands/hubdb/list.js +83 -0
- package/commands/hubdb.d.ts +3 -2
- package/commands/hubdb.js +24 -47
- package/commands/init.d.ts +3 -7
- package/commands/init.js +31 -24
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +42 -44
- package/commands/list.d.ts +3 -7
- package/commands/list.js +21 -16
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -45
- package/commands/mcp/setup.d.ts +7 -0
- package/commands/mcp/setup.js +50 -0
- package/commands/mcp/start.d.ts +3 -0
- package/commands/mcp/start.js +75 -0
- package/commands/mcp.d.ts +3 -0
- package/commands/mcp.js +26 -0
- package/commands/module/marketplace-validate.d.ts +6 -1
- package/commands/module/marketplace-validate.js +39 -30
- package/commands/module.d.ts +3 -1
- package/commands/module.js +23 -12
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +20 -15
- package/commands/open.d.ts +3 -7
- package/commands/open.js +20 -15
- package/commands/project/add.d.ts +8 -9
- package/commands/project/add.js +53 -85
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +51 -47
- package/commands/project/create.d.ts +4 -1
- package/commands/project/create.js +132 -81
- package/commands/project/deploy.d.ts +5 -6
- package/commands/project/deploy.js +93 -37
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +41 -26
- package/commands/project/dev/index.d.ts +4 -5
- package/commands/project/dev/index.js +103 -33
- package/commands/project/dev/unifiedFlow.d.ts +11 -2
- package/commands/project/dev/unifiedFlow.js +85 -46
- package/commands/project/download.d.ts +3 -7
- package/commands/project/download.js +18 -19
- package/commands/project/installDeps.d.ts +6 -1
- package/commands/project/installDeps.js +48 -32
- package/commands/project/listBuilds.d.ts +3 -7
- package/commands/project/listBuilds.js +32 -30
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +7 -8
- package/commands/project/migrate.js +49 -26
- package/commands/project/migrateApp.d.ts +3 -8
- package/commands/project/migrateApp.js +23 -20
- package/commands/project/open.d.ts +3 -7
- package/commands/project/open.js +29 -21
- package/commands/project/profile/add.d.ts +7 -0
- package/commands/project/profile/add.js +209 -0
- package/commands/project/profile/delete.d.ts +6 -0
- package/commands/project/profile/delete.js +123 -0
- package/commands/project/profile.d.ts +3 -0
- package/commands/project/profile.js +25 -0
- package/commands/project/upload.d.ts +10 -1
- package/commands/project/upload.js +94 -56
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +81 -0
- package/commands/project/watch.d.ts +6 -1
- package/commands/project/watch.js +95 -61
- package/commands/project.d.ts +3 -1
- package/commands/project.js +49 -37
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +22 -20
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +27 -21
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +35 -29
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +18 -44
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +21 -15
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +28 -18
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +19 -13
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +25 -17
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +23 -49
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +20 -16
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +22 -18
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +36 -30
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +22 -48
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +116 -135
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +74 -76
- package/lang/en.d.ts +3218 -0
- package/lang/en.js +3075 -3313
- package/lang/en.lyaml +96 -228
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +11 -0
- package/lib/app/migrate.d.ts +33 -4
- package/lib/app/migrate.js +179 -88
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +12 -11
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +11 -10
- package/lib/commonOpts.d.ts +4 -7
- package/lib/commonOpts.js +47 -19
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +83 -0
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -45
- package/lib/constants.d.ts +33 -0
- package/lib/constants.js +34 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +14 -40
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +19 -16
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -9
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +60 -46
- package/lib/errorHandlers/index.js +13 -7
- package/lib/errorHandlers/suppressError.js +18 -26
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +3 -6
- package/lib/hasFeature.d.ts +3 -1
- package/lib/interpolation.d.ts +2 -3
- package/lib/lang.d.ts +2 -3
- package/lib/marketplaceValidate.d.ts +12 -2
- package/lib/marketplaceValidate.js +22 -29
- package/lib/mcp/setup.d.ts +12 -0
- package/lib/mcp/setup.js +216 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +3 -3
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +37 -3
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +125 -0
- package/lib/middleware/yargsChecksMiddleware.js +2 -2
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/oauth.js +1 -2
- package/lib/process.js +1 -2
- package/lib/projectProfiles.d.ts +7 -0
- package/lib/projectProfiles.js +83 -0
- package/lib/projects/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +16 -21
- package/lib/projects/add/legacyAddComponent.d.ts +5 -0
- package/lib/projects/add/legacyAddComponent.js +48 -0
- package/lib/projects/add/v3AddComponent.d.ts +8 -0
- package/lib/projects/add/v3AddComponent.js +85 -0
- package/lib/projects/buildAndDeploy.js +46 -42
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -0
- package/lib/projects/create/index.d.ts +23 -0
- package/lib/projects/create/index.js +33 -0
- package/lib/projects/create/legacy.d.ts +6 -0
- package/lib/projects/{create.js → create/legacy.js} +23 -15
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
- package/lib/projects/localDev/AppDevModeInterface.js +215 -0
- package/lib/{DevServerManager.d.ts → projects/localDev/DevServerManager.d.ts} +1 -1
- package/lib/{DevServerManager.js → projects/localDev/DevServerManager.js} +6 -6
- package/lib/projects/localDev/DevServerManagerV2.d.ts +22 -0
- package/lib/{DevServerManagerV2.js → projects/localDev/DevServerManagerV2.js} +22 -19
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +159 -0
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +57 -83
- package/lib/projects/localDev/LocalDevProcess.d.ts +34 -0
- package/lib/projects/localDev/LocalDevProcess.js +201 -0
- package/lib/projects/localDev/LocalDevState.d.ts +50 -0
- package/lib/projects/localDev/LocalDevState.js +119 -0
- package/lib/projects/localDev/LocalDevWatcher.d.ts +10 -0
- package/lib/projects/localDev/LocalDevWatcher.js +53 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +20 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +131 -0
- package/lib/{localDev.d.ts → projects/localDev/helpers.d.ts} +6 -4
- package/lib/{localDev.js → projects/localDev/helpers.js} +127 -114
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +17 -2
- package/lib/projects/upload.js +74 -50
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +23 -1
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +21 -18
- package/lib/prompts/accountNamePrompt.js +16 -13
- package/lib/prompts/accountsPrompt.js +1 -2
- package/lib/prompts/cmsFieldPrompt.js +1 -2
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createApiSamplePrompt.js +4 -5
- package/lib/prompts/createFunctionPrompt.js +13 -14
- package/lib/prompts/createModulePrompt.js +8 -9
- package/lib/prompts/createProjectPrompt.d.ts +20 -4
- package/lib/prompts/createProjectPrompt.js +43 -13
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/createTemplatePrompt.js +1 -2
- package/lib/prompts/downloadProjectPrompt.js +3 -4
- package/lib/prompts/installAppPrompt.d.ts +2 -0
- package/lib/prompts/installAppPrompt.js +45 -0
- package/lib/prompts/personalAccessKeyPrompt.js +35 -25
- package/lib/prompts/previewPrompt.js +5 -6
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -8
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +15 -16
- package/lib/prompts/projectNamePrompt.js +5 -6
- package/lib/prompts/projectsLogsPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +4 -2
- package/lib/prompts/promptUtils.js +3 -1
- package/lib/prompts/sandboxesPrompt.js +5 -6
- package/lib/prompts/secretPrompt.js +2 -3
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/selectHubDBTablePrompt.js +11 -8
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -9
- package/lib/prompts/setAsDefaultAccountPrompt.js +11 -2
- package/lib/prompts/uploadPrompt.js +4 -5
- package/lib/sandboxSync.js +15 -14
- package/lib/sandboxes.js +12 -13
- package/lib/serverlessLogs.js +4 -6
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/boxen.d.ts +5 -0
- package/lib/ui/boxen.js +30 -0
- package/lib/ui/git.js +8 -9
- package/lib/ui/index.d.ts +4 -2
- package/lib/ui/index.js +20 -17
- package/lib/ui/logger.d.ts +10 -0
- package/lib/ui/logger.js +15 -0
- package/lib/ui/serverlessFunctionLogs.js +2 -3
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +5 -1
- package/lib/yargsUtils.js +6 -0
- package/mcp-server/server.d.ts +1 -0
- package/mcp-server/server.js +18 -0
- package/mcp-server/tools/index.d.ts +2 -0
- package/mcp-server/tools/index.js +17 -0
- package/mcp-server/tools/project/AddFeatureToProject.d.ts +29 -0
- package/mcp-server/tools/project/AddFeatureToProject.js +85 -0
- package/mcp-server/tools/project/CreateProjectTool.d.ts +35 -0
- package/mcp-server/tools/project/CreateProjectTool.js +100 -0
- package/mcp-server/tools/project/DeployProject.d.ts +20 -0
- package/mcp-server/tools/project/DeployProject.js +50 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +17 -0
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +58 -0
- package/mcp-server/tools/project/UploadProjectTools.d.ts +17 -0
- package/mcp-server/tools/project/UploadProjectTools.js +35 -0
- package/mcp-server/tools/project/constants.d.ts +3 -0
- package/mcp-server/tools/project/constants.js +13 -0
- package/mcp-server/types.d.ts +14 -0
- package/mcp-server/types.js +17 -0
- package/mcp-server/utils/command.d.ts +3 -0
- package/mcp-server/utils/command.js +16 -0
- package/mcp-server/utils/content.d.ts +3 -0
- package/mcp-server/utils/content.js +21 -0
- package/mcp-server/utils/project.d.ts +5 -0
- package/mcp-server/utils/project.js +17 -0
- package/package.json +19 -11
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +35 -0
- package/types/LocalDev.js +2 -0
- package/types/Projects.d.ts +19 -2
- package/types/Prompts.d.ts +0 -7
- package/types/Yargs.d.ts +14 -14
- package/lib/DevServerManagerV2.d.ts +0 -33
- package/lib/LocalDevManagerV2.d.ts +0 -64
- package/lib/LocalDevManagerV2.js +0 -377
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/index.d.ts +0 -21
- package/lib/projects/index.js +0 -194
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -40
package/lib/generateSelectors.js
CHANGED
|
@@ -10,12 +10,11 @@ exports.setPreviewSelectors = setPreviewSelectors;
|
|
|
10
10
|
exports.generateInheritedSelectors = generateInheritedSelectors;
|
|
11
11
|
exports.generateSelectorsMap = generateSelectorsMap;
|
|
12
12
|
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
13
|
const exitCodes_1 = require("./enums/exitCodes");
|
|
15
|
-
const
|
|
14
|
+
const en_1 = require("../lang/en");
|
|
15
|
+
const logger_1 = require("./ui/logger");
|
|
16
16
|
const CSS_COMMENTS_REGEX = new RegExp(/\/\*.*\*\//, 'g');
|
|
17
17
|
const CSS_PSEUDO_CLASS_REGEX = new RegExp(/:active|:checked|:disabled|:empty|:enabled|:first-of-type|:focus|:hover|:in-range|:invalid|:link|:optional|:out-of-range|:read-only|:read-write|:required|:target|:valid|:visited/, 'g');
|
|
18
|
-
const i18nKey = 'commands.theme.subcommands.generateSelectors';
|
|
19
18
|
let maxFieldsDepth = 0;
|
|
20
19
|
function getMaxFieldsDepth() {
|
|
21
20
|
return maxFieldsDepth;
|
|
@@ -23,9 +22,7 @@ function getMaxFieldsDepth() {
|
|
|
23
22
|
function findFieldsJsonPath(basePath) {
|
|
24
23
|
const _path = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;
|
|
25
24
|
if (!fs_1.default.existsSync(_path)) {
|
|
26
|
-
logger_1.
|
|
27
|
-
themePath: basePath,
|
|
28
|
-
}));
|
|
25
|
+
logger_1.uiLogger.error(en_1.commands.theme.subcommands.generateSelectors.errors.invalidPath(basePath));
|
|
29
26
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
27
|
}
|
|
31
28
|
const files = fs_1.default.readdirSync(_path);
|
package/lib/hasFeature.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { FEATURES } from './constants';
|
|
2
|
+
import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
|
|
3
|
+
export declare function hasFeature(accountId: number, feature: ValueOf<typeof FEATURES>): Promise<boolean>;
|
package/lib/interpolation.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export declare const helpers: {
|
|
2
2
|
[key: string]: (stringValue: string) => string;
|
|
3
3
|
};
|
|
4
|
-
type InterpolationData = {
|
|
5
|
-
[identifier: string]: string | number;
|
|
4
|
+
export type InterpolationData = {
|
|
5
|
+
[identifier: string]: string | undefined | null | number | boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
|
|
8
|
-
export {};
|
package/lib/lang.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { InterpolationData } from './interpolation';
|
|
1
2
|
export declare const MISSING_LANGUAGE_DATA_PREFIX = "[Missing language data]";
|
|
2
3
|
type LanguageObject = {
|
|
3
4
|
[key: string]: string | LanguageObject;
|
|
4
5
|
};
|
|
5
|
-
export declare function i18n(lookupDotNotation: string, options?:
|
|
6
|
-
[identifier: string]: string | number;
|
|
7
|
-
}): string;
|
|
6
|
+
export declare function i18n(lookupDotNotation: string, options?: InterpolationData): string;
|
|
8
7
|
export declare function setLangData(newLocale: string, newLangObj: LanguageObject): void;
|
|
9
8
|
export {};
|
|
@@ -2,5 +2,15 @@ import { GetValidationResultsResponse } from '@hubspot/local-dev-lib/types/Marke
|
|
|
2
2
|
export declare function kickOffValidation(accountId: number, assetType: string, src: string): Promise<number>;
|
|
3
3
|
export declare function pollForValidationFinish(accountId: number, validationId: number): Promise<void>;
|
|
4
4
|
export declare function fetchValidationResults(accountId: number, validationId: number): Promise<GetValidationResultsResponse>;
|
|
5
|
-
export declare function processValidationErrors(
|
|
6
|
-
|
|
5
|
+
export declare function processValidationErrors(invalidPathError: (path: string) => string, validationResults: GetValidationResultsResponse): void;
|
|
6
|
+
type ResultsCopy = {
|
|
7
|
+
noErrors: string;
|
|
8
|
+
required: string;
|
|
9
|
+
recommended: string;
|
|
10
|
+
warnings: {
|
|
11
|
+
file: (file: string) => string;
|
|
12
|
+
lineNumber: (line: string) => string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function displayValidationResults(resultsCopy: ResultsCopy, validationResults: GetValidationResultsResponse): void;
|
|
16
|
+
export {};
|
|
@@ -10,8 +10,7 @@ exports.processValidationErrors = processValidationErrors;
|
|
|
10
10
|
exports.displayValidationResults = displayValidationResults;
|
|
11
11
|
const chalk_1 = __importDefault(require("chalk"));
|
|
12
12
|
const marketplaceValidation_1 = require("@hubspot/local-dev-lib/api/marketplaceValidation");
|
|
13
|
-
const logger_1 = require("
|
|
14
|
-
const lang_1 = require("./lang");
|
|
13
|
+
const logger_1 = require("./ui/logger");
|
|
15
14
|
const exitCodes_1 = require("./enums/exitCodes");
|
|
16
15
|
const SLEEP_TIME = 2000;
|
|
17
16
|
async function kickOffValidation(accountId, assetType, src) {
|
|
@@ -25,7 +24,7 @@ async function kickOffValidation(accountId, assetType, src) {
|
|
|
25
24
|
return requestResult;
|
|
26
25
|
}
|
|
27
26
|
catch (err) {
|
|
28
|
-
logger_1.
|
|
27
|
+
logger_1.uiLogger.debug(err);
|
|
29
28
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
@@ -43,7 +42,7 @@ async function pollForValidationFinish(accountId, validationId) {
|
|
|
43
42
|
await checkValidationStatus();
|
|
44
43
|
}
|
|
45
44
|
catch (err) {
|
|
46
|
-
logger_1.
|
|
45
|
+
logger_1.uiLogger.debug(err);
|
|
47
46
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -55,69 +54,63 @@ async function fetchValidationResults(accountId, validationId) {
|
|
|
55
54
|
return validationResults;
|
|
56
55
|
}
|
|
57
56
|
catch (err) {
|
|
58
|
-
logger_1.
|
|
57
|
+
logger_1.uiLogger.debug(err);
|
|
59
58
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
function processValidationErrors(
|
|
61
|
+
function processValidationErrors(invalidPathError, validationResults) {
|
|
63
62
|
if (validationResults.errors.length) {
|
|
64
63
|
const { assetPath, errors } = validationResults;
|
|
65
64
|
errors.forEach(err => {
|
|
66
65
|
if (err.failureReasonType === 'DOWNLOAD_EMPTY') {
|
|
67
|
-
logger_1.
|
|
68
|
-
path: assetPath,
|
|
69
|
-
}));
|
|
66
|
+
logger_1.uiLogger.error(invalidPathError(assetPath));
|
|
70
67
|
}
|
|
71
68
|
else {
|
|
72
|
-
logger_1.
|
|
69
|
+
logger_1.uiLogger.error(`${err.context}`);
|
|
73
70
|
}
|
|
74
71
|
});
|
|
75
72
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
function displayFileInfo(file, line,
|
|
75
|
+
function displayFileInfo(file, line, resultsCopy) {
|
|
79
76
|
if (file) {
|
|
80
|
-
logger_1.
|
|
81
|
-
file,
|
|
82
|
-
}));
|
|
77
|
+
logger_1.uiLogger.log(resultsCopy.warnings.file(file));
|
|
83
78
|
}
|
|
84
79
|
if (line) {
|
|
85
|
-
logger_1.
|
|
86
|
-
line,
|
|
87
|
-
}));
|
|
80
|
+
logger_1.uiLogger.log(resultsCopy.warnings.lineNumber(line.toString()));
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
|
-
function displayResults(checks,
|
|
83
|
+
function displayResults(checks, resultsCopy) {
|
|
91
84
|
if (checks) {
|
|
92
85
|
const { status, results } = checks;
|
|
93
86
|
if (status === 'FAIL') {
|
|
94
87
|
const failedValidations = results.filter(test => test.status === 'FAIL');
|
|
95
88
|
const warningValidations = results.filter(test => test.status === 'WARN');
|
|
96
89
|
failedValidations.forEach(val => {
|
|
97
|
-
logger_1.
|
|
98
|
-
displayFileInfo(val.file, val.line,
|
|
90
|
+
logger_1.uiLogger.error(`${val.message}`);
|
|
91
|
+
displayFileInfo(val.file, val.line, resultsCopy);
|
|
99
92
|
});
|
|
100
93
|
warningValidations.forEach(val => {
|
|
101
|
-
logger_1.
|
|
102
|
-
displayFileInfo(val.file, val.line,
|
|
94
|
+
logger_1.uiLogger.warn(`${val.message}`);
|
|
95
|
+
displayFileInfo(val.file, val.line, resultsCopy);
|
|
103
96
|
});
|
|
104
97
|
}
|
|
105
98
|
if (status === 'PASS') {
|
|
106
|
-
logger_1.
|
|
99
|
+
logger_1.uiLogger.success(resultsCopy.noErrors);
|
|
107
100
|
results.forEach(test => {
|
|
108
101
|
if (test.status === 'WARN') {
|
|
109
|
-
logger_1.
|
|
110
|
-
displayFileInfo(test.file, test.line,
|
|
102
|
+
logger_1.uiLogger.warn(`${test.message}`);
|
|
103
|
+
displayFileInfo(test.file, test.line, resultsCopy);
|
|
111
104
|
}
|
|
112
105
|
});
|
|
113
106
|
}
|
|
114
107
|
}
|
|
115
108
|
return;
|
|
116
109
|
}
|
|
117
|
-
function displayValidationResults(
|
|
110
|
+
function displayValidationResults(resultsCopy, validationResults) {
|
|
118
111
|
Object.keys(validationResults.results).forEach(type => {
|
|
119
|
-
logger_1.
|
|
120
|
-
displayResults(validationResults.results[type],
|
|
121
|
-
logger_1.
|
|
112
|
+
logger_1.uiLogger.log(chalk_1.default.bold(resultsCopy[type.toLowerCase()]));
|
|
113
|
+
displayResults(validationResults.results[type], resultsCopy);
|
|
114
|
+
logger_1.uiLogger.log('');
|
|
122
115
|
});
|
|
123
116
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const supportedTools: ({
|
|
2
|
+
name: "Claude Code";
|
|
3
|
+
value: string;
|
|
4
|
+
} | {
|
|
5
|
+
name: "Cursor";
|
|
6
|
+
value: string;
|
|
7
|
+
} | {
|
|
8
|
+
name: "Windsurf";
|
|
9
|
+
value: string;
|
|
10
|
+
})[];
|
|
11
|
+
export declare function addMintlifyMcpServer(installTargets: string[]): Promise<void>;
|
|
12
|
+
export declare function addMcpServerToConfig(targets: string[] | undefined): Promise<string[]>;
|
package/lib/mcp/setup.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.supportedTools = void 0;
|
|
7
|
+
exports.addMintlifyMcpServer = addMintlifyMcpServer;
|
|
8
|
+
exports.addMcpServerToConfig = addMcpServerToConfig;
|
|
9
|
+
const logger_1 = require("../ui/logger");
|
|
10
|
+
const en_1 = require("../../lang/en");
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
const promptUtils_1 = require("../prompts/promptUtils");
|
|
13
|
+
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
14
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const command_1 = require("../../mcp-server/utils/command");
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const os_1 = __importDefault(require("os"));
|
|
19
|
+
const mcpServerName = 'hubspot-cli-mcp';
|
|
20
|
+
const claudeCode = 'claude';
|
|
21
|
+
const windsurf = 'windsurf';
|
|
22
|
+
const cursor = 'cursor';
|
|
23
|
+
const supportedMintlifyClients = [windsurf, cursor];
|
|
24
|
+
exports.supportedTools = [
|
|
25
|
+
{ name: en_1.commands.mcp.setup.claudeCode, value: claudeCode },
|
|
26
|
+
{ name: en_1.commands.mcp.setup.cursor, value: cursor },
|
|
27
|
+
{ name: en_1.commands.mcp.setup.windsurf, value: windsurf },
|
|
28
|
+
];
|
|
29
|
+
const hsCommand = 'hs';
|
|
30
|
+
const mcpCommandArgs = ['mcp', 'start'];
|
|
31
|
+
async function addMintlifyMcpServer(installTargets) {
|
|
32
|
+
await runSetupFunction(() => setupMintlify(installTargets));
|
|
33
|
+
}
|
|
34
|
+
async function setupMintlify(derivedTargets) {
|
|
35
|
+
logger_1.uiLogger.info(en_1.commands.mcp.setup.installingDocSearch);
|
|
36
|
+
logger_1.uiLogger.log('');
|
|
37
|
+
return new Promise(resolve => {
|
|
38
|
+
const subcommands = ['mint-mcp', 'add', 'hubspot-migration'];
|
|
39
|
+
const docsSearchClients = derivedTargets.filter(target => supportedMintlifyClients.includes(target));
|
|
40
|
+
const childProcess = (0, child_process_1.spawn)(`npx`, docsSearchClients && docsSearchClients.length
|
|
41
|
+
? [...subcommands, '--client', ...docsSearchClients]
|
|
42
|
+
: subcommands, {
|
|
43
|
+
stdio: 'inherit',
|
|
44
|
+
});
|
|
45
|
+
childProcess.on('exit', code => {
|
|
46
|
+
if (code !== 0) {
|
|
47
|
+
resolve(false);
|
|
48
|
+
}
|
|
49
|
+
resolve(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async function addMcpServerToConfig(targets) {
|
|
54
|
+
try {
|
|
55
|
+
let derivedTargets = [];
|
|
56
|
+
if (!targets || targets.length === 0) {
|
|
57
|
+
const { selectedTargets } = await (0, promptUtils_1.promptUser)({
|
|
58
|
+
name: 'selectedTargets',
|
|
59
|
+
type: 'checkbox',
|
|
60
|
+
message: en_1.commands.mcp.setup.prompts.targets,
|
|
61
|
+
choices: exports.supportedTools,
|
|
62
|
+
validate: (choices) => {
|
|
63
|
+
return choices.length === 0
|
|
64
|
+
? en_1.commands.mcp.setup.prompts.targetsRequired
|
|
65
|
+
: true;
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
derivedTargets = selectedTargets;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
derivedTargets = targets;
|
|
72
|
+
}
|
|
73
|
+
SpinniesManager_1.default.init();
|
|
74
|
+
if (derivedTargets.includes(claudeCode)) {
|
|
75
|
+
await runSetupFunction(setupClaudeCode);
|
|
76
|
+
}
|
|
77
|
+
if (derivedTargets.includes(cursor)) {
|
|
78
|
+
await runSetupFunction(setupCursor);
|
|
79
|
+
}
|
|
80
|
+
if (derivedTargets.includes(windsurf)) {
|
|
81
|
+
await runSetupFunction(setupWindsurf);
|
|
82
|
+
}
|
|
83
|
+
logger_1.uiLogger.info(en_1.commands.mcp.setup.success(derivedTargets));
|
|
84
|
+
return derivedTargets;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
SpinniesManager_1.default.fail('mcpSetup', {
|
|
88
|
+
text: en_1.commands.mcp.setup.spinners.failedToConfigure,
|
|
89
|
+
});
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function runSetupFunction(func) {
|
|
94
|
+
const result = await func();
|
|
95
|
+
if (!result) {
|
|
96
|
+
throw new Error();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function setupMcpConfigFile(config) {
|
|
100
|
+
try {
|
|
101
|
+
SpinniesManager_1.default.add('spinner', {
|
|
102
|
+
text: config.configuringMessage,
|
|
103
|
+
});
|
|
104
|
+
if (!fs_1.default.existsSync(config.configPath)) {
|
|
105
|
+
SpinniesManager_1.default.fail('spinner', {
|
|
106
|
+
text: config.configMissingMessage,
|
|
107
|
+
});
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
let mcpConfig = {};
|
|
111
|
+
try {
|
|
112
|
+
const configContent = fs_1.default.readFileSync(config.configPath, 'utf8');
|
|
113
|
+
mcpConfig = JSON.parse(configContent);
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
SpinniesManager_1.default.fail('spinner', {
|
|
117
|
+
text: config.failedMessage,
|
|
118
|
+
});
|
|
119
|
+
(0, errorHandlers_1.logError)(error);
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
// Initialize mcpServers if it doesn't exist
|
|
123
|
+
if (!mcpConfig.mcpServers) {
|
|
124
|
+
mcpConfig.mcpServers = {};
|
|
125
|
+
}
|
|
126
|
+
// Add or update HubSpot CLI MCP server
|
|
127
|
+
mcpConfig.mcpServers[mcpServerName] = {
|
|
128
|
+
command: hsCommand,
|
|
129
|
+
args: mcpCommandArgs,
|
|
130
|
+
};
|
|
131
|
+
// Write the updated config
|
|
132
|
+
fs_1.default.writeFileSync(config.configPath, JSON.stringify(mcpConfig, null, 2));
|
|
133
|
+
SpinniesManager_1.default.succeed('spinner', {
|
|
134
|
+
text: config.configuredMessage,
|
|
135
|
+
});
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
SpinniesManager_1.default.fail('spinner', {
|
|
140
|
+
text: config.failedMessage,
|
|
141
|
+
});
|
|
142
|
+
(0, errorHandlers_1.logError)(error);
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async function setupClaudeCode() {
|
|
147
|
+
try {
|
|
148
|
+
SpinniesManager_1.default.add('claudeCode', {
|
|
149
|
+
text: en_1.commands.mcp.setup.spinners.configuringClaudeCode,
|
|
150
|
+
});
|
|
151
|
+
try {
|
|
152
|
+
// Check if claude command is available
|
|
153
|
+
await (0, command_1.execAsync)('claude --version');
|
|
154
|
+
// Run claude mcp add command
|
|
155
|
+
const mcpConfig = JSON.stringify({
|
|
156
|
+
type: 'stdio',
|
|
157
|
+
command: hsCommand,
|
|
158
|
+
args: mcpCommandArgs,
|
|
159
|
+
});
|
|
160
|
+
const { stdout } = await (0, command_1.execAsync)('claude mcp list');
|
|
161
|
+
if (stdout.includes(mcpServerName)) {
|
|
162
|
+
SpinniesManager_1.default.update('claudeCode', {
|
|
163
|
+
text: en_1.commands.mcp.setup.spinners.alreadyInstalled,
|
|
164
|
+
});
|
|
165
|
+
await (0, command_1.execAsync)(`claude mcp remove "${mcpServerName}" --scope user`);
|
|
166
|
+
}
|
|
167
|
+
await (0, command_1.execAsync)(`claude mcp add-json "${mcpServerName}" '${mcpConfig}' --scope user`);
|
|
168
|
+
SpinniesManager_1.default.succeed('claudeCode', {
|
|
169
|
+
text: en_1.commands.mcp.setup.spinners.configuredClaudeCode,
|
|
170
|
+
});
|
|
171
|
+
return true;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
if (error instanceof Error &&
|
|
175
|
+
error.message.includes('claude: command not found')) {
|
|
176
|
+
SpinniesManager_1.default.fail('claudeCode', {
|
|
177
|
+
text: en_1.commands.mcp.setup.spinners.claudeCodeNotFound,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
SpinniesManager_1.default.fail('claudeCode', {
|
|
182
|
+
text: en_1.commands.mcp.setup.spinners.claudeCodeInstallFailed,
|
|
183
|
+
});
|
|
184
|
+
(0, errorHandlers_1.logError)(error);
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
SpinniesManager_1.default.fail('claudeCode', {
|
|
191
|
+
text: en_1.commands.mcp.setup.spinners.claudeCodeInstallFailed,
|
|
192
|
+
});
|
|
193
|
+
(0, errorHandlers_1.logError)(error);
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function setupCursor() {
|
|
198
|
+
const cursorConfigPath = path_1.default.join(os_1.default.homedir(), '.cursor', 'mcp.json');
|
|
199
|
+
return setupMcpConfigFile({
|
|
200
|
+
configPath: cursorConfigPath,
|
|
201
|
+
configuringMessage: en_1.commands.mcp.setup.spinners.configuringCursor,
|
|
202
|
+
configuredMessage: en_1.commands.mcp.setup.spinners.configuredCursor,
|
|
203
|
+
failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureCursor,
|
|
204
|
+
configMissingMessage: en_1.commands.mcp.setup.spinners.noCursorMcpFile(cursorConfigPath),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function setupWindsurf() {
|
|
208
|
+
const windsurfConfigPath = path_1.default.join(os_1.default.homedir(), '.codeium', 'windsurf', 'mcp_config.json');
|
|
209
|
+
return setupMcpConfigFile({
|
|
210
|
+
configPath: windsurfConfigPath,
|
|
211
|
+
configuringMessage: en_1.commands.mcp.setup.spinners.configuringWindsurf,
|
|
212
|
+
configuredMessage: en_1.commands.mcp.setup.spinners.configuredWindsurf,
|
|
213
|
+
failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureWindsurf,
|
|
214
|
+
configMissingMessage: en_1.commands.mcp.setup.spinners.noWindsurfFile(windsurfConfigPath),
|
|
215
|
+
});
|
|
216
|
+
}
|
|
@@ -35,18 +35,18 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
37
37
|
const exitCodes_1 = require("../../enums/exitCodes");
|
|
38
|
-
const
|
|
38
|
+
const projectsConfig = __importStar(require("../../projects/config"));
|
|
39
39
|
const yargsChecksMiddleware_1 = require("../yargsChecksMiddleware");
|
|
40
40
|
jest.mock('@hubspot/local-dev-lib/logger', () => ({
|
|
41
41
|
logger: {
|
|
42
42
|
error: jest.fn(),
|
|
43
43
|
},
|
|
44
44
|
}));
|
|
45
|
-
jest.mock('../../projects');
|
|
45
|
+
jest.mock('../../projects/config');
|
|
46
46
|
jest.mock('../../lang', () => ({
|
|
47
47
|
i18n: jest.fn(key => key),
|
|
48
48
|
}));
|
|
49
|
-
const getIsInProjectSpy = jest.spyOn(
|
|
49
|
+
const getIsInProjectSpy = jest.spyOn(projectsConfig, 'getIsInProject');
|
|
50
50
|
const processExitSpy = jest.spyOn(process, 'exit');
|
|
51
51
|
describe('lib/middleware/yargsChecksMiddleware', () => {
|
|
52
52
|
beforeEach(() => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function autoUpdateCLI(): Promise<void>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.autoUpdateCLI = autoUpdateCLI;
|
|
7
|
+
// Update-notifier is CommonJS, so we need to use require
|
|
8
|
+
const updateNotifier = require('update-notifier');
|
|
9
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
10
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
+
const ui_1 = require("../ui");
|
|
12
|
+
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
13
|
+
const en_1 = require("../../lang/en");
|
|
14
|
+
const npm_1 = require("../npm");
|
|
15
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
16
|
+
const logger_1 = require("../ui/logger");
|
|
17
|
+
// Default behavior is to check for notifications at most once per day
|
|
18
|
+
// update-notifier stores the last checked date in the user's home directory
|
|
19
|
+
const notifier = updateNotifier({
|
|
20
|
+
pkg: { ...package_json_1.default, name: '@hubspot/cli' },
|
|
21
|
+
distTag: 'latest',
|
|
22
|
+
shouldNotifyInNpmScript: true,
|
|
23
|
+
});
|
|
24
|
+
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
25
|
+
function updateNotification() {
|
|
26
|
+
notifier.notify({
|
|
27
|
+
message: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
|
|
28
|
+
? en_1.lib.middleware.updateNotification.cmsUpdateNotification(CMS_CLI_PACKAGE_NAME)
|
|
29
|
+
: en_1.lib.middleware.updateNotification.cliUpdateNotification,
|
|
30
|
+
defer: false,
|
|
31
|
+
boxenOptions: {
|
|
32
|
+
borderColor: ui_1.UI_COLORS.MARIGOLD_DARK,
|
|
33
|
+
margin: 1,
|
|
34
|
+
padding: 1,
|
|
35
|
+
textAlignment: 'center',
|
|
36
|
+
borderStyle: 'round',
|
|
37
|
+
title: package_json_1.default.name === CMS_CLI_PACKAGE_NAME
|
|
38
|
+
? null
|
|
39
|
+
: en_1.lib.middleware.updateNotification.notifyTitle,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function autoUpdateCLI() {
|
|
44
|
+
// This lets us back to default update-notifier behavior
|
|
45
|
+
let showManualInstallHelp = true;
|
|
46
|
+
if (notifier &&
|
|
47
|
+
notifier.update &&
|
|
48
|
+
!process.env.SKIP_HUBSPOT_CLI_AUTO_UPDATES &&
|
|
49
|
+
(0, config_1.isConfigFlagEnabled)('allowAutoUpdates')) {
|
|
50
|
+
// Ignore all update notifications if the current version is a pre-release
|
|
51
|
+
if (!notifier.update.current.includes('-')) {
|
|
52
|
+
// Attempt auto-update if the current version is not the latest version
|
|
53
|
+
// Never auto-update for major version updates b/c they are breaking
|
|
54
|
+
if (!['major', 'latest'].includes(notifier.update.type)) {
|
|
55
|
+
SpinniesManager_1.default.init({
|
|
56
|
+
succeedColor: 'white',
|
|
57
|
+
});
|
|
58
|
+
SpinniesManager_1.default.add('cliAutoUpdate', {
|
|
59
|
+
text: en_1.lib.middleware.autoUpdateCLI.updateAvailable(notifier.update.latest),
|
|
60
|
+
});
|
|
61
|
+
try {
|
|
62
|
+
if ((await (0, npm_1.isGloballyInstalled)(npm_1.DEFAULT_PACKAGE_MANAGER)) &&
|
|
63
|
+
(await (0, npm_1.isGloballyInstalled)('hs'))) {
|
|
64
|
+
await (0, npm_1.executeInstall)(['@hubspot/cli@latest'], '-g');
|
|
65
|
+
showManualInstallHelp = false;
|
|
66
|
+
SpinniesManager_1.default.succeed('cliAutoUpdate', {
|
|
67
|
+
text: en_1.lib.middleware.autoUpdateCLI.updateSucceeded(notifier.update.latest),
|
|
68
|
+
});
|
|
69
|
+
logger_1.uiLogger.log('');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
SpinniesManager_1.default.fail('cliAutoUpdate', {
|
|
73
|
+
text: en_1.lib.middleware.autoUpdateCLI.notInstalledGlobally,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
(0, errorHandlers_1.debugError)(e);
|
|
79
|
+
SpinniesManager_1.default.fail('cliAutoUpdate', {
|
|
80
|
+
text: en_1.lib.middleware.autoUpdateCLI.updateFailed(notifier.update.latest),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (showManualInstallHelp) {
|
|
87
|
+
updateNotification();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -40,10 +40,17 @@ async function injectAccountIdMiddleware(argv) {
|
|
|
40
40
|
const SKIP_CONFIG_VALIDATION = {
|
|
41
41
|
init: { target: true },
|
|
42
42
|
auth: { target: true },
|
|
43
|
+
mcp: {
|
|
44
|
+
target: false,
|
|
45
|
+
subCommands: {
|
|
46
|
+
setup: { target: true },
|
|
47
|
+
start: { target: true },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
43
50
|
};
|
|
44
51
|
async function loadConfigMiddleware(argv) {
|
|
45
52
|
// Skip this when no command is provided
|
|
46
|
-
if (!argv._.length) {
|
|
53
|
+
if (!argv._.length || argv.help) {
|
|
47
54
|
return;
|
|
48
55
|
}
|
|
49
56
|
const maybeValidateConfig = () => {
|
|
@@ -52,7 +59,18 @@ async function loadConfigMiddleware(argv) {
|
|
|
52
59
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
60
|
}
|
|
54
61
|
};
|
|
55
|
-
if ((0, config_1.configFileExists)(true) &&
|
|
62
|
+
if (!(0, config_1.configFileExists)(true) &&
|
|
63
|
+
(0, utils_1.isTargetedCommand)(argv._, {
|
|
64
|
+
account: { target: false, subCommands: { auth: { target: true } } },
|
|
65
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
66
|
+
})) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if ((0, config_1.configFileExists)(true) &&
|
|
70
|
+
argv.config &&
|
|
71
|
+
!(0, utils_1.isTargetedCommand)(argv._, {
|
|
72
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
73
|
+
})) {
|
|
56
74
|
logger_1.logger.error((0, lang_1.i18n)(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
57
75
|
configPath: (0, config_1.getConfigPath)(),
|
|
58
76
|
}));
|
|
@@ -71,10 +89,12 @@ async function loadConfigMiddleware(argv) {
|
|
|
71
89
|
const accountsSubCommands = {
|
|
72
90
|
target: false,
|
|
73
91
|
subCommands: {
|
|
92
|
+
auth: { target: true },
|
|
74
93
|
clean: { target: true },
|
|
75
94
|
list: { target: true },
|
|
76
95
|
ls: { target: true },
|
|
77
96
|
remove: { target: true },
|
|
97
|
+
use: { target: true },
|
|
78
98
|
},
|
|
79
99
|
};
|
|
80
100
|
const sandboxesSubCommands = {
|
|
@@ -83,17 +103,31 @@ const sandboxesSubCommands = {
|
|
|
83
103
|
delete: { target: true },
|
|
84
104
|
},
|
|
85
105
|
};
|
|
106
|
+
const configSubCommands = {
|
|
107
|
+
target: false,
|
|
108
|
+
subCommands: {
|
|
109
|
+
migrate: { target: true },
|
|
110
|
+
},
|
|
111
|
+
};
|
|
86
112
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
87
113
|
init: { target: true },
|
|
88
114
|
auth: { target: true },
|
|
115
|
+
mcp: {
|
|
116
|
+
target: false,
|
|
117
|
+
subCommands: {
|
|
118
|
+
setup: { target: true },
|
|
119
|
+
start: { target: true },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
89
122
|
account: accountsSubCommands,
|
|
90
123
|
accounts: accountsSubCommands,
|
|
91
124
|
sandbox: sandboxesSubCommands,
|
|
92
125
|
sandboxes: sandboxesSubCommands,
|
|
126
|
+
config: configSubCommands,
|
|
93
127
|
};
|
|
94
128
|
async function validateAccountOptions(argv) {
|
|
95
129
|
// Skip this when no command is provided
|
|
96
|
-
if (argv._.length) {
|
|
130
|
+
if (argv._.length && !argv.help) {
|
|
97
131
|
let validAccount = true;
|
|
98
132
|
if (!(0, utils_1.isTargetedCommand)(argv._, SKIP_ACCOUNT_VALIDATION)) {
|
|
99
133
|
validAccount = await (0, validation_1.validateAccount)(argv);
|