@hubspot/cli 6.2.2-experimental.1 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/auth.js +0 -2
- package/commands/create/api-sample.js +2 -2
- package/commands/create.js +0 -2
- package/commands/feedback.js +19 -4
- package/commands/functions/list.js +1 -1
- package/commands/init.js +0 -2
- package/commands/lint.js +28 -1
- package/commands/module/marketplace-validate.js +1 -1
- package/commands/project/deploy.js +10 -3
- package/commands/project/logs.js +1 -1
- package/commands/sandbox/delete.js +5 -3
- package/commands/theme/generate-selectors.js +1 -1
- package/commands/theme/marketplace-validate.js +1 -1
- package/lang/en.lyaml +8 -13
- package/lib/LocalDevManager.js +2 -2
- package/lib/commonOpts.d.ts +26 -1
- package/lib/commonOpts.js +72 -55
- package/lib/constants.d.ts +0 -8
- package/lib/constants.js +1 -9
- package/lib/interpolation.d.ts +4 -0
- package/lib/interpolation.js +38 -46
- package/lib/lang.d.ts +8 -0
- package/lib/lang.js +37 -32
- package/lib/process.d.ts +11 -0
- package/lib/process.js +16 -16
- package/lib/prompts/accountNamePrompt.js +1 -2
- package/lib/prompts/accountsPrompt.js +0 -17
- package/lib/prompts/createFunctionPrompt.js +3 -4
- package/lib/prompts/promptUtils.d.ts +12 -1
- package/lib/prompts/promptUtils.js +24 -13
- package/lib/usageTracking.js +10 -1
- package/lib/validation.js +0 -2
- package/package.json +3 -1
- package/lib/debugInfo.js +0 -20
- package/lib/environment.d.ts +0 -1
- package/lib/environment.js +0 -13
- package/lib/hublValidate.d.ts +0 -2
- package/lib/hublValidate.js +0 -32
- package/lib/interpolationHelpers.d.ts +0 -10
- package/lib/interpolationHelpers.js +0 -34
- package/lib/projectLogsManager.d.ts +0 -1
- package/lib/prompts/activeInstallConfirmationPrompt.d.ts +0 -1
- package/lib/prompts/activeInstallConfirmationPrompt.js +0 -20
- package/lib/prompts/deployBuildIdPrompt.d.ts +0 -1
- package/lib/prompts/deployBuildIdPrompt.js +0 -22
- package/lib/prompts/feedbackPrompt.d.ts +0 -1
- package/lib/prompts/feedbackPrompt.js +0 -39
- package/lib/prompts/folderOverwritePrompt.d.ts +0 -1
- package/lib/prompts/folderOverwritePrompt.js +0 -17
- package/lib/regex.d.ts +0 -1
- package/lib/regex.js +0 -4
- /package/lib/{debugInfo.d.ts → ProjectLogsManager.d.ts} +0 -0
- /package/lib/{projectLogsManager.js → ProjectLogsManager.js} +0 -0
- /package/lib/{generate-selectors.d.ts → generateSelectors.d.ts} +0 -0
- /package/lib/{generate-selectors.js → generateSelectors.js} +0 -0
- /package/lib/{marketplace-validate.d.ts → marketplaceValidate.d.ts} +0 -0
- /package/lib/{marketplace-validate.js → marketplaceValidate.js} +0 -0
package/lib/interpolation.js
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
const
|
|
6
|
+
exports.interpolate = interpolate;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const helpers = {
|
|
9
|
+
bold: function (stringValue) {
|
|
10
|
+
return chalk_1.default.bold(stringValue);
|
|
11
|
+
},
|
|
12
|
+
yellow: function (stringValue) {
|
|
13
|
+
return chalk_1.default.reset.yellow(stringValue);
|
|
14
|
+
},
|
|
15
|
+
green: function (stringValue) {
|
|
16
|
+
return chalk_1.default.reset.green(stringValue);
|
|
17
|
+
},
|
|
18
|
+
red: function (stringValue) {
|
|
19
|
+
return chalk_1.default.reset.red(stringValue);
|
|
20
|
+
},
|
|
21
|
+
cyan: function (stringValue) {
|
|
22
|
+
return chalk_1.default.cyan(stringValue);
|
|
23
|
+
},
|
|
24
|
+
orange: function (stringValue) {
|
|
25
|
+
return chalk_1.default.hex('#FC9900')(stringValue);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
5
28
|
const delimiters = {
|
|
6
29
|
interpolation: {
|
|
7
30
|
start: '{{',
|
|
@@ -12,25 +35,16 @@ const delimiters = {
|
|
|
12
35
|
end: '/',
|
|
13
36
|
},
|
|
14
37
|
};
|
|
15
|
-
|
|
38
|
+
function isHelperIdentifier(identifier) {
|
|
16
39
|
return (identifier.startsWith(delimiters.helpers.start) ||
|
|
17
40
|
identifier.startsWith(delimiters.helpers.end));
|
|
18
|
-
}
|
|
19
|
-
|
|
41
|
+
}
|
|
42
|
+
function generateReplaceFn(matchedText, startIndex, replacementString) {
|
|
20
43
|
return currentStringValue => `${currentStringValue.slice(0, startIndex)}${replacementString !== null && replacementString !== undefined
|
|
21
44
|
? replacementString
|
|
22
45
|
: ''}${currentStringValue.slice(startIndex + matchedText.length)}`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
* Interpolate a string with data
|
|
26
|
-
* @param {string} stringValue - The string to interpolate
|
|
27
|
-
* @param {object} interpolationData - The data to interpolate with
|
|
28
|
-
* @returns {string} - The interpolated string
|
|
29
|
-
* @example
|
|
30
|
-
* interpolation('Hello {{name}}', { name: 'World' })
|
|
31
|
-
* // 'Hello World'
|
|
32
|
-
*/
|
|
33
|
-
const interpolation = (stringValue, interpolationData) => {
|
|
46
|
+
}
|
|
47
|
+
function interpolation(stringValue, interpolationData) {
|
|
34
48
|
const interpolationIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`, 'g');
|
|
35
49
|
const replaceQueue = [];
|
|
36
50
|
let match;
|
|
@@ -40,23 +54,13 @@ const interpolation = (stringValue, interpolationData) => {
|
|
|
40
54
|
const { 0: matchedText, 1: rawIdentifier, index } = match;
|
|
41
55
|
const identifier = rawIdentifier.trim();
|
|
42
56
|
if (identifier && !isHelperIdentifier(identifier)) {
|
|
43
|
-
replaceQueue.unshift(generateReplaceFn(matchedText, index, interpolationData[identifier]));
|
|
57
|
+
replaceQueue.unshift(generateReplaceFn(matchedText, index, String(interpolationData[identifier])));
|
|
44
58
|
}
|
|
45
59
|
}
|
|
46
60
|
const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
|
|
47
61
|
return compiledString;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
* Compile a string using a specified helper function
|
|
51
|
-
* @param {string} stringValue - The string to modify
|
|
52
|
-
* @param {object} helperIdentifier - Helper name
|
|
53
|
-
* @param {function} helperFn - Helper function to call on string
|
|
54
|
-
* @returns {string} - The modified string
|
|
55
|
-
* @example
|
|
56
|
-
* compileHelper('White {{#yellow}}yellow{{/yellow}}', 'yellow', (string) => { chalk.reset.yellow(string) }))))
|
|
57
|
-
* // 'White yellow' (with 'yellow' colored yellow)
|
|
58
|
-
*/
|
|
59
|
-
const compileHelper = (stringValue, helperIdentifier, helperFn) => {
|
|
62
|
+
}
|
|
63
|
+
function compileHelper(stringValue, helperIdentifier, helperFn) {
|
|
60
64
|
const helperIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(${delimiters.helpers.start}${helperIdentifier})${delimiters.interpolation.end}(.*?)${delimiters.interpolation.start}(${delimiters.helpers.end}${helperIdentifier})${delimiters.interpolation.end}`, 'g');
|
|
61
65
|
const replaceQueue = [];
|
|
62
66
|
let match;
|
|
@@ -73,26 +77,14 @@ const compileHelper = (stringValue, helperIdentifier, helperFn) => {
|
|
|
73
77
|
}
|
|
74
78
|
const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
|
|
75
79
|
return compiledString;
|
|
76
|
-
}
|
|
77
|
-
|
|
80
|
+
}
|
|
81
|
+
function compileHelpers(stringValue) {
|
|
78
82
|
return Object.keys(helpers).reduce((currentStringValue, helperIdentifier) => {
|
|
79
83
|
return compileHelper(currentStringValue, helperIdentifier, helpers[helperIdentifier]);
|
|
80
84
|
}, stringValue);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
* Interpolate a string with data and compile helpers on the string
|
|
84
|
-
* @param {string} stringValue - The string to interpolate
|
|
85
|
-
* @param {object} interpolationData - The data to interpolate with
|
|
86
|
-
* @returns {string} - The interpolated and helper-compiled string
|
|
87
|
-
* @example
|
|
88
|
-
* interpolateAndCompile('Some {{#bold}}{{text}}{{/bold}} text', { text: 'awesomely bold' })
|
|
89
|
-
* // 'Some awsomely bold text' (with the words 'awesomely bold' in bold)
|
|
90
|
-
*/
|
|
91
|
-
const interpolate = (stringValue, interpolationData) => {
|
|
85
|
+
}
|
|
86
|
+
function interpolate(stringValue, interpolationData) {
|
|
92
87
|
const interpolatedString = interpolation(stringValue, interpolationData);
|
|
93
88
|
const helperCompiledString = compileHelpers(interpolatedString);
|
|
94
89
|
return helperCompiledString;
|
|
95
|
-
}
|
|
96
|
-
module.exports = {
|
|
97
|
-
interpolate,
|
|
98
|
-
};
|
|
90
|
+
}
|
package/lib/lang.d.ts
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
+
export declare const MISSING_LANGUAGE_DATA_PREFIX = "[Missing language data]";
|
|
2
|
+
type LanguageObject = {
|
|
3
|
+
[key: string]: string | LanguageObject;
|
|
4
|
+
};
|
|
5
|
+
export declare function i18n(lookupDotNotation: string, options?: {
|
|
6
|
+
[identifier: string]: string | number;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function setLangData(newLocale: string, newLangObj: LanguageObject): void;
|
|
1
9
|
export {};
|
package/lib/lang.js
CHANGED
|
@@ -1,55 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
exports.MISSING_LANGUAGE_DATA_PREFIX = void 0;
|
|
7
|
+
exports.i18n = i18n;
|
|
8
|
+
exports.setLangData = setLangData;
|
|
9
|
+
const util_1 = __importDefault(require("util"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
12
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
13
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
|
+
const interpolation_1 = require("./interpolation");
|
|
15
|
+
exports.MISSING_LANGUAGE_DATA_PREFIX = '[Missing language data]';
|
|
11
16
|
let locale;
|
|
12
17
|
let languageObj;
|
|
13
|
-
|
|
18
|
+
function loadLanguageFromYaml() {
|
|
14
19
|
if (languageObj)
|
|
15
20
|
return;
|
|
16
21
|
try {
|
|
17
22
|
const nodeLocale = Intl.DateTimeFormat()
|
|
18
23
|
.resolvedOptions()
|
|
19
24
|
.locale.split('-')[0];
|
|
20
|
-
const languageFilePath =
|
|
21
|
-
const languageFileExists =
|
|
25
|
+
const languageFilePath = path_1.default.join(__dirname, `../lang/${nodeLocale}.lyaml`);
|
|
26
|
+
const languageFileExists = fs_extra_1.default.existsSync(languageFilePath);
|
|
22
27
|
// Fall back to using the default language file
|
|
23
28
|
locale = languageFileExists ? nodeLocale : 'en';
|
|
24
|
-
languageObj =
|
|
25
|
-
logger.debug('Loaded language data: ',
|
|
29
|
+
languageObj = js_yaml_1.default.load(fs_extra_1.default.readFileSync(path_1.default.join(__dirname, `../lang/${locale}.lyaml`), 'utf8'));
|
|
30
|
+
logger_1.logger.debug('Loaded language data: ', util_1.default.inspect(languageObj, true, 999, true));
|
|
26
31
|
}
|
|
27
32
|
catch (e) {
|
|
28
|
-
logger.error('Error loading language data: ', e);
|
|
33
|
+
logger_1.logger.error('Error loading language data: ', e);
|
|
29
34
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
35
|
+
}
|
|
36
|
+
function getTextValue(lookupDotNotation) {
|
|
32
37
|
const lookupProps = [locale, ...lookupDotNotation.split('.')];
|
|
33
|
-
const missingTextData = `${MISSING_LANGUAGE_DATA_PREFIX}: ${lookupProps.join('.')}`;
|
|
38
|
+
const missingTextData = `${exports.MISSING_LANGUAGE_DATA_PREFIX}: ${lookupProps.join('.')}`;
|
|
34
39
|
let textValue = languageObj;
|
|
35
40
|
let previouslyCheckedProp = lookupProps[0];
|
|
36
41
|
try {
|
|
37
42
|
lookupProps.forEach(prop => {
|
|
38
|
-
textValue
|
|
43
|
+
if (textValue && typeof textValue === 'object') {
|
|
44
|
+
textValue = textValue[prop];
|
|
45
|
+
}
|
|
39
46
|
previouslyCheckedProp = prop;
|
|
40
47
|
});
|
|
41
48
|
}
|
|
42
49
|
catch (e) {
|
|
43
|
-
logger.debug(`Unable to access language property: ${lookupProps.join('.')}. Failed to access prop "${previouslyCheckedProp}".`);
|
|
44
|
-
logger.error('Unable to access language property.');
|
|
50
|
+
logger_1.logger.debug(`Unable to access language property: ${lookupProps.join('.')}. Failed to access prop "${previouslyCheckedProp}".`);
|
|
51
|
+
logger_1.logger.error('Unable to access language property.');
|
|
45
52
|
return missingTextData;
|
|
46
53
|
}
|
|
47
54
|
if (!textValue) {
|
|
48
55
|
return missingTextData;
|
|
49
56
|
}
|
|
57
|
+
if (typeof textValue !== 'string') {
|
|
58
|
+
return missingTextData;
|
|
59
|
+
}
|
|
50
60
|
return textValue;
|
|
51
|
-
}
|
|
52
|
-
|
|
61
|
+
}
|
|
62
|
+
function i18n(lookupDotNotation, options = {}) {
|
|
53
63
|
if (!languageObj) {
|
|
54
64
|
loadLanguageFromYaml();
|
|
55
65
|
}
|
|
@@ -57,15 +67,10 @@ const i18n = (lookupDotNotation, options = {}) => {
|
|
|
57
67
|
throw new Error(`i18n must be passed a string value for lookupDotNotation, received ${typeof lookupDotNotation}`);
|
|
58
68
|
}
|
|
59
69
|
const textValue = getTextValue(lookupDotNotation);
|
|
60
|
-
const shouldInterpolate = !textValue.startsWith(MISSING_LANGUAGE_DATA_PREFIX);
|
|
61
|
-
return shouldInterpolate ? interpolate(textValue, options) : textValue;
|
|
62
|
-
}
|
|
63
|
-
|
|
70
|
+
const shouldInterpolate = !textValue.startsWith(exports.MISSING_LANGUAGE_DATA_PREFIX);
|
|
71
|
+
return shouldInterpolate ? (0, interpolation_1.interpolate)(textValue, options) : textValue;
|
|
72
|
+
}
|
|
73
|
+
function setLangData(newLocale, newLangObj) {
|
|
64
74
|
locale = newLocale;
|
|
65
75
|
languageObj = newLangObj;
|
|
66
|
-
}
|
|
67
|
-
module.exports = {
|
|
68
|
-
i18n,
|
|
69
|
-
setLangData,
|
|
70
|
-
MISSING_LANGUAGE_DATA_PREFIX,
|
|
71
|
-
};
|
|
76
|
+
}
|
package/lib/process.d.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
+
interface KeyPress {
|
|
2
|
+
ctrl?: boolean;
|
|
3
|
+
shift?: boolean;
|
|
4
|
+
alt?: boolean;
|
|
5
|
+
meta?: boolean;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function handleExit(callback: (onTerminate: {
|
|
9
|
+
isSIGHUP: boolean;
|
|
10
|
+
}) => void): void;
|
|
11
|
+
export declare function handleKeypress(callback: (onKeyPress: KeyPress) => void): void;
|
|
1
12
|
export {};
|
package/lib/process.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
6
|
+
exports.handleExit = handleExit;
|
|
7
|
+
exports.handleKeypress = handleKeypress;
|
|
8
|
+
const readline_1 = __importDefault(require("readline"));
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const lang_1 = require("./lang");
|
|
7
11
|
const i18nKey = 'lib.process';
|
|
8
|
-
|
|
12
|
+
function handleExit(callback) {
|
|
9
13
|
const terminationSignals = [
|
|
10
14
|
'beforeExit',
|
|
11
15
|
'SIGINT', // Terminal trying to interrupt (Ctrl + C)
|
|
@@ -25,17 +29,17 @@ const handleExit = callback => {
|
|
|
25
29
|
const isSIGHUP = signal === 'SIGHUP';
|
|
26
30
|
// Prevent logs when terminal closes
|
|
27
31
|
if (isSIGHUP) {
|
|
28
|
-
setLogLevel(LOG_LEVEL.NONE);
|
|
32
|
+
(0, logger_1.setLogLevel)(logger_1.LOG_LEVEL.NONE);
|
|
29
33
|
}
|
|
30
|
-
logger.debug(i18n(`${i18nKey}.exitDebug`, { signal }));
|
|
34
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.exitDebug`, { signal }));
|
|
31
35
|
await callback({ isSIGHUP });
|
|
32
36
|
}
|
|
33
37
|
});
|
|
34
38
|
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
}
|
|
40
|
+
function handleKeypress(callback) {
|
|
41
|
+
readline_1.default.createInterface(process.stdin, process.stdout);
|
|
42
|
+
readline_1.default.emitKeypressEvents(process.stdin);
|
|
39
43
|
if (process.stdin.isTTY) {
|
|
40
44
|
process.stdin.setRawMode(true);
|
|
41
45
|
}
|
|
@@ -45,8 +49,4 @@ const handleKeypress = callback => {
|
|
|
45
49
|
callback(key);
|
|
46
50
|
}
|
|
47
51
|
});
|
|
48
|
-
}
|
|
49
|
-
module.exports = {
|
|
50
|
-
handleExit,
|
|
51
|
-
handleKeypress,
|
|
52
|
-
};
|
|
52
|
+
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { accountNameExistsInConfig } = require('@hubspot/local-dev-lib/config');
|
|
5
|
-
const { STRING_WITH_NO_SPACES_REGEX } = require('../regex');
|
|
6
5
|
const { promptUser } = require('./promptUtils');
|
|
7
6
|
const { i18n } = require('../lang');
|
|
8
7
|
const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
|
|
@@ -18,7 +17,7 @@ const getCliAccountNamePromptConfig = defaultName => ({
|
|
|
18
17
|
else if (!val.length) {
|
|
19
18
|
return i18n(`${i18nKey}.errors.nameRequired`);
|
|
20
19
|
}
|
|
21
|
-
else if (
|
|
20
|
+
else if (val.indexOf(' ') >= 0) {
|
|
22
21
|
return i18n(`${i18nKey}.errors.spacesInName`);
|
|
23
22
|
}
|
|
24
23
|
return accountNameExistsInConfig(val)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { updateDefaultAccount } = require('@hubspot/local-dev-lib/config');
|
|
5
4
|
const { promptUser } = require('./promptUtils');
|
|
6
5
|
const { i18n } = require('../lang');
|
|
7
6
|
const { uiAccountDescription } = require('../ui');
|
|
@@ -24,22 +23,6 @@ const selectAccountFromConfig = async (config, prompt) => {
|
|
|
24
23
|
]);
|
|
25
24
|
return selectedDefault;
|
|
26
25
|
};
|
|
27
|
-
const selectAndSetAsDefaultAccountPrompt = async (config) => {
|
|
28
|
-
const { default: selectedDefault } = await promptUser([
|
|
29
|
-
{
|
|
30
|
-
type: 'list',
|
|
31
|
-
look: false,
|
|
32
|
-
name: 'default',
|
|
33
|
-
pageSize: 20,
|
|
34
|
-
message: i18n(`${i18nKey}.promptMessage`),
|
|
35
|
-
choices: mapAccountChoices(config.portals),
|
|
36
|
-
default: config.defaultPortal,
|
|
37
|
-
},
|
|
38
|
-
]);
|
|
39
|
-
updateDefaultAccount(selectedDefault);
|
|
40
|
-
};
|
|
41
26
|
module.exports = {
|
|
42
|
-
selectAndSetAsDefaultAccountPrompt,
|
|
43
27
|
selectAccountFromConfig,
|
|
44
|
-
mapAccountChoices,
|
|
45
28
|
};
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { promptUser } = require('./promptUtils');
|
|
5
5
|
const { i18n } = require('../lang');
|
|
6
|
-
const { STRING_WITH_NO_SPACES_REGEX } = require('../regex');
|
|
7
6
|
const i18nKey = 'lib.prompts.createFunctionPrompt';
|
|
8
7
|
const FUNCTIONS_FOLDER_PROMPT = {
|
|
9
8
|
name: 'functionsFolder',
|
|
@@ -15,7 +14,7 @@ const FUNCTIONS_FOLDER_PROMPT = {
|
|
|
15
14
|
else if (!val.length) {
|
|
16
15
|
return i18n(`${i18nKey}.errors.blank`);
|
|
17
16
|
}
|
|
18
|
-
else if (
|
|
17
|
+
else if (val.indexOf(' ') >= 0) {
|
|
19
18
|
return i18n(`${i18nKey}.errors.space`);
|
|
20
19
|
}
|
|
21
20
|
return true;
|
|
@@ -31,7 +30,7 @@ const FUNCTION_FILENAME_PROMPT = {
|
|
|
31
30
|
else if (!val.length) {
|
|
32
31
|
return i18n(`${i18nKey}.errors.blank`);
|
|
33
32
|
}
|
|
34
|
-
else if (
|
|
33
|
+
else if (val.indexOf(' ') >= 0) {
|
|
35
34
|
return i18n(`${i18nKey}.errors.space`);
|
|
36
35
|
}
|
|
37
36
|
return true;
|
|
@@ -54,7 +53,7 @@ const ENDPOINT_PATH_PROMPT = {
|
|
|
54
53
|
else if (!val.length) {
|
|
55
54
|
return i18n(`${i18nKey}.errors.blank`);
|
|
56
55
|
}
|
|
57
|
-
else if (
|
|
56
|
+
else if (val.indexOf(' ') >= 0) {
|
|
58
57
|
return i18n(`${i18nKey}.errors.space`);
|
|
59
58
|
}
|
|
60
59
|
return true;
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const promptUser: any;
|
|
2
|
+
export declare function confirmPrompt(message: string, options?: {
|
|
3
|
+
defaultAnswer?: boolean;
|
|
4
|
+
when?: boolean | (() => boolean);
|
|
5
|
+
}): Promise<boolean>;
|
|
6
|
+
export declare function listPrompt(message: string, { choices, when, }: {
|
|
7
|
+
choices: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}>;
|
|
11
|
+
when?: boolean | (() => boolean);
|
|
12
|
+
}): Promise<string>;
|
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.promptUser = void 0;
|
|
4
|
+
exports.confirmPrompt = confirmPrompt;
|
|
5
|
+
exports.listPrompt = listPrompt;
|
|
4
6
|
const inquirer = require('inquirer');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
const
|
|
10
|
-
const { choice } = await promptUser([
|
|
7
|
+
// NOTE: we can eventually delete this and directly use inquirer.prompt when the files support imports
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
exports.promptUser = inquirer.createPromptModule();
|
|
10
|
+
async function confirmPrompt(message, options = {}) {
|
|
11
|
+
const { defaultAnswer, when } = options;
|
|
12
|
+
const { choice } = await (0, exports.promptUser)([
|
|
11
13
|
{
|
|
12
14
|
name: 'choice',
|
|
13
15
|
type: 'confirm',
|
|
14
|
-
default: defaultAnswer,
|
|
15
16
|
message,
|
|
17
|
+
default: defaultAnswer || true,
|
|
18
|
+
when,
|
|
16
19
|
},
|
|
17
20
|
]);
|
|
18
21
|
return choice;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
promptUser
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
}
|
|
23
|
+
async function listPrompt(message, { choices, when, }) {
|
|
24
|
+
const { choice } = await (0, exports.promptUser)([
|
|
25
|
+
{
|
|
26
|
+
name: 'choice',
|
|
27
|
+
type: 'list',
|
|
28
|
+
message,
|
|
29
|
+
choices,
|
|
30
|
+
when,
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
return choice;
|
|
34
|
+
}
|
package/lib/usageTracking.js
CHANGED
|
@@ -6,7 +6,6 @@ const { isTrackingAllowed, getAccountConfig, } = require('@hubspot/local-dev-lib
|
|
|
6
6
|
const { API_KEY_AUTH_METHOD, } = require('@hubspot/local-dev-lib/constants/auth');
|
|
7
7
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
8
|
const { version } = require('../package.json');
|
|
9
|
-
const { getPlatform } = require('./environment');
|
|
10
9
|
const { setLogLevel } = require('./commonOpts');
|
|
11
10
|
/* **
|
|
12
11
|
Available tracking meta properties
|
|
@@ -36,6 +35,16 @@ const getNodeVersionData = () => ({
|
|
|
36
35
|
nodeVersion: process.version,
|
|
37
36
|
nodeMajorVersion: (process.version || '').split('.')[0],
|
|
38
37
|
});
|
|
38
|
+
const getPlatform = () => {
|
|
39
|
+
switch (process.platform) {
|
|
40
|
+
case 'darwin':
|
|
41
|
+
return 'macos';
|
|
42
|
+
case 'win32':
|
|
43
|
+
return 'windows';
|
|
44
|
+
default:
|
|
45
|
+
return process.platform;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
39
48
|
function trackCommandUsage(command, meta = {}, accountId) {
|
|
40
49
|
if (!isTrackingAllowed()) {
|
|
41
50
|
return;
|
package/lib/validation.js
CHANGED
|
@@ -12,13 +12,11 @@ const { getOauthManager } = require('@hubspot/local-dev-lib/oauth');
|
|
|
12
12
|
const { accessTokenForPersonalAccessKey, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
13
13
|
const { getAbsoluteFilePath, getCwd, getExt, } = require('@hubspot/local-dev-lib/path');
|
|
14
14
|
const { getAccountId, getMode, setLogLevel } = require('./commonOpts');
|
|
15
|
-
const { logDebugInfo } = require('./debugInfo');
|
|
16
15
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
17
16
|
const { checkAndWarnGitInclusion } = require('./ui/git');
|
|
18
17
|
const { logError } = require('./errorHandlers/index');
|
|
19
18
|
async function loadAndValidateOptions(options, shouldValidateAccount = true) {
|
|
20
19
|
setLogLevel(options);
|
|
21
|
-
logDebugInfo(options);
|
|
22
20
|
const { config: configPath } = options;
|
|
23
21
|
loadConfig(configPath, options);
|
|
24
22
|
checkAndWarnGitInclusion(getConfigPath());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"@hubspot/serverless-dev-runtime": "7.0.0",
|
|
10
10
|
"@hubspot/theme-preview-dev-server": "0.0.9",
|
|
11
11
|
"@hubspot/ui-extensions-dev-server": "0.8.33",
|
|
12
|
+
"@types/fs-extra": "^11.0.4",
|
|
13
|
+
"@types/js-yaml": "^4.0.9",
|
|
12
14
|
"archiver": "^7.0.1",
|
|
13
15
|
"chalk": "^4.1.2",
|
|
14
16
|
"chokidar": "^3.0.1",
|
package/lib/debugInfo.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// @ts-nocheck
|
|
4
|
-
const { version } = require('../package.json');
|
|
5
|
-
const { getPlatform } = require('./environment');
|
|
6
|
-
const logDebugInfo = ({ debug }) => {
|
|
7
|
-
if (!debug) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
console.log('');
|
|
11
|
-
console.log('Debugging info');
|
|
12
|
-
console.log('==============');
|
|
13
|
-
console.log(`CLI version: ${version}`);
|
|
14
|
-
console.log(`node version: ${process.version}`);
|
|
15
|
-
console.log(`platform: ${getPlatform()}`);
|
|
16
|
-
console.log('');
|
|
17
|
-
};
|
|
18
|
-
module.exports = {
|
|
19
|
-
logDebugInfo,
|
|
20
|
-
};
|
package/lib/environment.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getPlatform(): string;
|
package/lib/environment.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPlatform = getPlatform;
|
|
4
|
-
function getPlatform() {
|
|
5
|
-
switch (process.platform) {
|
|
6
|
-
case 'darwin':
|
|
7
|
-
return 'macos';
|
|
8
|
-
case 'win32':
|
|
9
|
-
return 'windows';
|
|
10
|
-
default:
|
|
11
|
-
return process.platform;
|
|
12
|
-
}
|
|
13
|
-
}
|
package/lib/hublValidate.d.ts
DELETED
package/lib/hublValidate.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printHublValidationResult = printHublValidationResult;
|
|
4
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
5
|
-
function getErrorsFromHublValidationObject(validation) {
|
|
6
|
-
return ((validation && validation.meta && validation.meta.template_errors) || []);
|
|
7
|
-
}
|
|
8
|
-
function printHublValidationError(err) {
|
|
9
|
-
const { severity, message, lineno, startPosition } = err;
|
|
10
|
-
const method = severity === 'FATAL' ? 'error' : 'warn';
|
|
11
|
-
logger_1.logger[method]('[%d, %d]: %s', lineno, startPosition, message);
|
|
12
|
-
}
|
|
13
|
-
function printHublValidationResult({ file, validation, }) {
|
|
14
|
-
let count = 0;
|
|
15
|
-
if (!validation) {
|
|
16
|
-
return count;
|
|
17
|
-
}
|
|
18
|
-
const errors = getErrorsFromHublValidationObject(validation);
|
|
19
|
-
if (!errors.length) {
|
|
20
|
-
return count;
|
|
21
|
-
}
|
|
22
|
-
logger_1.logger.group(file);
|
|
23
|
-
errors.forEach(err => {
|
|
24
|
-
if (err.reason !== 'SYNTAX_ERROR') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
++count;
|
|
28
|
-
printHublValidationError(err);
|
|
29
|
-
});
|
|
30
|
-
logger_1.logger.groupEnd();
|
|
31
|
-
return count;
|
|
32
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* These helper methods are used to modify text output within the CLI. They
|
|
3
|
-
* should all take in a string value and output a modified string value.
|
|
4
|
-
*/
|
|
5
|
-
export declare function bold(stringValue: string): string;
|
|
6
|
-
export declare function yellow(stringValue: string): string;
|
|
7
|
-
export declare function green(stringValue: string): string;
|
|
8
|
-
export declare function red(stringValue: string): string;
|
|
9
|
-
export declare function cyan(stringValue: string): string;
|
|
10
|
-
export declare function orange(stringValue: string): string;
|
|
@@ -1,34 +0,0 @@
|
|
|
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.bold = bold;
|
|
7
|
-
exports.yellow = yellow;
|
|
8
|
-
exports.green = green;
|
|
9
|
-
exports.red = red;
|
|
10
|
-
exports.cyan = cyan;
|
|
11
|
-
exports.orange = orange;
|
|
12
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
-
/**
|
|
14
|
-
* These helper methods are used to modify text output within the CLI. They
|
|
15
|
-
* should all take in a string value and output a modified string value.
|
|
16
|
-
*/
|
|
17
|
-
function bold(stringValue) {
|
|
18
|
-
return chalk_1.default.bold(stringValue);
|
|
19
|
-
}
|
|
20
|
-
function yellow(stringValue) {
|
|
21
|
-
return chalk_1.default.reset.yellow(stringValue);
|
|
22
|
-
}
|
|
23
|
-
function green(stringValue) {
|
|
24
|
-
return chalk_1.default.reset.green(stringValue);
|
|
25
|
-
}
|
|
26
|
-
function red(stringValue) {
|
|
27
|
-
return chalk_1.default.reset.red(stringValue);
|
|
28
|
-
}
|
|
29
|
-
function cyan(stringValue) {
|
|
30
|
-
return chalk_1.default.cyan(stringValue);
|
|
31
|
-
}
|
|
32
|
-
function orange(stringValue) {
|
|
33
|
-
return chalk_1.default.hex('#FC9900')(stringValue);
|
|
34
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|