@hubspot/cli 3.0.10-beta.6 → 3.0.10
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 +7 -1
- package/bin/cli.js +3 -4
- package/commands/accounts/list.js +18 -26
- package/commands/accounts/rename.js +13 -24
- package/commands/accounts.js +4 -1
- package/commands/auth.js +33 -16
- package/commands/config/set/allowUsageTracking.js +17 -33
- package/commands/config/set/defaultAccount.js +24 -34
- package/commands/config/set/defaultMode.js +25 -44
- package/commands/config/set/httpTimeout.js +10 -28
- package/commands/config/set.js +4 -1
- package/commands/config.js +4 -1
- package/commands/create/api-sample.js +20 -14
- package/commands/create/function.js +3 -1
- package/commands/create/index.js +0 -1
- package/commands/create/module.js +20 -7
- package/commands/create/template.js +22 -5
- package/commands/create/website-theme.js +12 -1
- package/commands/create.js +23 -8
- package/commands/customObject/create.js +22 -24
- package/commands/customObject/schema/create.js +30 -28
- package/commands/customObject/schema/delete.js +20 -20
- package/commands/customObject/schema/fetch-all.js +17 -24
- package/commands/customObject/schema/fetch.js +29 -24
- package/commands/customObject/schema/list.js +8 -17
- package/commands/customObject/schema/update.js +31 -29
- package/commands/customObject/schema.js +4 -1
- package/commands/customObject.js +10 -21
- package/commands/fetch.js +15 -30
- package/commands/filemanager/fetch.js +13 -25
- package/commands/filemanager/upload.js +47 -35
- package/commands/filemanager.js +4 -1
- package/commands/functions/deploy.js +34 -37
- package/commands/functions/list.js +9 -24
- package/commands/functions/server.js +13 -29
- package/commands/functions.js +4 -1
- package/commands/hubdb/clear.js +25 -21
- package/commands/hubdb/create.js +25 -22
- package/commands/hubdb/delete.js +19 -20
- package/commands/hubdb/fetch.js +15 -20
- package/commands/hubdb.js +4 -1
- package/commands/init.js +25 -13
- package/commands/lint.js +14 -23
- package/commands/list.js +19 -25
- package/commands/logs.js +23 -44
- package/commands/mv.js +21 -25
- package/commands/open.js +9 -7
- package/commands/project/create.js +26 -42
- package/commands/project/deploy.js +35 -36
- package/commands/project/listBuilds.js +160 -0
- package/commands/project/logs.js +87 -79
- package/commands/project/upload.js +74 -78
- package/commands/project/watch.js +103 -0
- package/commands/project.js +5 -6
- package/commands/remove.js +12 -20
- package/commands/sandbox/create.js +18 -13
- package/commands/secrets/addSecret.js +19 -22
- package/commands/secrets/deleteSecret.js +18 -21
- package/commands/secrets/listSecrets.js +10 -19
- package/commands/secrets/updateSecret.js +19 -22
- package/commands/secrets.js +4 -1
- package/commands/server.js +15 -6
- package/commands/{marketplaceValidate/validateTheme.js → theme/marketplace-validate.js} +26 -24
- package/commands/theme.js +5 -3
- package/commands/upload.js +66 -45
- package/commands/watch.js +33 -55
- package/lib/commonOpts.js +14 -11
- package/lib/enums/exitCodes.js +14 -0
- package/lib/links.js +0 -10
- package/lib/projects.js +121 -77
- package/lib/{createApiSamplePrompt.js → prompts/createApiSamplePrompt.js} +10 -11
- package/lib/{createFunctionPrompt.js → prompts/createFunctionPrompt.js} +27 -21
- package/lib/{createModulePrompt.js → prompts/createModulePrompt.js} +12 -9
- package/lib/prompts/createProjectPrompt.js +68 -0
- package/lib/{createTemplatePrompt.js → prompts/createTemplatePrompt.js} +7 -4
- package/lib/prompts/folderOverwritePrompt.js +17 -0
- package/lib/{prompts.js → prompts/personalAccessKeyPrompt.js} +25 -42
- package/lib/prompts/promptUtils.js +10 -0
- package/lib/prompts/sandboxesPrompt.js +24 -0
- package/lib/prompts/secretPrompt.js +25 -0
- package/lib/serverlessLogs.js +4 -3
- package/lib/ui.js +48 -0
- package/lib/validation.js +4 -3
- package/package.json +8 -7
- package/commands/app/deploy.js +0 -116
- package/commands/app.js +0 -14
- package/commands/create/project.js +0 -25
- package/lib/prompts/projects.js +0 -40
- package/lib/prompts/sandboxes.js +0 -22
- package/lib/secretPrompt.js +0 -22
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @hubspot/cli
|
|
2
2
|
|
|
3
|
-
Provides an `hs` command for interacting with
|
|
3
|
+
Provides an `hs` command for interacting with HubSpot. [Learn more about building on HubSpot](https://developers.hubspot.com).
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
@@ -160,3 +160,9 @@ portals:
|
|
|
160
160
|
authType: apikey
|
|
161
161
|
apiKey: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
162
162
|
```
|
|
163
|
+
### Exit Codes
|
|
164
|
+
|
|
165
|
+
The CLI will exit with one of the following exit codes:
|
|
166
|
+
- `0`: A successful run
|
|
167
|
+
- `1`: There was a config problem or an internal error
|
|
168
|
+
- `2`: There are warnings or validation issues
|
package/bin/cli.js
CHANGED
|
@@ -10,7 +10,6 @@ const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
|
10
10
|
const { trackHelpUsage } = require('../lib/usageTracking');
|
|
11
11
|
const pkg = require('../package.json');
|
|
12
12
|
|
|
13
|
-
const appCommand = require('../commands/app');
|
|
14
13
|
const removeCommand = require('../commands/remove');
|
|
15
14
|
const initCommand = require('../commands/init');
|
|
16
15
|
const logsCommand = require('../commands/logs');
|
|
@@ -33,6 +32,7 @@ const themeCommand = require('../commands/theme');
|
|
|
33
32
|
const configCommand = require('../commands/config');
|
|
34
33
|
const accountsCommand = require('../commands/accounts');
|
|
35
34
|
const sandboxesCommand = require('../commands/sandbox');
|
|
35
|
+
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
36
36
|
|
|
37
37
|
const notifier = updateNotifier({ pkg: { ...pkg, name: '@hubspot/cli' } });
|
|
38
38
|
|
|
@@ -63,9 +63,9 @@ const argv = yargs
|
|
|
63
63
|
|
|
64
64
|
if (msg === null) {
|
|
65
65
|
yargs.showHelp();
|
|
66
|
-
process.exit(
|
|
66
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
67
67
|
} else {
|
|
68
|
-
process.exit(
|
|
68
|
+
process.exit(EXIT_CODES.ERROR);
|
|
69
69
|
}
|
|
70
70
|
})
|
|
71
71
|
.option('debug', {
|
|
@@ -74,7 +74,6 @@ const argv = yargs
|
|
|
74
74
|
describe: 'set log level to debug',
|
|
75
75
|
type: 'boolean',
|
|
76
76
|
})
|
|
77
|
-
.command(appCommand)
|
|
78
77
|
.command(authCommand)
|
|
79
78
|
.command(initCommand)
|
|
80
79
|
.command(logsCommand)
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { getConfig, getConfigPath } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
const {
|
|
4
|
-
loadConfig,
|
|
5
|
-
validateConfig,
|
|
6
|
-
checkAndWarnGitInclusion,
|
|
7
|
-
} = require('@hubspot/cli-lib');
|
|
8
3
|
const {
|
|
9
4
|
getTableContents,
|
|
10
5
|
getTableHeader,
|
|
@@ -14,29 +9,18 @@ const {
|
|
|
14
9
|
addConfigOptions,
|
|
15
10
|
addAccountOptions,
|
|
16
11
|
getAccountId,
|
|
17
|
-
setLogLevel,
|
|
18
12
|
} = require('../../lib/commonOpts');
|
|
19
13
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
20
|
-
const {
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
const loadAndValidateOptions = async options => {
|
|
24
|
-
setLogLevel(options);
|
|
25
|
-
logDebugInfo(options);
|
|
26
|
-
const { config: configPath } = options;
|
|
27
|
-
loadConfig(configPath, options);
|
|
28
|
-
checkAndWarnGitInclusion();
|
|
14
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
15
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
17
|
+
const i18nKey = 'cli.commands.accounts.subcommands.list';
|
|
34
18
|
|
|
35
19
|
exports.command = 'list';
|
|
36
|
-
exports.describe =
|
|
20
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
37
21
|
|
|
38
22
|
exports.handler = async options => {
|
|
39
|
-
loadAndValidateOptions(options);
|
|
23
|
+
await loadAndValidateOptions(options);
|
|
40
24
|
|
|
41
25
|
const accountId = getAccountId(options);
|
|
42
26
|
|
|
@@ -47,11 +31,19 @@ exports.handler = async options => {
|
|
|
47
31
|
const portalData = config.portals.map(portal => {
|
|
48
32
|
return [portal.name, portal.portalId, portal.authType];
|
|
49
33
|
});
|
|
50
|
-
portalData.unshift(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
portalData.unshift(
|
|
35
|
+
getTableHeader([
|
|
36
|
+
i18n(`${i18nKey}.labels.name`),
|
|
37
|
+
i18n(`${i18nKey}.labels.accountId`),
|
|
38
|
+
i18n(`${i18nKey}.labels.authType`),
|
|
39
|
+
])
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
logger.log(i18n(`${i18nKey}.configPath`, { configPath }));
|
|
43
|
+
logger.log(
|
|
44
|
+
i18n(`${i18nKey}.defaultAccount`, { account: config.defaultPortal })
|
|
45
|
+
);
|
|
46
|
+
logger.log(i18n(`${i18nKey}.accounts`));
|
|
55
47
|
logger.log(getTableContents(portalData, { border: { bodyLeft: ' ' } }));
|
|
56
48
|
};
|
|
57
49
|
|
|
@@ -1,35 +1,19 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { renameAccount } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
const {
|
|
4
|
-
loadConfig,
|
|
5
|
-
validateConfig,
|
|
6
|
-
checkAndWarnGitInclusion,
|
|
7
|
-
} = require('@hubspot/cli-lib');
|
|
8
3
|
|
|
9
4
|
const {
|
|
10
5
|
addConfigOptions,
|
|
11
6
|
addAccountOptions,
|
|
12
7
|
getAccountId,
|
|
13
|
-
setLogLevel,
|
|
14
8
|
} = require('../../lib/commonOpts');
|
|
15
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
16
|
-
const {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
setLogLevel(options);
|
|
21
|
-
logDebugInfo(options);
|
|
22
|
-
const { config: configPath } = options;
|
|
23
|
-
loadConfig(configPath, options);
|
|
24
|
-
checkAndWarnGitInclusion();
|
|
25
|
-
|
|
26
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
10
|
+
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
11
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
12
|
+
|
|
13
|
+
const i18nKey = 'cli.commands.accounts.subcommands.rename';
|
|
30
14
|
|
|
31
15
|
exports.command = 'rename <accountName> <newName>';
|
|
32
|
-
exports.describe =
|
|
16
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
33
17
|
|
|
34
18
|
exports.handler = async options => {
|
|
35
19
|
loadAndValidateOptions(options);
|
|
@@ -41,7 +25,12 @@ exports.handler = async options => {
|
|
|
41
25
|
|
|
42
26
|
await renameAccount(accountName, newName);
|
|
43
27
|
|
|
44
|
-
return logger.log(
|
|
28
|
+
return logger.log(
|
|
29
|
+
i18n(`${i18nKey}.success.renamed`, {
|
|
30
|
+
name: accountName,
|
|
31
|
+
newName,
|
|
32
|
+
})
|
|
33
|
+
);
|
|
45
34
|
};
|
|
46
35
|
|
|
47
36
|
exports.builder = yargs => {
|
|
@@ -49,11 +38,11 @@ exports.builder = yargs => {
|
|
|
49
38
|
addAccountOptions(yargs, true);
|
|
50
39
|
|
|
51
40
|
yargs.positional('accountName', {
|
|
52
|
-
describe:
|
|
41
|
+
describe: i18n(`${i18nKey}.positionals.accountName.describe`),
|
|
53
42
|
type: 'string',
|
|
54
43
|
});
|
|
55
44
|
yargs.positional('newName', {
|
|
56
|
-
describe:
|
|
45
|
+
describe: i18n(`${i18nKey}.positionals.newName.describe`),
|
|
57
46
|
type: 'string',
|
|
58
47
|
});
|
|
59
48
|
|
package/commands/accounts.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
const { addConfigOptions, addAccountOptions } = require('../lib/commonOpts');
|
|
2
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
2
3
|
const list = require('./accounts/list');
|
|
3
4
|
const rename = require('./accounts/rename');
|
|
4
5
|
|
|
6
|
+
const i18nKey = 'cli.commands.accounts';
|
|
7
|
+
|
|
5
8
|
exports.command = 'accounts';
|
|
6
|
-
exports.describe =
|
|
9
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
7
10
|
|
|
8
11
|
exports.builder = yargs => {
|
|
9
12
|
addConfigOptions(yargs, true);
|
package/commands/auth.js
CHANGED
|
@@ -7,6 +7,7 @@ const {
|
|
|
7
7
|
ENVIRONMENTS,
|
|
8
8
|
DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
9
9
|
} = require('@hubspot/cli-lib/lib/constants');
|
|
10
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
10
11
|
const {
|
|
11
12
|
updateConfigWithPersonalAccessKey,
|
|
12
13
|
} = require('@hubspot/cli-lib/personalAccessKey');
|
|
@@ -17,13 +18,13 @@ const {
|
|
|
17
18
|
getConfigPath,
|
|
18
19
|
} = require('@hubspot/cli-lib/lib/config');
|
|
19
20
|
const { commaSeparatedValues } = require('@hubspot/cli-lib/lib/text');
|
|
21
|
+
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
20
22
|
const {
|
|
21
|
-
promptUser,
|
|
22
23
|
personalAccessKeyPrompt,
|
|
23
24
|
OAUTH_FLOW,
|
|
24
25
|
API_KEY_FLOW,
|
|
25
26
|
ACCOUNT_NAME,
|
|
26
|
-
} = require('../lib/prompts');
|
|
27
|
+
} = require('../lib/prompts/personalAccessKeyPrompt');
|
|
27
28
|
const {
|
|
28
29
|
addConfigOptions,
|
|
29
30
|
setLogLevel,
|
|
@@ -32,6 +33,9 @@ const {
|
|
|
32
33
|
const { logDebugInfo } = require('../lib/debugInfo');
|
|
33
34
|
const { trackCommandUsage } = require('../lib/usageTracking');
|
|
34
35
|
const { authenticateWithOauth } = require('../lib/oauth');
|
|
36
|
+
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
37
|
+
|
|
38
|
+
const i18nKey = 'cli.commands.auth';
|
|
35
39
|
|
|
36
40
|
const ALLOWED_AUTH_METHODS = [
|
|
37
41
|
OAUTH_AUTH_METHOD.value,
|
|
@@ -52,7 +56,9 @@ const promptForAccountNameIfNotSet = async updatedConfig => {
|
|
|
52
56
|
validName = promptAnswer.name;
|
|
53
57
|
} else {
|
|
54
58
|
logger.log(
|
|
55
|
-
|
|
59
|
+
i18n(`${i18nKey}.errors.accountNameExists`, {
|
|
60
|
+
name: promptAnswer.name,
|
|
61
|
+
})
|
|
56
62
|
);
|
|
57
63
|
}
|
|
58
64
|
}
|
|
@@ -61,7 +67,9 @@ const promptForAccountNameIfNotSet = async updatedConfig => {
|
|
|
61
67
|
};
|
|
62
68
|
|
|
63
69
|
exports.command = 'auth [type]';
|
|
64
|
-
exports.describe =
|
|
70
|
+
exports.describe = i18n(`${i18nKey}.describe`, {
|
|
71
|
+
supportedProtocols: SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT,
|
|
72
|
+
});
|
|
65
73
|
|
|
66
74
|
exports.handler = async options => {
|
|
67
75
|
const { type, config: configPath, qa } = options;
|
|
@@ -71,15 +79,13 @@ exports.handler = async options => {
|
|
|
71
79
|
logDebugInfo(options);
|
|
72
80
|
|
|
73
81
|
if (!getConfigPath()) {
|
|
74
|
-
logger.error(
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
process.exit(1);
|
|
82
|
+
logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
|
|
83
|
+
process.exit(EXIT_CODES.ERROR);
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
81
87
|
loadConfig(configPath);
|
|
82
|
-
checkAndWarnGitInclusion();
|
|
88
|
+
checkAndWarnGitInclusion(getConfigPath());
|
|
83
89
|
|
|
84
90
|
trackCommandUsage('auth');
|
|
85
91
|
|
|
@@ -100,7 +106,10 @@ exports.handler = async options => {
|
|
|
100
106
|
writeConfig();
|
|
101
107
|
|
|
102
108
|
logger.success(
|
|
103
|
-
`${
|
|
109
|
+
i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
110
|
+
configFilename: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
111
|
+
authMethod: API_KEY_AUTH_METHOD.name,
|
|
112
|
+
})
|
|
104
113
|
);
|
|
105
114
|
|
|
106
115
|
break;
|
|
@@ -116,7 +125,7 @@ exports.handler = async options => {
|
|
|
116
125
|
updatedConfig = await updateConfigWithPersonalAccessKey(configData);
|
|
117
126
|
|
|
118
127
|
if (!updatedConfig) {
|
|
119
|
-
process.exit();
|
|
128
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
validName = await promptForAccountNameIfNotSet(updatedConfig);
|
|
@@ -130,21 +139,27 @@ exports.handler = async options => {
|
|
|
130
139
|
writeConfig();
|
|
131
140
|
|
|
132
141
|
logger.success(
|
|
133
|
-
`${
|
|
142
|
+
i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
143
|
+
configFilename: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
144
|
+
authMethod: PERSONAL_ACCESS_KEY_AUTH_METHOD.name,
|
|
145
|
+
})
|
|
134
146
|
);
|
|
135
147
|
break;
|
|
136
148
|
default:
|
|
137
149
|
logger.error(
|
|
138
|
-
|
|
150
|
+
i18n(`${i18nKey}.errors.unsupportedAuthType`, {
|
|
151
|
+
supportedProtocols: SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT,
|
|
152
|
+
type,
|
|
153
|
+
})
|
|
139
154
|
);
|
|
140
155
|
break;
|
|
141
156
|
}
|
|
142
|
-
process.exit();
|
|
157
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
143
158
|
};
|
|
144
159
|
|
|
145
160
|
exports.builder = yargs => {
|
|
146
161
|
yargs.positional('type', {
|
|
147
|
-
describe:
|
|
162
|
+
describe: i18n(`${i18nKey}.positionals.type.describe`),
|
|
148
163
|
type: 'string',
|
|
149
164
|
choices: [
|
|
150
165
|
`${PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
@@ -152,7 +167,9 @@ exports.builder = yargs => {
|
|
|
152
167
|
`${API_KEY_AUTH_METHOD.value}`,
|
|
153
168
|
],
|
|
154
169
|
default: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
155
|
-
defaultDescription:
|
|
170
|
+
defaultDescription: i18n(`${i18nKey}.positionals.type.defaultDescription`, {
|
|
171
|
+
authMethod: PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
172
|
+
}),
|
|
156
173
|
});
|
|
157
174
|
|
|
158
175
|
addConfigOptions(yargs, true);
|
|
@@ -1,43 +1,32 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateAllowUsageTracking } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
const inquirer = require('inquirer');
|
|
4
|
-
const {
|
|
5
|
-
loadConfig,
|
|
6
|
-
validateConfig,
|
|
7
|
-
checkAndWarnGitInclusion,
|
|
8
|
-
} = require('@hubspot/cli-lib');
|
|
9
3
|
|
|
10
|
-
const { getAccountId
|
|
4
|
+
const { getAccountId } = require('../../../lib/commonOpts');
|
|
11
5
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
12
|
-
const {
|
|
13
|
-
const {
|
|
6
|
+
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
7
|
+
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
8
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
14
9
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
logDebugInfo(options);
|
|
18
|
-
const { config: configPath } = options;
|
|
19
|
-
loadConfig(configPath, options);
|
|
20
|
-
checkAndWarnGitInclusion();
|
|
21
|
-
|
|
22
|
-
if (!(validateConfig() && (await validateAccount(options)))) {
|
|
23
|
-
process.exit(1);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
10
|
+
const i18nKey =
|
|
11
|
+
'cli.commands.config.subcommands.set.subcommands.allowUsageTracking';
|
|
26
12
|
|
|
27
13
|
const enableOrDisableUsageTracking = async () => {
|
|
28
|
-
const { isEnabled } = await
|
|
14
|
+
const { isEnabled } = await promptUser([
|
|
29
15
|
{
|
|
30
16
|
type: 'list',
|
|
31
17
|
look: false,
|
|
32
18
|
name: 'isEnabled',
|
|
33
19
|
pageSize: 20,
|
|
34
|
-
message:
|
|
20
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
35
21
|
choices: [
|
|
36
22
|
{
|
|
37
|
-
name:
|
|
23
|
+
name: i18n(`${i18nKey}.labels.enabled`),
|
|
38
24
|
value: true,
|
|
39
25
|
},
|
|
40
|
-
{
|
|
26
|
+
{
|
|
27
|
+
name: i18n(`${i18nKey}.labels.disabled`),
|
|
28
|
+
value: false,
|
|
29
|
+
},
|
|
41
30
|
],
|
|
42
31
|
default: true,
|
|
43
32
|
},
|
|
@@ -47,10 +36,10 @@ const enableOrDisableUsageTracking = async () => {
|
|
|
47
36
|
};
|
|
48
37
|
|
|
49
38
|
exports.command = 'allow-usage-tracking';
|
|
50
|
-
exports.describe =
|
|
39
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
51
40
|
|
|
52
41
|
exports.handler = async options => {
|
|
53
|
-
loadAndValidateOptions(options);
|
|
42
|
+
await loadAndValidateOptions(options);
|
|
54
43
|
|
|
55
44
|
const accountId = getAccountId(options);
|
|
56
45
|
|
|
@@ -59,17 +48,12 @@ exports.handler = async options => {
|
|
|
59
48
|
const isEnabled = await enableOrDisableUsageTracking();
|
|
60
49
|
updateAllowUsageTracking(isEnabled);
|
|
61
50
|
|
|
62
|
-
return logger.log(
|
|
63
|
-
`Usage tracking is now ${isEnabled ? 'enabled' : 'disabled'}.`
|
|
64
|
-
);
|
|
51
|
+
return logger.log(i18n(`${i18nKey}.${isEnabled ? 'enabled' : 'disabled'}`));
|
|
65
52
|
};
|
|
66
53
|
|
|
67
54
|
exports.builder = yargs => {
|
|
68
55
|
yargs.example([
|
|
69
|
-
[
|
|
70
|
-
'$0 config set allow-usage-tracking',
|
|
71
|
-
'Select to enable or disable usage tracking from a list',
|
|
72
|
-
],
|
|
56
|
+
['$0 config set allow-usage-tracking', i18n(`${i18nKey}.examples.default`)],
|
|
73
57
|
]);
|
|
74
58
|
|
|
75
59
|
return yargs;
|
|
@@ -4,38 +4,24 @@ const {
|
|
|
4
4
|
getConfigPath,
|
|
5
5
|
updateDefaultAccount,
|
|
6
6
|
} = require('@hubspot/cli-lib/lib/config');
|
|
7
|
-
const
|
|
8
|
-
const {
|
|
9
|
-
loadConfig,
|
|
10
|
-
validateConfig,
|
|
11
|
-
checkAndWarnGitInclusion,
|
|
12
|
-
} = require('@hubspot/cli-lib');
|
|
7
|
+
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
13
8
|
|
|
14
|
-
const { getAccountId
|
|
9
|
+
const { getAccountId } = require('../../../lib/commonOpts');
|
|
15
10
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
16
|
-
const {
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
const loadAndValidateOptions = async options => {
|
|
20
|
-
setLogLevel(options);
|
|
21
|
-
logDebugInfo(options);
|
|
22
|
-
const { config: configPath } = options;
|
|
23
|
-
loadConfig(configPath, options);
|
|
24
|
-
checkAndWarnGitInclusion();
|
|
11
|
+
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
12
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
};
|
|
14
|
+
const i18nKey =
|
|
15
|
+
'cli.commands.config.subcommands.set.subcommands.defaultAccount';
|
|
30
16
|
|
|
31
17
|
const selectAccountFromConfig = async config => {
|
|
32
|
-
const { default: selectedDefault } = await
|
|
18
|
+
const { default: selectedDefault } = await promptUser([
|
|
33
19
|
{
|
|
34
20
|
type: 'list',
|
|
35
21
|
look: false,
|
|
36
22
|
name: 'default',
|
|
37
23
|
pageSize: 20,
|
|
38
|
-
message:
|
|
24
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
39
25
|
choices: config.portals.map(p => p.name || p.portalId),
|
|
40
26
|
default: config.defaultPortal,
|
|
41
27
|
},
|
|
@@ -45,10 +31,10 @@ const selectAccountFromConfig = async config => {
|
|
|
45
31
|
};
|
|
46
32
|
|
|
47
33
|
exports.command = 'default-account [newDefault]';
|
|
48
|
-
exports.describe =
|
|
34
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
49
35
|
|
|
50
36
|
exports.handler = async options => {
|
|
51
|
-
loadAndValidateOptions(options);
|
|
37
|
+
await loadAndValidateOptions(options);
|
|
52
38
|
|
|
53
39
|
const accountId = getAccountId(options);
|
|
54
40
|
const config = getConfig();
|
|
@@ -68,35 +54,39 @@ exports.handler = async options => {
|
|
|
68
54
|
) {
|
|
69
55
|
newDefault = specifiedNewDefault;
|
|
70
56
|
} else {
|
|
71
|
-
logger.
|
|
72
|
-
|
|
57
|
+
logger.error(
|
|
58
|
+
i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
59
|
+
specifiedAccount: specifiedNewDefault,
|
|
60
|
+
configPath,
|
|
61
|
+
})
|
|
73
62
|
);
|
|
74
63
|
newDefault = await selectAccountFromConfig(config);
|
|
75
64
|
}
|
|
76
65
|
|
|
77
66
|
updateDefaultAccount(newDefault);
|
|
78
67
|
|
|
79
|
-
return logger.
|
|
68
|
+
return logger.success(
|
|
69
|
+
i18n(`${i18nKey}.success.defaultAccountUpdated`, {
|
|
70
|
+
accountName: newDefault,
|
|
71
|
+
})
|
|
72
|
+
);
|
|
80
73
|
};
|
|
81
74
|
|
|
82
75
|
exports.builder = yargs => {
|
|
83
76
|
yargs.positional('newDefault', {
|
|
84
|
-
describe:
|
|
77
|
+
describe: i18n(`${i18nKey}.positionals.newDefault.describe`),
|
|
85
78
|
type: 'string',
|
|
86
79
|
});
|
|
87
80
|
|
|
88
81
|
yargs.example([
|
|
89
|
-
[
|
|
90
|
-
'$0 config set default-account',
|
|
91
|
-
'Select account to use as the default from a list',
|
|
92
|
-
],
|
|
82
|
+
['$0 config set default-account', i18n(`${i18nKey}.examples.default`)],
|
|
93
83
|
[
|
|
94
84
|
'$0 config set default-account MyAccount',
|
|
95
|
-
|
|
85
|
+
i18n(`${i18nKey}.examples.nameBased`),
|
|
96
86
|
],
|
|
97
87
|
[
|
|
98
88
|
'$0 config set default-account 1234567',
|
|
99
|
-
|
|
89
|
+
i18n(`${i18nKey}.examples.idBased`),
|
|
100
90
|
],
|
|
101
91
|
]);
|
|
102
92
|
|
|
@@ -1,41 +1,26 @@
|
|
|
1
1
|
const { logger } = require('@hubspot/cli-lib/logger');
|
|
2
2
|
const { updateDefaultMode } = require('@hubspot/cli-lib/lib/config');
|
|
3
|
-
const
|
|
4
|
-
const {
|
|
5
|
-
Mode,
|
|
6
|
-
loadConfig,
|
|
7
|
-
validateConfig,
|
|
8
|
-
checkAndWarnGitInclusion,
|
|
9
|
-
} = require('@hubspot/cli-lib');
|
|
3
|
+
const { Mode } = require('@hubspot/cli-lib');
|
|
10
4
|
const { commaSeparatedValues } = require('@hubspot/cli-lib/lib/text');
|
|
11
5
|
|
|
12
|
-
const { getAccountId
|
|
6
|
+
const { getAccountId } = require('../../../lib/commonOpts');
|
|
13
7
|
const { trackCommandUsage } = require('../../../lib/usageTracking');
|
|
14
|
-
const {
|
|
15
|
-
const {
|
|
8
|
+
const { promptUser } = require('../../../lib/prompts/promptUtils');
|
|
9
|
+
const { loadAndValidateOptions } = require('../../../lib/validation');
|
|
10
|
+
const { i18n } = require('@hubspot/cli-lib/lib/lang');
|
|
16
11
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const loadAndValidateOptions = async options => {
|
|
20
|
-
setLogLevel(options);
|
|
21
|
-
logDebugInfo(options);
|
|
22
|
-
const { config: configPath } = options;
|
|
23
|
-
loadConfig(configPath, options);
|
|
24
|
-
checkAndWarnGitInclusion();
|
|
12
|
+
const i18nKey = 'cli.commands.config.subcommands.set.subcommands.defaultMode';
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
process.exit(1);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
14
|
+
const ALL_MODES = Object.values(Mode);
|
|
30
15
|
|
|
31
16
|
const selectMode = async () => {
|
|
32
|
-
const { mode } = await
|
|
17
|
+
const { mode } = await promptUser([
|
|
33
18
|
{
|
|
34
19
|
type: 'list',
|
|
35
20
|
look: false,
|
|
36
21
|
name: 'mode',
|
|
37
22
|
pageSize: 20,
|
|
38
|
-
message:
|
|
23
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
39
24
|
choices: ALL_MODES,
|
|
40
25
|
default: Mode.publish,
|
|
41
26
|
},
|
|
@@ -45,10 +30,10 @@ const selectMode = async () => {
|
|
|
45
30
|
};
|
|
46
31
|
|
|
47
32
|
exports.command = 'default-mode [newDefault]';
|
|
48
|
-
exports.describe =
|
|
33
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
49
34
|
|
|
50
35
|
exports.handler = async options => {
|
|
51
|
-
loadAndValidateOptions(options);
|
|
36
|
+
await loadAndValidateOptions(options);
|
|
52
37
|
|
|
53
38
|
const accountId = getAccountId(options);
|
|
54
39
|
const { newMode: specifiedNewDefault } = options;
|
|
@@ -64,38 +49,34 @@ exports.handler = async options => {
|
|
|
64
49
|
) {
|
|
65
50
|
newDefault = specifiedNewDefault;
|
|
66
51
|
} else {
|
|
67
|
-
logger.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
logger.error(
|
|
53
|
+
i18n(`${i18nKey}.errors.invalidMode`, {
|
|
54
|
+
mode: specifiedNewDefault,
|
|
55
|
+
validModes: commaSeparatedValues(ALL_MODES),
|
|
56
|
+
})
|
|
71
57
|
);
|
|
72
58
|
newDefault = await selectMode();
|
|
73
59
|
}
|
|
74
60
|
|
|
75
61
|
updateDefaultMode(newDefault);
|
|
76
62
|
|
|
77
|
-
return logger.
|
|
63
|
+
return logger.success(
|
|
64
|
+
i18n(`${i18nKey}.success.modeUpdated`, {
|
|
65
|
+
mode: newDefault,
|
|
66
|
+
})
|
|
67
|
+
);
|
|
78
68
|
};
|
|
79
69
|
|
|
80
70
|
exports.builder = yargs => {
|
|
81
71
|
yargs.positional('newMode', {
|
|
82
|
-
describe:
|
|
72
|
+
describe: i18n(`${i18nKey}.positionals.newMode.describe`),
|
|
83
73
|
type: 'string',
|
|
84
74
|
});
|
|
85
75
|
|
|
86
76
|
yargs.example([
|
|
87
|
-
[
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
],
|
|
91
|
-
[
|
|
92
|
-
'$0 config set default-mode publish',
|
|
93
|
-
'Set the default mode in the config to "publish"',
|
|
94
|
-
],
|
|
95
|
-
[
|
|
96
|
-
'$0 config set default-mode draft',
|
|
97
|
-
'Set the default mode in the config to "draft"',
|
|
98
|
-
],
|
|
77
|
+
['$0 config set default-mode', i18n(`${i18nKey}.examples.default`)],
|
|
78
|
+
['$0 config set default-mode publish', i18n(`${i18nKey}.examples.publish`)],
|
|
79
|
+
['$0 config set default-mode draft', i18n(`${i18nKey}.examples.draft`)],
|
|
99
80
|
]);
|
|
100
81
|
|
|
101
82
|
return yargs;
|