@hubspot/cli 6.4.0 → 7.0.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 +36 -15
- package/commands/{accounts → account}/clean.js +10 -9
- package/commands/{accounts → account}/info.js +10 -14
- package/commands/{accounts → account}/list.js +16 -13
- package/commands/{accounts → account}/remove.js +8 -8
- package/commands/{accounts → account}/rename.js +4 -5
- package/commands/{accounts → account}/use.js +5 -8
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -23
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -19
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -22
- package/commands/config.js +2 -2
- package/commands/create.js +5 -3
- package/commands/customObject/create.js +18 -13
- package/commands/customObject/schema/create.js +14 -14
- package/commands/customObject/schema/delete.js +29 -9
- package/commands/customObject/schema/fetch-all.js +14 -9
- package/commands/customObject/schema/fetch.js +22 -12
- package/commands/customObject/schema/list.js +3 -4
- package/commands/customObject/schema/update.js +27 -16
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +2 -0
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -12
- package/commands/filemanager/fetch.js +6 -5
- package/commands/filemanager/upload.js +10 -10
- package/commands/filemanager.js +0 -4
- package/commands/{functions → function}/deploy.js +13 -11
- package/commands/{functions → function}/list.js +7 -7
- package/commands/{functions → function}/server.js +5 -6
- package/commands/function.js +20 -0
- package/commands/hubdb/clear.js +14 -8
- package/commands/hubdb/create.js +36 -11
- package/commands/hubdb/delete.js +31 -8
- package/commands/hubdb/fetch.js +14 -7
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -5
- package/commands/list.js +5 -5
- package/commands/logs.js +24 -13
- package/commands/module/marketplace-validate.js +6 -7
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -11
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -3
- package/commands/project/cloneApp.js +28 -30
- package/commands/project/create.js +8 -8
- package/commands/project/deploy.js +16 -13
- package/commands/project/dev.js +14 -14
- package/commands/project/download.js +18 -13
- package/commands/project/listBuilds.js +34 -29
- package/commands/project/logs.js +5 -5
- package/commands/project/migrateApp.js +27 -25
- package/commands/project/open.js +7 -8
- package/commands/project/upload.js +27 -29
- package/commands/project/watch.js +12 -19
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -11
- package/commands/sandbox/create.js +12 -13
- package/commands/sandbox/delete.js +15 -13
- package/commands/sandbox.js +3 -4
- package/commands/{secrets → secret}/addSecret.js +24 -9
- package/commands/secret/deleteSecret.js +71 -0
- package/commands/{secrets → secret}/listSecrets.js +6 -6
- package/commands/secret/updateSecret.d.ts +1 -0
- package/commands/{secrets → secret}/updateSecret.js +20 -10
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -11
- package/commands/theme/preview.js +6 -7
- package/commands/theme.js +3 -1
- package/commands/upload.js +28 -24
- package/commands/watch.js +19 -19
- package/lang/en.lyaml +177 -111
- package/lib/buildAccount.js +3 -1
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -38
- package/lib/configOptions.js +19 -18
- package/lib/developerTestAccounts.js +8 -5
- package/lib/oauth.js +3 -1
- package/lib/projects.js +10 -5
- package/lib/prompts/accountsPrompt.js +9 -5
- package/lib/prompts/createModulePrompt.js +17 -2
- package/lib/prompts/createProjectPrompt.js +5 -5
- package/lib/prompts/projectDevTargetAccountPrompt.js +3 -2
- package/lib/prompts/promptUtils.d.ts +3 -0
- package/lib/prompts/promptUtils.js +14 -2
- package/lib/prompts/sandboxesPrompt.js +10 -7
- package/lib/prompts/secretPrompt.d.ts +3 -1
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +8 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -2
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/validation.js +14 -13
- package/package.json +5 -4
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
package/lib/buildAccount.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { getAccessToken, updateConfigWithAccessToken, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
5
5
|
const { personalAccessKeyPrompt, } = require('./prompts/personalAccessKeyPrompt');
|
|
6
6
|
const { accountNameExistsInConfig, updateAccountConfig, writeConfig, getAccountId, } = require('@hubspot/local-dev-lib/config');
|
|
7
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
7
8
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
8
9
|
const { i18n } = require('./lang');
|
|
9
10
|
const { cliAccountNamePrompt } = require('./prompts/accountNamePrompt');
|
|
@@ -62,7 +63,8 @@ force = false, }) {
|
|
|
62
63
|
SpinniesManager.init({
|
|
63
64
|
succeedColor: 'white',
|
|
64
65
|
});
|
|
65
|
-
const
|
|
66
|
+
const id = getAccountIdentifier(accountConfig);
|
|
67
|
+
const accountId = getAccountId(id);
|
|
66
68
|
const isSandbox = accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX ||
|
|
67
69
|
accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX;
|
|
68
70
|
const isDeveloperTestAccount = accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST;
|
package/lib/commonOpts.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
1
2
|
import { Argv, Arguments } from 'yargs';
|
|
2
|
-
|
|
3
|
+
export declare function addGlobalOptions(yargs: Argv): Argv<{
|
|
4
|
+
debug: boolean;
|
|
5
|
+
}>;
|
|
3
6
|
export declare function addAccountOptions(yargs: Argv): Argv;
|
|
4
7
|
export declare function addConfigOptions(yargs: Argv): Argv;
|
|
5
8
|
export declare function addOverwriteOptions(yargs: Argv): Argv;
|
|
6
|
-
export declare function
|
|
9
|
+
export declare function addCmsPublishModeOptions(yargs: Argv, { read, write }: {
|
|
7
10
|
read?: boolean;
|
|
8
11
|
write?: boolean;
|
|
9
12
|
}): Argv;
|
|
@@ -19,9 +22,15 @@ export declare function getCommandName(argv: Arguments<{
|
|
|
19
22
|
* Obtains accountId using supplied --account flag or from environment variables
|
|
20
23
|
*/
|
|
21
24
|
export declare function getAccountId(options: Arguments<{
|
|
22
|
-
portal?: number | string;
|
|
23
25
|
account?: number | string;
|
|
24
26
|
}>): number | null;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Auto-injects the derivedAccountId flag into all commands
|
|
29
|
+
*/
|
|
30
|
+
export declare function injectAccountIdMiddleware(options: Arguments<{
|
|
31
|
+
derivedAccountId?: number | null;
|
|
32
|
+
account?: number | string;
|
|
33
|
+
}>): Promise<void>;
|
|
34
|
+
export declare function getCmsPublishMode(options: Arguments<{
|
|
35
|
+
cmsPublishMode?: CmsPublishMode;
|
|
36
|
+
}>): CmsPublishMode;
|
package/lib/commonOpts.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addGlobalOptions = addGlobalOptions;
|
|
3
4
|
exports.addAccountOptions = addAccountOptions;
|
|
4
5
|
exports.addConfigOptions = addConfigOptions;
|
|
5
6
|
exports.addOverwriteOptions = addOverwriteOptions;
|
|
6
|
-
exports.
|
|
7
|
+
exports.addCmsPublishModeOptions = addCmsPublishModeOptions;
|
|
7
8
|
exports.addTestingOptions = addTestingOptions;
|
|
8
9
|
exports.addUseEnvironmentOptions = addUseEnvironmentOptions;
|
|
9
10
|
exports.setLogLevel = setLogLevel;
|
|
10
11
|
exports.getCommandName = getCommandName;
|
|
11
12
|
exports.getAccountId = getAccountId;
|
|
12
|
-
exports.
|
|
13
|
+
exports.injectAccountIdMiddleware = injectAccountIdMiddleware;
|
|
14
|
+
exports.getCmsPublishMode = getCmsPublishMode;
|
|
13
15
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
14
16
|
const files_1 = require("@hubspot/local-dev-lib/constants/files");
|
|
15
17
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
16
18
|
const lang_1 = require("./lang");
|
|
17
19
|
const i18nKey = 'lib.commonOpts';
|
|
20
|
+
function addGlobalOptions(yargs) {
|
|
21
|
+
yargs.version(false);
|
|
22
|
+
return yargs.option('debug', {
|
|
23
|
+
alias: 'd',
|
|
24
|
+
default: false,
|
|
25
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.debug.describe`),
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
18
29
|
function addAccountOptions(yargs) {
|
|
19
|
-
return yargs.option('
|
|
20
|
-
alias:
|
|
21
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.
|
|
30
|
+
return yargs.option('account', {
|
|
31
|
+
alias: 'a',
|
|
32
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
22
33
|
type: 'string',
|
|
23
34
|
});
|
|
24
35
|
}
|
|
@@ -37,11 +48,11 @@ function addOverwriteOptions(yargs) {
|
|
|
37
48
|
default: false,
|
|
38
49
|
});
|
|
39
50
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
return yargs.option('mode', {
|
|
51
|
+
function addCmsPublishModeOptions(yargs, { read, write }) {
|
|
52
|
+
const cmsPublishModes = `<${Object.values(files_1.CMS_PUBLISH_MODE).join(' | ')}>`;
|
|
53
|
+
return yargs.option('cms-publish-mode', {
|
|
43
54
|
alias: 'm',
|
|
44
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.modes.describe.${read ? 'read' : write ? 'write' : 'default'}`, { modes }),
|
|
55
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.modes.describe.${read ? 'read' : write ? 'write' : 'default'}`, { modes: cmsPublishModes }),
|
|
45
56
|
type: 'string',
|
|
46
57
|
});
|
|
47
58
|
}
|
|
@@ -54,11 +65,13 @@ function addTestingOptions(yargs) {
|
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
67
|
function addUseEnvironmentOptions(yargs) {
|
|
57
|
-
return yargs
|
|
68
|
+
return yargs
|
|
69
|
+
.option('use-env', {
|
|
58
70
|
describe: (0, lang_1.i18n)(`${i18nKey}.options.useEnv.describe`),
|
|
59
71
|
type: 'boolean',
|
|
60
72
|
default: false,
|
|
61
|
-
})
|
|
73
|
+
})
|
|
74
|
+
.conflicts('use-env', 'account');
|
|
62
75
|
}
|
|
63
76
|
function setLogLevel(options) {
|
|
64
77
|
const { debug } = options;
|
|
@@ -76,40 +89,42 @@ function getCommandName(argv) {
|
|
|
76
89
|
* Obtains accountId using supplied --account flag or from environment variables
|
|
77
90
|
*/
|
|
78
91
|
function getAccountId(options) {
|
|
79
|
-
const {
|
|
80
|
-
if (options?.useEnv && process.env.
|
|
81
|
-
return parseInt(process.env.
|
|
92
|
+
const { account } = options || {};
|
|
93
|
+
if (options?.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
94
|
+
return parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
95
|
+
}
|
|
96
|
+
return (0, config_1.getAccountId)(account);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Auto-injects the derivedAccountId flag into all commands
|
|
100
|
+
*/
|
|
101
|
+
async function injectAccountIdMiddleware(options) {
|
|
102
|
+
const { account } = options;
|
|
103
|
+
// Preserves the original --account flag for certain commands.
|
|
104
|
+
options.providedAccountId = account;
|
|
105
|
+
if (options.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
106
|
+
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
107
|
+
return;
|
|
82
108
|
}
|
|
83
|
-
|
|
109
|
+
options.derivedAccountId = (0, config_1.getAccountId)(account);
|
|
84
110
|
}
|
|
85
|
-
function
|
|
86
|
-
// 1. --
|
|
87
|
-
const {
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
111
|
+
function getCmsPublishMode(options) {
|
|
112
|
+
// 1. --cmsPublishMode
|
|
113
|
+
const { cmsPublishMode } = options;
|
|
114
|
+
if (cmsPublishMode && typeof cmsPublishMode === 'string') {
|
|
115
|
+
return cmsPublishMode.toLowerCase();
|
|
90
116
|
}
|
|
91
|
-
// 2. config[
|
|
117
|
+
// 2. config[account].defaultCmsPublishMode
|
|
92
118
|
const accountId = getAccountId(options);
|
|
93
119
|
if (accountId) {
|
|
94
120
|
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
95
|
-
if (accountConfig && accountConfig.
|
|
96
|
-
return accountConfig.
|
|
121
|
+
if (accountConfig && accountConfig.defaultCmsPublishMode) {
|
|
122
|
+
return accountConfig.defaultCmsPublishMode;
|
|
97
123
|
}
|
|
98
124
|
}
|
|
99
|
-
// 3. config.
|
|
100
|
-
// 4.
|
|
125
|
+
// 3. config.defaultCmsPublishMode
|
|
126
|
+
// 4. DEFAULT_CMS_PUBLISH_MODE
|
|
101
127
|
const config = (0, config_1.getAndLoadConfigIfNeeded)();
|
|
102
|
-
return (config && config.
|
|
128
|
+
return ((config && config.defaultCmsPublishMode) ||
|
|
129
|
+
files_1.DEFAULT_CMS_PUBLISH_MODE);
|
|
103
130
|
}
|
|
104
|
-
module.exports = {
|
|
105
|
-
addAccountOptions,
|
|
106
|
-
addConfigOptions,
|
|
107
|
-
addOverwriteOptions,
|
|
108
|
-
addModeOptions,
|
|
109
|
-
addTestingOptions,
|
|
110
|
-
addUseEnvironmentOptions,
|
|
111
|
-
getCommandName,
|
|
112
|
-
getMode,
|
|
113
|
-
getAccountId,
|
|
114
|
-
setLogLevel,
|
|
115
|
-
};
|
package/lib/configOptions.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const { updateAllowUsageTracking,
|
|
6
|
-
const {
|
|
5
|
+
const { updateAllowUsageTracking, updateDefaultCmsPublishMode, updateHttpTimeout, } = require('@hubspot/local-dev-lib/config');
|
|
6
|
+
const { CMS_PUBLISH_MODE } = require('@hubspot/local-dev-lib/constants/files');
|
|
7
7
|
const { commaSeparatedValues } = require('@hubspot/local-dev-lib/text');
|
|
8
8
|
const { trackCommandUsage } = require('./usageTracking');
|
|
9
9
|
const { promptUser } = require('./prompts/promptUtils');
|
|
@@ -44,38 +44,39 @@ const setAllowUsageTracking = async ({ accountId, allowUsageTracking }) => {
|
|
|
44
44
|
updateAllowUsageTracking(isEnabled);
|
|
45
45
|
return logger.log(i18n(`${i18nKey}.allowUsageTracking.success`, { isEnabled }));
|
|
46
46
|
};
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const {
|
|
47
|
+
const ALL_CMS_PUBLISH_MODES = Object.values(CMS_PUBLISH_MODE);
|
|
48
|
+
const selectCmsPublishMode = async () => {
|
|
49
|
+
const { cmsPublishMode } = await promptUser([
|
|
50
50
|
{
|
|
51
51
|
type: 'list',
|
|
52
52
|
look: false,
|
|
53
|
-
name: '
|
|
53
|
+
name: 'cmsPublishMode',
|
|
54
54
|
pageSize: 20,
|
|
55
55
|
message: i18n(`${i18nKey}.defaultMode.promptMessage`),
|
|
56
|
-
choices:
|
|
57
|
-
default:
|
|
56
|
+
choices: ALL_CMS_PUBLISH_MODES,
|
|
57
|
+
default: CMS_PUBLISH_MODE.publish,
|
|
58
58
|
},
|
|
59
59
|
]);
|
|
60
|
-
return
|
|
60
|
+
return cmsPublishMode;
|
|
61
61
|
};
|
|
62
|
-
const
|
|
62
|
+
const setDefaultCmsPublishMode = async ({ accountId, defaultCmsPublishMode, }) => {
|
|
63
63
|
trackCommandUsage('config-set-default-mode', null, accountId);
|
|
64
64
|
let newDefault;
|
|
65
|
-
if (!
|
|
66
|
-
newDefault = await
|
|
65
|
+
if (!defaultCmsPublishMode) {
|
|
66
|
+
newDefault = await selectCmsPublishMode();
|
|
67
67
|
}
|
|
68
|
-
else if (
|
|
69
|
-
|
|
68
|
+
else if (defaultCmsPublishMode &&
|
|
69
|
+
ALL_CMS_PUBLISH_MODES.find(m => m === defaultCmsPublishMode)) {
|
|
70
|
+
newDefault = defaultCmsPublishMode;
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
73
|
logger.error(i18n(`${i18nKey}.defaultMode.errors`, {
|
|
73
74
|
mode: newDefault,
|
|
74
|
-
validModes: commaSeparatedValues(
|
|
75
|
+
validModes: commaSeparatedValues(ALL_CMS_PUBLISH_MODES),
|
|
75
76
|
}));
|
|
76
|
-
newDefault = await
|
|
77
|
+
newDefault = await selectCMsPublishMode();
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
+
updateDefaultCmsPublishMode(newDefault);
|
|
79
80
|
return logger.success(i18n(`${i18nKey}.defaultMode.success`, {
|
|
80
81
|
mode: newDefault,
|
|
81
82
|
}));
|
|
@@ -105,6 +106,6 @@ const setHttpTimeout = async ({ accountId, httpTimeout }) => {
|
|
|
105
106
|
};
|
|
106
107
|
module.exports = {
|
|
107
108
|
setAllowUsageTracking,
|
|
108
|
-
|
|
109
|
+
setDefaultCmsPublishMode,
|
|
109
110
|
setHttpTimeout,
|
|
110
111
|
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { HUBSPOT_ACCOUNT_TYPES, } = require('@hubspot/local-dev-lib/constants/config');
|
|
5
|
-
const { getAccountId,
|
|
5
|
+
const { getAccountId, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
6
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
6
7
|
const { i18n } = require('./lang');
|
|
7
8
|
const { fetchDeveloperTestAccounts, } = require('@hubspot/local-dev-lib/api/developerTestAccounts');
|
|
8
9
|
const { isMissingScopeError, isSpecifiedError, } = require('@hubspot/local-dev-lib/errors/index');
|
|
@@ -11,9 +12,10 @@ const { uiAccountDescription } = require('./ui');
|
|
|
11
12
|
const { getHubSpotWebsiteOrigin } = require('@hubspot/local-dev-lib/urls');
|
|
12
13
|
const { logError } = require('./errorHandlers/index');
|
|
13
14
|
const getHasDevTestAccounts = appDeveloperAccountConfig => {
|
|
14
|
-
const
|
|
15
|
-
const parentPortalId = getAccountId(
|
|
16
|
-
|
|
15
|
+
const id = getAccountIdentifier(appDeveloperAccountConfig);
|
|
16
|
+
const parentPortalId = getAccountId(id);
|
|
17
|
+
const accountsList = getConfigAccounts();
|
|
18
|
+
for (const portal of accountsList) {
|
|
17
19
|
if (Boolean(portal.parentAccountId) &&
|
|
18
20
|
portal.parentAccountId === parentPortalId &&
|
|
19
21
|
portal.accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST) {
|
|
@@ -23,7 +25,8 @@ const getHasDevTestAccounts = appDeveloperAccountConfig => {
|
|
|
23
25
|
return false;
|
|
24
26
|
};
|
|
25
27
|
const validateDevTestAccountUsageLimits = async (accountConfig) => {
|
|
26
|
-
const
|
|
28
|
+
const id = getAccountIdentifier(accountConfig);
|
|
29
|
+
const accountId = getAccountId(id);
|
|
27
30
|
const { data } = await fetchDeveloperTestAccounts(accountId);
|
|
28
31
|
if (!data) {
|
|
29
32
|
return null;
|
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/projects.js
CHANGED
|
@@ -21,7 +21,7 @@ const { getCwd, getAbsoluteFilePath } = require('@hubspot/local-dev-lib/path');
|
|
|
21
21
|
const { downloadGithubRepoContents } = require('@hubspot/local-dev-lib/github');
|
|
22
22
|
const { promptUser } = require('./prompts/promptUtils');
|
|
23
23
|
const { EXIT_CODES } = require('./enums/exitCodes');
|
|
24
|
-
const { uiLine, uiLink, uiAccountDescription } = require('./ui');
|
|
24
|
+
const { uiLine, uiLink, uiAccountDescription, uiCommandReference, } = require('./ui');
|
|
25
25
|
const { i18n } = require('./lang');
|
|
26
26
|
const SpinniesManager = require('./ui/SpinniesManager');
|
|
27
27
|
const { logError, ApiErrorContext } = require('./errorHandlers/index');
|
|
@@ -109,24 +109,29 @@ const createProjectConfig = async (projectPath, projectName, template, templateS
|
|
|
109
109
|
};
|
|
110
110
|
const validateProjectConfig = (projectConfig, projectDir) => {
|
|
111
111
|
if (!projectConfig) {
|
|
112
|
-
logger.error(
|
|
112
|
+
logger.error(i18n(`${i18nKey}.validateProjectConfig.configNotFound`, {
|
|
113
|
+
createCommand: uiCommandReference('hs project create'),
|
|
114
|
+
}));
|
|
113
115
|
return process.exit(EXIT_CODES.ERROR);
|
|
114
116
|
}
|
|
115
117
|
if (!projectConfig.name || !projectConfig.srcDir) {
|
|
116
|
-
logger.error(
|
|
118
|
+
logger.error(i18n(`${i18nKey}.validateProjectConfig.configMissingFields`));
|
|
117
119
|
return process.exit(EXIT_CODES.ERROR);
|
|
118
120
|
}
|
|
119
121
|
const resolvedPath = path.resolve(projectDir, projectConfig.srcDir);
|
|
120
122
|
if (!resolvedPath.startsWith(projectDir)) {
|
|
121
123
|
const projectConfigFile = path.relative('.', path.join(projectDir, PROJECT_CONFIG_FILE));
|
|
122
|
-
logger.error(i18n(`${i18nKey}.
|
|
124
|
+
logger.error(i18n(`${i18nKey}.validateProjectConfig.srcOutsideProjectDir`, {
|
|
123
125
|
srcDir: projectConfig.srcDir,
|
|
124
126
|
projectConfig: projectConfigFile,
|
|
125
127
|
}));
|
|
126
128
|
return process.exit(EXIT_CODES.ERROR);
|
|
127
129
|
}
|
|
128
130
|
if (!fs.existsSync(resolvedPath)) {
|
|
129
|
-
logger.error(
|
|
131
|
+
logger.error(i18n(`${i18nKey}.validateProjectConfig.srcDirNotFound`, {
|
|
132
|
+
srcDir: projectConfig.srcDir,
|
|
133
|
+
projectDir: projectDir,
|
|
134
|
+
}));
|
|
130
135
|
return process.exit(EXIT_CODES.ERROR);
|
|
131
136
|
}
|
|
132
137
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
const { getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
5
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
4
6
|
const { promptUser } = require('./promptUtils');
|
|
5
7
|
const { i18n } = require('../lang');
|
|
6
8
|
const { uiAccountDescription } = require('../ui');
|
|
7
9
|
const mapAccountChoices = portals => portals.map(p => ({
|
|
8
|
-
name: uiAccountDescription(p
|
|
9
|
-
value: p.name || p
|
|
10
|
+
name: uiAccountDescription(getAccountIdentifier(p), false),
|
|
11
|
+
value: p.name || getAccountIdentifier(p),
|
|
10
12
|
}));
|
|
11
|
-
const i18nKey = 'commands.
|
|
13
|
+
const i18nKey = 'commands.account.subcommands.use';
|
|
12
14
|
const selectAccountFromConfig = async (config, prompt) => {
|
|
15
|
+
const accountsList = getConfigAccounts();
|
|
16
|
+
const defaultAccount = getConfigDefaultAccount(config);
|
|
13
17
|
const { default: selectedDefault } = await promptUser([
|
|
14
18
|
{
|
|
15
19
|
type: 'list',
|
|
@@ -17,8 +21,8 @@ const selectAccountFromConfig = async (config, prompt) => {
|
|
|
17
21
|
name: 'default',
|
|
18
22
|
pageSize: 20,
|
|
19
23
|
message: prompt || i18n(`${i18nKey}.promptMessage`),
|
|
20
|
-
choices: mapAccountChoices(
|
|
21
|
-
default:
|
|
24
|
+
choices: mapAccountChoices(accountsList),
|
|
25
|
+
default: defaultAccount,
|
|
22
26
|
},
|
|
23
27
|
]);
|
|
24
28
|
return selectedDefault;
|
|
@@ -27,12 +27,20 @@ const CONTENT_TYPES_PROMPT = {
|
|
|
27
27
|
type: 'checkbox',
|
|
28
28
|
name: 'contentTypes',
|
|
29
29
|
message: i18n(`${i18nKey}.selectContentType`),
|
|
30
|
-
default: ['
|
|
30
|
+
default: ['ANY'],
|
|
31
31
|
choices: [
|
|
32
|
-
{ name: '
|
|
32
|
+
{ name: 'Any', value: 'ANY' },
|
|
33
|
+
{ name: 'Landing page', value: 'LANDING_PAGE' },
|
|
34
|
+
{ name: 'Site page', value: 'SITE_PAGE' },
|
|
33
35
|
{ name: 'Blog post', value: 'BLOG_POST' },
|
|
34
36
|
{ name: 'Blog listing', value: 'BLOG_LISTING' },
|
|
35
37
|
{ name: 'Email', value: 'EMAIL' },
|
|
38
|
+
{ name: 'Knowledge base', value: 'KNOWLEDGE_BASE' },
|
|
39
|
+
{ name: 'Quote template', value: 'QUOTE_TEMPLATE' },
|
|
40
|
+
{ name: 'Customer portal', value: 'CUSTOMER_PORTAL' },
|
|
41
|
+
{ name: 'Web interactive', value: 'WEB_INTERACTIVE' },
|
|
42
|
+
{ name: 'Subscription', value: 'SUBSCRIPTION' },
|
|
43
|
+
{ name: 'Membership', value: 'MEMBERSHIP' },
|
|
36
44
|
],
|
|
37
45
|
validate: input => {
|
|
38
46
|
return new Promise(function (resolve, reject) {
|
|
@@ -49,12 +57,19 @@ const GLOBAL_PROMPT = {
|
|
|
49
57
|
message: i18n(`${i18nKey}.confirmGlobal`),
|
|
50
58
|
default: false,
|
|
51
59
|
};
|
|
60
|
+
const AVAILABLE_FOR_NEW_CONTENT = {
|
|
61
|
+
type: 'confirm',
|
|
62
|
+
name: 'availableForNewContent',
|
|
63
|
+
message: i18n(`${i18nKey}.availableForNewContent`),
|
|
64
|
+
default: true,
|
|
65
|
+
};
|
|
52
66
|
function createModulePrompt() {
|
|
53
67
|
return promptUser([
|
|
54
68
|
MODULE_LABEL_PROMPT,
|
|
55
69
|
REACT_TYPE_PROMPT,
|
|
56
70
|
CONTENT_TYPES_PROMPT,
|
|
57
71
|
GLOBAL_PROMPT,
|
|
72
|
+
AVAILABLE_FOR_NEW_CONTENT,
|
|
58
73
|
]);
|
|
59
74
|
}
|
|
60
75
|
module.exports = {
|
|
@@ -57,19 +57,19 @@ const createProjectPrompt = async (githubRef, promptOptions = {}, skipTemplatePr
|
|
|
57
57
|
},
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
|
-
name: '
|
|
61
|
-
message: i18n(`${i18nKey}.
|
|
62
|
-
when: !promptOptions.
|
|
60
|
+
name: 'dest',
|
|
61
|
+
message: i18n(`${i18nKey}.enterDest`),
|
|
62
|
+
when: !promptOptions.dest,
|
|
63
63
|
default: answers => {
|
|
64
64
|
const projectName = sanitizeFileName(answers.name || promptOptions.name);
|
|
65
65
|
return path.resolve(getCwd(), projectName);
|
|
66
66
|
},
|
|
67
67
|
validate: input => {
|
|
68
68
|
if (!input) {
|
|
69
|
-
return i18n(`${i18nKey}.errors.
|
|
69
|
+
return i18n(`${i18nKey}.errors.destRequired`);
|
|
70
70
|
}
|
|
71
71
|
if (fs.existsSync(input)) {
|
|
72
|
-
return i18n(`${i18nKey}.errors.
|
|
72
|
+
return i18n(`${i18nKey}.errors.invalidDest`);
|
|
73
73
|
}
|
|
74
74
|
if (!isValidPath(input)) {
|
|
75
75
|
return i18n(`${i18nKey}.errors.invalidCharacters`);
|
|
@@ -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({
|
|
@@ -10,3 +10,6 @@ export declare function listPrompt(message: string, { choices, when, }: {
|
|
|
10
10
|
}>;
|
|
11
11
|
when?: boolean | (() => boolean);
|
|
12
12
|
}): Promise<string>;
|
|
13
|
+
export declare function inputPrompt(message: string, { when, }?: {
|
|
14
|
+
when?: boolean | (() => boolean);
|
|
15
|
+
}): Promise<string>;
|
|
@@ -3,18 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.promptUser = void 0;
|
|
4
4
|
exports.confirmPrompt = confirmPrompt;
|
|
5
5
|
exports.listPrompt = listPrompt;
|
|
6
|
+
exports.inputPrompt = inputPrompt;
|
|
6
7
|
const inquirer = require('inquirer');
|
|
7
8
|
// NOTE: we can eventually delete this and directly use inquirer.prompt when the files support imports
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
10
|
exports.promptUser = inquirer.createPromptModule();
|
|
10
11
|
async function confirmPrompt(message, options = {}) {
|
|
11
|
-
const { defaultAnswer, when } = options;
|
|
12
|
+
const { defaultAnswer = true, when } = options;
|
|
12
13
|
const { choice } = await (0, exports.promptUser)([
|
|
13
14
|
{
|
|
14
15
|
name: 'choice',
|
|
15
16
|
type: 'confirm',
|
|
16
17
|
message,
|
|
17
|
-
default: defaultAnswer
|
|
18
|
+
default: defaultAnswer,
|
|
18
19
|
when,
|
|
19
20
|
},
|
|
20
21
|
]);
|
|
@@ -32,3 +33,14 @@ async function listPrompt(message, { choices, when, }) {
|
|
|
32
33
|
]);
|
|
33
34
|
return choice;
|
|
34
35
|
}
|
|
36
|
+
async function inputPrompt(message, { when, } = {}) {
|
|
37
|
+
const { input } = await (0, exports.promptUser)([
|
|
38
|
+
{
|
|
39
|
+
name: 'input',
|
|
40
|
+
type: 'input',
|
|
41
|
+
message,
|
|
42
|
+
when,
|
|
43
|
+
},
|
|
44
|
+
]);
|
|
45
|
+
return input;
|
|
46
|
+
}
|
|
@@ -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,24 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.secretValuePrompt = secretValuePrompt;
|
|
4
|
+
exports.secretNamePrompt = secretNamePrompt;
|
|
5
|
+
exports.secretListPrompt = secretListPrompt;
|
|
6
|
+
const promptUtils_1 = require("./promptUtils");
|
|
7
|
+
const lang_1 = require("../lang");
|
|
6
8
|
const i18nKey = 'lib.prompts.secretPrompt';
|
|
7
|
-
const SECRET_VALUE_PROMPT = {
|
|
8
|
-
name: 'secretValue',
|
|
9
|
-
type: 'password',
|
|
10
|
-
mask: '*',
|
|
11
|
-
message: i18n(`${i18nKey}.enterValue`),
|
|
12
|
-
validate(val) {
|
|
13
|
-
if (typeof val !== 'string') {
|
|
14
|
-
return i18n(`${i18nKey}.errors.invalidValue`);
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
9
|
function secretValuePrompt() {
|
|
20
|
-
return promptUser([
|
|
10
|
+
return (0, promptUtils_1.promptUser)([
|
|
11
|
+
{
|
|
12
|
+
name: 'secretValue',
|
|
13
|
+
type: 'password',
|
|
14
|
+
mask: '*',
|
|
15
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterValue`),
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
}
|
|
19
|
+
function secretNamePrompt() {
|
|
20
|
+
return (0, promptUtils_1.promptUser)([
|
|
21
|
+
{
|
|
22
|
+
name: 'secretName',
|
|
23
|
+
type: 'input',
|
|
24
|
+
message: (0, lang_1.i18n)(`${i18nKey}.enterName`),
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
function secretListPrompt(secrets, message) {
|
|
29
|
+
return (0, promptUtils_1.promptUser)([
|
|
30
|
+
{
|
|
31
|
+
name: 'secretToModify',
|
|
32
|
+
type: 'list',
|
|
33
|
+
choices: secrets,
|
|
34
|
+
message,
|
|
35
|
+
},
|
|
36
|
+
]);
|
|
21
37
|
}
|
|
22
|
-
module.exports = {
|
|
23
|
-
secretValuePrompt,
|
|
24
|
-
};
|