@hubspot/cli 7.2.5-experimental.0 → 7.3.0-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +79 -73
- package/commands/account/clean.js +5 -36
- package/commands/account/info.js +0 -23
- package/commands/account/list.js +4 -22
- package/commands/account/remove.js +0 -28
- package/commands/account/use.js +0 -13
- package/commands/account.js +0 -6
- package/commands/auth.js +2 -6
- package/commands/config/set.d.ts +0 -12
- package/commands/config/set.js +29 -30
- package/commands/config.d.ts +1 -4
- package/commands/config.js +10 -45
- package/commands/customObject.d.ts +1 -1
- package/commands/init.js +10 -9
- package/commands/mv.d.ts +1 -1
- package/commands/project/add.d.ts +10 -0
- package/commands/project/add.js +64 -52
- package/commands/project/deploy.d.ts +11 -1
- package/commands/project/deploy.js +79 -71
- package/commands/project/dev/index.d.ts +1 -1
- package/commands/project/download.d.ts +11 -0
- package/commands/project/download.js +56 -54
- package/commands/project/listBuilds.d.ts +10 -0
- package/commands/project/listBuilds.js +101 -91
- package/commands/project/open.d.ts +9 -0
- package/commands/project/open.js +43 -35
- package/commands/sandbox/create.d.ts +1 -1
- package/commands/sandbox/delete.d.ts +1 -1
- package/commands/sandbox.d.ts +1 -1
- package/lang/en.js +3448 -0
- package/lang/en.lyaml +13 -88
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +13 -39
- package/lib/doctor/Diagnosis.d.ts +2 -1
- package/lib/doctor/Diagnosis.js +6 -10
- 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 +2 -19
- package/lib/errorHandlers/index.js +17 -0
- package/lib/npm.d.ts +9 -0
- package/lib/npm.js +36 -0
- package/lib/projects/buildAndDeploy.d.ts +1 -1
- package/lib/projects/buildAndDeploy.js +1 -1
- package/lib/projects/index.d.ts +1 -1
- package/lib/projects/index.js +1 -1
- package/lib/prompts/downloadProjectPrompt.js +5 -1
- package/lib/prompts/projectNamePrompt.d.ts +6 -1
- package/lib/prompts/projectNamePrompt.js +17 -16
- package/lib/testUtils.d.ts +4 -2
- package/lib/testUtils.js +17 -3
- package/lib/ui/index.d.ts +2 -2
- package/lib/ui/index.js +0 -5
- package/lib/yargsUtils.d.ts +2 -2
- package/lib/yargsUtils.js +2 -2
- package/package.json +2 -2
- package/commands/account/auth.d.ts +0 -10
- package/commands/account/auth.js +0 -169
- package/commands/account/createOverride.d.ts +0 -10
- package/commands/account/createOverride.js +0 -103
- package/commands/account/removeOverride.d.ts +0 -10
- package/commands/account/removeOverride.js +0 -77
- package/commands/config/migrate.d.ts +0 -10
- package/commands/config/migrate.js +0 -85
- package/lib/configMigrate.d.ts +0 -2
- package/lib/configMigrate.js +0 -105
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');
|
|
@@ -17,6 +16,8 @@ const { i18n } = require('../lib/lang');
|
|
|
17
16
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
18
17
|
const { UI_COLORS, uiCommandReference, uiDeprecatedTag } = require('../lib/ui');
|
|
19
18
|
const { checkAndWarnGitInclusion } = require('../lib/ui/git');
|
|
19
|
+
const SpinniesManager = require('../lib/ui/SpinniesManager');
|
|
20
|
+
const { isGloballyInstalled, executeInstall } = require('../lib/npm');
|
|
20
21
|
const removeCommand = require('../commands/remove');
|
|
21
22
|
const initCommand = require('../commands/init');
|
|
22
23
|
const logsCommand = require('../commands/logs');
|
|
@@ -51,27 +52,29 @@ const notifier = updateNotifier({
|
|
|
51
52
|
});
|
|
52
53
|
const i18nKey = 'commands.generalErrors';
|
|
53
54
|
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
55
|
+
const showUpdateNotification = () => {
|
|
56
|
+
notifier.notify({
|
|
57
|
+
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
58
|
+
? i18n(`${i18nKey}.updateNotify.cmsUpdateNotification`, {
|
|
59
|
+
packageName: CMS_CLI_PACKAGE_NAME,
|
|
60
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
61
|
+
})
|
|
62
|
+
: i18n(`${i18nKey}.updateNotify.cliUpdateNotification`, {
|
|
63
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
64
|
+
}),
|
|
65
|
+
defer: false,
|
|
66
|
+
boxenOptions: {
|
|
67
|
+
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
68
|
+
margin: 1,
|
|
69
|
+
padding: 1,
|
|
70
|
+
textAlignment: 'center',
|
|
71
|
+
borderStyle: 'round',
|
|
72
|
+
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
73
|
+
? null
|
|
74
|
+
: chalk.bold(i18n(`${i18nKey}.updateNotify.notifyTitle`)),
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
};
|
|
75
78
|
const getTerminalWidth = () => {
|
|
76
79
|
const width = yargs.terminalWidth();
|
|
77
80
|
if (width >= 100)
|
|
@@ -121,6 +124,56 @@ const performChecks = argv => {
|
|
|
121
124
|
const setRequestHeaders = () => {
|
|
122
125
|
addUserAgentHeader('HubSpot CLI', pkg.version);
|
|
123
126
|
};
|
|
127
|
+
const updateCLIVersion = async () => {
|
|
128
|
+
if (!process.env.SKIP_HUBSPOT_CLI_AUTO_UPDATES &&
|
|
129
|
+
notifier &&
|
|
130
|
+
notifier.update) {
|
|
131
|
+
let updateInfo;
|
|
132
|
+
try {
|
|
133
|
+
updateInfo = await notifier.fetchInfo();
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
// Update if the current version is not the latest version.
|
|
139
|
+
// Don't auto-update if the current version is a pre-release
|
|
140
|
+
// or if this would be a major version update
|
|
141
|
+
if (updateInfo.current.includes('-') &&
|
|
142
|
+
!['major', 'latest'].includes(updateInfo.type)) {
|
|
143
|
+
SpinniesManager.init({
|
|
144
|
+
succeedColor: 'white',
|
|
145
|
+
});
|
|
146
|
+
SpinniesManager.add('cliAutoUpdate', {
|
|
147
|
+
text: `New HubSpot CLI version available. Updating to version ${updateInfo.latest}`,
|
|
148
|
+
});
|
|
149
|
+
let showManualInstallHelp = false;
|
|
150
|
+
try {
|
|
151
|
+
if (await isGloballyInstalled()) {
|
|
152
|
+
await executeInstall(['@hubspot/cli@latest'], '-g');
|
|
153
|
+
SpinniesManager.succeed('cliAutoUpdate', {
|
|
154
|
+
text: `Successfully updated HubSpot CLI to version ${updateInfo.latest}`,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
SpinniesManager.fail('cliAutoUpdate', {
|
|
159
|
+
text: `Cannot auto-update the HubSpot CLI if it is not globall installed with NPM`,
|
|
160
|
+
});
|
|
161
|
+
showManualInstallHelp = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
logger.debug(e);
|
|
166
|
+
SpinniesManager.fail('cliAutoUpdate', {
|
|
167
|
+
text: `Failed to update HubSpot CLI to version ${updateInfo.latest}`,
|
|
168
|
+
});
|
|
169
|
+
showManualInstallHelp = true;
|
|
170
|
+
}
|
|
171
|
+
if (showManualInstallHelp) {
|
|
172
|
+
showUpdateNotification();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
124
177
|
const isTargetedCommand = (options, commandMap) => {
|
|
125
178
|
const checkCommand = (options, commandMap) => {
|
|
126
179
|
const currentCommand = options._[0];
|
|
@@ -138,17 +191,9 @@ const isTargetedCommand = (options, commandMap) => {
|
|
|
138
191
|
};
|
|
139
192
|
return checkCommand(options, commandMap);
|
|
140
193
|
};
|
|
141
|
-
const skipConfigAccountsSubCommands = {
|
|
142
|
-
target: false,
|
|
143
|
-
subCommands: {
|
|
144
|
-
auth: { target: true },
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
194
|
const SKIP_CONFIG_VALIDATION = {
|
|
148
195
|
init: { target: true },
|
|
149
196
|
auth: { target: true },
|
|
150
|
-
accounts: skipConfigAccountsSubCommands,
|
|
151
|
-
account: skipConfigAccountsSubCommands,
|
|
152
197
|
};
|
|
153
198
|
const handleDeprecatedEnvVariables = options => {
|
|
154
199
|
// HUBSPOT_PORTAL_ID is deprecated, but we'll still support it for now
|
|
@@ -173,39 +218,9 @@ const injectAccountIdMiddleware = async (options) => {
|
|
|
173
218
|
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
174
219
|
}
|
|
175
220
|
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
|
-
}
|
|
221
|
+
options.derivedAccountId = getAccountId(account);
|
|
196
222
|
}
|
|
197
223
|
};
|
|
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
|
-
const SKIP_CONFIG_FLAG_VALIDATION = {
|
|
207
|
-
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
208
|
-
};
|
|
209
224
|
const loadConfigMiddleware = async (options) => {
|
|
210
225
|
// Skip this when no command is provided
|
|
211
226
|
if (!options._.length) {
|
|
@@ -217,21 +232,13 @@ const loadConfigMiddleware = async (options) => {
|
|
|
217
232
|
process.exit(EXIT_CODES.ERROR);
|
|
218
233
|
}
|
|
219
234
|
};
|
|
220
|
-
if (configFileExists(true) &&
|
|
221
|
-
options.config &&
|
|
222
|
-
!isTargetedCommand(options, SKIP_CONFIG_FLAG_VALIDATION)) {
|
|
235
|
+
if (configFileExists(true) && options.config) {
|
|
223
236
|
logger.error(i18n(`${i18nKey}.loadConfigMiddleware.configFileExists`, {
|
|
224
237
|
configPath: getConfigPath(),
|
|
225
238
|
}));
|
|
226
239
|
process.exit(EXIT_CODES.ERROR);
|
|
227
240
|
}
|
|
228
|
-
|
|
229
|
-
// 1. `hs init`
|
|
230
|
-
// 2. `hs account auth` only if the global config file does not exist
|
|
231
|
-
if (!isTargetedCommand(options, {
|
|
232
|
-
init: { target: true },
|
|
233
|
-
}) &&
|
|
234
|
-
!(isTargetedCommand(options, SKIP_LOAD_CONFIG) && !configFileExists(true))) {
|
|
241
|
+
else if (!isTargetedCommand(options, { init: { target: true } })) {
|
|
235
242
|
const { config: configPath } = options;
|
|
236
243
|
const config = loadConfig(configPath, options);
|
|
237
244
|
// We don't run validateConfig() for auth because users should be able to run it when
|
|
@@ -252,7 +259,6 @@ const checkAndWarnGitInclusionMiddleware = options => {
|
|
|
252
259
|
const accountsSubCommands = {
|
|
253
260
|
target: false,
|
|
254
261
|
subCommands: {
|
|
255
|
-
auth: { target: true },
|
|
256
262
|
clean: { target: true },
|
|
257
263
|
list: { target: true },
|
|
258
264
|
ls: { target: true },
|
|
@@ -268,7 +274,6 @@ const sandboxesSubCommands = {
|
|
|
268
274
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
269
275
|
init: { target: true },
|
|
270
276
|
auth: { target: true },
|
|
271
|
-
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
272
277
|
account: accountsSubCommands,
|
|
273
278
|
accounts: accountsSubCommands,
|
|
274
279
|
sandbox: sandboxesSubCommands,
|
|
@@ -292,6 +297,7 @@ const argv = yargs
|
|
|
292
297
|
// loadConfigMiddleware loads the new hidden config for all commands
|
|
293
298
|
.middleware([
|
|
294
299
|
setLogLevel,
|
|
300
|
+
updateCLIVersion,
|
|
295
301
|
setRequestHeaders,
|
|
296
302
|
handleDeprecatedEnvVariables,
|
|
297
303
|
loadConfigMiddleware,
|
|
@@ -6,23 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.describe = exports.command = void 0;
|
|
7
7
|
exports.handler = handler;
|
|
8
8
|
exports.builder = builder;
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
9
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
10
|
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
12
11
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
13
12
|
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
14
13
|
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
15
|
-
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
16
14
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
17
15
|
const lang_1 = require("../../lib/lang");
|
|
18
16
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
19
17
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
20
18
|
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
21
|
-
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
22
19
|
const table_1 = require("../../lib/ui/table");
|
|
23
20
|
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
24
21
|
const ui_1 = require("../../lib/ui");
|
|
25
|
-
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
26
22
|
const i18nKey = 'commands.account.subcommands.clean';
|
|
27
23
|
exports.command = 'clean';
|
|
28
24
|
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
@@ -74,52 +70,25 @@ async function handler(args) {
|
|
|
74
70
|
logger_1.logger.log((0, table_1.getTableContents)(accountsToRemove.map(p => [
|
|
75
71
|
(0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(p)),
|
|
76
72
|
]), { border: { bodyLeft: ' ' } }));
|
|
77
|
-
let promptMessage = (0, lang_1.i18n)(oneAccountFound ? `${i18nKey}.confirm.one` : `${i18nKey}.confirm.other`, {
|
|
78
|
-
count: accountsToRemove.length,
|
|
79
|
-
});
|
|
80
|
-
const accountOverride = (0, config_2.getCWDAccountOverride)();
|
|
81
|
-
const overrideFilePath = (0, config_2.getDefaultAccountOverrideFilePath)();
|
|
82
|
-
const accountOverrideMatches = accountsToRemove.some(account => account.name === accountOverride ||
|
|
83
|
-
// @ts-expect-error: Default account override files can only exist with global config
|
|
84
|
-
account.accountId === accountOverride);
|
|
85
|
-
if (overrideFilePath && accountOverride && accountOverrideMatches) {
|
|
86
|
-
promptMessage = `${promptMessage}${(0, lang_1.i18n)(`${i18nKey}.defaultAccountOverride`, {
|
|
87
|
-
overrideFilePath,
|
|
88
|
-
})}`;
|
|
89
|
-
}
|
|
90
73
|
const { accountsCleanPrompt } = await (0, promptUtils_1.promptUser)([
|
|
91
74
|
{
|
|
92
75
|
name: 'accountsCleanPrompt',
|
|
93
76
|
type: 'confirm',
|
|
94
|
-
message:
|
|
77
|
+
message: (0, lang_1.i18n)(oneAccountFound
|
|
78
|
+
? `${i18nKey}.confirm.one`
|
|
79
|
+
: `${i18nKey}.confirm.other`, {
|
|
80
|
+
count: accountsToRemove.length,
|
|
81
|
+
}),
|
|
95
82
|
},
|
|
96
83
|
]);
|
|
97
84
|
if (accountsCleanPrompt) {
|
|
98
85
|
logger_1.logger.log('');
|
|
99
|
-
try {
|
|
100
|
-
if (overrideFilePath) {
|
|
101
|
-
fs_1.default.unlinkSync(overrideFilePath);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
(0, errorHandlers_1.logError)(error);
|
|
106
|
-
}
|
|
107
86
|
for (const accountToRemove of accountsToRemove) {
|
|
108
87
|
await (0, config_1.deleteAccount)(accountToRemove.name);
|
|
109
88
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.removeSuccess`, {
|
|
110
89
|
accountName: accountToRemove.name,
|
|
111
90
|
}));
|
|
112
91
|
}
|
|
113
|
-
// Get updated version of the config
|
|
114
|
-
(0, config_1.loadConfig)((0, config_1.getConfigPath)());
|
|
115
|
-
const defaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
116
|
-
if (defaultAccount &&
|
|
117
|
-
accountsToRemove.some(p => p.name === defaultAccount)) {
|
|
118
|
-
logger_1.logger.log();
|
|
119
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.replaceDefaultAccount`));
|
|
120
|
-
const newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
121
|
-
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
122
|
-
}
|
|
123
92
|
}
|
|
124
93
|
}
|
|
125
94
|
else {
|
package/commands/account/info.js
CHANGED
|
@@ -7,7 +7,6 @@ const config_1 = require("@hubspot/local-dev-lib/config");
|
|
|
7
7
|
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
8
8
|
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
9
9
|
const lang_1 = require("../../lib/lang");
|
|
10
|
-
const index_1 = require("../../lib/ui/index");
|
|
11
10
|
const table_1 = require("../../lib/ui/table");
|
|
12
11
|
const i18nKey = 'commands.account.subcommands.info';
|
|
13
12
|
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
@@ -21,28 +20,6 @@ async function handler(args) {
|
|
|
21
20
|
let scopeGroups = [];
|
|
22
21
|
const response = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env, derivedAccountId);
|
|
23
22
|
scopeGroups = response.scopeGroups.map(s => [s]);
|
|
24
|
-
// If a default account is present in the config, display it
|
|
25
|
-
const configPath = (0, config_1.getConfigPath)();
|
|
26
|
-
if (configPath) {
|
|
27
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.defaultAccountTitle`));
|
|
28
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.configPath`, {
|
|
29
|
-
configPath,
|
|
30
|
-
})}`);
|
|
31
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.defaultAccount`, {
|
|
32
|
-
account: (0, config_1.getDisplayDefaultAccount)(),
|
|
33
|
-
})}`);
|
|
34
|
-
}
|
|
35
|
-
// If a default account override is present, display it
|
|
36
|
-
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
37
|
-
if (overrideFilePath) {
|
|
38
|
-
logger_1.logger.log('');
|
|
39
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.overrideFilePathTitle`));
|
|
40
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.overrideFilePath`, { overrideFilePath })}`);
|
|
41
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.overrideAccount`, {
|
|
42
|
-
account: (0, config_1.getConfigDefaultAccount)(),
|
|
43
|
-
})}`);
|
|
44
|
-
}
|
|
45
|
-
logger_1.logger.log('');
|
|
46
23
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.name`, { name: name }));
|
|
47
24
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accountId`, { accountId: derivedAccountId }));
|
|
48
25
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.scopeGroups`));
|
package/commands/account/list.js
CHANGED
|
@@ -7,7 +7,6 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
|
7
7
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
8
|
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
9
9
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
|
-
const index_1 = require("../../lib/ui/index");
|
|
11
10
|
const table_1 = require("../../lib/ui/table");
|
|
12
11
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
13
12
|
const accountTypes_1 = require("../../lib/accountTypes");
|
|
@@ -82,27 +81,10 @@ async function handler(args) {
|
|
|
82
81
|
(0, lang_1.i18n)(`${i18nKey}.labels.accountId`),
|
|
83
82
|
(0, lang_1.i18n)(`${i18nKey}.labels.authType`),
|
|
84
83
|
]));
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
configPath,
|
|
90
|
-
})}`);
|
|
91
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.defaultAccount`, {
|
|
92
|
-
account: (0, config_1.getDisplayDefaultAccount)(),
|
|
93
|
-
})}`);
|
|
94
|
-
logger_1.logger.log('');
|
|
95
|
-
}
|
|
96
|
-
// If a default account override is present, display it
|
|
97
|
-
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
98
|
-
if (overrideFilePath) {
|
|
99
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.overrideFilePathTitle`));
|
|
100
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.overrideFilePath`, { overrideFilePath })}`);
|
|
101
|
-
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`${i18nKey}.overrideAccount`, {
|
|
102
|
-
account: (0, config_1.getConfigDefaultAccount)(),
|
|
103
|
-
})}`);
|
|
104
|
-
logger_1.logger.log('');
|
|
105
|
-
}
|
|
84
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.configPath`, { configPath: configPath }));
|
|
85
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.defaultAccount`, {
|
|
86
|
+
account: (0, config_1.getConfigDefaultAccount)(),
|
|
87
|
+
}));
|
|
106
88
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accounts`));
|
|
107
89
|
logger_1.logger.log((0, table_1.getTableContents)(accountData, { border: { bodyLeft: ' ' } }));
|
|
108
90
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.describe = exports.command = void 0;
|
|
7
4
|
exports.handler = handler;
|
|
8
5
|
exports.builder = builder;
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
6
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
7
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
12
8
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
13
9
|
const lang_1 = require("../../lib/lang");
|
|
14
|
-
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
15
|
-
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
16
10
|
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
17
11
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
18
12
|
const i18nKey = 'commands.account.subcommands.remove';
|
|
@@ -32,28 +26,6 @@ async function handler(args) {
|
|
|
32
26
|
}
|
|
33
27
|
(0, usageTracking_1.trackCommandUsage)('accounts-remove', undefined, (0, config_1.getAccountId)(accountToRemove));
|
|
34
28
|
const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
35
|
-
const accountOverride = (0, config_1.getCWDAccountOverride)();
|
|
36
|
-
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
37
|
-
if (overrideFilePath &&
|
|
38
|
-
accountOverride &&
|
|
39
|
-
accountOverride === accountToRemove) {
|
|
40
|
-
const { deleteOverrideFile } = await (0, promptUtils_1.promptUser)({
|
|
41
|
-
type: 'confirm',
|
|
42
|
-
name: 'deleteOverrideFile',
|
|
43
|
-
message: (0, lang_1.i18n)(`${i18nKey}.prompts.deleteOverrideFile`, {
|
|
44
|
-
overrideFilePath,
|
|
45
|
-
accountName: accountToRemove,
|
|
46
|
-
}),
|
|
47
|
-
});
|
|
48
|
-
try {
|
|
49
|
-
if (deleteOverrideFile) {
|
|
50
|
-
fs_1.default.unlinkSync(overrideFilePath);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
(0, errorHandlers_1.logError)(error);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
29
|
await (0, config_1.deleteAccount)(accountToRemove);
|
|
58
30
|
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.accountRemoved`, {
|
|
59
31
|
accountName: accountToRemove,
|
package/commands/account/use.js
CHANGED
|
@@ -8,7 +8,6 @@ const config_1 = require("@hubspot/local-dev-lib/config");
|
|
|
8
8
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
9
9
|
const lang_1 = require("../../lib/lang");
|
|
10
10
|
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
11
|
-
const ui_1 = require("../../lib/ui");
|
|
12
11
|
const i18nKey = 'commands.account.subcommands.use';
|
|
13
12
|
exports.command = 'use [account]';
|
|
14
13
|
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
@@ -25,18 +24,6 @@ async function handler(args) {
|
|
|
25
24
|
newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
26
25
|
}
|
|
27
26
|
(0, usageTracking_1.trackCommandUsage)('accounts-use', undefined, (0, config_1.getAccountId)(newDefaultAccount));
|
|
28
|
-
const accountOverride = (0, config_1.getCWDAccountOverride)();
|
|
29
|
-
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
30
|
-
if (accountOverride && overrideFilePath) {
|
|
31
|
-
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.accountOverride`, {
|
|
32
|
-
accountOverride,
|
|
33
|
-
}));
|
|
34
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accountOverrideCommands`, {
|
|
35
|
-
createOverrideCommand: (0, ui_1.uiCommandReference)('hs account create-override'),
|
|
36
|
-
removeOverrideCommand: (0, ui_1.uiCommandReference)('hs account remove-override'),
|
|
37
|
-
}));
|
|
38
|
-
logger_1.logger.log('');
|
|
39
|
-
}
|
|
40
27
|
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
41
28
|
return logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.defaultAccountUpdated`, {
|
|
42
29
|
accountName: newDefaultAccount,
|
package/commands/account.js
CHANGED
|
@@ -37,30 +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
|
-
const removeOverride = __importStar(require("./account/removeOverride"));
|
|
49
46
|
const i18nKey = 'commands.account';
|
|
50
47
|
exports.command = ['account', 'accounts'];
|
|
51
48
|
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
52
49
|
function builder(yargs) {
|
|
53
50
|
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
54
51
|
yargs
|
|
55
|
-
.command(auth)
|
|
56
52
|
.command(list)
|
|
57
53
|
.command(rename)
|
|
58
54
|
.command(use)
|
|
59
55
|
.command(info)
|
|
60
56
|
.command(remove)
|
|
61
57
|
.command(clean)
|
|
62
|
-
.command(createOverride)
|
|
63
|
-
.command(removeOverride)
|
|
64
58
|
.demandCommand(1, '');
|
|
65
59
|
return yargs;
|
|
66
60
|
}
|
package/commands/auth.js
CHANGED
|
@@ -47,12 +47,8 @@ async function handler(args) {
|
|
|
47
47
|
if (configPath) {
|
|
48
48
|
(0, git_1.checkAndWarnGitInclusion)(configPath);
|
|
49
49
|
}
|
|
50
|
-
if ((0, config_2.
|
|
51
|
-
|
|
52
|
-
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.globalConfigFileExists`, {
|
|
53
|
-
configPath: globalConfigPath,
|
|
54
|
-
authCommand: (0, ui_1.uiCommandReference)('hs account auth'),
|
|
55
|
-
}));
|
|
50
|
+
if (!(0, config_2.getConfigPath)(configFlagValue)) {
|
|
51
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.noConfigFileFound`));
|
|
56
52
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
57
53
|
}
|
|
58
54
|
(0, usageTracking_1.trackCommandUsage)('auth');
|
package/commands/config/set.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
-
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
-
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
4
|
-
export declare const command = "set";
|
|
5
|
-
export declare const describe: string;
|
|
6
|
-
type ConfigSetArgs = CommonArgs & {
|
|
7
|
-
defaultCmsPublishMode: CmsPublishMode;
|
|
8
|
-
allowUsageTracking?: boolean;
|
|
9
|
-
httpTimeout?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function handler(args: ArgumentsCamelCase<ConfigSetArgs>): Promise<void>;
|
|
12
|
-
export declare function builder(yargs: Argv): Argv<ConfigSetArgs>;
|
|
13
1
|
export {};
|
package/commands/config/set.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
10
|
-
const configOptions_1 = require("../../lib/configOptions");
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const { i18n } = require('../../lib/lang');
|
|
5
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
6
|
+
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
7
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
8
|
+
const { setDefaultCmsPublishMode, setHttpTimeout, setAllowUsageTracking, } = require('../../lib/configOptions');
|
|
11
9
|
const i18nKey = 'commands.config.subcommands.set';
|
|
12
10
|
exports.command = 'set';
|
|
13
|
-
exports.describe =
|
|
14
|
-
async
|
|
15
|
-
const { cmsPublishMode } = await
|
|
11
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
+
const selectOptions = async () => {
|
|
13
|
+
const { cmsPublishMode } = await promptUser([
|
|
16
14
|
{
|
|
17
15
|
type: 'list',
|
|
16
|
+
look: false,
|
|
18
17
|
name: 'cmsPublishMode',
|
|
19
18
|
pageSize: 20,
|
|
20
|
-
message:
|
|
19
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
21
20
|
choices: [
|
|
22
21
|
{
|
|
23
22
|
name: 'Default CMS publish mode',
|
|
@@ -29,52 +28,52 @@ async function selectOptions() {
|
|
|
29
28
|
},
|
|
30
29
|
]);
|
|
31
30
|
return cmsPublishMode;
|
|
32
|
-
}
|
|
33
|
-
async
|
|
31
|
+
};
|
|
32
|
+
const handleConfigUpdate = async (accountId, options) => {
|
|
34
33
|
const { allowUsageTracking, defaultCmsPublishMode, httpTimeout } = options;
|
|
35
34
|
if (typeof defaultCmsPublishMode !== 'undefined') {
|
|
36
|
-
await
|
|
35
|
+
await setDefaultCmsPublishMode({ defaultCmsPublishMode, accountId });
|
|
37
36
|
return true;
|
|
38
37
|
}
|
|
39
38
|
else if (typeof httpTimeout !== 'undefined') {
|
|
40
|
-
await
|
|
39
|
+
await setHttpTimeout({ httpTimeout, accountId });
|
|
41
40
|
return true;
|
|
42
41
|
}
|
|
43
42
|
else if (typeof allowUsageTracking !== 'undefined') {
|
|
44
|
-
await
|
|
43
|
+
await setAllowUsageTracking({ allowUsageTracking, accountId });
|
|
45
44
|
return true;
|
|
46
45
|
}
|
|
47
46
|
return false;
|
|
48
|
-
}
|
|
49
|
-
async
|
|
50
|
-
const { derivedAccountId } =
|
|
51
|
-
|
|
52
|
-
const configUpdated = await handleConfigUpdate(derivedAccountId,
|
|
47
|
+
};
|
|
48
|
+
exports.handler = async (options) => {
|
|
49
|
+
const { derivedAccountId } = options;
|
|
50
|
+
trackCommandUsage('config-set', null, derivedAccountId);
|
|
51
|
+
const configUpdated = await handleConfigUpdate(derivedAccountId, options);
|
|
53
52
|
if (!configUpdated) {
|
|
54
53
|
const selectedOptions = await selectOptions();
|
|
55
54
|
await handleConfigUpdate(derivedAccountId, selectedOptions);
|
|
56
55
|
}
|
|
57
|
-
process.exit(
|
|
58
|
-
}
|
|
59
|
-
|
|
56
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
57
|
+
};
|
|
58
|
+
exports.builder = yargs => {
|
|
60
59
|
yargs
|
|
61
60
|
.options({
|
|
62
61
|
'default-cms-publish-mode': {
|
|
63
|
-
describe:
|
|
62
|
+
describe: i18n(`${i18nKey}.options.defaultMode.describe`),
|
|
64
63
|
type: 'string',
|
|
65
64
|
},
|
|
66
65
|
'allow-usage-tracking': {
|
|
67
|
-
describe:
|
|
66
|
+
describe: i18n(`${i18nKey}.options.allowUsageTracking.describe`),
|
|
68
67
|
type: 'boolean',
|
|
69
68
|
},
|
|
70
69
|
'http-timeout': {
|
|
71
|
-
describe:
|
|
70
|
+
describe: i18n(`${i18nKey}.options.httpTimeout.describe`),
|
|
72
71
|
type: 'string',
|
|
73
72
|
},
|
|
74
73
|
})
|
|
75
74
|
.conflicts('defaultCmsPublishMode', 'allowUsageTracking')
|
|
76
75
|
.conflicts('defaultCmsPublishMode', 'httpTimeout')
|
|
77
76
|
.conflicts('allowUsageTracking', 'httpTimeout')
|
|
78
|
-
.example([['$0 config set',
|
|
77
|
+
.example([['$0 config set', i18n(`${i18nKey}.examples.default`)]]);
|
|
79
78
|
return yargs;
|
|
80
|
-
}
|
|
79
|
+
};
|
package/commands/config.d.ts
CHANGED