@hubspot/cli 7.5.11-experimental.0 → 7.6.0-beta.1
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 +102 -95
- package/commands/account/auth.d.ts +5 -7
- package/commands/account/auth.js +74 -87
- package/commands/account/clean.d.ts +3 -7
- package/commands/account/clean.js +16 -9
- package/commands/account/createOverride.d.ts +3 -7
- package/commands/account/createOverride.js +23 -6
- package/commands/account/info.d.ts +3 -7
- package/commands/account/info.js +13 -5
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +15 -8
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +21 -9
- package/commands/account/removeOverride.d.ts +3 -7
- package/commands/account/removeOverride.js +23 -6
- 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 +14 -6
- package/commands/account.d.ts +3 -4
- package/commands/account.js +33 -58
- package/commands/app/migrate.d.ts +1 -2
- package/commands/app/migrate.js +7 -8
- 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 -8
- package/commands/auth.d.ts +5 -7
- package/commands/auth.js +29 -28
- 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 -15
- package/commands/completion.d.ts +3 -1
- package/commands/completion.js +23 -12
- package/commands/config/migrate.d.ts +3 -7
- package/commands/config/migrate.js +37 -46
- package/commands/config/set.d.ts +5 -6
- package/commands/config/set.js +38 -14
- package/commands/config.d.ts +3 -4
- package/commands/config.js +18 -44
- 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 -74
- 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 +18 -45
- package/commands/doctor.d.ts +6 -8
- package/commands/doctor.js +30 -21
- package/commands/feedback.d.ts +4 -1
- package/commands/feedback.js +38 -47
- package/commands/fetch.d.ts +12 -1
- package/commands/fetch.js +49 -33
- 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 -41
- 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 -10
- 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 +17 -10
- package/commands/hubdb/create.d.ts +4 -9
- package/commands/hubdb/create.js +17 -10
- package/commands/hubdb/delete.d.ts +4 -9
- package/commands/hubdb/delete.js +17 -10
- package/commands/hubdb/fetch.d.ts +4 -9
- package/commands/hubdb/fetch.js +17 -10
- 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 +23 -45
- package/commands/init.d.ts +3 -7
- package/commands/init.js +17 -8
- package/commands/lint.d.ts +6 -4
- package/commands/lint.js +42 -43
- package/commands/list.d.ts +3 -7
- package/commands/list.js +17 -11
- package/commands/logs.d.ts +10 -1
- package/commands/logs.js +53 -44
- package/commands/mcp/setup.d.ts +7 -0
- package/commands/mcp/setup.js +52 -0
- package/commands/mcp/start.d.ts +3 -0
- package/commands/mcp/start.js +77 -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 -29
- package/commands/module.d.ts +3 -1
- package/commands/module.js +23 -10
- package/commands/mv.d.ts +3 -7
- package/commands/mv.js +17 -11
- package/commands/open.d.ts +3 -7
- package/commands/open.js +17 -11
- package/commands/project/add.d.ts +5 -2
- package/commands/project/add.js +43 -80
- package/commands/project/cloneApp.d.ts +1 -1
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/create.d.ts +2 -8
- package/commands/project/create.js +84 -55
- package/commands/project/deploy.d.ts +2 -0
- package/commands/project/deploy.js +67 -13
- package/commands/project/dev/deprecatedFlow.d.ts +8 -2
- package/commands/project/dev/deprecatedFlow.js +9 -1
- package/commands/project/dev/index.d.ts +1 -4
- package/commands/project/dev/index.js +88 -31
- package/commands/project/dev/unifiedFlow.d.ts +11 -2
- package/commands/project/dev/unifiedFlow.js +81 -41
- package/commands/project/listBuilds.js +2 -5
- package/commands/project/migrate.d.ts +1 -0
- 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 +1 -0
- package/commands/project/upload.js +22 -8
- package/commands/project/validate.d.ts +6 -0
- package/commands/project/validate.js +82 -0
- package/commands/project.js +4 -2
- package/commands/remove.d.ts +3 -7
- package/commands/remove.js +22 -22
- package/commands/sandbox/create.d.ts +4 -9
- package/commands/sandbox/create.js +18 -11
- package/commands/sandbox/delete.d.ts +4 -9
- package/commands/sandbox/delete.js +18 -11
- package/commands/sandbox.d.ts +3 -4
- package/commands/sandbox.js +18 -43
- package/commands/secret/addSecret.d.ts +4 -9
- package/commands/secret/addSecret.js +17 -10
- package/commands/secret/deleteSecret.d.ts +4 -9
- package/commands/secret/deleteSecret.js +17 -10
- package/commands/secret/listSecret.d.ts +4 -9
- package/commands/secret/listSecret.js +17 -10
- package/commands/secret/updateSecret.d.ts +4 -9
- package/commands/secret/updateSecret.js +17 -10
- package/commands/secret.d.ts +3 -4
- package/commands/secret.js +23 -48
- package/commands/testAccount/create.d.ts +6 -0
- package/commands/testAccount/create.js +100 -0
- package/commands/testAccount/createConfig.d.ts +10 -0
- package/commands/testAccount/createConfig.js +98 -0
- package/commands/testAccount/delete.d.ts +6 -0
- package/commands/testAccount/delete.js +48 -0
- package/commands/testAccount.d.ts +3 -0
- package/commands/testAccount.js +28 -0
- package/commands/theme/generate-selectors.d.ts +3 -7
- package/commands/theme/generate-selectors.js +20 -15
- package/commands/theme/marketplace-validate.d.ts +4 -9
- package/commands/theme/marketplace-validate.js +22 -17
- package/commands/theme/preview.d.ts +4 -9
- package/commands/theme/preview.js +32 -26
- package/commands/theme.d.ts +3 -4
- package/commands/theme.js +22 -47
- package/commands/upload.d.ts +12 -1
- package/commands/upload.js +116 -134
- package/commands/watch.d.ts +14 -1
- package/commands/watch.js +74 -75
- package/lang/en.d.ts +1135 -660
- package/lang/en.js +935 -471
- package/lang/en.lyaml +30 -213
- package/lib/accountTypes.js +1 -2
- package/lib/app/migrate.d.ts +23 -0
- package/lib/app/migrate.js +29 -6
- package/lib/app/migrate_legacy.js +7 -7
- package/lib/app/urls.d.ts +16 -0
- package/lib/app/urls.js +16 -0
- package/lib/commonOpts.d.ts +1 -3
- package/lib/commonOpts.js +1 -1
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +34 -55
- package/lib/configOptions.d.ts +4 -0
- package/lib/configOptions.js +41 -46
- package/lib/constants.d.ts +29 -0
- package/lib/constants.js +30 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +13 -39
- package/lib/doctor/Doctor.js +3 -2
- package/lib/errorHandlers/index.js +7 -0
- package/lib/filesystem.d.ts +1 -1
- package/lib/generateSelectors.js +3 -5
- 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 +21 -0
- package/lib/mcp/setup.js +218 -0
- package/lib/middleware/autoUpdateMiddleware.d.ts +1 -0
- package/lib/middleware/autoUpdateMiddleware.js +89 -0
- package/lib/middleware/configMiddleware.js +23 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +2 -2
- package/lib/middleware/fireAlarmMiddleware.js +5 -3
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/projectProfiles.d.ts +7 -0
- package/lib/projectProfiles.js +83 -0
- 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 +18 -3
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -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} +20 -11
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +30 -0
- package/lib/projects/localDev/AppDevModeInterface.js +215 -0
- package/lib/projects/localDev/DevServerManagerV2.d.ts +11 -22
- package/lib/projects/localDev/DevServerManagerV2.js +19 -15
- package/lib/projects/localDev/LocalDevLogger.d.ts +30 -0
- package/lib/projects/localDev/LocalDevLogger.js +159 -0
- package/lib/projects/localDev/LocalDevManager.js +12 -5
- 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/projects/localDev/helpers.d.ts +3 -2
- package/lib/projects/localDev/helpers.js +32 -2
- package/lib/projects/upload.d.ts +5 -1
- package/lib/projects/upload.js +60 -20
- package/lib/projects/urls.d.ts +3 -0
- package/lib/projects/urls.js +17 -1
- package/lib/prompts/createApiSamplePrompt.d.ts +2 -10
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +17 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +96 -0
- package/lib/prompts/createProjectPrompt.d.ts +14 -5
- package/lib/prompts/createProjectPrompt.js +38 -13
- package/lib/prompts/createTemplatePrompt.d.ts +22 -4
- package/lib/prompts/installAppPrompt.d.ts +2 -0
- package/lib/prompts/installAppPrompt.js +45 -0
- package/lib/prompts/personalAccessKeyPrompt.js +35 -24
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -7
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +6 -6
- package/lib/prompts/promptUtils.d.ts +4 -1
- package/lib/prompts/promptUtils.js +5 -1
- package/lib/prompts/selectAppPrompt.d.ts +2 -0
- package/lib/prompts/selectAppPrompt.js +40 -0
- package/lib/prompts/{selectPublicAppPrompt.d.ts → selectPublicAppForMigrationPrompt.d.ts} +1 -1
- package/lib/prompts/{selectPublicAppPrompt.js → selectPublicAppForMigrationPrompt.js} +8 -8
- package/lib/prompts/setAsDefaultAccountPrompt.js +10 -0
- package/lib/testUtils.d.ts +3 -3
- package/lib/testUtils.js +8 -9
- package/lib/ui/index.js +4 -1
- package/lib/upload.d.ts +1 -1
- package/lib/validation.js +4 -5
- package/lib/yargsUtils.d.ts +4 -0
- 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 +19 -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 +104 -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/ValidateProjectTool.d.ts +17 -0
- package/mcp-server/tools/project/ValidateProjectTool.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 +24 -16
- 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 +10 -1
- package/lib/projects/create.d.ts +0 -5
- package/lib/projects/localDev/LocalDevManagerV2.d.ts +0 -64
- package/lib/projects/localDev/LocalDevManagerV2.js +0 -345
- package/lib/prompts/installPublicAppPrompt.d.ts +0 -1
- package/lib/prompts/installPublicAppPrompt.js +0 -41
|
@@ -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,21 @@
|
|
|
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
|
+
interface McpCommand {
|
|
12
|
+
command: string;
|
|
13
|
+
args: string[];
|
|
14
|
+
}
|
|
15
|
+
export declare function addMintlifyMcpServer(installTargets: string[]): Promise<void>;
|
|
16
|
+
export declare function setupMintlify(derivedTargets?: string[]): Promise<boolean>;
|
|
17
|
+
export declare function addMcpServerToConfig(targets: string[] | undefined): Promise<string[]>;
|
|
18
|
+
export declare function setupClaudeCode(mcpCommand?: McpCommand): Promise<boolean>;
|
|
19
|
+
export declare function setupCursor(mcpCommand?: McpCommand): boolean;
|
|
20
|
+
export declare function setupWindsurf(mcpCommand?: McpCommand): boolean;
|
|
21
|
+
export {};
|
package/lib/mcp/setup.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
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.setupMintlify = setupMintlify;
|
|
9
|
+
exports.addMcpServerToConfig = addMcpServerToConfig;
|
|
10
|
+
exports.setupClaudeCode = setupClaudeCode;
|
|
11
|
+
exports.setupCursor = setupCursor;
|
|
12
|
+
exports.setupWindsurf = setupWindsurf;
|
|
13
|
+
const logger_1 = require("../ui/logger");
|
|
14
|
+
const en_1 = require("../../lang/en");
|
|
15
|
+
const promptUtils_1 = require("../prompts/promptUtils");
|
|
16
|
+
const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
|
|
17
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
18
|
+
const command_1 = require("../../mcp-server/utils/command");
|
|
19
|
+
const child_process_1 = require("child_process");
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const os_1 = __importDefault(require("os"));
|
|
22
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
23
|
+
const fs_1 = require("fs");
|
|
24
|
+
const mcpServerName = 'hubspot-cli-mcp';
|
|
25
|
+
const claudeCode = 'claude';
|
|
26
|
+
const windsurf = 'windsurf';
|
|
27
|
+
const cursor = 'cursor';
|
|
28
|
+
const supportedMintlifyClients = [windsurf, cursor];
|
|
29
|
+
exports.supportedTools = [
|
|
30
|
+
{ name: en_1.commands.mcp.setup.claudeCode, value: claudeCode },
|
|
31
|
+
{ name: en_1.commands.mcp.setup.cursor, value: cursor },
|
|
32
|
+
{ name: en_1.commands.mcp.setup.windsurf, value: windsurf },
|
|
33
|
+
];
|
|
34
|
+
const defaultMcpCommand = {
|
|
35
|
+
command: 'hs',
|
|
36
|
+
args: ['mcp', 'start'],
|
|
37
|
+
};
|
|
38
|
+
async function addMintlifyMcpServer(installTargets) {
|
|
39
|
+
await runSetupFunction(() => setupMintlify(installTargets));
|
|
40
|
+
}
|
|
41
|
+
async function setupMintlify(derivedTargets = supportedMintlifyClients) {
|
|
42
|
+
logger_1.uiLogger.info(en_1.commands.mcp.setup.installingDocSearch);
|
|
43
|
+
logger_1.uiLogger.log('');
|
|
44
|
+
return new Promise(resolve => {
|
|
45
|
+
const subcommands = ['mint-mcp', 'add', 'hubspot-migration'];
|
|
46
|
+
const docsSearchClients = derivedTargets.filter(target => supportedMintlifyClients.includes(target));
|
|
47
|
+
const childProcess = (0, child_process_1.spawn)(`npx`, docsSearchClients && docsSearchClients.length
|
|
48
|
+
? [...subcommands, '--client', ...docsSearchClients]
|
|
49
|
+
: subcommands, {
|
|
50
|
+
stdio: 'inherit',
|
|
51
|
+
});
|
|
52
|
+
childProcess.on('exit', code => {
|
|
53
|
+
if (code !== 0) {
|
|
54
|
+
resolve(false);
|
|
55
|
+
}
|
|
56
|
+
resolve(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async function addMcpServerToConfig(targets) {
|
|
61
|
+
try {
|
|
62
|
+
let derivedTargets = [];
|
|
63
|
+
if (!targets || targets.length === 0) {
|
|
64
|
+
const { selectedTargets } = await (0, promptUtils_1.promptUser)({
|
|
65
|
+
name: 'selectedTargets',
|
|
66
|
+
type: 'checkbox',
|
|
67
|
+
message: en_1.commands.mcp.setup.prompts.targets,
|
|
68
|
+
choices: exports.supportedTools,
|
|
69
|
+
validate: (choices) => {
|
|
70
|
+
return choices.length === 0
|
|
71
|
+
? en_1.commands.mcp.setup.prompts.targetsRequired
|
|
72
|
+
: true;
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
derivedTargets = selectedTargets;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
derivedTargets = targets;
|
|
79
|
+
}
|
|
80
|
+
SpinniesManager_1.default.init();
|
|
81
|
+
if (derivedTargets.includes(claudeCode)) {
|
|
82
|
+
await runSetupFunction(setupClaudeCode);
|
|
83
|
+
}
|
|
84
|
+
if (derivedTargets.includes(cursor)) {
|
|
85
|
+
await runSetupFunction(setupCursor);
|
|
86
|
+
}
|
|
87
|
+
if (derivedTargets.includes(windsurf)) {
|
|
88
|
+
await runSetupFunction(setupWindsurf);
|
|
89
|
+
}
|
|
90
|
+
logger_1.uiLogger.info(en_1.commands.mcp.setup.success(derivedTargets));
|
|
91
|
+
return derivedTargets;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
SpinniesManager_1.default.fail('mcpSetup', {
|
|
95
|
+
text: en_1.commands.mcp.setup.spinners.failedToConfigure,
|
|
96
|
+
});
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function runSetupFunction(func) {
|
|
101
|
+
const result = await func();
|
|
102
|
+
if (!result) {
|
|
103
|
+
throw new Error();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function setupMcpConfigFile(config) {
|
|
107
|
+
try {
|
|
108
|
+
SpinniesManager_1.default.add('spinner', {
|
|
109
|
+
text: config.configuringMessage,
|
|
110
|
+
});
|
|
111
|
+
if (!(0, fs_1.existsSync)(config.configPath)) {
|
|
112
|
+
fs_extra_1.default.writeFileSync(config.configPath, JSON.stringify({}, null, 2));
|
|
113
|
+
}
|
|
114
|
+
let mcpConfig = {};
|
|
115
|
+
try {
|
|
116
|
+
const configContent = fs_extra_1.default.readFileSync(config.configPath, 'utf8');
|
|
117
|
+
mcpConfig = JSON.parse(configContent);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
SpinniesManager_1.default.fail('spinner', {
|
|
121
|
+
text: config.failedMessage,
|
|
122
|
+
});
|
|
123
|
+
(0, errorHandlers_1.logError)(error);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
// Initialize mcpServers if it doesn't exist
|
|
127
|
+
if (!mcpConfig.mcpServers) {
|
|
128
|
+
mcpConfig.mcpServers = {};
|
|
129
|
+
}
|
|
130
|
+
// Add or update HubSpot CLI MCP server
|
|
131
|
+
mcpConfig.mcpServers[mcpServerName] = {
|
|
132
|
+
...config.mcpCommand,
|
|
133
|
+
};
|
|
134
|
+
// Write the updated config
|
|
135
|
+
fs_extra_1.default.writeFileSync(config.configPath, JSON.stringify(mcpConfig, null, 2));
|
|
136
|
+
SpinniesManager_1.default.succeed('spinner', {
|
|
137
|
+
text: config.configuredMessage,
|
|
138
|
+
});
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
SpinniesManager_1.default.fail('spinner', {
|
|
143
|
+
text: config.failedMessage,
|
|
144
|
+
});
|
|
145
|
+
(0, errorHandlers_1.logError)(error);
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function setupClaudeCode(mcpCommand = defaultMcpCommand) {
|
|
150
|
+
try {
|
|
151
|
+
SpinniesManager_1.default.add('claudeCode', {
|
|
152
|
+
text: en_1.commands.mcp.setup.spinners.configuringClaudeCode,
|
|
153
|
+
});
|
|
154
|
+
try {
|
|
155
|
+
// Check if claude command is available
|
|
156
|
+
await (0, command_1.execAsync)('claude --version');
|
|
157
|
+
// Run claude mcp add command
|
|
158
|
+
const mcpConfig = JSON.stringify({
|
|
159
|
+
type: 'stdio',
|
|
160
|
+
...mcpCommand,
|
|
161
|
+
});
|
|
162
|
+
const { stdout } = await (0, command_1.execAsync)('claude mcp list');
|
|
163
|
+
if (stdout.includes(mcpServerName)) {
|
|
164
|
+
SpinniesManager_1.default.update('claudeCode', {
|
|
165
|
+
text: en_1.commands.mcp.setup.spinners.alreadyInstalled,
|
|
166
|
+
});
|
|
167
|
+
await (0, command_1.execAsync)(`claude mcp remove "${mcpServerName}" --scope user`);
|
|
168
|
+
}
|
|
169
|
+
await (0, command_1.execAsync)(`claude mcp add-json "${mcpServerName}" '${mcpConfig}' --scope user`);
|
|
170
|
+
SpinniesManager_1.default.succeed('claudeCode', {
|
|
171
|
+
text: en_1.commands.mcp.setup.spinners.configuredClaudeCode,
|
|
172
|
+
});
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
if (error instanceof Error &&
|
|
177
|
+
error.message.includes('claude: command not found')) {
|
|
178
|
+
SpinniesManager_1.default.fail('claudeCode', {
|
|
179
|
+
text: en_1.commands.mcp.setup.spinners.claudeCodeNotFound,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
SpinniesManager_1.default.fail('claudeCode', {
|
|
184
|
+
text: en_1.commands.mcp.setup.spinners.claudeCodeInstallFailed,
|
|
185
|
+
});
|
|
186
|
+
(0, errorHandlers_1.logError)(error);
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
SpinniesManager_1.default.fail('claudeCode', {
|
|
193
|
+
text: en_1.commands.mcp.setup.spinners.claudeCodeInstallFailed,
|
|
194
|
+
});
|
|
195
|
+
(0, errorHandlers_1.logError)(error);
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function setupCursor(mcpCommand = defaultMcpCommand) {
|
|
200
|
+
const cursorConfigPath = path_1.default.join(os_1.default.homedir(), '.cursor', 'mcp.json');
|
|
201
|
+
return setupMcpConfigFile({
|
|
202
|
+
configPath: cursorConfigPath,
|
|
203
|
+
configuringMessage: en_1.commands.mcp.setup.spinners.configuringCursor,
|
|
204
|
+
configuredMessage: en_1.commands.mcp.setup.spinners.configuredCursor,
|
|
205
|
+
failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureCursor,
|
|
206
|
+
mcpCommand,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function setupWindsurf(mcpCommand = defaultMcpCommand) {
|
|
210
|
+
const windsurfConfigPath = path_1.default.join(os_1.default.homedir(), '.codeium', 'windsurf', 'mcp_config.json');
|
|
211
|
+
return setupMcpConfigFile({
|
|
212
|
+
configPath: windsurfConfigPath,
|
|
213
|
+
configuringMessage: en_1.commands.mcp.setup.spinners.configuringWindsurf,
|
|
214
|
+
configuredMessage: en_1.commands.mcp.setup.spinners.configuredWindsurf,
|
|
215
|
+
failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureWindsurf,
|
|
216
|
+
mcpCommand,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
@@ -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,6 +40,13 @@ 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
|
|
@@ -55,6 +62,7 @@ async function loadConfigMiddleware(argv) {
|
|
|
55
62
|
if (!(0, config_1.configFileExists)(true) &&
|
|
56
63
|
(0, utils_1.isTargetedCommand)(argv._, {
|
|
57
64
|
account: { target: false, subCommands: { auth: { target: true } } },
|
|
65
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
58
66
|
})) {
|
|
59
67
|
return;
|
|
60
68
|
}
|
|
@@ -86,6 +94,7 @@ const accountsSubCommands = {
|
|
|
86
94
|
list: { target: true },
|
|
87
95
|
ls: { target: true },
|
|
88
96
|
remove: { target: true },
|
|
97
|
+
use: { target: true },
|
|
89
98
|
},
|
|
90
99
|
};
|
|
91
100
|
const sandboxesSubCommands = {
|
|
@@ -94,13 +103,27 @@ const sandboxesSubCommands = {
|
|
|
94
103
|
delete: { target: true },
|
|
95
104
|
},
|
|
96
105
|
};
|
|
106
|
+
const configSubCommands = {
|
|
107
|
+
target: false,
|
|
108
|
+
subCommands: {
|
|
109
|
+
migrate: { target: true },
|
|
110
|
+
},
|
|
111
|
+
};
|
|
97
112
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
98
113
|
init: { target: true },
|
|
99
114
|
auth: { target: true },
|
|
115
|
+
mcp: {
|
|
116
|
+
target: false,
|
|
117
|
+
subCommands: {
|
|
118
|
+
setup: { target: true },
|
|
119
|
+
start: { target: true },
|
|
120
|
+
},
|
|
121
|
+
},
|
|
100
122
|
account: accountsSubCommands,
|
|
101
123
|
accounts: accountsSubCommands,
|
|
102
124
|
sandbox: sandboxesSubCommands,
|
|
103
125
|
sandboxes: sandboxesSubCommands,
|
|
126
|
+
config: configSubCommands,
|
|
104
127
|
};
|
|
105
128
|
async function validateAccountOptions(argv) {
|
|
106
129
|
// Skip this when no command is provided
|
|
@@ -112,10 +112,12 @@ async function logFireAlarms(accountId, command, version) {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
async function checkFireAlarms(
|
|
116
|
-
const { derivedAccountId } =
|
|
115
|
+
async function checkFireAlarms(argv) {
|
|
116
|
+
const { derivedAccountId } = argv;
|
|
117
117
|
try {
|
|
118
|
-
|
|
118
|
+
if (derivedAccountId) {
|
|
119
|
+
await logFireAlarms(derivedAccountId, argv._.join(' '), package_json_1.default.version);
|
|
120
|
+
}
|
|
119
121
|
}
|
|
120
122
|
catch (error) {
|
|
121
123
|
(0, errorHandlers_1.debugError)(error);
|
package/lib/npm.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_PACKAGE_MANAGER = "npm";
|
|
2
|
+
export declare function isGloballyInstalled(packageName: string): Promise<boolean>;
|
|
3
|
+
export declare function getLatestCliVersion(): Promise<{
|
|
4
|
+
latest: string;
|
|
5
|
+
next: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function executeInstall(packages?: string[], flags?: string | null, options?: {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
}): Promise<void>;
|
package/lib/npm.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
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.DEFAULT_PACKAGE_MANAGER = void 0;
|
|
7
|
+
exports.isGloballyInstalled = isGloballyInstalled;
|
|
8
|
+
exports.getLatestCliVersion = getLatestCliVersion;
|
|
9
|
+
exports.executeInstall = executeInstall;
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = __importDefault(require("util"));
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
14
|
+
exports.DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
15
|
+
async function isGloballyInstalled(packageName) {
|
|
16
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
17
|
+
try {
|
|
18
|
+
await exec(`${packageName} --version`);
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function getLatestCliVersion() {
|
|
26
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
27
|
+
const { stdout } = await exec(`npm info ${package_json_1.default.name} dist-tags --json`);
|
|
28
|
+
const { latest, next } = JSON.parse(stdout);
|
|
29
|
+
return { latest, next };
|
|
30
|
+
}
|
|
31
|
+
async function executeInstall(packages = [], flags, options) {
|
|
32
|
+
const installCommand = `${exports.DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
|
|
33
|
+
logger_1.logger.debug('Running ', installCommand);
|
|
34
|
+
const exec = util_1.default.promisify(child_process_1.exec);
|
|
35
|
+
await exec(installCommand, options);
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HsProfileFile } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
|
+
import { ProjectConfig } from '../types/Projects';
|
|
3
|
+
export declare function logProfileHeader(profileName: string): void;
|
|
4
|
+
export declare function logProfileFooter(profile: HsProfileFile, includeVariables?: boolean): void;
|
|
5
|
+
export declare function loadProfile(projectConfig: ProjectConfig | null, projectDir: string | null, profileName: string): HsProfileFile | undefined;
|
|
6
|
+
export declare function exitIfUsingProfiles(projectConfig: ProjectConfig | null, projectDir: string | null): Promise<void>;
|
|
7
|
+
export declare function loadAndValidateProfile(projectConfig: ProjectConfig | null, projectDir: string | null, argsProfile: string | undefined): Promise<number | undefined>;
|
|
@@ -0,0 +1,83 @@
|
|
|
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.logProfileHeader = logProfileHeader;
|
|
7
|
+
exports.logProfileFooter = logProfileFooter;
|
|
8
|
+
exports.loadProfile = loadProfile;
|
|
9
|
+
exports.exitIfUsingProfiles = exitIfUsingProfiles;
|
|
10
|
+
exports.loadAndValidateProfile = loadAndValidateProfile;
|
|
11
|
+
const path_1 = __importDefault(require("path"));
|
|
12
|
+
const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
|
|
13
|
+
const en_1 = require("../lang/en");
|
|
14
|
+
const ui_1 = require("./ui");
|
|
15
|
+
const logger_1 = require("./ui/logger");
|
|
16
|
+
const exitCodes_1 = require("./enums/exitCodes");
|
|
17
|
+
function logProfileHeader(profileName) {
|
|
18
|
+
(0, ui_1.uiLine)();
|
|
19
|
+
(0, ui_1.uiBetaTag)(en_1.lib.projectProfiles.logs.usingProfile((0, project_parsing_lib_1.getHsProfileFilename)(profileName)));
|
|
20
|
+
logger_1.uiLogger.log('');
|
|
21
|
+
}
|
|
22
|
+
function logProfileFooter(profile, includeVariables = false) {
|
|
23
|
+
logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileTargetAccount(profile.accountId));
|
|
24
|
+
if (includeVariables) {
|
|
25
|
+
logger_1.uiLogger.log('');
|
|
26
|
+
logger_1.uiLogger.log(en_1.lib.projectProfiles.logs.profileVariables);
|
|
27
|
+
Object.entries(profile.variables ?? {}).forEach(([key, value]) => {
|
|
28
|
+
logger_1.uiLogger.log(` ${key}: ${value}`);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
(0, ui_1.uiLine)();
|
|
32
|
+
logger_1.uiLogger.log('');
|
|
33
|
+
}
|
|
34
|
+
function loadProfile(projectConfig, projectDir, profileName) {
|
|
35
|
+
if (!projectConfig || !projectDir) {
|
|
36
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.noProjectConfig);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const projectSourceDir = path_1.default.join(projectDir, projectConfig.srcDir);
|
|
40
|
+
const profileFilename = (0, project_parsing_lib_1.getHsProfileFilename)(profileName);
|
|
41
|
+
try {
|
|
42
|
+
const profile = (0, project_parsing_lib_1.loadHsProfileFile)(projectSourceDir, profileName);
|
|
43
|
+
if (!profile) {
|
|
44
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.profileNotFound(profileFilename));
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!profile.accountId) {
|
|
48
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.missingAccountId(profileFilename));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
return profile;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.loadProfile.errors.failedToLoadProfile(profileFilename));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function exitIfUsingProfiles(projectConfig, projectDir) {
|
|
59
|
+
if (projectConfig && projectDir) {
|
|
60
|
+
const existingProfiles = await (0, project_parsing_lib_1.getAllHsProfiles)(path_1.default.join(projectDir, projectConfig.srcDir));
|
|
61
|
+
if (existingProfiles.length > 0) {
|
|
62
|
+
logger_1.uiLogger.error(en_1.lib.projectProfiles.exitIfUsingProfiles.errors.noProfileSpecified);
|
|
63
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async function loadAndValidateProfile(projectConfig, projectDir, argsProfile) {
|
|
68
|
+
if (argsProfile) {
|
|
69
|
+
logProfileHeader(argsProfile);
|
|
70
|
+
const profile = loadProfile(projectConfig, projectDir, argsProfile);
|
|
71
|
+
if (!profile) {
|
|
72
|
+
(0, ui_1.uiLine)();
|
|
73
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
74
|
+
}
|
|
75
|
+
logProfileFooter(profile, true);
|
|
76
|
+
return profile.accountId;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
// A profile must be specified if this project has profiles configured
|
|
80
|
+
await exitIfUsingProfiles(projectConfig, projectDir);
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|