@hubspot/cli 4.1.8-beta.1 → 4.1.8-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/bin/cli.js +1 -1
- package/commands/accounts/info.js +1 -1
- package/commands/accounts/list.js +1 -1
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +1 -1
- package/commands/accounts/use.js +1 -1
- package/commands/accounts.js +1 -1
- package/commands/auth.js +1 -1
- package/commands/cms/convertFields.js +1 -1
- package/commands/cms/lighthouseScore.js +1 -1
- package/commands/cms.js +1 -1
- package/commands/config/set/allowUsageTracking.js +1 -1
- package/commands/config/set/defaultMode.js +1 -1
- package/commands/config/set/httpTimeout.js +1 -1
- package/commands/config/set.js +1 -1
- package/commands/config.js +1 -1
- package/commands/create/api-sample.js +2 -2
- package/commands/create/module.js +1 -1
- package/commands/create/template.js +1 -1
- package/commands/create.js +1 -1
- package/commands/customObject/create.js +1 -1
- package/commands/customObject/schema/create.js +1 -1
- package/commands/customObject/schema/delete.js +1 -1
- package/commands/customObject/schema/fetch-all.js +1 -1
- package/commands/customObject/schema/fetch.js +1 -1
- package/commands/customObject/schema/list.js +1 -1
- package/commands/customObject/schema/update.js +1 -1
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +1 -1
- package/commands/feedback.js +1 -1
- package/commands/fetch.js +1 -1
- package/commands/filemanager/fetch.js +1 -1
- package/commands/filemanager/upload.js +1 -1
- package/commands/filemanager.js +1 -1
- package/commands/functions/deploy.js +1 -1
- package/commands/functions/list.js +1 -1
- package/commands/functions/server.js +1 -1
- package/commands/functions.js +1 -1
- package/commands/hubdb/clear.js +1 -1
- package/commands/hubdb/create.js +1 -1
- package/commands/hubdb/delete.js +1 -1
- package/commands/hubdb/fetch.js +1 -1
- package/commands/hubdb.js +1 -1
- package/commands/init.js +1 -1
- package/commands/lint.js +1 -1
- package/commands/list.js +1 -1
- package/commands/logs.js +1 -1
- package/commands/module/marketplace-validate.js +1 -1
- package/commands/module.js +1 -1
- package/commands/mv.js +1 -1
- package/commands/open.js +1 -1
- package/commands/project/add.js +56 -0
- package/commands/project/create.js +7 -4
- package/commands/project/deploy.js +33 -19
- package/commands/project/dev.js +300 -0
- package/commands/project/download.js +28 -17
- package/commands/project/logs.js +1 -1
- package/commands/project/open.js +1 -1
- package/commands/project/upload.js +28 -76
- package/commands/project/watch.js +1 -1
- package/commands/project.js +4 -0
- package/commands/remove.js +1 -1
- package/commands/sandbox/create.js +159 -10
- package/commands/sandbox/delete.js +6 -7
- package/commands/sandbox/sync.js +15 -1
- package/commands/secrets/addSecret.js +1 -1
- package/commands/secrets/deleteSecret.js +1 -1
- package/commands/secrets/listSecrets.js +1 -1
- package/commands/secrets/updateSecret.js +1 -1
- package/commands/secrets.js +1 -1
- package/commands/theme/marketplace-validate.js +1 -1
- package/commands/theme.js +1 -1
- package/commands/upload.js +1 -1
- package/commands/watch.js +1 -1
- package/lang/en.lyaml +1202 -0
- package/lib/LocalDevManager.js +533 -0
- package/lib/SpinniesManager.js +96 -0
- package/lib/commonOpts.js +1 -1
- package/lib/interpolation.js +137 -0
- package/lib/interpolationHelpers.js +23 -0
- package/lib/lang.js +95 -0
- package/lib/marketplace-validate.js +1 -1
- package/lib/projects.js +315 -127
- package/lib/prompts/accountsPrompt.js +3 -7
- package/lib/prompts/buildIdPrompt.js +35 -0
- package/lib/prompts/cmsFieldPrompt.js +1 -1
- package/lib/prompts/createApiSamplePrompt.js +1 -1
- package/lib/prompts/createFunctionPrompt.js +1 -1
- package/lib/prompts/createModulePrompt.js +1 -1
- package/lib/prompts/createProjectPrompt.js +44 -7
- package/lib/prompts/createTemplatePrompt.js +1 -1
- package/lib/prompts/downloadProjectPrompt.js +44 -0
- package/lib/prompts/enterAccountNamePrompt.js +1 -1
- package/lib/prompts/feedbackPrompt.js +1 -1
- package/lib/prompts/folderOverwritePrompt.js +1 -1
- package/lib/prompts/personalAccessKeyPrompt.js +1 -1
- package/lib/prompts/projectAddPrompt.js +57 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +105 -0
- package/lib/prompts/projectNamePrompt.js +1 -1
- package/lib/prompts/projectsLogsPrompt.js +1 -1
- package/lib/prompts/promptUtils.js +13 -0
- package/lib/prompts/sandboxesPrompt.js +13 -5
- package/lib/prompts/secretPrompt.js +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +1 -1
- package/lib/prompts/uploadPrompt.js +1 -1
- package/lib/sandbox-create.js +22 -160
- package/lib/sandbox-sync.js +89 -64
- package/lib/sandboxes.js +162 -15
- package/lib/ui.js +20 -8
- package/package.json +7 -4
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
const helpers = require('./interpolationHelpers');
|
|
2
|
+
const delimiters = {
|
|
3
|
+
interpolation: {
|
|
4
|
+
start: '{{',
|
|
5
|
+
end: '}}',
|
|
6
|
+
},
|
|
7
|
+
helpers: {
|
|
8
|
+
start: '#',
|
|
9
|
+
end: '/',
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const isHelperIdentifier = identifier => {
|
|
14
|
+
return (
|
|
15
|
+
identifier.startsWith(delimiters.helpers.start) ||
|
|
16
|
+
identifier.startsWith(delimiters.helpers.end)
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const generateReplaceFn = (matchedText, startIndex, replacementString) => {
|
|
21
|
+
return currentStringValue =>
|
|
22
|
+
`${currentStringValue.slice(0, startIndex)}${replacementString ||
|
|
23
|
+
''}${currentStringValue.slice(startIndex + matchedText.length)}`;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Interpolate a string with data
|
|
28
|
+
* @param {string} stringValue - The string to interpolate
|
|
29
|
+
* @param {object} interpolationData - The data to interpolate with
|
|
30
|
+
* @returns {string} - The interpolated string
|
|
31
|
+
* @example
|
|
32
|
+
* interpolation('Hello {{name}}', { name: 'World' })
|
|
33
|
+
* // 'Hello World'
|
|
34
|
+
*/
|
|
35
|
+
const interpolation = (stringValue, interpolationData) => {
|
|
36
|
+
const interpolationIdentifierRegEx = new RegExp(
|
|
37
|
+
`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`,
|
|
38
|
+
'g'
|
|
39
|
+
);
|
|
40
|
+
const replaceQueue = [];
|
|
41
|
+
let match;
|
|
42
|
+
|
|
43
|
+
// while & reduce necessary because RegExp.exec is stateful and only runs
|
|
44
|
+
// from beginning to end of string
|
|
45
|
+
while ((match = interpolationIdentifierRegEx.exec(stringValue)) != null) {
|
|
46
|
+
const { 0: matchedText, 1: rawIdentifier, index } = match;
|
|
47
|
+
const identifier = rawIdentifier.trim();
|
|
48
|
+
|
|
49
|
+
if (identifier && !isHelperIdentifier(identifier)) {
|
|
50
|
+
replaceQueue.unshift(
|
|
51
|
+
generateReplaceFn(matchedText, index, interpolationData[identifier])
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const compiledString = replaceQueue.reduce(
|
|
57
|
+
(currentValue, replaceFn) => replaceFn(currentValue),
|
|
58
|
+
stringValue
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return compiledString;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Compile a string using a specified helper function
|
|
66
|
+
* @param {string} stringValue - The string to modify
|
|
67
|
+
* @param {object} helperIdentifier - Helper name
|
|
68
|
+
* @param {function} helperFn - Helper function to call on string
|
|
69
|
+
* @returns {string} - The modified string
|
|
70
|
+
* @example
|
|
71
|
+
* compileHelper('White {{#yellow}}yellow{{/yellow}}', 'yellow', (string) => { chalk.reset.yellow(string) }))))
|
|
72
|
+
* // 'White yellow' (with 'yellow' colored yellow)
|
|
73
|
+
*/
|
|
74
|
+
const compileHelper = (stringValue, helperIdentifier, helperFn) => {
|
|
75
|
+
const helperIdentifierRegEx = new RegExp(
|
|
76
|
+
`${delimiters.interpolation.start}(${delimiters.helpers.start}${helperIdentifier})${delimiters.interpolation.end}(.*?)${delimiters.interpolation.start}(${delimiters.helpers.end}${helperIdentifier})${delimiters.interpolation.end}`,
|
|
77
|
+
'g'
|
|
78
|
+
);
|
|
79
|
+
const replaceQueue = [];
|
|
80
|
+
let match;
|
|
81
|
+
|
|
82
|
+
// while & reduce necessary because RegExp.exec is stateful and only runs
|
|
83
|
+
// from beginning to end of string
|
|
84
|
+
while ((match = helperIdentifierRegEx.exec(stringValue)) != null) {
|
|
85
|
+
const {
|
|
86
|
+
0: matchedText,
|
|
87
|
+
1: rawHelperIdentifierStart,
|
|
88
|
+
2: innerText,
|
|
89
|
+
index,
|
|
90
|
+
} = match;
|
|
91
|
+
const identifier = rawHelperIdentifierStart
|
|
92
|
+
.replace(delimiters.helpers.start, '')
|
|
93
|
+
.trim();
|
|
94
|
+
|
|
95
|
+
if (identifier && helperFn) {
|
|
96
|
+
replaceQueue.unshift(
|
|
97
|
+
generateReplaceFn(matchedText, index, helperFn(innerText))
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const compiledString = replaceQueue.reduce(
|
|
103
|
+
(currentValue, replaceFn) => replaceFn(currentValue),
|
|
104
|
+
stringValue
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return compiledString;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const compileHelpers = stringValue => {
|
|
111
|
+
return Object.keys(helpers).reduce((currentStringValue, helperIdentifier) => {
|
|
112
|
+
return compileHelper(
|
|
113
|
+
currentStringValue,
|
|
114
|
+
helperIdentifier,
|
|
115
|
+
helpers[helperIdentifier]
|
|
116
|
+
);
|
|
117
|
+
}, stringValue);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Interpolate a string with data and compile helpers on the string
|
|
122
|
+
* @param {string} stringValue - The string to interpolate
|
|
123
|
+
* @param {object} interpolationData - The data to interpolate with
|
|
124
|
+
* @returns {string} - The interpolated and helper-compiled string
|
|
125
|
+
* @example
|
|
126
|
+
* interpolateAndCompile('Some {{#bold}}{{text}}{{/bold}} text', { text: 'awesomely bold' })
|
|
127
|
+
* // 'Some awsomely bold text' (with the words 'awesomely bold' in bold)
|
|
128
|
+
*/
|
|
129
|
+
const interpolate = (stringValue, interpolationData) => {
|
|
130
|
+
const interpolatedString = interpolation(stringValue, interpolationData);
|
|
131
|
+
const helperCompiledString = compileHelpers(interpolatedString);
|
|
132
|
+
return helperCompiledString;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
module.exports = {
|
|
136
|
+
interpolate,
|
|
137
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* These helper methods are used to modify text output within the CLI. They
|
|
5
|
+
* should all take in a string value and output a modified string value.
|
|
6
|
+
*/
|
|
7
|
+
module.exports = {
|
|
8
|
+
bold: function(stringValue) {
|
|
9
|
+
return chalk.bold(stringValue);
|
|
10
|
+
},
|
|
11
|
+
yellow: function(stringValue) {
|
|
12
|
+
return chalk.reset.yellow(stringValue);
|
|
13
|
+
},
|
|
14
|
+
green: function(stringValue) {
|
|
15
|
+
return chalk.reset.green(stringValue);
|
|
16
|
+
},
|
|
17
|
+
red: function(stringValue) {
|
|
18
|
+
return chalk.reset.red(stringValue);
|
|
19
|
+
},
|
|
20
|
+
cyan: function(stringValue) {
|
|
21
|
+
return chalk.cyan(stringValue);
|
|
22
|
+
},
|
|
23
|
+
};
|
package/lib/lang.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
const util = require('util');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const yaml = require('js-yaml');
|
|
5
|
+
const { logger } = require('@hubspot/cli-lib/logger');
|
|
6
|
+
const { interpolate } = require('./interpolation');
|
|
7
|
+
|
|
8
|
+
const MISSING_LANGUAGE_DATA_PREFIX = '[Missing language data]';
|
|
9
|
+
|
|
10
|
+
let locale;
|
|
11
|
+
let languageObj;
|
|
12
|
+
|
|
13
|
+
const loadLanguageFromYaml = () => {
|
|
14
|
+
if (languageObj) return;
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const nodeLocale = Intl.DateTimeFormat()
|
|
18
|
+
.resolvedOptions()
|
|
19
|
+
.locale.split('-')[0];
|
|
20
|
+
const languageFilePath = path.join(
|
|
21
|
+
__dirname,
|
|
22
|
+
`../lang/${nodeLocale}.lyaml`
|
|
23
|
+
);
|
|
24
|
+
const languageFileExists = fs.existsSync(languageFilePath);
|
|
25
|
+
|
|
26
|
+
// Fall back to using the default language file
|
|
27
|
+
locale = languageFileExists ? nodeLocale : 'en';
|
|
28
|
+
languageObj = yaml.load(
|
|
29
|
+
fs.readFileSync(path.join(__dirname, `../lang/${locale}.lyaml`), 'utf8')
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
logger.debug(
|
|
33
|
+
'Loaded language data: ',
|
|
34
|
+
util.inspect(languageObj, true, 999, true)
|
|
35
|
+
);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
logger.error('Error loading language data: ', e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const getTextValue = lookupDotNotation => {
|
|
42
|
+
const lookupProps = [locale, ...lookupDotNotation.split('.')];
|
|
43
|
+
const missingTextData = `${MISSING_LANGUAGE_DATA_PREFIX}: ${lookupProps.join(
|
|
44
|
+
'.'
|
|
45
|
+
)}`;
|
|
46
|
+
let textValue = languageObj;
|
|
47
|
+
let previouslyCheckedProp = lookupProps[0];
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
lookupProps.forEach(prop => {
|
|
51
|
+
textValue = textValue[prop];
|
|
52
|
+
previouslyCheckedProp = prop;
|
|
53
|
+
});
|
|
54
|
+
} catch (e) {
|
|
55
|
+
logger.error(
|
|
56
|
+
`Unable to access language property: ${lookupProps.join(
|
|
57
|
+
'.'
|
|
58
|
+
)}. Failed to access prop "${previouslyCheckedProp}".`
|
|
59
|
+
);
|
|
60
|
+
return missingTextData;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!textValue) {
|
|
64
|
+
return missingTextData;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return textValue;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const i18n = (lookupDotNotation, options = {}) => {
|
|
71
|
+
if (!languageObj) {
|
|
72
|
+
loadLanguageFromYaml();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (typeof lookupDotNotation !== 'string') {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`i18n must be passed a string value for lookupDotNotation, received ${typeof lookupDotNotation}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const textValue = getTextValue(lookupDotNotation);
|
|
82
|
+
const shouldInterpolate = !textValue.startsWith(MISSING_LANGUAGE_DATA_PREFIX);
|
|
83
|
+
|
|
84
|
+
return shouldInterpolate ? interpolate(textValue, options) : textValue;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const setLangData = (newLocale, newLangObj) => {
|
|
88
|
+
locale = newLocale;
|
|
89
|
+
languageObj = newLangObj;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
i18n,
|
|
94
|
+
setLangData,
|
|
95
|
+
};
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
getValidationStatus,
|
|
7
7
|
getValidationResults,
|
|
8
8
|
} = require('@hubspot/cli-lib/api/marketplaceValidation');
|
|
9
|
-
const { i18n } = require('
|
|
9
|
+
const { i18n } = require('./lang');
|
|
10
10
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
11
11
|
|
|
12
12
|
const SLEEP_TIME = 2000;
|