@hubspot/cli 7.0.13-experimental.0 → 7.0.14-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 +2 -45
- package/commands/account/list.js +0 -4
- package/commands/account.js +0 -4
- package/commands/auth.js +5 -9
- package/commands/init.js +26 -15
- package/lang/en.lyaml +4 -34
- package/lib/doctor/Diagnosis.d.ts +0 -1
- package/lib/doctor/Diagnosis.js +0 -7
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +0 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +0 -1
- package/lib/doctor/Doctor.d.ts +0 -1
- package/lib/doctor/Doctor.js +0 -18
- package/lib/projects/buildAndDeploy.js +4 -1
- package/lib/prompts/accountNamePrompt.d.ts +1 -1
- package/lib/ui/index.d.ts +1 -1
- package/lib/usageTracking.d.ts +1 -1
- package/package.json +2 -2
- package/commands/account/auth.d.ts +0 -10
- package/commands/account/auth.js +0 -140
- package/commands/account/createOverride.d.ts +0 -10
- package/commands/account/createOverride.js +0 -62
package/bin/cli.js
CHANGED
|
@@ -6,7 +6,6 @@ const chalk = require('chalk');
|
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { addUserAgentHeader } = require('@hubspot/local-dev-lib/http');
|
|
8
8
|
const { loadConfig, getAccountId, configFileExists, getConfigPath, validateConfig, } = require('@hubspot/local-dev-lib/config');
|
|
9
|
-
const { DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID, DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND, DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME, } = require('@hubspot/local-dev-lib/constants/config');
|
|
10
9
|
const { logError } = require('../lib/errorHandlers/index');
|
|
11
10
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
12
11
|
const { validateAccount } = require('../lib/validation');
|
|
@@ -138,17 +137,9 @@ const isTargetedCommand = (options, commandMap) => {
|
|
|
138
137
|
};
|
|
139
138
|
return checkCommand(options, commandMap);
|
|
140
139
|
};
|
|
141
|
-
const skipConfigAccountsSubCommands = {
|
|
142
|
-
target: false,
|
|
143
|
-
subCommands: {
|
|
144
|
-
auth: { target: true },
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
140
|
const SKIP_CONFIG_VALIDATION = {
|
|
148
141
|
init: { target: true },
|
|
149
142
|
auth: { target: true },
|
|
150
|
-
accounts: skipConfigAccountsSubCommands,
|
|
151
|
-
account: skipConfigAccountsSubCommands,
|
|
152
143
|
};
|
|
153
144
|
const handleDeprecatedEnvVariables = options => {
|
|
154
145
|
// HUBSPOT_PORTAL_ID is deprecated, but we'll still support it for now
|
|
@@ -173,36 +164,9 @@ const injectAccountIdMiddleware = async (options) => {
|
|
|
173
164
|
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
174
165
|
}
|
|
175
166
|
else {
|
|
176
|
-
|
|
177
|
-
options.derivedAccountId = getAccountId(account);
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
logError(error);
|
|
181
|
-
if (error.cause === DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID) {
|
|
182
|
-
logger.log(i18n(`${i18nKey}.injectAccountIdMiddleware.invalidAccountId`, {
|
|
183
|
-
overrideCommand: uiCommandReference('hs account create-override'),
|
|
184
|
-
hsAccountFileName: DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
|
-
if (error.cause === DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND) {
|
|
188
|
-
logger.log(i18n(`${i18nKey}.injectAccountIdMiddleware.accountNotFound`, {
|
|
189
|
-
configPath: getConfigPath(),
|
|
190
|
-
authCommand: uiCommandReference('hs account auth'),
|
|
191
|
-
hsAccountFileName: DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
process.exit(EXIT_CODES.ERROR);
|
|
195
|
-
}
|
|
167
|
+
options.derivedAccountId = getAccountId(account);
|
|
196
168
|
}
|
|
197
169
|
};
|
|
198
|
-
const skipLoadConfigAccountSubCommands = {
|
|
199
|
-
target: false,
|
|
200
|
-
subCommands: { auth: { target: true } },
|
|
201
|
-
};
|
|
202
|
-
const SKIP_LOAD_CONFIG = {
|
|
203
|
-
account: skipLoadConfigAccountSubCommands,
|
|
204
|
-
accounts: skipLoadConfigAccountSubCommands,
|
|
205
|
-
};
|
|
206
170
|
const loadConfigMiddleware = async (options) => {
|
|
207
171
|
// Skip this when no command is provided
|
|
208
172
|
if (!options._.length) {
|
|
@@ -220,13 +184,7 @@ const loadConfigMiddleware = async (options) => {
|
|
|
220
184
|
}));
|
|
221
185
|
process.exit(EXIT_CODES.ERROR);
|
|
222
186
|
}
|
|
223
|
-
|
|
224
|
-
// 1. `hs init`
|
|
225
|
-
// 2. `hs account auth` only if the centralized config file does not exist
|
|
226
|
-
if (!isTargetedCommand(options, {
|
|
227
|
-
init: { target: true },
|
|
228
|
-
}) &&
|
|
229
|
-
!(isTargetedCommand(options, SKIP_LOAD_CONFIG) && !configFileExists(true))) {
|
|
187
|
+
else if (!isTargetedCommand(options, { init: { target: true } })) {
|
|
230
188
|
const { config: configPath } = options;
|
|
231
189
|
const config = loadConfig(configPath, options);
|
|
232
190
|
// We don't run validateConfig() for auth because users should be able to run it when
|
|
@@ -247,7 +205,6 @@ const checkAndWarnGitInclusionMiddleware = options => {
|
|
|
247
205
|
const accountsSubCommands = {
|
|
248
206
|
target: false,
|
|
249
207
|
subCommands: {
|
|
250
|
-
auth: { target: true },
|
|
251
208
|
clean: { target: true },
|
|
252
209
|
list: { target: true },
|
|
253
210
|
ls: { target: true },
|
package/commands/account/list.js
CHANGED
|
@@ -73,7 +73,6 @@ async function handler(args) {
|
|
|
73
73
|
const { derivedAccountId } = args;
|
|
74
74
|
(0, usageTracking_1.trackCommandUsage)('accounts-list', undefined, derivedAccountId);
|
|
75
75
|
const configPath = (0, config_1.getConfigPath)();
|
|
76
|
-
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
77
76
|
const accountsList = (0, config_1.getConfigAccounts)() || [];
|
|
78
77
|
const mappedAccountData = sortAndMapAccounts(accountsList);
|
|
79
78
|
const accountData = getAccountData(mappedAccountData);
|
|
@@ -83,9 +82,6 @@ async function handler(args) {
|
|
|
83
82
|
(0, lang_1.i18n)(`${i18nKey}.labels.authType`),
|
|
84
83
|
]));
|
|
85
84
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.configPath`, { configPath: configPath }));
|
|
86
|
-
if (overrideFilePath) {
|
|
87
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.overrideFilePath`, { overrideFilePath }));
|
|
88
|
-
}
|
|
89
85
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.defaultAccount`, {
|
|
90
86
|
account: (0, config_1.getConfigDefaultAccount)(),
|
|
91
87
|
}));
|
package/commands/account.js
CHANGED
|
@@ -37,28 +37,24 @@ exports.describe = exports.command = void 0;
|
|
|
37
37
|
exports.builder = builder;
|
|
38
38
|
const commonOpts_1 = require("../lib/commonOpts");
|
|
39
39
|
const lang_1 = require("../lib/lang");
|
|
40
|
-
const auth = __importStar(require("./account/auth"));
|
|
41
40
|
const list = __importStar(require("./account/list"));
|
|
42
41
|
const rename = __importStar(require("./account/rename"));
|
|
43
42
|
const use = __importStar(require("./account/use"));
|
|
44
43
|
const info = __importStar(require("./account/info"));
|
|
45
44
|
const remove = __importStar(require("./account/remove"));
|
|
46
45
|
const clean = __importStar(require("./account/clean"));
|
|
47
|
-
const createOverride = __importStar(require("./account/createOverride"));
|
|
48
46
|
const i18nKey = 'commands.account';
|
|
49
47
|
exports.command = ['account', 'accounts'];
|
|
50
48
|
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
51
49
|
function builder(yargs) {
|
|
52
50
|
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
53
51
|
yargs
|
|
54
|
-
.command(auth)
|
|
55
52
|
.command(list)
|
|
56
53
|
.command(rename)
|
|
57
54
|
.command(use)
|
|
58
55
|
.command(info)
|
|
59
56
|
.command(remove)
|
|
60
57
|
.command(clean)
|
|
61
|
-
.command(createOverride)
|
|
62
58
|
.demandCommand(1, '');
|
|
63
59
|
return yargs;
|
|
64
60
|
}
|
package/commands/auth.js
CHANGED
|
@@ -8,7 +8,7 @@ const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments
|
|
|
8
8
|
const { DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME, } = require('@hubspot/local-dev-lib/constants/config');
|
|
9
9
|
const { i18n } = require('../lib/lang');
|
|
10
10
|
const { getAccessToken, updateConfigWithAccessToken, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
11
|
-
const { updateAccountConfig, writeConfig, getConfigPath, loadConfig, getConfigDefaultAccount, getAccountId,
|
|
11
|
+
const { updateAccountConfig, writeConfig, getConfigPath, loadConfig, getConfigDefaultAccount, getAccountId, } = require('@hubspot/local-dev-lib/config');
|
|
12
12
|
const { commaSeparatedValues, toKebabCase, } = require('@hubspot/local-dev-lib/text');
|
|
13
13
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
14
14
|
const { personalAccessKeyPrompt, OAUTH_FLOW, } = require('../lib/prompts/personalAccessKeyPrompt');
|
|
@@ -18,7 +18,7 @@ const { addConfigOptions, setLogLevel, addTestingOptions, addGlobalOptions, } =
|
|
|
18
18
|
const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
|
|
19
19
|
const { authenticateWithOauth } = require('../lib/oauth');
|
|
20
20
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
21
|
-
const { uiFeatureHighlight
|
|
21
|
+
const { uiFeatureHighlight } = require('../lib/ui');
|
|
22
22
|
const { logError } = require('../lib/errorHandlers/index');
|
|
23
23
|
const i18nKey = 'commands.auth';
|
|
24
24
|
const TRACKING_STATUS = {
|
|
@@ -43,13 +43,9 @@ exports.handler = async (options) => {
|
|
|
43
43
|
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
44
44
|
// Needed to load deprecated config
|
|
45
45
|
loadConfig(configFlagValue);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
logger.error(i18n(`${i18nKey}.errors.centralizedConfigFileExists`, {
|
|
50
|
-
configPath,
|
|
51
|
-
authCommand: uiCommandReference('hs account auth'),
|
|
52
|
-
}));
|
|
46
|
+
checkAndWarnGitInclusion(getConfigPath());
|
|
47
|
+
if (!getConfigPath(configFlagValue)) {
|
|
48
|
+
logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
|
|
53
49
|
process.exit(EXIT_CODES.ERROR);
|
|
54
50
|
}
|
|
55
51
|
trackCommandUsage('auth');
|
package/commands/init.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs-extra');
|
|
6
|
-
const { getConfigPath, createEmptyConfigFile, deleteEmptyConfigFile, updateDefaultAccount, configFileExists, } = require('@hubspot/local-dev-lib/config');
|
|
6
|
+
const { getConfigPath, createEmptyConfigFile, deleteEmptyConfigFile, updateDefaultAccount, loadConfig, configFileExists, } = require('@hubspot/local-dev-lib/config');
|
|
7
7
|
const { addConfigOptions, addGlobalOptions } = require('../lib/commonOpts');
|
|
8
8
|
const { handleExit } = require('../lib/process');
|
|
9
9
|
const { checkAndAddConfigToGitignore, } = require('@hubspot/local-dev-lib/gitignore');
|
|
@@ -67,11 +67,11 @@ exports.describe = i18n(`${i18nKey}.describe`, {
|
|
|
67
67
|
configName: DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
68
68
|
});
|
|
69
69
|
exports.handler = async (options) => {
|
|
70
|
-
const { authType: authTypeFlagValue, c: configFlagValue, providedAccountId, disableTracking, } = options;
|
|
70
|
+
const { authType: authTypeFlagValue, c: configFlagValue, providedAccountId, disableTracking, useHiddenConfig, } = options;
|
|
71
71
|
const authType = (authTypeFlagValue && authTypeFlagValue.toLowerCase()) ||
|
|
72
72
|
PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
73
73
|
const configPath = (configFlagValue && path.join(getCwd(), configFlagValue)) ||
|
|
74
|
-
getConfigPath();
|
|
74
|
+
getConfigPath('', useHiddenConfig);
|
|
75
75
|
setLogLevel(options);
|
|
76
76
|
if (!disableTracking) {
|
|
77
77
|
trackCommandUsage('init', {
|
|
@@ -79,13 +79,6 @@ exports.handler = async (options) => {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
const env = options.qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
82
|
-
if (configFileExists(true)) {
|
|
83
|
-
const centralConfigPath = getConfigPath('', true);
|
|
84
|
-
logger.error(i18n(`${i18nKey}.errors.centralizedConfigFileExists`, {
|
|
85
|
-
configPath: centralConfigPath,
|
|
86
|
-
}));
|
|
87
|
-
process.exit(EXIT_CODES.ERROR);
|
|
88
|
-
}
|
|
89
82
|
if (fs.existsSync(configPath)) {
|
|
90
83
|
logger.error(i18n(`${i18nKey}.errors.configFileExists`, {
|
|
91
84
|
configPath,
|
|
@@ -96,21 +89,32 @@ exports.handler = async (options) => {
|
|
|
96
89
|
if (!disableTracking) {
|
|
97
90
|
await trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
|
|
98
91
|
}
|
|
92
|
+
const doesOtherConfigFileExist = configFileExists(!useHiddenConfig);
|
|
93
|
+
if (doesOtherConfigFileExist) {
|
|
94
|
+
const path = getConfigPath('', !useHiddenConfig);
|
|
95
|
+
logger.error(i18n(`${i18nKey}.errors.bothConfigFilesNotAllowed`, { path }));
|
|
96
|
+
process.exit(EXIT_CODES.ERROR);
|
|
97
|
+
}
|
|
99
98
|
trackAuthAction('init', authType, TRACKING_STATUS.STARTED);
|
|
100
|
-
createEmptyConfigFile({ path: configPath });
|
|
99
|
+
createEmptyConfigFile({ path: configPath }, useHiddenConfig);
|
|
100
|
+
//Needed to load deprecated config
|
|
101
|
+
loadConfig(configPath, options);
|
|
101
102
|
handleExit(deleteEmptyConfigFile);
|
|
102
103
|
try {
|
|
103
104
|
const { accountId, name } = await CONFIG_CREATION_FLOWS[authType](env, providedAccountId);
|
|
104
|
-
const configPath = getConfigPath();
|
|
105
105
|
try {
|
|
106
106
|
checkAndAddConfigToGitignore(configPath);
|
|
107
107
|
}
|
|
108
108
|
catch (e) {
|
|
109
109
|
debugError(e);
|
|
110
110
|
}
|
|
111
|
+
let newConfigPath = configPath;
|
|
112
|
+
if (!newConfigPath && !useHiddenConfig) {
|
|
113
|
+
newConfigPath = `${getCwd()}/${DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME}`;
|
|
114
|
+
}
|
|
111
115
|
logger.log('');
|
|
112
116
|
logger.success(i18n(`${i18nKey}.success.configFileCreated`, {
|
|
113
|
-
configPath,
|
|
117
|
+
configPath: newConfigPath,
|
|
114
118
|
}));
|
|
115
119
|
logger.success(i18n(`${i18nKey}.success.configFileUpdated`, {
|
|
116
120
|
authType: AUTH_TYPE_NAMES[authType],
|
|
@@ -131,7 +135,8 @@ exports.handler = async (options) => {
|
|
|
131
135
|
}
|
|
132
136
|
};
|
|
133
137
|
exports.builder = yargs => {
|
|
134
|
-
yargs
|
|
138
|
+
yargs
|
|
139
|
+
.options({
|
|
135
140
|
'auth-type': {
|
|
136
141
|
describe: i18n(`${i18nKey}.options.authType.describe`),
|
|
137
142
|
type: 'string',
|
|
@@ -154,7 +159,13 @@ exports.builder = yargs => {
|
|
|
154
159
|
hidden: true,
|
|
155
160
|
default: false,
|
|
156
161
|
},
|
|
157
|
-
|
|
162
|
+
'use-hidden-config': {
|
|
163
|
+
describe: i18n(`${i18nKey}.options.useHiddenConfig.describe`),
|
|
164
|
+
hidden: true,
|
|
165
|
+
type: 'boolean',
|
|
166
|
+
},
|
|
167
|
+
})
|
|
168
|
+
.conflicts('use-hidden-config', 'config');
|
|
158
169
|
addConfigOptions(yargs);
|
|
159
170
|
addTestingOptions(yargs);
|
|
160
171
|
addGlobalOptions(yargs);
|
package/lang/en.lyaml
CHANGED
|
@@ -11,9 +11,6 @@ en:
|
|
|
11
11
|
portalEnvVarDeprecated: "The HUBSPOT_PORTAL_ID environment variable is deprecated. Please use HUBSPOT_ACCOUNT_ID instead."
|
|
12
12
|
loadConfigMiddleware:
|
|
13
13
|
configFileExists: "A configuration file already exists at {{ configPath }}. To specify a new configuration file, delete the existing one and try again."
|
|
14
|
-
injectAccountIdMiddleware:
|
|
15
|
-
invalidAccountId: "In the default override file ({{ hsAccountFileName }}), the account ID must be a number. Please delete the current file and generate a new one using {{ overrideCommand }}."
|
|
16
|
-
accountNotFound: "The account in the default override file ({{ hsAccountFileName }}) wasn't found in your configured accounts. You can authorize this account using {{ authCommand }}."
|
|
17
14
|
completion:
|
|
18
15
|
describe: "Enable bash completion shortcuts for commands. Concat the generated script to your .bashrc, .bash_profile, or .zshrc file."
|
|
19
16
|
examples:
|
|
@@ -21,35 +18,11 @@ en:
|
|
|
21
18
|
account:
|
|
22
19
|
describe: "Commands for managing configured accounts."
|
|
23
20
|
subcommands:
|
|
24
|
-
auth:
|
|
25
|
-
describe: "Configure authentication for your HubSpot account."
|
|
26
|
-
options:
|
|
27
|
-
account:
|
|
28
|
-
describe: "HubSpot account to authenticate"
|
|
29
|
-
errors:
|
|
30
|
-
failedToUpdateConfig: "Failed to update the configuration file. Please try again."
|
|
31
|
-
bothConfigFilesNotAllowed: "Unable to create config file, because there is an existing \"{{ deprecatedConfig }}\" file. To create a new config file, delete the existing one and try again."
|
|
32
|
-
success:
|
|
33
|
-
configFileCreated: "Created config file \"{{ configPath }}\""
|
|
34
|
-
configFileUpdated: "Connected account \"{{ account }}\" and set it as the default account"
|
|
35
|
-
createOverride:
|
|
36
|
-
describe: "Create a new default account override file (.hs-account) in the current working directory."
|
|
37
|
-
success: "Default account override file created at {{ overrideFilePath }}"
|
|
38
|
-
errors:
|
|
39
|
-
accountNotFound: "The specified account could not be found in the config file {{ configPath }}"
|
|
40
|
-
options:
|
|
41
|
-
account:
|
|
42
|
-
describe: "Name or ID of the account to create an override file for."
|
|
43
|
-
examples:
|
|
44
|
-
default: "Create a new default account override file (.hs-account) in the current working directory"
|
|
45
|
-
idBased: "Create a new default account override file (.hs-account) in the current working directory, using the account with accountId \"1234567\""
|
|
46
|
-
nameBased: "Create a new default account override file (.hs-account) in the current working directory, using the account with name \"MyAccount\""
|
|
47
21
|
list:
|
|
48
22
|
accounts: "{{#bold}}Accounts{{/bold}}:"
|
|
49
23
|
defaultAccount: "{{#bold}}Default account{{/bold}}: {{ account }}"
|
|
50
24
|
describe: "List names of accounts defined in config."
|
|
51
25
|
configPath: "{{#bold}}Config path{{/bold}}: {{ configPath }}"
|
|
52
|
-
overrideFilePath: "{{#bold}}Default account override file path{{/bold}}: {{ overrideFilePath }}"
|
|
53
26
|
labels:
|
|
54
27
|
accountId: "Account ID"
|
|
55
28
|
authType: "Auth Type"
|
|
@@ -120,8 +93,8 @@ en:
|
|
|
120
93
|
auth:
|
|
121
94
|
describe: "Configure authentication for your HubSpot account. This will update the {{ configName }} file that stores your account information."
|
|
122
95
|
errors:
|
|
96
|
+
noConfigFileFound: "No config file was found. To create a new config file, use the \"hs init\" command."
|
|
123
97
|
unsupportedAuthType: "Unsupported auth type: {{ type }}. The only supported authentication protocols are {{ supportedProtocols }}."
|
|
124
|
-
centralizedConfigFileExists: "A centralized config file exists at {{ configPath }}. To authorize an account, please use {{ authCommand }}."
|
|
125
98
|
options:
|
|
126
99
|
authType:
|
|
127
100
|
describe: "Authentication mechanism"
|
|
@@ -477,6 +450,8 @@ en:
|
|
|
477
450
|
defaultDescription: "\"{{ authMethod }}\": An access token tied to a specific user account. This is the recommended way of authenticating with local development tools."
|
|
478
451
|
account:
|
|
479
452
|
describe: "HubSpot account to authenticate"
|
|
453
|
+
useHiddenConfig:
|
|
454
|
+
describe: "Use the new HubSpot configuration file located in a hidden file in the user's home directory"
|
|
480
455
|
success:
|
|
481
456
|
configFileCreated: "Created config file \"{{ configPath }}\""
|
|
482
457
|
configFileUpdated: "Connected account \"{{ account }}\" using \"{{ authType }}\" and set it as the default account"
|
|
@@ -484,7 +459,7 @@ en:
|
|
|
484
459
|
updateConfig: "To update an existing config file, use the \"hs auth\" command."
|
|
485
460
|
errors:
|
|
486
461
|
configFileExists: "The config file {{ configPath }} already exists."
|
|
487
|
-
|
|
462
|
+
bothConfigFilesNotAllowed: "Unable to create config file, because there is an existing one at \"{{ path }}\". To create a new config file, delete the existing one and try again."
|
|
488
463
|
lint:
|
|
489
464
|
issuesFound: "{{ count }} issues found."
|
|
490
465
|
groupName: "Linting {{ path }}"
|
|
@@ -1536,9 +1511,6 @@ en:
|
|
|
1536
1511
|
doctor:
|
|
1537
1512
|
runningDiagnostics: "Running diagnostics..."
|
|
1538
1513
|
diagnosticsComplete: "Diagnostics complete"
|
|
1539
|
-
defaultAccountOverrideFileChecks:
|
|
1540
|
-
overrideActive: "Default account override file active: {{ defaultAccountOverrideFile }}"
|
|
1541
|
-
overrideAccountId: "Active account ID: {{ overrideAccountId }}"
|
|
1542
1514
|
accountChecks:
|
|
1543
1515
|
active: "Default account active"
|
|
1544
1516
|
inactive: "Default account isn't active"
|
|
@@ -1587,8 +1559,6 @@ en:
|
|
|
1587
1559
|
defaultAccountSubHeader: "Default Account: {{accountDetails}}"
|
|
1588
1560
|
noConfigFile: "CLI configuration not found"
|
|
1589
1561
|
noConfigFileSecondary: "Run {{command}} and follow the prompts to create your CLI configuration file and connect it to your HubSpot account"
|
|
1590
|
-
defaultAccountOverrideFile:
|
|
1591
|
-
header: "Default account override file path:"
|
|
1592
1562
|
projectConfig:
|
|
1593
1563
|
header: "Project configuration"
|
|
1594
1564
|
projectDirSubHeader: "Project dir: {{#bold}}{{ projectDir }}{{/bold}}"
|
|
@@ -21,7 +21,6 @@ export declare class Diagnosis {
|
|
|
21
21
|
addCliSection(section: Section): void;
|
|
22
22
|
addProjectSection(section: Section): void;
|
|
23
23
|
addCLIConfigSection(section: Section): void;
|
|
24
|
-
addDefaultAccountOverrideFileSection(section: Section): void;
|
|
25
24
|
toString(): string;
|
|
26
25
|
private generateSections;
|
|
27
26
|
}
|
package/lib/doctor/Diagnosis.js
CHANGED
|
@@ -29,10 +29,6 @@ class Diagnosis {
|
|
|
29
29
|
header: i18n(`${i18nKey}.cliConfig.header`),
|
|
30
30
|
sections: [],
|
|
31
31
|
},
|
|
32
|
-
defaultAccountOverrideFile: {
|
|
33
|
-
header: i18n(`${i18nKey}.defaultAccountOverrideFile.header`),
|
|
34
|
-
sections: [],
|
|
35
|
-
},
|
|
36
32
|
project: {
|
|
37
33
|
header: i18n(`${i18nKey}.projectConfig.header`),
|
|
38
34
|
subheaders: [
|
|
@@ -75,9 +71,6 @@ class Diagnosis {
|
|
|
75
71
|
addCLIConfigSection(section) {
|
|
76
72
|
this.diagnosis.cliConfig.sections.push(section);
|
|
77
73
|
}
|
|
78
|
-
addDefaultAccountOverrideFileSection(section) {
|
|
79
|
-
this.diagnosis.defaultAccountOverrideFile.sections.push(section);
|
|
80
|
-
}
|
|
81
74
|
toString() {
|
|
82
75
|
const output = [];
|
|
83
76
|
for (const value of Object.values(this.diagnosis)) {
|
|
@@ -60,7 +60,6 @@ class DiagnosticInfoBuilder {
|
|
|
60
60
|
arch,
|
|
61
61
|
path: mainModule?.path,
|
|
62
62
|
config: (0, config_2.getConfigPath)(),
|
|
63
|
-
defaultAccountOverrideFile: (0, config_1.getDefaultAccountOverrideFilePath)(),
|
|
64
63
|
versions: {
|
|
65
64
|
[hubspotCli]: package_json_1.default.version,
|
|
66
65
|
node,
|
package/lib/doctor/Doctor.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare class Doctor {
|
|
|
10
10
|
private performCliChecks;
|
|
11
11
|
private performProjectChecks;
|
|
12
12
|
private performCliConfigChecks;
|
|
13
|
-
private performDefaultAccountOverrideFileChecks;
|
|
14
13
|
private checkIfAccessTokenValid;
|
|
15
14
|
private checkIfNodeIsInstalled;
|
|
16
15
|
private checkIfNpmIsInstalled;
|
package/lib/doctor/Doctor.js
CHANGED
|
@@ -51,7 +51,6 @@ class Doctor {
|
|
|
51
51
|
...this.performCliConfigChecks(),
|
|
52
52
|
...(this.projectConfig?.projectConfig ? this.performProjectChecks() : []),
|
|
53
53
|
]);
|
|
54
|
-
this.performDefaultAccountOverrideFileChecks();
|
|
55
54
|
SpinniesManager_1.default.succeed('runningDiagnostics', {
|
|
56
55
|
text: i18n(`${i18nKey}.diagnosticsComplete`),
|
|
57
56
|
succeedColor: 'white',
|
|
@@ -88,23 +87,6 @@ class Doctor {
|
|
|
88
87
|
}
|
|
89
88
|
return [this.checkIfAccessTokenValid()];
|
|
90
89
|
}
|
|
91
|
-
performDefaultAccountOverrideFileChecks() {
|
|
92
|
-
const localI18nKey = `${i18nKey}.defaultAccountOverrideFileChecks`;
|
|
93
|
-
if (this.diagnosticInfo?.defaultAccountOverrideFile) {
|
|
94
|
-
this.diagnosis?.addDefaultAccountOverrideFileSection({
|
|
95
|
-
type: 'warning',
|
|
96
|
-
message: i18n(`${localI18nKey}.overrideActive`, {
|
|
97
|
-
defaultAccountOverrideFile: this.diagnosticInfo.defaultAccountOverrideFile,
|
|
98
|
-
}),
|
|
99
|
-
});
|
|
100
|
-
this.diagnosis?.addDefaultAccountOverrideFileSection({
|
|
101
|
-
type: 'warning',
|
|
102
|
-
message: i18n(`${localI18nKey}.overrideAccountId`, {
|
|
103
|
-
overrideAccountId: (0, config_1.getCWDAccountOverride)(),
|
|
104
|
-
}),
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
90
|
async checkIfAccessTokenValid() {
|
|
109
91
|
const localI18nKey = `${i18nKey}.accountChecks`;
|
|
110
92
|
try {
|
|
@@ -24,8 +24,11 @@ function useV3Api(platformVersion) {
|
|
|
24
24
|
if (!platformVersion || typeof platformVersion !== 'string') {
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
27
|
+
if (platformVersion.toLowerCase() === 'unstable') {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
27
30
|
const [year, minor] = platformVersion.split('.');
|
|
28
|
-
return Number(year) >= 2025 && Number(minor) >=
|
|
31
|
+
return Number(year) >= 2025 && Number(minor) >= 2;
|
|
29
32
|
}
|
|
30
33
|
function getSubtasks(task) {
|
|
31
34
|
if ('subbuildStatuses' in task) {
|
|
@@ -4,7 +4,7 @@ type AccountNamePromptResponse = {
|
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function getCliAccountNamePromptConfig(defaultName?: string): PromptConfig<AccountNamePromptResponse>;
|
|
7
|
-
export declare function cliAccountNamePrompt(defaultName
|
|
7
|
+
export declare function cliAccountNamePrompt(defaultName: string): Promise<AccountNamePromptResponse>;
|
|
8
8
|
export declare function hubspotAccountNamePrompt({ accountType, currentPortalCount, }: {
|
|
9
9
|
accountType: AccountType;
|
|
10
10
|
currentPortalCount?: number;
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function uiLink(linkText: string, url: string): string;
|
|
|
8
8
|
export declare function uiAccountDescription(accountId?: number | null, bold?: boolean): string;
|
|
9
9
|
export declare function uiInfoSection(title: string, logContent: () => void): void;
|
|
10
10
|
export declare function uiCommandReference(command: string): string;
|
|
11
|
-
export declare function uiFeatureHighlight(commands: string[], title
|
|
11
|
+
export declare function uiFeatureHighlight(commands: string[], title: string): void;
|
|
12
12
|
export declare function uiBetaTag(message: string, log?: boolean): void | string;
|
|
13
13
|
export declare function uiDeprecatedTag(message: string): void;
|
|
14
14
|
export declare function uiCommandDisabledBanner(command: string, url?: string, message?: string): void;
|
package/lib/usageTracking.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ type Meta = {
|
|
|
16
16
|
export declare function trackCommandUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
|
|
17
17
|
export declare function trackHelpUsage(command: string): Promise<void>;
|
|
18
18
|
export declare function trackConvertFieldsUsage(command: string): Promise<void>;
|
|
19
|
-
export declare function trackAuthAction(command: string, authType: string, step: string, accountId
|
|
19
|
+
export declare function trackAuthAction(command: string, authType: string, step: string, accountId: number): Promise<void>;
|
|
20
20
|
export declare function trackCommandMetadataUsage(command: string, meta?: Meta, accountId?: number): Promise<void>;
|
|
21
21
|
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.14-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@hubspot/local-dev-lib": "3.3.1",
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.0.
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.0.5-beta.0",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.2",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
12
|
"@hubspot/ui-extensions-dev-server": "0.8.42",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
-
export declare const describe: undefined;
|
|
4
|
-
export declare const command = "auth";
|
|
5
|
-
type AccountAuthArgs = CommonArgs & ConfigArgs & {
|
|
6
|
-
disableTracking?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function handler(args: ArgumentsCamelCase<AccountAuthArgs>): Promise<void>;
|
|
9
|
-
export declare function builder(yargs: Argv): Argv<AccountAuthArgs>;
|
|
10
|
-
export {};
|
package/commands/account/auth.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.command = exports.describe = void 0;
|
|
4
|
-
exports.handler = handler;
|
|
5
|
-
exports.builder = builder;
|
|
6
|
-
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
7
|
-
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
8
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
9
|
-
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
10
|
-
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
11
|
-
const text_1 = require("@hubspot/local-dev-lib/text");
|
|
12
|
-
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
13
|
-
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
14
|
-
const commonOpts_1 = require("../../lib/commonOpts");
|
|
15
|
-
const process_1 = require("../../lib/process");
|
|
16
|
-
const index_1 = require("../../lib/errorHandlers/index");
|
|
17
|
-
const lang_1 = require("../../lib/lang");
|
|
18
|
-
const usageTracking_1 = require("../../lib/usageTracking");
|
|
19
|
-
const personalAccessKeyPrompt_1 = require("../../lib/prompts/personalAccessKeyPrompt");
|
|
20
|
-
const accountNamePrompt_1 = require("../../lib/prompts/accountNamePrompt");
|
|
21
|
-
const setAsDefaultAccountPrompt_1 = require("../../lib/prompts/setAsDefaultAccountPrompt");
|
|
22
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
23
|
-
const ui_1 = require("../../lib/ui");
|
|
24
|
-
const i18nKey = 'commands.account.subcommands.auth';
|
|
25
|
-
const TRACKING_STATUS = {
|
|
26
|
-
STARTED: 'started',
|
|
27
|
-
ERROR: 'error',
|
|
28
|
-
COMPLETE: 'complete',
|
|
29
|
-
};
|
|
30
|
-
async function createOrUpdateConfig(env, doesConfigExist, disableTracking, authType, account) {
|
|
31
|
-
try {
|
|
32
|
-
const { personalAccessKey } = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
|
|
33
|
-
env,
|
|
34
|
-
account,
|
|
35
|
-
});
|
|
36
|
-
const token = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env);
|
|
37
|
-
const defaultName = token.hubName ? (0, text_1.toKebabCase)(token.hubName) : undefined;
|
|
38
|
-
const name = doesConfigExist
|
|
39
|
-
? undefined
|
|
40
|
-
: (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
|
|
41
|
-
const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env, name, !doesConfigExist);
|
|
42
|
-
if (!updatedConfig)
|
|
43
|
-
return null;
|
|
44
|
-
if (doesConfigExist && !updatedConfig.name) {
|
|
45
|
-
updatedConfig.name = (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
|
|
46
|
-
(0, config_1.updateAccountConfig)({
|
|
47
|
-
...updatedConfig,
|
|
48
|
-
});
|
|
49
|
-
(0, config_1.writeConfig)();
|
|
50
|
-
}
|
|
51
|
-
return updatedConfig;
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
if (!disableTracking) {
|
|
55
|
-
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
|
|
56
|
-
}
|
|
57
|
-
(0, index_1.debugError)(e);
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.describe = undefined; // i18n(`${i18nKey}.describe`);
|
|
62
|
-
exports.command = 'auth';
|
|
63
|
-
async function handler(args) {
|
|
64
|
-
const { providedAccountId, disableTracking } = args;
|
|
65
|
-
const authType = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
66
|
-
const deprecatedConfigExists = (0, config_1.configFileExists)(false);
|
|
67
|
-
if (deprecatedConfigExists) {
|
|
68
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.bothConfigFilesNotAllowed`, {
|
|
69
|
-
deprecatedConfig: config_2.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
70
|
-
}));
|
|
71
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
72
|
-
}
|
|
73
|
-
if (!disableTracking) {
|
|
74
|
-
(0, usageTracking_1.trackCommandUsage)('account-auth', {}, providedAccountId);
|
|
75
|
-
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
|
|
76
|
-
}
|
|
77
|
-
const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
|
|
78
|
-
const configExists = (0, config_1.configFileExists)(true);
|
|
79
|
-
if (!configExists) {
|
|
80
|
-
if (!disableTracking) {
|
|
81
|
-
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
|
|
82
|
-
}
|
|
83
|
-
(0, config_1.createEmptyConfigFile)({}, true);
|
|
84
|
-
}
|
|
85
|
-
(0, config_1.loadConfig)('');
|
|
86
|
-
(0, process_1.handleExit)(config_1.deleteEmptyConfigFile);
|
|
87
|
-
const updatedConfig = await createOrUpdateConfig(env, configExists, disableTracking, authType, providedAccountId);
|
|
88
|
-
if (!updatedConfig) {
|
|
89
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.failedToUpdateConfig`));
|
|
90
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
91
|
-
}
|
|
92
|
-
const { name } = updatedConfig;
|
|
93
|
-
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(updatedConfig);
|
|
94
|
-
// If the config file was just created, we don't need to prompt the user to set as default
|
|
95
|
-
if (!configExists) {
|
|
96
|
-
logger_1.logger.log('');
|
|
97
|
-
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileCreated`, {
|
|
98
|
-
configPath: (0, config_1.getConfigPath)('', true),
|
|
99
|
-
}));
|
|
100
|
-
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.configFileUpdated`, {
|
|
101
|
-
account: name || accountId || '',
|
|
102
|
-
}));
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const setAsDefault = await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(name);
|
|
106
|
-
logger_1.logger.log('');
|
|
107
|
-
if (setAsDefault) {
|
|
108
|
-
logger_1.logger.success((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount`, {
|
|
109
|
-
accountName: name,
|
|
110
|
-
}));
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
logger_1.logger.info((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
|
|
114
|
-
accountName: (0, config_1.getConfigDefaultAccount)(),
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
(0, ui_1.uiFeatureHighlight)(['helpCommand', 'authCommand', 'accountsListCommand']);
|
|
119
|
-
if (!disableTracking) {
|
|
120
|
-
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.COMPLETE, accountId);
|
|
121
|
-
}
|
|
122
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
123
|
-
}
|
|
124
|
-
function builder(yargs) {
|
|
125
|
-
yargs.options({
|
|
126
|
-
account: {
|
|
127
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
128
|
-
type: 'string',
|
|
129
|
-
alias: 'a',
|
|
130
|
-
},
|
|
131
|
-
'disable-tracking': {
|
|
132
|
-
type: 'boolean',
|
|
133
|
-
hidden: true,
|
|
134
|
-
default: false,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
(0, commonOpts_1.addTestingOptions)(yargs);
|
|
138
|
-
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
139
|
-
return yargs;
|
|
140
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
-
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
-
export declare const describe: undefined;
|
|
4
|
-
export declare const command = "create-override [account]";
|
|
5
|
-
type AccountCreateOverrideArgs = CommonArgs & {
|
|
6
|
-
account: string | number;
|
|
7
|
-
};
|
|
8
|
-
export declare function handler(args: ArgumentsCamelCase<AccountCreateOverrideArgs>): Promise<void>;
|
|
9
|
-
export declare function builder(yargs: Argv): Argv<AccountCreateOverrideArgs>;
|
|
10
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.command = exports.describe = void 0;
|
|
7
|
-
exports.handler = handler;
|
|
8
|
-
exports.builder = builder;
|
|
9
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
12
|
-
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
-
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
14
|
-
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
15
|
-
const lang_1 = require("../../lib/lang");
|
|
16
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
17
|
-
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
18
|
-
const index_1 = require("../../lib/errorHandlers/index");
|
|
19
|
-
const i18nKey = 'commands.account.subcommands.createOverride';
|
|
20
|
-
exports.describe = undefined; // i18n(`${i18nKey}.describe`);
|
|
21
|
-
exports.command = 'create-override [account]';
|
|
22
|
-
async function handler(args) {
|
|
23
|
-
let overrideDefaultAccount = args.account;
|
|
24
|
-
if (!overrideDefaultAccount) {
|
|
25
|
-
overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
26
|
-
}
|
|
27
|
-
else if (!(0, config_2.getAccountId)(overrideDefaultAccount)) {
|
|
28
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountNotFound`, {
|
|
29
|
-
configPath: (0, config_2.getConfigPath)() || '',
|
|
30
|
-
}));
|
|
31
|
-
overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
32
|
-
}
|
|
33
|
-
const accountId = (0, config_2.getAccountId)(overrideDefaultAccount);
|
|
34
|
-
try {
|
|
35
|
-
const overrideFilePath = path_1.default.join((0, path_2.getCwd)(), config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME);
|
|
36
|
-
await fs_extra_1.default.writeFile(overrideFilePath, accountId.toString(), 'utf8');
|
|
37
|
-
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success`, { overrideFilePath }));
|
|
38
|
-
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
(0, index_1.logError)(e);
|
|
42
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function builder(yargs) {
|
|
46
|
-
yargs.positional('account', {
|
|
47
|
-
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
48
|
-
type: 'string',
|
|
49
|
-
});
|
|
50
|
-
yargs.example([
|
|
51
|
-
['$0 account create-override', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
52
|
-
[
|
|
53
|
-
'$0 account create-override 12345678',
|
|
54
|
-
(0, lang_1.i18n)(`${i18nKey}.examples.idBased`),
|
|
55
|
-
],
|
|
56
|
-
[
|
|
57
|
-
'$0 account create-override MyAccount',
|
|
58
|
-
(0, lang_1.i18n)(`${i18nKey}.examples.nameBased`),
|
|
59
|
-
],
|
|
60
|
-
]);
|
|
61
|
-
return yargs;
|
|
62
|
-
}
|