@hubspot/cli 6.2.2-experimental.1 → 6.3.0-experimental.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/bin/cli.js +23 -2
- package/commands/accounts/clean.js +8 -5
- package/commands/accounts/info.js +6 -6
- package/commands/accounts/list.js +14 -10
- package/commands/accounts/remove.js +1 -1
- package/commands/accounts/rename.js +3 -4
- package/commands/auth.js +11 -9
- package/commands/cms/lighthouseScore.js +19 -19
- package/commands/config/set.js +4 -5
- package/commands/create/api-sample.js +2 -2
- package/commands/create.js +3 -4
- package/commands/customObject/create.js +4 -6
- package/commands/customObject/schema/create.js +8 -9
- package/commands/customObject/schema/delete.js +3 -5
- package/commands/customObject/schema/fetch-all.js +3 -4
- package/commands/customObject/schema/fetch.js +4 -6
- package/commands/customObject/schema/list.js +3 -4
- package/commands/customObject/schema/update.js +8 -9
- package/commands/doctor.d.ts +8 -0
- package/commands/doctor.js +60 -0
- package/commands/feedback.js +19 -4
- package/commands/fetch.js +4 -4
- package/commands/filemanager/fetch.js +4 -5
- package/commands/filemanager/upload.js +9 -10
- package/commands/functions/deploy.js +12 -10
- package/commands/functions/list.js +6 -6
- package/commands/functions/server.js +4 -5
- package/commands/hubdb/clear.js +5 -6
- package/commands/hubdb/create.js +5 -6
- package/commands/hubdb/delete.js +5 -6
- package/commands/hubdb/fetch.js +4 -5
- package/commands/init.js +44 -15
- package/commands/lint.d.ts +4 -1
- package/commands/lint.js +44 -8
- package/commands/list.js +4 -5
- package/commands/logs.js +4 -5
- package/commands/module/marketplace-validate.js +7 -8
- package/commands/mv.js +7 -8
- package/commands/open.js +7 -8
- package/commands/project/add.js +2 -3
- package/commands/project/cloneApp.js +14 -14
- package/commands/project/create.js +3 -3
- package/commands/project/deploy.js +24 -14
- package/commands/project/dev.js +13 -13
- package/commands/project/download.js +11 -9
- package/commands/project/installDeps.js +5 -5
- package/commands/project/listBuilds.js +10 -8
- package/commands/project/logs.js +6 -6
- package/commands/project/migrateApp.js +18 -18
- package/commands/project/open.js +6 -7
- package/commands/project/upload.js +12 -10
- package/commands/project/watch.js +9 -10
- package/commands/remove.js +10 -8
- package/commands/sandbox/create.js +8 -9
- package/commands/sandbox/delete.js +16 -12
- package/commands/secrets/addSecret.js +6 -7
- package/commands/secrets/deleteSecret.js +6 -7
- package/commands/secrets/listSecrets.js +6 -6
- package/commands/secrets/updateSecret.js +6 -7
- package/commands/theme/generate-selectors.js +1 -1
- package/commands/theme/marketplace-validate.js +7 -8
- package/commands/theme/preview.js +5 -6
- package/commands/upload.js +18 -15
- package/commands/watch.js +9 -10
- package/lang/en.lyaml +78 -13
- package/lib/DevServerManager.js +2 -5
- package/lib/LocalDevManager.js +2 -2
- package/lib/buildAccount.js +3 -1
- package/lib/commonOpts.d.ts +35 -1
- package/lib/commonOpts.js +86 -67
- package/lib/constants.d.ts +0 -8
- package/lib/constants.js +1 -9
- package/lib/dependencyManagement.d.ts +3 -1
- package/lib/dependencyManagement.js +19 -0
- package/lib/developerTestAccounts.js +8 -5
- package/lib/doctor/Diagnosis.d.ts +27 -0
- package/lib/doctor/Diagnosis.js +119 -0
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +61 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +158 -0
- package/lib/doctor/Doctor.d.ts +21 -0
- package/lib/doctor/Doctor.js +328 -0
- package/lib/interpolation.d.ts +7 -0
- package/lib/interpolation.js +41 -48
- package/lib/lang.d.ts +8 -0
- package/lib/lang.js +37 -32
- package/lib/oauth.js +3 -1
- package/lib/process.d.ts +11 -0
- package/lib/process.js +16 -16
- package/lib/projects.d.ts +4 -1
- package/lib/projects.js +5 -3
- package/lib/prompts/accountNamePrompt.js +1 -2
- package/lib/prompts/accountsPrompt.js +8 -21
- package/lib/prompts/createFunctionPrompt.js +3 -4
- package/lib/prompts/projectDevTargetAccountPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +12 -1
- package/lib/prompts/promptUtils.js +24 -13
- package/lib/prompts/sandboxesPrompt.js +10 -7
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -2
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/SpinniesManager.d.ts +39 -1
- package/lib/ui/SpinniesManager.js +66 -35
- package/lib/ui/git.d.ts +1 -1
- package/lib/ui/git.js +17 -17
- package/lib/ui/index.d.ts +16 -1
- package/lib/ui/index.js +87 -114
- package/lib/ui/serverlessFunctionLogs.js +25 -20
- package/lib/ui/spinniesUtils.d.ts +31 -0
- package/lib/ui/spinniesUtils.js +45 -31
- package/lib/ui/supportHyperlinks.d.ts +6 -0
- package/lib/ui/supportHyperlinks.js +10 -10
- package/lib/ui/supportsColor.d.ts +16 -0
- package/lib/ui/supportsColor.js +19 -17
- package/lib/ui/table.d.ts +3 -1
- package/lib/ui/table.js +17 -11
- package/lib/usageTracking.d.ts +2 -1
- package/lib/usageTracking.js +12 -1
- package/lib/validation.js +0 -2
- package/package.json +7 -3
- 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/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/oauth.js
CHANGED
|
@@ -5,6 +5,7 @@ const express = require('express');
|
|
|
5
5
|
const open = require('open');
|
|
6
6
|
const { OAuth2Manager, } = require('@hubspot/local-dev-lib/models/OAuth2Manager');
|
|
7
7
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
8
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
8
9
|
const { addOauthToAccountConfig } = require('@hubspot/local-dev-lib/oauth');
|
|
9
10
|
const { handleExit } = require('./process');
|
|
10
11
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
@@ -74,7 +75,8 @@ const authorize = async (oauthManager) => {
|
|
|
74
75
|
});
|
|
75
76
|
};
|
|
76
77
|
const setupOauth = accountConfig => {
|
|
77
|
-
const
|
|
78
|
+
const id = getAccountIdentifier(accountConfig);
|
|
79
|
+
const accountId = parseInt(id, 10);
|
|
78
80
|
const config = getAccountConfig(accountId) || {};
|
|
79
81
|
return new OAuth2Manager({
|
|
80
82
|
...accountConfig,
|
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
|
+
}
|
package/lib/projects.d.ts
CHANGED
package/lib/projects.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProjectConfig = void 0;
|
|
3
4
|
// @ts-nocheck
|
|
4
5
|
const fs = require('fs-extra');
|
|
5
6
|
const path = require('path');
|
|
@@ -69,8 +70,9 @@ const getProjectConfig = async (_dir) => {
|
|
|
69
70
|
logger.error('Could not read from project config');
|
|
70
71
|
}
|
|
71
72
|
};
|
|
73
|
+
exports.getProjectConfig = getProjectConfig;
|
|
72
74
|
const createProjectConfig = async (projectPath, projectName, template, templateSource, githubRef) => {
|
|
73
|
-
const { projectConfig, projectDir } = await getProjectConfig(projectPath);
|
|
75
|
+
const { projectConfig, projectDir } = await (0, exports.getProjectConfig)(projectPath);
|
|
74
76
|
if (projectConfig) {
|
|
75
77
|
logger.warn(projectPath === projectDir
|
|
76
78
|
? 'A project already exists in that location.'
|
|
@@ -616,7 +618,7 @@ const logFeedbackMessage = buildId => {
|
|
|
616
618
|
const createProjectComponent = async (component, name, projectComponentsVersion) => {
|
|
617
619
|
const i18nKey = 'commands.project.subcommands.add';
|
|
618
620
|
const componentName = name;
|
|
619
|
-
const configInfo = await getProjectConfig();
|
|
621
|
+
const configInfo = await (0, exports.getProjectConfig)();
|
|
620
622
|
if (!configInfo.projectDir && !configInfo.projectConfig) {
|
|
621
623
|
logger.error(i18n(`${i18nKey}.error.locationInProject`));
|
|
622
624
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -660,7 +662,7 @@ const getProjectComponentsByVersion = async (projectComponentsVersion) => {
|
|
|
660
662
|
};
|
|
661
663
|
module.exports = {
|
|
662
664
|
writeProjectConfig,
|
|
663
|
-
getProjectConfig,
|
|
665
|
+
getProjectConfig: exports.getProjectConfig,
|
|
664
666
|
getIsInProject,
|
|
665
667
|
pollProjectBuildAndDeploy,
|
|
666
668
|
handleProjectUpload,
|
|
@@ -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,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const {
|
|
4
|
+
const { getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
5
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
5
6
|
const { promptUser } = require('./promptUtils');
|
|
6
7
|
const { i18n } = require('../lang');
|
|
7
8
|
const { uiAccountDescription } = require('../ui');
|
|
8
9
|
const mapAccountChoices = portals => portals.map(p => ({
|
|
9
|
-
name: uiAccountDescription(p
|
|
10
|
-
value: p.name || p
|
|
10
|
+
name: uiAccountDescription(getAccountIdentifier(p), false),
|
|
11
|
+
value: p.name || getAccountIdentifier(p),
|
|
11
12
|
}));
|
|
12
13
|
const i18nKey = 'commands.accounts.subcommands.use';
|
|
13
14
|
const selectAccountFromConfig = async (config, prompt) => {
|
|
15
|
+
const accountsList = getConfigAccounts();
|
|
16
|
+
const defaultAccount = getConfigDefaultAccount(config);
|
|
14
17
|
const { default: selectedDefault } = await promptUser([
|
|
15
18
|
{
|
|
16
19
|
type: 'list',
|
|
@@ -18,28 +21,12 @@ const selectAccountFromConfig = async (config, prompt) => {
|
|
|
18
21
|
name: 'default',
|
|
19
22
|
pageSize: 20,
|
|
20
23
|
message: prompt || i18n(`${i18nKey}.promptMessage`),
|
|
21
|
-
choices: mapAccountChoices(
|
|
22
|
-
default:
|
|
24
|
+
choices: mapAccountChoices(accountsList),
|
|
25
|
+
default: defaultAccount,
|
|
23
26
|
},
|
|
24
27
|
]);
|
|
25
28
|
return selectedDefault;
|
|
26
29
|
};
|
|
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
30
|
module.exports = {
|
|
42
|
-
selectAndSetAsDefaultAccountPrompt,
|
|
43
31
|
selectAccountFromConfig,
|
|
44
|
-
mapAccountChoices,
|
|
45
32
|
};
|
|
@@ -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;
|
|
@@ -8,11 +8,12 @@ const { isSandbox } = require('../accountTypes');
|
|
|
8
8
|
const { getAccountId } = require('@hubspot/local-dev-lib/config');
|
|
9
9
|
const { getSandboxUsageLimits, } = require('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
10
10
|
const { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
|
|
11
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
11
12
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
12
13
|
const { fetchDeveloperTestAccounts, } = require('@hubspot/local-dev-lib/api/developerTestAccounts');
|
|
13
14
|
const i18nKey = 'lib.prompts.projectDevTargetAccountPrompt';
|
|
14
15
|
const mapNestedAccount = accountConfig => ({
|
|
15
|
-
name: uiAccountDescription(accountConfig
|
|
16
|
+
name: uiAccountDescription(getAccountIdentifier(accountConfig), false),
|
|
16
17
|
value: {
|
|
17
18
|
targetAccountId: getAccountId(accountConfig.name),
|
|
18
19
|
createNestedAccount: false,
|
|
@@ -97,7 +98,7 @@ const selectDeveloperTestTargetAccountPrompt = async (accounts, defaultAccountCo
|
|
|
97
98
|
}
|
|
98
99
|
const devTestAccounts = [];
|
|
99
100
|
if (devTestAccountsResponse && devTestAccountsResponse.results) {
|
|
100
|
-
const accountIds = accounts.map(account => account
|
|
101
|
+
const accountIds = accounts.map(account => getAccountIdentifier(account));
|
|
101
102
|
devTestAccountsResponse.results.forEach(acct => {
|
|
102
103
|
const inConfig = accountIds.includes(acct.id);
|
|
103
104
|
devTestAccounts.push({
|
|
@@ -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
|
+
}
|
|
@@ -5,22 +5,24 @@ const { promptUser } = require('./promptUtils');
|
|
|
5
5
|
const { i18n } = require('../lang');
|
|
6
6
|
const { uiAccountDescription } = require('../ui');
|
|
7
7
|
const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
|
|
8
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
8
9
|
const { isSandbox } = require('../accountTypes');
|
|
10
|
+
const { getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
9
11
|
const i18nKey = 'lib.prompts.sandboxesPrompt';
|
|
10
12
|
const mapSandboxAccountChoices = portals => portals
|
|
11
13
|
.filter(p => isSandbox(p))
|
|
12
14
|
.map(p => {
|
|
13
15
|
return {
|
|
14
|
-
name: uiAccountDescription(p
|
|
15
|
-
value: p.name || p
|
|
16
|
+
name: uiAccountDescription(getAccountIdentifier(p), false),
|
|
17
|
+
value: p.name || getAccountIdentifier(p),
|
|
16
18
|
};
|
|
17
19
|
});
|
|
18
20
|
const mapNonSandboxAccountChoices = portals => portals
|
|
19
21
|
.filter(p => !isSandbox(p))
|
|
20
22
|
.map(p => {
|
|
21
23
|
return {
|
|
22
|
-
name: `${p.name} (${p
|
|
23
|
-
value: p.name || p
|
|
24
|
+
name: `${p.name} (${getAccountIdentifier(p)})`,
|
|
25
|
+
value: p.name || getAccountIdentifier(p),
|
|
24
26
|
};
|
|
25
27
|
});
|
|
26
28
|
const sandboxTypePrompt = () => {
|
|
@@ -45,9 +47,10 @@ const sandboxTypePrompt = () => {
|
|
|
45
47
|
]);
|
|
46
48
|
};
|
|
47
49
|
const deleteSandboxPrompt = (config, promptParentAccount = false) => {
|
|
50
|
+
const accountsList = getConfigAccounts();
|
|
48
51
|
const choices = promptParentAccount
|
|
49
|
-
? mapNonSandboxAccountChoices(
|
|
50
|
-
: mapSandboxAccountChoices(
|
|
52
|
+
? mapNonSandboxAccountChoices(accountsList)
|
|
53
|
+
: mapSandboxAccountChoices(accountsList);
|
|
51
54
|
if (!choices.length) {
|
|
52
55
|
return undefined;
|
|
53
56
|
}
|
|
@@ -61,7 +64,7 @@ const deleteSandboxPrompt = (config, promptParentAccount = false) => {
|
|
|
61
64
|
look: false,
|
|
62
65
|
pageSize: 20,
|
|
63
66
|
choices,
|
|
64
|
-
default: config
|
|
67
|
+
default: getConfigDefaultAccount(config),
|
|
65
68
|
},
|
|
66
69
|
]);
|
|
67
70
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
-
const { getConfig, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
4
|
+
const { getConfig, updateDefaultAccount, getConfigDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
5
5
|
const { promptUser } = require('./promptUtils');
|
|
6
6
|
const { i18n } = require('../lang');
|
|
7
7
|
const i18nKey = 'lib.prompts.setAsDefaultAccountPrompt';
|
|
8
8
|
const setAsDefaultAccountPrompt = async (accountName) => {
|
|
9
9
|
const config = getConfig();
|
|
10
|
+
// Accounts for deprecated and new config
|
|
11
|
+
const defaultAccount = getConfigDefaultAccount(config);
|
|
10
12
|
const { setAsDefault } = await promptUser([
|
|
11
13
|
{
|
|
12
14
|
name: 'setAsDefault',
|
|
13
15
|
type: 'confirm',
|
|
14
|
-
when:
|
|
16
|
+
when: defaultAccount !== accountName,
|
|
15
17
|
message: i18n(`${i18nKey}.setAsDefaultAccountMessage`),
|
|
16
18
|
},
|
|
17
19
|
]);
|
package/lib/sandboxSync.js
CHANGED
|
@@ -11,6 +11,7 @@ const { debugError, logError, ApiErrorContext, } = require('./errorHandlers/inde
|
|
|
11
11
|
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
12
12
|
const { getSandboxTypeAsString } = require('./sandboxes');
|
|
13
13
|
const { getAccountId } = require('@hubspot/local-dev-lib/config');
|
|
14
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
14
15
|
const { uiAccountDescription, uiLine, uiLink, uiCommandDisabledBanner, } = require('./ui');
|
|
15
16
|
const { isDevelopmentSandbox } = require('./accountTypes');
|
|
16
17
|
const i18nKey = 'lib.sandbox.sync';
|
|
@@ -22,8 +23,10 @@ const i18nKey = 'lib.sandbox.sync';
|
|
|
22
23
|
* @returns
|
|
23
24
|
*/
|
|
24
25
|
const syncSandbox = async ({ accountConfig, parentAccountConfig, env, syncTasks, slimInfoMessage = false, }) => {
|
|
25
|
-
const
|
|
26
|
-
const
|
|
26
|
+
const id = getAccountIdentifier(accountConfig);
|
|
27
|
+
const accountId = getAccountId(id);
|
|
28
|
+
const parentId = getAccountIdentifier(parentAccountConfig);
|
|
29
|
+
const parentAccountId = getAccountId(parentId);
|
|
27
30
|
const isDevSandbox = isDevelopmentSandbox(accountConfig);
|
|
28
31
|
SpinniesManager.init({
|
|
29
32
|
succeedColor: 'white',
|
package/lib/sandboxes.js
CHANGED
|
@@ -5,11 +5,12 @@ const { i18n } = require('./lang');
|
|
|
5
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
6
6
|
const { getSandboxUsageLimits, } = require('@hubspot/local-dev-lib/api/sandboxHubs');
|
|
7
7
|
const { fetchTypes } = require('@hubspot/local-dev-lib/api/sandboxSync');
|
|
8
|
-
const {
|
|
8
|
+
const { getAccountId, getEnv, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
9
9
|
const { promptUser } = require('./prompts/promptUtils');
|
|
10
10
|
const { isDevelopmentSandbox } = require('./accountTypes');
|
|
11
11
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
12
12
|
const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
|
|
13
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
13
14
|
const { uiAccountDescription } = require('./ui');
|
|
14
15
|
const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
|
|
15
16
|
const { getValidEnv } = require('@hubspot/local-dev-lib/environment');
|
|
@@ -34,9 +35,10 @@ const getSandboxTypeAsString = accountType => {
|
|
|
34
35
|
return 'standard';
|
|
35
36
|
};
|
|
36
37
|
function getHasSandboxesByType(parentAccountConfig, type) {
|
|
37
|
-
const
|
|
38
|
-
const parentPortalId = getAccountId(
|
|
39
|
-
|
|
38
|
+
const id = getAccountIdentifier(parentAccountConfig);
|
|
39
|
+
const parentPortalId = getAccountId(id);
|
|
40
|
+
const accountsList = getConfigAccounts();
|
|
41
|
+
for (const portal of accountsList) {
|
|
40
42
|
if ((portal.parentAccountId !== null ||
|
|
41
43
|
portal.parentAccountId !== undefined) &&
|
|
42
44
|
portal.parentAccountId === parentPortalId &&
|
|
@@ -54,8 +56,10 @@ function getSandboxLimit(error) {
|
|
|
54
56
|
}
|
|
55
57
|
// Fetches available sync types for a given sandbox portal
|
|
56
58
|
async function getAvailableSyncTypes(parentAccountConfig, config) {
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
+
const parentId = getAccountIdentifier(parentAccountConfig);
|
|
60
|
+
const parentPortalId = getAccountId(parentId);
|
|
61
|
+
const id = getAccountIdentifier(config);
|
|
62
|
+
const portalId = getAccountId(id);
|
|
59
63
|
const { data: { results: syncTypes }, } = await fetchTypes(parentPortalId, portalId);
|
|
60
64
|
if (!syncTypes) {
|
|
61
65
|
throw new Error('Unable to fetch available sandbox sync types. Please try again.');
|
|
@@ -98,7 +102,8 @@ const getSyncTypesWithContactRecordsPrompt = async (accountConfig, syncTasks, sk
|
|
|
98
102
|
* @returns {null}
|
|
99
103
|
*/
|
|
100
104
|
const validateSandboxUsageLimits = async (accountConfig, sandboxType, env) => {
|
|
101
|
-
const
|
|
105
|
+
const id = getAccountIdentifier(accountConfig);
|
|
106
|
+
const accountId = getAccountId(id);
|
|
102
107
|
const { data: { usage }, } = await getSandboxUsageLimits(accountId);
|
|
103
108
|
if (!usage) {
|
|
104
109
|
throw new Error('Unable to fetch sandbox usage limits. Please try again.');
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import { SpinnerOptions as BaseSpinnerOptions, VALID_STATUSES } from './spinniesUtils';
|
|
2
|
+
interface SpinnerState extends BaseSpinnerOptions {
|
|
3
|
+
name?: string;
|
|
4
|
+
}
|
|
5
|
+
declare class SpinniesManager {
|
|
6
|
+
private options;
|
|
7
|
+
private spinners;
|
|
8
|
+
private isCursorHidden;
|
|
9
|
+
private currentInterval;
|
|
10
|
+
private stream;
|
|
11
|
+
private lineCount;
|
|
12
|
+
private currentFrameIndex;
|
|
13
|
+
private spin;
|
|
14
|
+
constructor();
|
|
15
|
+
init(options?: Partial<SpinnerState>): void;
|
|
16
|
+
private resetState;
|
|
17
|
+
pick(name: string): SpinnerState | undefined;
|
|
18
|
+
add(name: string, options?: Partial<SpinnerState>): SpinnerState & {
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
update(name: string, options?: Partial<SpinnerState>): SpinnerState;
|
|
22
|
+
succeed(name: string, options?: Partial<SpinnerState>): SpinnerState;
|
|
23
|
+
fail(name: string, options?: Partial<SpinnerState>): SpinnerState;
|
|
24
|
+
remove(name: string): SpinnerState;
|
|
25
|
+
stopAll(newStatus?: typeof VALID_STATUSES[number]): {
|
|
26
|
+
[key: string]: SpinnerState;
|
|
27
|
+
};
|
|
28
|
+
private hasAnySpinners;
|
|
29
|
+
hasActiveSpinners(): boolean;
|
|
30
|
+
private setSpinnerProperties;
|
|
31
|
+
private updateSpinnerState;
|
|
32
|
+
private loopStream;
|
|
33
|
+
private setStreamOutput;
|
|
34
|
+
private setRawStreamOutput;
|
|
35
|
+
private checkIfActiveSpinners;
|
|
36
|
+
private bindSigint;
|
|
37
|
+
}
|
|
38
|
+
declare const toExport: SpinniesManager;
|
|
39
|
+
export default toExport;
|