@hubspot/cli 7.0.0-experimental.1 → 7.0.0-experimental.2
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 +97 -15
- package/bin/hs +2 -0
- package/bin/hscms +2 -0
- package/bin/silenceErrors.d.ts +2 -0
- package/bin/silenceErrors.js +12 -0
- package/commands/{accounts → account}/clean.js +10 -11
- package/commands/{accounts → account}/info.js +10 -16
- package/commands/{accounts → account}/list.js +16 -16
- package/commands/{accounts → account}/remove.js +12 -15
- package/commands/{accounts → account}/rename.js +4 -7
- package/commands/{accounts → account}/use.js +8 -14
- package/commands/account.js +26 -0
- package/commands/auth.js +30 -24
- package/commands/cms/getReactModule.js +70 -0
- package/commands/cms/lighthouseScore.js +19 -21
- package/commands/cms.js +4 -3
- package/commands/completion.js +22 -0
- package/commands/config/set.js +22 -24
- package/commands/config.js +2 -2
- package/commands/create.js +6 -3
- package/commands/customObject/create.js +19 -15
- package/commands/customObject/schema/create.js +15 -16
- package/commands/customObject/schema/delete.js +29 -11
- package/commands/customObject/schema/fetch-all.js +14 -11
- package/commands/customObject/schema/fetch.js +22 -14
- package/commands/customObject/schema/list.js +3 -6
- package/commands/customObject/schema/update.js +28 -18
- package/commands/customObject/schema.js +1 -1
- package/commands/customObject.js +3 -4
- package/commands/doctor.js +4 -2
- package/commands/feedback.js +2 -0
- package/commands/fetch.js +13 -13
- package/commands/filemanager/fetch.js +6 -7
- package/commands/filemanager/upload.js +10 -12
- package/commands/filemanager.js +1 -8
- package/commands/{functions → function}/deploy.js +13 -13
- package/commands/{functions → function}/list.js +7 -9
- package/commands/{functions → function}/server.js +5 -8
- package/commands/function.js +16 -0
- package/commands/hubdb/clear.js +14 -10
- package/commands/hubdb/create.js +37 -13
- package/commands/hubdb/delete.js +31 -10
- package/commands/hubdb/fetch.js +14 -9
- package/commands/hubdb.js +2 -3
- package/commands/init.js +37 -14
- package/commands/lint.js +6 -7
- package/commands/list.js +5 -7
- package/commands/logs.js +24 -15
- package/commands/module/marketplace-validate.js +6 -9
- package/commands/module.js +2 -1
- package/commands/mv.js +11 -13
- package/commands/open.js +11 -10
- package/commands/project/add.js +2 -5
- package/commands/project/cloneApp.js +28 -32
- package/commands/project/create.js +8 -10
- package/commands/project/deploy.js +19 -16
- package/commands/project/dev.js +17 -18
- package/commands/project/download.js +18 -15
- package/commands/project/listBuilds.js +36 -32
- package/commands/project/logs.js +6 -8
- package/commands/project/migrateApp.js +27 -27
- package/commands/project/open.js +9 -11
- package/commands/project/upload.js +30 -32
- package/commands/project/watch.js +17 -24
- package/commands/project.js +3 -4
- package/commands/remove.js +14 -13
- package/commands/sandbox/create.js +12 -15
- package/commands/sandbox/delete.js +19 -20
- package/commands/sandbox.js +4 -8
- package/commands/{secrets → secret}/addSecret.js +25 -12
- package/commands/secret/deleteSecret.js +69 -0
- package/commands/{secrets → secret}/listSecrets.js +7 -9
- package/commands/{secrets → secret}/updateSecret.js +21 -13
- package/commands/secret.js +22 -0
- package/commands/theme/generate-selectors.js +8 -8
- package/commands/theme/marketplace-validate.js +10 -13
- package/commands/theme/preview.js +7 -10
- package/commands/theme.js +3 -1
- package/commands/upload.js +32 -26
- package/commands/watch.js +19 -20
- package/lang/en.lyaml +200 -126
- package/lib/DevServerManager.js +1 -1
- package/lib/LocalDevManager.js +3 -3
- package/lib/buildAccount.js +5 -11
- package/lib/commonOpts.d.ts +15 -6
- package/lib/commonOpts.js +53 -38
- package/lib/configOptions.d.ts +13 -1
- package/lib/configOptions.js +54 -57
- package/lib/constants.d.ts +1 -4
- package/lib/developerTestAccounts.d.ts +5 -1
- package/lib/developerTestAccounts.js +45 -39
- package/lib/doctor/DiagnosticInfoBuilder.js +8 -4
- package/lib/doctor/Doctor.js +4 -3
- package/lib/generateSelectors.d.ts +19 -0
- package/lib/generateSelectors.js +23 -23
- package/lib/localDev.js +2 -1
- package/lib/marketplaceValidate.d.ts +6 -1
- package/lib/marketplaceValidate.js +76 -77
- package/lib/oauth.d.ts +2 -1
- package/lib/oauth.js +49 -37
- package/lib/polling.d.ts +8 -0
- package/lib/polling.js +9 -12
- package/lib/projects/ProjectLogsManager.d.ts +20 -0
- package/lib/projects/ProjectLogsManager.js +105 -0
- package/lib/projects/buildAndDeploy.d.ts +16 -0
- package/lib/projects/buildAndDeploy.js +342 -0
- package/lib/projects/index.d.ts +24 -0
- package/lib/projects/index.js +256 -0
- package/lib/projects/structure.d.ts +78 -0
- package/lib/projects/structure.js +151 -0
- package/lib/projects/upload.d.ts +8 -0
- package/lib/projects/upload.js +107 -0
- package/lib/projects/urls.d.ts +4 -0
- package/lib/projects/urls.js +27 -0
- package/lib/{projectsWatch.js → projects/watch.js} +3 -3
- package/lib/prompts/accountNamePrompt.d.ts +11 -0
- package/lib/prompts/accountNamePrompt.js +45 -46
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +21 -19
- package/lib/prompts/cmsFieldPrompt.d.ts +1 -1
- package/lib/prompts/cmsFieldPrompt.js +23 -24
- package/lib/prompts/createApiSamplePrompt.d.ts +17 -0
- package/lib/prompts/createApiSamplePrompt.js +47 -44
- package/lib/prompts/createFunctionPrompt.d.ts +7 -0
- package/lib/prompts/createFunctionPrompt.js +17 -20
- package/lib/prompts/createModulePrompt.d.ts +8 -0
- package/lib/prompts/createModulePrompt.js +29 -17
- package/lib/prompts/createProjectPrompt.d.ts +13 -0
- package/lib/prompts/createProjectPrompt.js +48 -49
- package/lib/prompts/createTemplatePrompt.d.ts +8 -0
- package/lib/prompts/createTemplatePrompt.js +15 -17
- package/lib/prompts/downloadProjectPrompt.d.ts +8 -0
- package/lib/prompts/downloadProjectPrompt.js +25 -23
- package/lib/prompts/installPublicAppPrompt.d.ts +1 -1
- package/lib/prompts/installPublicAppPrompt.js +21 -19
- package/lib/prompts/personalAccessKeyPrompt.d.ts +28 -0
- package/lib/prompts/personalAccessKeyPrompt.js +46 -52
- package/lib/prompts/previewPrompt.d.ts +14 -0
- package/lib/prompts/previewPrompt.js +24 -24
- package/lib/prompts/projectAddPrompt.d.ts +9 -0
- package/lib/prompts/projectAddPrompt.js +11 -14
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +6 -1
- package/lib/prompts/projectDevTargetAccountPrompt.js +87 -69
- package/lib/prompts/projectsLogsPrompt.d.ts +11 -0
- package/lib/prompts/projectsLogsPrompt.js +8 -11
- package/lib/prompts/promptUtils.d.ts +7 -6
- package/lib/prompts/promptUtils.js +21 -8
- package/lib/prompts/sandboxesPrompt.d.ts +8 -0
- package/lib/prompts/sandboxesPrompt.js +43 -45
- package/lib/prompts/secretPrompt.d.ts +12 -0
- package/lib/prompts/secretPrompt.js +32 -19
- package/lib/prompts/selectHubDBTablePrompt.d.ts +12 -0
- package/lib/prompts/selectHubDBTablePrompt.js +69 -0
- package/lib/prompts/selectPublicAppPrompt.d.ts +8 -0
- package/lib/prompts/selectPublicAppPrompt.js +28 -27
- package/lib/prompts/setAsDefaultAccountPrompt.d.ts +1 -1
- package/lib/prompts/setAsDefaultAccountPrompt.js +12 -14
- package/lib/prompts/uploadPrompt.d.ts +8 -0
- package/lib/prompts/uploadPrompt.js +18 -18
- package/lib/sandboxSync.js +5 -2
- package/lib/sandboxes.js +12 -7
- package/lib/ui/index.d.ts +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/usageTracking.d.ts +21 -2
- package/lib/usageTracking.js +53 -81
- package/lib/validation.d.ts +11 -1
- package/lib/validation.js +98 -91
- package/package.json +13 -7
- package/types/Projects.d.ts +43 -0
- package/types/Projects.js +2 -0
- package/types/Prompts.d.ts +25 -0
- package/types/Prompts.js +2 -0
- package/commands/accounts.js +0 -30
- package/commands/cms/reactModules.js +0 -60
- package/commands/functions.js +0 -24
- package/commands/secrets/deleteSecret.js +0 -46
- package/commands/secrets.js +0 -23
- package/lib/ProjectLogsManager.js +0 -91
- package/lib/projectStructure.js +0 -116
- package/lib/projects.d.ts +0 -4
- package/lib/projects.js +0 -681
- package/lib/projectsWatch.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.d.ts +0 -1
- package/lib/prompts/cleanUploadPrompt.js +0 -20
- /package/commands/{accounts → account}/clean.d.ts +0 -0
- /package/commands/{accounts → account}/info.d.ts +0 -0
- /package/commands/{accounts → account}/list.d.ts +0 -0
- /package/commands/{accounts → account}/remove.d.ts +0 -0
- /package/commands/{accounts → account}/rename.d.ts +0 -0
- /package/commands/{accounts → account}/use.d.ts +0 -0
- /package/commands/{accounts.d.ts → account.d.ts} +0 -0
- /package/commands/cms/{reactModules.d.ts → getReactModule.d.ts} +0 -0
- /package/commands/{functions.d.ts → completion.d.ts} +0 -0
- /package/commands/{functions/list.d.ts → function/deploy.d.ts} +0 -0
- /package/commands/{functions/server.d.ts → function/list.d.ts} +0 -0
- /package/commands/{secrets.d.ts → function/server.d.ts} +0 -0
- /package/commands/{functions/deploy.d.ts → function.d.ts} +0 -0
- /package/commands/{secrets/deleteSecret.d.ts → secret/addSecret.d.ts} +0 -0
- /package/commands/{secrets/listSecrets.d.ts → secret/deleteSecret.d.ts} +0 -0
- /package/commands/{secrets/updateSecret.d.ts → secret/listSecrets.d.ts} +0 -0
- /package/{lib/ProjectLogsManager.d.ts → commands/secret/updateSecret.d.ts} +0 -0
- /package/commands/{secrets/addSecret.d.ts → secret.d.ts} +0 -0
- /package/lib/{projectStructure.d.ts → projects/watch.d.ts} +0 -0
package/bin/cli.js
CHANGED
|
@@ -5,14 +5,17 @@ const updateNotifier = require('update-notifier');
|
|
|
5
5
|
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
|
+
const { loadConfig, configFileExists, getConfigPath, validateConfig, } = require('@hubspot/local-dev-lib/config');
|
|
8
9
|
const { logError } = require('../lib/errorHandlers/index');
|
|
9
|
-
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
10
|
+
const { setLogLevel, getCommandName, injectAccountIdMiddleware, } = require('../lib/commonOpts');
|
|
11
|
+
const { validateAccount } = require('../lib/validation');
|
|
10
12
|
const { trackHelpUsage, trackConvertFieldsUsage, } = require('../lib/usageTracking');
|
|
11
13
|
const { getIsInProject } = require('../lib/projects');
|
|
12
14
|
const pkg = require('../package.json');
|
|
13
15
|
const { i18n } = require('../lib/lang');
|
|
14
16
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
15
17
|
const { UI_COLORS, uiCommandReference } = require('../lib/ui');
|
|
18
|
+
const { checkAndWarnGitInclusion } = require('../lib/ui/git');
|
|
16
19
|
const removeCommand = require('../commands/remove');
|
|
17
20
|
const initCommand = require('../commands/init');
|
|
18
21
|
const logsCommand = require('../commands/logs');
|
|
@@ -24,9 +27,9 @@ const uploadCommand = require('../commands/upload');
|
|
|
24
27
|
const createCommand = require('../commands/create');
|
|
25
28
|
const fetchCommand = require('../commands/fetch');
|
|
26
29
|
const filemanagerCommand = require('../commands/filemanager');
|
|
27
|
-
const
|
|
30
|
+
const secretCommands = require('../commands/secret');
|
|
28
31
|
const customObjectCommand = require('../commands/customObject');
|
|
29
|
-
const
|
|
32
|
+
const functionCommands = require('../commands/function');
|
|
30
33
|
const listCommand = require('../commands/list');
|
|
31
34
|
const openCommand = require('../commands/open');
|
|
32
35
|
const mvCommand = require('../commands/mv');
|
|
@@ -34,11 +37,12 @@ const projectCommands = require('../commands/project');
|
|
|
34
37
|
const themeCommand = require('../commands/theme');
|
|
35
38
|
const moduleCommand = require('../commands/module');
|
|
36
39
|
const configCommand = require('../commands/config');
|
|
37
|
-
const
|
|
40
|
+
const accountCommands = require('../commands/account');
|
|
38
41
|
const sandboxesCommand = require('../commands/sandbox');
|
|
39
42
|
const cmsCommand = require('../commands/cms');
|
|
40
43
|
const feedbackCommand = require('../commands/feedback');
|
|
41
44
|
const doctorCommand = require('../commands/doctor');
|
|
45
|
+
const completionCommand = require('../commands/completion');
|
|
42
46
|
const notifier = updateNotifier({
|
|
43
47
|
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
44
48
|
distTag: 'latest',
|
|
@@ -116,17 +120,94 @@ const performChecks = argv => {
|
|
|
116
120
|
const setRequestHeaders = () => {
|
|
117
121
|
addUserAgentHeader('HubSpot CLI', pkg.version);
|
|
118
122
|
};
|
|
123
|
+
const isTargetedCommand = (options, commandMap) => {
|
|
124
|
+
const checkCommand = (options, commandMap) => {
|
|
125
|
+
const currentCommand = options._[0];
|
|
126
|
+
if (!commandMap[currentCommand]) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
if (commandMap[currentCommand].target) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
const subCommands = commandMap[currentCommand].subCommands || {};
|
|
133
|
+
if (options._.length > 1) {
|
|
134
|
+
return checkCommand({ _: options._.slice(1) }, subCommands);
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
};
|
|
138
|
+
return checkCommand(options, commandMap);
|
|
139
|
+
};
|
|
140
|
+
const SKIP_CONFIG_VALIDATION = {
|
|
141
|
+
init: { target: true },
|
|
142
|
+
auth: { target: true },
|
|
143
|
+
};
|
|
144
|
+
const loadConfigMiddleware = async (options) => {
|
|
145
|
+
const maybeValidateConfig = () => {
|
|
146
|
+
if (!isTargetedCommand(options, SKIP_CONFIG_VALIDATION) &&
|
|
147
|
+
!validateConfig()) {
|
|
148
|
+
process.exit(EXIT_CODES.ERROR);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
if (configFileExists(true) && options.config) {
|
|
152
|
+
logger.error(i18n(`${i18nKey}.loadConfigMiddleware.configFileExists`, {
|
|
153
|
+
configPath: getConfigPath(),
|
|
154
|
+
}));
|
|
155
|
+
process.exit(EXIT_CODES.ERROR);
|
|
156
|
+
}
|
|
157
|
+
else if (!options._.includes('init')) {
|
|
158
|
+
const { config: configPath } = options;
|
|
159
|
+
loadConfig(configPath, options);
|
|
160
|
+
}
|
|
161
|
+
maybeValidateConfig();
|
|
162
|
+
};
|
|
163
|
+
const checkAndWarnGitInclusionMiddleware = () => {
|
|
164
|
+
checkAndWarnGitInclusion(getConfigPath());
|
|
165
|
+
};
|
|
166
|
+
const accountsSubCommands = {
|
|
167
|
+
target: false,
|
|
168
|
+
subCommands: {
|
|
169
|
+
clean: { target: true },
|
|
170
|
+
list: { target: true },
|
|
171
|
+
ls: { target: true },
|
|
172
|
+
remove: { target: true },
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
const sandboxesSubCommands = {
|
|
176
|
+
target: false,
|
|
177
|
+
subCommands: {
|
|
178
|
+
delete: { target: true },
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
const SKIP_ACCOUNT_VALIDATION = {
|
|
182
|
+
init: { target: true },
|
|
183
|
+
auth: { target: true },
|
|
184
|
+
account: accountsSubCommands,
|
|
185
|
+
accounts: accountsSubCommands,
|
|
186
|
+
sandbox: sandboxesSubCommands,
|
|
187
|
+
sandboxes: sandboxesSubCommands,
|
|
188
|
+
};
|
|
189
|
+
const validateAccountOptions = async (options) => {
|
|
190
|
+
let validAccount = true;
|
|
191
|
+
if (!isTargetedCommand(options, SKIP_ACCOUNT_VALIDATION)) {
|
|
192
|
+
validAccount = await validateAccount(options);
|
|
193
|
+
}
|
|
194
|
+
if (!validAccount) {
|
|
195
|
+
process.exit(EXIT_CODES.ERROR);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
119
198
|
const argv = yargs
|
|
120
199
|
.usage('The command line interface to interact with HubSpot.')
|
|
121
|
-
|
|
200
|
+
// loadConfigMiddleware loads the new hidden config for all commands
|
|
201
|
+
.middleware([
|
|
202
|
+
setLogLevel,
|
|
203
|
+
setRequestHeaders,
|
|
204
|
+
loadConfigMiddleware,
|
|
205
|
+
injectAccountIdMiddleware,
|
|
206
|
+
checkAndWarnGitInclusionMiddleware,
|
|
207
|
+
validateAccountOptions,
|
|
208
|
+
])
|
|
122
209
|
.exitProcess(false)
|
|
123
210
|
.fail(handleFailure)
|
|
124
|
-
.option('debug', {
|
|
125
|
-
alias: 'd',
|
|
126
|
-
default: false,
|
|
127
|
-
describe: 'Set log level to debug',
|
|
128
|
-
type: 'boolean',
|
|
129
|
-
})
|
|
130
211
|
.option('noHyperlinks', {
|
|
131
212
|
default: false,
|
|
132
213
|
describe: 'prevent hyperlinks from displaying in the ui',
|
|
@@ -152,9 +233,9 @@ const argv = yargs
|
|
|
152
233
|
.command(createCommand)
|
|
153
234
|
.command(fetchCommand)
|
|
154
235
|
.command(filemanagerCommand)
|
|
155
|
-
.command(
|
|
236
|
+
.command(secretCommands)
|
|
156
237
|
.command(customObjectCommand)
|
|
157
|
-
.command(
|
|
238
|
+
.command(functionCommands)
|
|
158
239
|
.command({
|
|
159
240
|
...listCommand,
|
|
160
241
|
aliases: 'ls',
|
|
@@ -165,14 +246,15 @@ const argv = yargs
|
|
|
165
246
|
.command(themeCommand)
|
|
166
247
|
.command(moduleCommand)
|
|
167
248
|
.command(configCommand)
|
|
168
|
-
.command(
|
|
249
|
+
.command(accountCommands)
|
|
169
250
|
.command(sandboxesCommand)
|
|
170
251
|
.command(feedbackCommand)
|
|
171
252
|
.command(doctorCommand)
|
|
253
|
+
.command(completionCommand)
|
|
172
254
|
.help()
|
|
255
|
+
.alias('h', 'help')
|
|
173
256
|
.recommendCommands()
|
|
174
257
|
.demandCommand(1, '')
|
|
175
|
-
.completion()
|
|
176
258
|
.wrap(getTerminalWidth())
|
|
177
259
|
.strict().argv;
|
|
178
260
|
if (argv.help) {
|
package/bin/hs
CHANGED
package/bin/hscms
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const SILENCED_ERRORS = ['DeprecationWarning:'];
|
|
5
|
+
const originalConsoleError = console.error;
|
|
6
|
+
console.error = msg => {
|
|
7
|
+
const isSilencedError = SILENCED_ERRORS.some(error => typeof msg === 'string' && msg.includes(error));
|
|
8
|
+
if (isSilencedError) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
originalConsoleError(msg);
|
|
12
|
+
};
|
|
@@ -5,24 +5,23 @@ const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
|
5
5
|
const { accessTokenForPersonalAccessKey, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
7
|
const { i18n } = require('../../lib/lang');
|
|
8
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
8
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
10
|
-
const {
|
|
9
|
+
const { addTestingOptions, addConfigOptions } = require('../../lib/commonOpts');
|
|
11
10
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
12
11
|
const { getTableContents } = require('../../lib/ui/table');
|
|
13
12
|
const SpinniesManager = require('../../lib/ui/SpinniesManager');
|
|
14
|
-
const { getConfig, deleteAccount } = require('@hubspot/local-dev-lib/config');
|
|
15
13
|
const { uiAccountDescription } = require('../../lib/ui');
|
|
14
|
+
const { deleteAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
15
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
16
16
|
const { isSpecifiedError } = require('@hubspot/local-dev-lib/errors/index');
|
|
17
|
-
const i18nKey = 'commands.
|
|
17
|
+
const i18nKey = 'commands.account.subcommands.clean';
|
|
18
18
|
exports.command = 'clean';
|
|
19
19
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
20
20
|
exports.handler = async (options) => {
|
|
21
21
|
const { qa } = options;
|
|
22
|
-
await loadAndValidateOptions(options, false);
|
|
23
|
-
const config = getConfig();
|
|
24
22
|
trackCommandUsage('accounts-clean', null);
|
|
25
|
-
const
|
|
23
|
+
const accountsList = getConfigAccounts();
|
|
24
|
+
const filteredTestAccounts = accountsList.filter(p => qa ? p.env === 'qa' : p.env !== 'qa');
|
|
26
25
|
if (filteredTestAccounts && filteredTestAccounts.length === 0) {
|
|
27
26
|
logger.log(i18n(`${i18nKey}.noResults`));
|
|
28
27
|
process.exit(EXIT_CODES.SUCCESS);
|
|
@@ -36,7 +35,7 @@ exports.handler = async (options) => {
|
|
|
36
35
|
});
|
|
37
36
|
for (const account of filteredTestAccounts) {
|
|
38
37
|
try {
|
|
39
|
-
await accessTokenForPersonalAccessKey(account
|
|
38
|
+
await accessTokenForPersonalAccessKey(getAccountIdentifier(account), true);
|
|
40
39
|
}
|
|
41
40
|
catch (error) {
|
|
42
41
|
if (isSpecifiedError(error, {
|
|
@@ -62,7 +61,9 @@ exports.handler = async (options) => {
|
|
|
62
61
|
count: accountsToRemove.length,
|
|
63
62
|
}),
|
|
64
63
|
});
|
|
65
|
-
logger.log(getTableContents(accountsToRemove.map(p => [
|
|
64
|
+
logger.log(getTableContents(accountsToRemove.map(p => [
|
|
65
|
+
uiAccountDescription(getAccountIdentifier(p)),
|
|
66
|
+
]), { border: { bodyLeft: ' ' } }));
|
|
66
67
|
const { accountsCleanPrompt } = await promptUser([
|
|
67
68
|
{
|
|
68
69
|
name: 'accountsCleanPrompt',
|
|
@@ -94,8 +95,6 @@ exports.handler = async (options) => {
|
|
|
94
95
|
};
|
|
95
96
|
exports.builder = yargs => {
|
|
96
97
|
addConfigOptions(yargs);
|
|
97
|
-
addAccountOptions(yargs);
|
|
98
|
-
addUseEnvironmentOptions(yargs);
|
|
99
98
|
addTestingOptions(yargs);
|
|
100
99
|
yargs.example([['$0 accounts clean']]);
|
|
101
100
|
return yargs;
|
|
@@ -4,24 +4,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { getAccountConfig } = require('@hubspot/local-dev-lib/config');
|
|
6
6
|
const { getAccessToken } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
7
|
-
const {
|
|
8
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
7
|
+
const { addConfigOptions } = require('../../lib/commonOpts');
|
|
9
8
|
const { i18n } = require('../../lib/lang');
|
|
10
9
|
const { getTableContents } = require('../../lib/ui/table');
|
|
11
|
-
const i18nKey = 'commands.
|
|
10
|
+
const i18nKey = 'commands.account.subcommands.info';
|
|
12
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
-
exports.command = 'info [
|
|
12
|
+
exports.command = 'info [account]';
|
|
14
13
|
exports.handler = async (options) => {
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const config = getAccountConfig(accountId);
|
|
14
|
+
const { derivedAccountId } = options;
|
|
15
|
+
const config = getAccountConfig(derivedAccountId);
|
|
18
16
|
// check if the provided account is using a personal access key, if not, show an error
|
|
19
|
-
if (config.authType === 'personalaccesskey') {
|
|
17
|
+
if (config && config.authType === 'personalaccesskey') {
|
|
20
18
|
const { name, personalAccessKey, env } = config;
|
|
21
|
-
const response = await getAccessToken(personalAccessKey, env,
|
|
19
|
+
const response = await getAccessToken(personalAccessKey, env, derivedAccountId);
|
|
22
20
|
const scopeGroups = response.scopeGroups.map(s => [s]);
|
|
23
21
|
logger.log(i18n(`${i18nKey}.name`, { name }));
|
|
24
|
-
logger.log(i18n(`${i18nKey}.accountId`, { accountId }));
|
|
22
|
+
logger.log(i18n(`${i18nKey}.accountId`, { accountId: derivedAccountId }));
|
|
25
23
|
logger.log(i18n(`${i18nKey}.scopeGroups`));
|
|
26
24
|
logger.log(getTableContents(scopeGroups, { border: { bodyLeft: ' ' } }));
|
|
27
25
|
}
|
|
@@ -31,14 +29,10 @@ exports.handler = async (options) => {
|
|
|
31
29
|
};
|
|
32
30
|
exports.builder = yargs => {
|
|
33
31
|
addConfigOptions(yargs);
|
|
34
|
-
addAccountOptions(yargs);
|
|
35
32
|
yargs.example([
|
|
36
33
|
['$0 accounts info', i18n(`${i18nKey}.examples.default`)],
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
i18n(`${i18nKey}.examples.nameBased`),
|
|
40
|
-
],
|
|
41
|
-
['$0 accounts info --account=1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
34
|
+
['$0 accounts info MyAccount', i18n(`${i18nKey}.examples.nameBased`)],
|
|
35
|
+
['$0 accounts info 1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
42
36
|
]);
|
|
43
37
|
return yargs;
|
|
44
38
|
};
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const {
|
|
5
|
+
const { getConfigPath, getConfigDefaultAccount, getConfigAccounts, } = require('@hubspot/local-dev-lib/config');
|
|
6
|
+
const { getAccountIdentifier, } = require('@hubspot/local-dev-lib/config/getAccountIdentifier');
|
|
7
|
+
const { addConfigOptions } = require('../../lib/commonOpts');
|
|
6
8
|
const { getTableContents, getTableHeader } = require('../../lib/ui/table');
|
|
7
|
-
const { addConfigOptions, addAccountOptions, getAccountId, } = require('../../lib/commonOpts');
|
|
8
9
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
9
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
10
10
|
const { isSandbox, isDeveloperTestAccount } = require('../../lib/accountTypes');
|
|
11
11
|
const { i18n } = require('../../lib/lang');
|
|
12
12
|
const { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } = require('@hubspot/local-dev-lib/constants/config');
|
|
13
|
-
const i18nKey = 'commands.
|
|
14
|
-
exports.command = 'list';
|
|
13
|
+
const i18nKey = 'commands.account.subcommands.list';
|
|
14
|
+
exports.command = ['list', 'ls'];
|
|
15
15
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
16
|
const sortAndMapPortals = portals => {
|
|
17
17
|
const mappedPortalData = {};
|
|
@@ -21,7 +21,7 @@ const sortAndMapPortals = portals => {
|
|
|
21
21
|
(p.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD ||
|
|
22
22
|
p.accountType === HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER))
|
|
23
23
|
.forEach(portal => {
|
|
24
|
-
mappedPortalData[portal
|
|
24
|
+
mappedPortalData[getAccountIdentifier(portal)] = [portal];
|
|
25
25
|
});
|
|
26
26
|
// Non-standard portals (sandbox, developer test account)
|
|
27
27
|
portals
|
|
@@ -34,7 +34,7 @@ const sortAndMapPortals = portals => {
|
|
|
34
34
|
];
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
mappedPortalData[p
|
|
37
|
+
mappedPortalData[getAccountIdentifier(p)] = [p];
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
return mappedPortalData;
|
|
@@ -42,7 +42,7 @@ const sortAndMapPortals = portals => {
|
|
|
42
42
|
const getPortalData = mappedPortalData => {
|
|
43
43
|
const portalData = [];
|
|
44
44
|
Object.entries(mappedPortalData).forEach(([key, set]) => {
|
|
45
|
-
const hasParentPortal = set.filter(p => p
|
|
45
|
+
const hasParentPortal = set.filter(p => getAccountIdentifier(p) === parseInt(key, 10))[0];
|
|
46
46
|
set.forEach(portal => {
|
|
47
47
|
let name = `${portal.name} [${HUBSPOT_ACCOUNT_TYPE_STRINGS[portal.accountType]}]`;
|
|
48
48
|
if (isSandbox(portal)) {
|
|
@@ -55,18 +55,17 @@ const getPortalData = mappedPortalData => {
|
|
|
55
55
|
name = `↳ ${name}`;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
portalData.push([name, portal
|
|
58
|
+
portalData.push([name, getAccountIdentifier(portal), portal.authType]);
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
return portalData;
|
|
62
62
|
};
|
|
63
63
|
exports.handler = async (options) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
trackCommandUsage('accounts-list', null, accountId);
|
|
67
|
-
const config = getConfig();
|
|
64
|
+
const { derivedAccountId } = options;
|
|
65
|
+
trackCommandUsage('accounts-list', null, derivedAccountId);
|
|
68
66
|
const configPath = getConfigPath();
|
|
69
|
-
const
|
|
67
|
+
const accountsList = getConfigAccounts();
|
|
68
|
+
const mappedPortalData = sortAndMapPortals(accountsList);
|
|
70
69
|
const portalData = getPortalData(mappedPortalData);
|
|
71
70
|
portalData.unshift(getTableHeader([
|
|
72
71
|
i18n(`${i18nKey}.labels.name`),
|
|
@@ -74,13 +73,14 @@ exports.handler = async (options) => {
|
|
|
74
73
|
i18n(`${i18nKey}.labels.authType`),
|
|
75
74
|
]));
|
|
76
75
|
logger.log(i18n(`${i18nKey}.configPath`, { configPath }));
|
|
77
|
-
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
76
|
+
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
77
|
+
account: getConfigDefaultAccount(),
|
|
78
|
+
}));
|
|
78
79
|
logger.log(i18n(`${i18nKey}.accounts`));
|
|
79
80
|
logger.log(getTableContents(portalData, { border: { bodyLeft: ' ' } }));
|
|
80
81
|
};
|
|
81
82
|
exports.builder = yargs => {
|
|
82
83
|
addConfigOptions(yargs);
|
|
83
|
-
addAccountOptions(yargs);
|
|
84
84
|
yargs.example([['$0 accounts list']]);
|
|
85
85
|
return yargs;
|
|
86
86
|
};
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
|
+
const { addConfigOptions } = require('../../lib/commonOpts');
|
|
4
5
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const {
|
|
6
|
+
const { loadConfig, getConfigPath, deleteAccount, getConfigDefaultAccount, getAccountId: getAccountIdFromConfig, updateDefaultAccount, } = require('@hubspot/local-dev-lib/config');
|
|
6
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
8
|
const { i18n } = require('../../lib/lang');
|
|
8
9
|
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
exports.command = 'remove [--account]';
|
|
10
|
+
const i18nKey = 'commands.account.subcommands.remove';
|
|
11
|
+
exports.command = 'remove [account]';
|
|
12
12
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
13
|
exports.handler = async (options) => {
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
let accountToRemove = options.account;
|
|
14
|
+
const { account } = options;
|
|
15
|
+
let accountToRemove = account;
|
|
17
16
|
if (accountToRemove && !getAccountIdFromConfig(accountToRemove)) {
|
|
18
17
|
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
19
18
|
specifiedAccount: accountToRemove,
|
|
@@ -21,7 +20,7 @@ exports.handler = async (options) => {
|
|
|
21
20
|
}));
|
|
22
21
|
}
|
|
23
22
|
if (!accountToRemove || !getAccountIdFromConfig(accountToRemove)) {
|
|
24
|
-
accountToRemove = await selectAccountFromConfig(
|
|
23
|
+
accountToRemove = await selectAccountFromConfig(i18n(`${i18nKey}.prompts.selectAccountToRemove`));
|
|
25
24
|
}
|
|
26
25
|
trackCommandUsage('accounts-remove', null, getAccountIdFromConfig(accountToRemove));
|
|
27
26
|
const currentDefaultAccount = getConfigDefaultAccount();
|
|
@@ -30,25 +29,23 @@ exports.handler = async (options) => {
|
|
|
30
29
|
accountName: accountToRemove,
|
|
31
30
|
}));
|
|
32
31
|
// Get updated version of the config
|
|
33
|
-
|
|
32
|
+
loadConfig(getConfigPath(), options);
|
|
34
33
|
if (accountToRemove === currentDefaultAccount) {
|
|
35
34
|
logger.log();
|
|
36
35
|
logger.log(i18n(`${i18nKey}.logs.replaceDefaultAccount`));
|
|
37
|
-
const newDefaultAccount = await selectAccountFromConfig(
|
|
36
|
+
const newDefaultAccount = await selectAccountFromConfig();
|
|
38
37
|
updateDefaultAccount(newDefaultAccount);
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
exports.builder = yargs => {
|
|
42
|
-
yargs
|
|
41
|
+
addConfigOptions(yargs);
|
|
42
|
+
yargs.positional('account', {
|
|
43
43
|
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
44
44
|
type: 'string',
|
|
45
45
|
});
|
|
46
46
|
yargs.example([
|
|
47
47
|
['$0 accounts remove', i18n(`${i18nKey}.examples.default`)],
|
|
48
|
-
[
|
|
49
|
-
'$0 accounts remove --account=MyAccount',
|
|
50
|
-
i18n(`${i18nKey}.examples.byName`),
|
|
51
|
-
],
|
|
48
|
+
['$0 accounts remove MyAccount', i18n(`${i18nKey}.examples.byName`)],
|
|
52
49
|
]);
|
|
53
50
|
return yargs;
|
|
54
51
|
};
|
|
@@ -3,18 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
5
|
const { renameAccount } = require('@hubspot/local-dev-lib/config');
|
|
6
|
-
const { addConfigOptions, addAccountOptions
|
|
6
|
+
const { addConfigOptions, addAccountOptions } = require('../../lib/commonOpts');
|
|
7
7
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
8
|
-
const { loadAndValidateOptions } = require('../../lib/validation');
|
|
9
8
|
const { i18n } = require('../../lib/lang');
|
|
10
|
-
const i18nKey = 'commands.
|
|
9
|
+
const i18nKey = 'commands.account.subcommands.rename';
|
|
11
10
|
exports.command = 'rename <accountName> <newName>';
|
|
12
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
12
|
exports.handler = async (options) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const accountId = getAccountId(options);
|
|
17
|
-
trackCommandUsage('accounts-rename', null, accountId);
|
|
13
|
+
const { accountName, newName, derivedAccountId } = options;
|
|
14
|
+
trackCommandUsage('accounts-rename', null, derivedAccountId);
|
|
18
15
|
await renameAccount(accountName, newName);
|
|
19
16
|
return logger.log(i18n(`${i18nKey}.success.renamed`, {
|
|
20
17
|
name: accountName,
|
|
@@ -2,27 +2,24 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @ts-nocheck
|
|
4
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
5
|
-
const {
|
|
5
|
+
const { getConfigPath, updateDefaultAccount, getAccountId: getAccountIdFromConfig, } = require('@hubspot/local-dev-lib/config');
|
|
6
6
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
7
7
|
const { i18n } = require('../../lib/lang');
|
|
8
8
|
const { selectAccountFromConfig } = require('../../lib/prompts/accountsPrompt');
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
exports.command = 'use [--account]';
|
|
9
|
+
const i18nKey = 'commands.account.subcommands.use';
|
|
10
|
+
exports.command = 'use [account]';
|
|
12
11
|
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
12
|
exports.handler = async (options) => {
|
|
14
|
-
await loadAndValidateOptions(options, false);
|
|
15
|
-
const config = getConfig();
|
|
16
13
|
let newDefaultAccount = options.account;
|
|
17
14
|
if (!newDefaultAccount) {
|
|
18
|
-
newDefaultAccount = await selectAccountFromConfig(
|
|
15
|
+
newDefaultAccount = await selectAccountFromConfig();
|
|
19
16
|
}
|
|
20
17
|
else if (!getAccountIdFromConfig(newDefaultAccount)) {
|
|
21
18
|
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
22
19
|
specifiedAccount: newDefaultAccount,
|
|
23
20
|
configPath: getConfigPath(),
|
|
24
21
|
}));
|
|
25
|
-
newDefaultAccount = await selectAccountFromConfig(
|
|
22
|
+
newDefaultAccount = await selectAccountFromConfig();
|
|
26
23
|
}
|
|
27
24
|
trackCommandUsage('accounts-use', null, getAccountIdFromConfig(newDefaultAccount));
|
|
28
25
|
updateDefaultAccount(newDefaultAccount);
|
|
@@ -31,17 +28,14 @@ exports.handler = async (options) => {
|
|
|
31
28
|
}));
|
|
32
29
|
};
|
|
33
30
|
exports.builder = yargs => {
|
|
34
|
-
yargs.
|
|
31
|
+
yargs.positional('account', {
|
|
35
32
|
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
36
33
|
type: 'string',
|
|
37
34
|
});
|
|
38
35
|
yargs.example([
|
|
39
36
|
['$0 accounts use', i18n(`${i18nKey}.examples.default`)],
|
|
40
|
-
[
|
|
41
|
-
|
|
42
|
-
i18n(`${i18nKey}.examples.nameBased`),
|
|
43
|
-
],
|
|
44
|
-
['$0 accounts use --account=1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
37
|
+
['$0 accounts use MyAccount', i18n(`${i18nKey}.examples.nameBased`)],
|
|
38
|
+
['$0 accounts use 1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
45
39
|
]);
|
|
46
40
|
return yargs;
|
|
47
41
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const { addGlobalOptions } = require('../lib/commonOpts');
|
|
5
|
+
const { i18n } = require('../lib/lang');
|
|
6
|
+
const list = require('./account/list');
|
|
7
|
+
const rename = require('./account/rename');
|
|
8
|
+
const use = require('./account/use');
|
|
9
|
+
const info = require('./account/info');
|
|
10
|
+
const remove = require('./account/remove');
|
|
11
|
+
const clean = require('./account/clean');
|
|
12
|
+
const i18nKey = 'commands.account';
|
|
13
|
+
exports.command = ['account', 'accounts'];
|
|
14
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
+
exports.builder = yargs => {
|
|
16
|
+
addGlobalOptions(yargs);
|
|
17
|
+
yargs
|
|
18
|
+
.command(list)
|
|
19
|
+
.command(rename)
|
|
20
|
+
.command(use)
|
|
21
|
+
.command(info)
|
|
22
|
+
.command(remove)
|
|
23
|
+
.command(clean)
|
|
24
|
+
.demandCommand(1, '');
|
|
25
|
+
return yargs;
|
|
26
|
+
};
|