@hubspot/cli 7.5.1-experimental.0 → 7.5.2-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/api/migrate.d.ts +12 -3
- package/api/migrate.js +9 -2
- package/bin/cli.js +96 -93
- package/commands/account/auth.d.ts +6 -0
- package/commands/account/auth.js +167 -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 +51 -9
- package/commands/account/list.d.ts +3 -7
- package/commands/account/list.js +38 -13
- package/commands/account/remove.d.ts +3 -7
- package/commands/account/remove.js +57 -11
- 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 +39 -9
- 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 +3 -7
- package/commands/auth.js +20 -25
- 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 +133 -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 +61 -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 -36
- 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 +21 -11
- package/commands/customObject/schema/fetch-all.d.ts +4 -9
- package/commands/customObject/schema/fetch-all.js +19 -11
- package/commands/customObject/schema/fetch.d.ts +4 -9
- package/commands/customObject/schema/fetch.js +19 -11
- 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/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 +25 -23
- 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/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 +4 -6
- package/commands/project/deploy.js +66 -36
- 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 -27
- 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 +110 -56
- 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 +47 -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 +3094 -0
- package/lang/en.js +2957 -3316
- package/lang/en.lyaml +89 -214
- 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 +171 -86
- 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 +28 -0
- package/lib/constants.js +29 -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 +59 -45
- package/lib/errorHandlers/index.js +6 -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/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 +23 -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 +6 -0
- package/lib/projectProfiles.js +65 -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 +45 -41
- 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 +27 -0
- package/lib/projects/localDev/AppDevModeInterface.js +186 -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 +14 -2
- package/lib/projects/upload.js +25 -35
- package/lib/projects/urls.d.ts +2 -0
- package/lib/projects/urls.js +14 -2
- 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 +41 -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 +1 -0
- package/lib/prompts/installAppPrompt.js +35 -0
- package/lib/prompts/personalAccessKeyPrompt.js +17 -18
- 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 +3 -2
- package/lib/prompts/promptUtils.js +2 -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/SpinniesManager.d.ts +1 -1
- 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/ui/spinniesUtils.d.ts +5 -5
- 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/package.json +17 -11
- package/types/Cms.d.ts +30 -0
- package/types/Cms.js +2 -0
- package/types/LocalDev.d.ts +34 -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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -43,7 +43,7 @@ const SKIP_CONFIG_VALIDATION = {
|
|
|
43
43
|
};
|
|
44
44
|
async function loadConfigMiddleware(argv) {
|
|
45
45
|
// Skip this when no command is provided
|
|
46
|
-
if (!argv._.length) {
|
|
46
|
+
if (!argv._.length || argv.help) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
const maybeValidateConfig = () => {
|
|
@@ -52,7 +52,18 @@ async function loadConfigMiddleware(argv) {
|
|
|
52
52
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
if ((0, config_1.configFileExists)(true) &&
|
|
55
|
+
if (!(0, config_1.configFileExists)(true) &&
|
|
56
|
+
(0, utils_1.isTargetedCommand)(argv._, {
|
|
57
|
+
account: { target: false, subCommands: { auth: { target: true } } },
|
|
58
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
59
|
+
})) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if ((0, config_1.configFileExists)(true) &&
|
|
63
|
+
argv.config &&
|
|
64
|
+
!(0, utils_1.isTargetedCommand)(argv._, {
|
|
65
|
+
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
66
|
+
})) {
|
|
56
67
|
logger_1.logger.error((0, lang_1.i18n)(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
57
68
|
configPath: (0, config_1.getConfigPath)(),
|
|
58
69
|
}));
|
|
@@ -71,10 +82,12 @@ async function loadConfigMiddleware(argv) {
|
|
|
71
82
|
const accountsSubCommands = {
|
|
72
83
|
target: false,
|
|
73
84
|
subCommands: {
|
|
85
|
+
auth: { target: true },
|
|
74
86
|
clean: { target: true },
|
|
75
87
|
list: { target: true },
|
|
76
88
|
ls: { target: true },
|
|
77
89
|
remove: { target: true },
|
|
90
|
+
use: { target: true },
|
|
78
91
|
},
|
|
79
92
|
};
|
|
80
93
|
const sandboxesSubCommands = {
|
|
@@ -83,6 +96,12 @@ const sandboxesSubCommands = {
|
|
|
83
96
|
delete: { target: true },
|
|
84
97
|
},
|
|
85
98
|
};
|
|
99
|
+
const configSubCommands = {
|
|
100
|
+
target: false,
|
|
101
|
+
subCommands: {
|
|
102
|
+
migrate: { target: true },
|
|
103
|
+
},
|
|
104
|
+
};
|
|
86
105
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
87
106
|
init: { target: true },
|
|
88
107
|
auth: { target: true },
|
|
@@ -90,10 +109,11 @@ const SKIP_ACCOUNT_VALIDATION = {
|
|
|
90
109
|
accounts: accountsSubCommands,
|
|
91
110
|
sandbox: sandboxesSubCommands,
|
|
92
111
|
sandboxes: sandboxesSubCommands,
|
|
112
|
+
config: configSubCommands,
|
|
93
113
|
};
|
|
94
114
|
async function validateAccountOptions(argv) {
|
|
95
115
|
// Skip this when no command is provided
|
|
96
|
-
if (argv._.length) {
|
|
116
|
+
if (argv._.length && !argv.help) {
|
|
97
117
|
let validAccount = true;
|
|
98
118
|
if (!(0, utils_1.isTargetedCommand)(argv._, SKIP_ACCOUNT_VALIDATION)) {
|
|
99
119
|
validAccount = await (0, validation_1.validateAccount)(argv);
|
|
@@ -0,0 +1,125 @@
|
|
|
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.checkFireAlarms = checkFireAlarms;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const fireAlarm_1 = require("@hubspot/local-dev-lib/api/fireAlarm");
|
|
9
|
+
const errorHandlers_1 = require("../errorHandlers");
|
|
10
|
+
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
+
const boxen_1 = require("../ui/boxen");
|
|
12
|
+
/*
|
|
13
|
+
* Versions can be formatted like this:
|
|
14
|
+
* =7.2.2 -> targets the exact version 7.2.2
|
|
15
|
+
* =7.2.* -> targets all versions with a major of 7 and a minor of 2
|
|
16
|
+
* =7.* -> targets all versions with a major of 7
|
|
17
|
+
* =* -> targets all versions
|
|
18
|
+
* <=7.2.2 -> targets all versions equal to or less than 7.2.2
|
|
19
|
+
* <=7.2.* -> targets all versions equal to or less than 7.2
|
|
20
|
+
*/
|
|
21
|
+
const WILDCARD = '*';
|
|
22
|
+
function isVersionTargeted(version, targetVersionString) {
|
|
23
|
+
// Assume we're targeting no versions if no version string is found
|
|
24
|
+
// Target all versions using the * wildcard
|
|
25
|
+
if (!targetVersionString) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
// Only support version targeting for the <= or = operator
|
|
29
|
+
if (!targetVersionString.startsWith('<=') &&
|
|
30
|
+
!targetVersionString.startsWith('=')) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const targetVersion = targetVersionString.substring(targetVersionString.indexOf('=') + 1);
|
|
34
|
+
// Only allow exact version matching for tagged CLI releases (like -beta)
|
|
35
|
+
if (version.includes('-') || targetVersionString.includes('-')) {
|
|
36
|
+
if (!targetVersionString.startsWith('=')) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return version === targetVersion;
|
|
40
|
+
}
|
|
41
|
+
const targetVersionParts = targetVersion.split('.');
|
|
42
|
+
const versionParts = version.split('.');
|
|
43
|
+
// Require the wildcard to be explicitly set to target all versions
|
|
44
|
+
if (versionParts.length < 3 &&
|
|
45
|
+
versionParts[versionParts.length - 1] !== WILDCARD) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// Don't allow the less than or equal to operator to be used with the wildcard
|
|
49
|
+
// in the major version part (e.g. <=*)
|
|
50
|
+
if (targetVersionString.startsWith('<=') && versionParts[0] === WILDCARD) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
let targetAnyVersion = false;
|
|
54
|
+
return targetVersionParts.every((targetPart, i) => {
|
|
55
|
+
const versionPart = versionParts[i];
|
|
56
|
+
// Support generic version targeting (like 1.2.*)
|
|
57
|
+
if (targetPart === WILDCARD || targetAnyVersion) {
|
|
58
|
+
targetAnyVersion = true;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
// Double check that the target part is a number
|
|
62
|
+
if (isNaN(Number(targetPart))) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return targetVersionString.startsWith('<=')
|
|
66
|
+
? Number(versionPart) <= Number(targetPart)
|
|
67
|
+
: Number(versionPart) === Number(targetPart);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function isCommandTargeted(command, targetCommandsString) {
|
|
71
|
+
// Require the wildcard to be explicitly set to target all commands
|
|
72
|
+
if (!targetCommandsString) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
if (targetCommandsString === WILDCARD) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
const targetCommands = targetCommandsString.split(',');
|
|
79
|
+
return targetCommands.some(cmd => command.startsWith(cmd));
|
|
80
|
+
}
|
|
81
|
+
function filterFireAlarm(fireAlarm, command, version) {
|
|
82
|
+
const commandIsTargeted = isCommandTargeted(command, fireAlarm.querySelector);
|
|
83
|
+
const versionIsTargeted = isVersionTargeted(version, fireAlarm.urlRegexPattern);
|
|
84
|
+
return commandIsTargeted && versionIsTargeted;
|
|
85
|
+
}
|
|
86
|
+
async function getFireAlarms(accountId, command, version) {
|
|
87
|
+
let relevantAlarms = [];
|
|
88
|
+
try {
|
|
89
|
+
const { data: fireAlarms } = await (0, fireAlarm_1.fetchFireAlarms)(accountId);
|
|
90
|
+
relevantAlarms = fireAlarms.filter(fireAlarm => filterFireAlarm(fireAlarm, command, version));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
(0, errorHandlers_1.debugError)(error);
|
|
94
|
+
}
|
|
95
|
+
return relevantAlarms;
|
|
96
|
+
}
|
|
97
|
+
async function logFireAlarms(accountId, command, version) {
|
|
98
|
+
const alarms = await getFireAlarms(accountId, command, version);
|
|
99
|
+
if (alarms.length > 0) {
|
|
100
|
+
const notifications = alarms.reduce((acc, alarm) => {
|
|
101
|
+
if (alarm.title && alarm.message) {
|
|
102
|
+
return (acc +
|
|
103
|
+
`${acc.length > 0 ? '\n\n' : ''}${chalk_1.default.bold(alarm.title)}\n${alarm.message}`);
|
|
104
|
+
}
|
|
105
|
+
return acc;
|
|
106
|
+
}, '');
|
|
107
|
+
await (0, boxen_1.logInBox)({
|
|
108
|
+
contents: notifications,
|
|
109
|
+
options: {
|
|
110
|
+
title: 'Notifications',
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async function checkFireAlarms(argv) {
|
|
116
|
+
const { derivedAccountId } = argv;
|
|
117
|
+
try {
|
|
118
|
+
if (derivedAccountId) {
|
|
119
|
+
await logFireAlarms(derivedAccountId, argv._.join(' '), package_json_1.default.version);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
(0, errorHandlers_1.debugError)(error);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -4,7 +4,7 @@ exports.performChecks = performChecks;
|
|
|
4
4
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
5
5
|
const exitCodes_1 = require("../enums/exitCodes");
|
|
6
6
|
const lang_1 = require("../lang");
|
|
7
|
-
const
|
|
7
|
+
const config_1 = require("../projects/config");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const UPLOAD_AND_WATCH_COMMANDS = {
|
|
10
10
|
upload: { target: true },
|
|
@@ -13,7 +13,7 @@ const UPLOAD_AND_WATCH_COMMANDS = {
|
|
|
13
13
|
function performChecks(argv) {
|
|
14
14
|
// Require "project" command when running upload/watch inside of a project
|
|
15
15
|
if ((0, utils_1.isTargetedCommand)(argv._, UPLOAD_AND_WATCH_COMMANDS) &&
|
|
16
|
-
(0,
|
|
16
|
+
(0, config_1.getIsInProject)(argv.src)) {
|
|
17
17
|
logger_1.logger.error((0, lang_1.i18n)(`commands.generalErrors.srcIsProject`, {
|
|
18
18
|
src: argv.src || './',
|
|
19
19
|
command: argv._.join(' '),
|
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
|
+
}
|
package/lib/oauth.js
CHANGED
|
@@ -19,13 +19,12 @@ const lang_1 = require("./lang");
|
|
|
19
19
|
const exitCodes_1 = require("./enums/exitCodes");
|
|
20
20
|
const PORT = 3000;
|
|
21
21
|
const redirectUri = `http://localhost:${PORT}/oauth-callback`;
|
|
22
|
-
const i18nKey = 'lib.oauth';
|
|
23
22
|
function buildAuthUrl(oauthManager) {
|
|
24
23
|
const { env: accountEnv, clientId, scopes: accountScopes, } = oauthManager.account;
|
|
25
24
|
const env = accountEnv || environments_1.ENVIRONMENTS.PROD;
|
|
26
25
|
const scopes = accountScopes || auth_1.DEFAULT_OAUTH_SCOPES;
|
|
27
26
|
if (!clientId) {
|
|
28
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
27
|
+
logger_1.logger.error((0, lang_1.i18n)(`lib.oauth.missingClientId`));
|
|
29
28
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
30
29
|
}
|
|
31
30
|
return (`${(0, urls_1.getHubSpotWebsiteOrigin)(env)}/oauth/${oauthManager.account.accountId}/authorize` +
|
package/lib/process.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.handleKeypress = handleKeypress;
|
|
|
9
9
|
const readline_1 = __importDefault(require("readline"));
|
|
10
10
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
11
|
const lang_1 = require("./lang");
|
|
12
|
-
const i18nKey = 'lib.process';
|
|
13
12
|
exports.TERMINATION_SIGNALS = [
|
|
14
13
|
'beforeExit',
|
|
15
14
|
'SIGINT', // Terminal trying to interrupt (Ctrl + C)
|
|
@@ -32,7 +31,7 @@ function handleExit(callback) {
|
|
|
32
31
|
if (isSIGHUP) {
|
|
33
32
|
(0, logger_1.setLogLevel)(logger_1.LOG_LEVEL.NONE);
|
|
34
33
|
}
|
|
35
|
-
logger_1.logger.debug((0, lang_1.i18n)(
|
|
34
|
+
logger_1.logger.debug((0, lang_1.i18n)(`lib.process.exitDebug`, { signal }));
|
|
36
35
|
await callback({ isSIGHUP });
|
|
37
36
|
}
|
|
38
37
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
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>;
|