@hubspot/cli 7.3.0-experimental.2 → 7.3.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 +25 -83
- package/commands/account/clean.js +9 -10
- package/commands/account/info.js +9 -11
- package/commands/account/list.js +7 -8
- package/commands/account/remove.js +8 -9
- package/commands/account/rename.js +4 -5
- package/commands/account/use.js +7 -8
- package/commands/cms/convertFields.js +5 -6
- package/commands/cms/getReactModule.js +7 -8
- package/commands/cms/lighthouseScore.js +15 -16
- package/commands/config/set.js +6 -7
- package/commands/create/api-sample.js +6 -7
- package/commands/create/module.js +1 -2
- package/commands/create/template.js +1 -2
- package/commands/customObject/create.js +8 -9
- package/commands/customObject/schema/create.js +5 -6
- package/commands/customObject/schema/delete.js +9 -10
- package/commands/customObject/schema/fetch-all.js +7 -8
- package/commands/customObject/schema/fetch.js +9 -10
- package/commands/customObject/schema/list.js +2 -3
- package/commands/customObject/schema/update.js +7 -8
- package/commands/customObject/schema.js +1 -2
- package/commands/filemanager/fetch.js +5 -6
- package/commands/filemanager/upload.js +12 -13
- package/commands/function/deploy.js +9 -10
- package/commands/function/list.js +4 -5
- package/commands/function/server.js +7 -8
- package/commands/project/create.js +1 -0
- package/lang/en.js +6 -1
- package/lang/en.lyaml +4 -0
- package/lib/DevServerManagerV2.d.ts +1 -2
- package/lib/DevServerManagerV2.js +1 -2
- package/lib/LocalDevManagerV2.js +10 -15
- package/lib/dependencyManagement.d.ts +5 -0
- package/lib/dependencyManagement.js +47 -22
- package/lib/doctor/Doctor.js +1 -2
- package/lib/projects/structure.d.ts +1 -2
- package/lib/projects/structure.js +0 -4
- package/package.json +3 -3
- package/types/ProjectComponents.d.ts +0 -15
- package/lib/npm.d.ts +0 -9
- package/lib/npm.js +0 -36
package/bin/cli.js
CHANGED
|
@@ -16,8 +16,6 @@ const { i18n } = require('../lib/lang');
|
|
|
16
16
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
17
17
|
const { UI_COLORS, uiCommandReference, uiDeprecatedTag } = require('../lib/ui');
|
|
18
18
|
const { checkAndWarnGitInclusion } = require('../lib/ui/git');
|
|
19
|
-
const SpinniesManager = require('../lib/ui/SpinniesManager');
|
|
20
|
-
const { isGloballyInstalled, executeInstall } = require('../lib/npm');
|
|
21
19
|
const removeCommand = require('../commands/remove');
|
|
22
20
|
const initCommand = require('../commands/init');
|
|
23
21
|
const logsCommand = require('../commands/logs');
|
|
@@ -50,31 +48,28 @@ const notifier = updateNotifier({
|
|
|
50
48
|
distTag: 'latest',
|
|
51
49
|
shouldNotifyInNpmScript: true,
|
|
52
50
|
});
|
|
53
|
-
const i18nKey = 'commands.generalErrors';
|
|
54
51
|
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
};
|
|
52
|
+
notifier.notify({
|
|
53
|
+
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
54
|
+
? i18n(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
|
|
55
|
+
packageName: CMS_CLI_PACKAGE_NAME,
|
|
56
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
57
|
+
})
|
|
58
|
+
: i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
59
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
60
|
+
}),
|
|
61
|
+
defer: false,
|
|
62
|
+
boxenOptions: {
|
|
63
|
+
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
64
|
+
margin: 1,
|
|
65
|
+
padding: 1,
|
|
66
|
+
textAlignment: 'center',
|
|
67
|
+
borderStyle: 'round',
|
|
68
|
+
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
69
|
+
? null
|
|
70
|
+
: chalk.bold(i18n(`commands.generalErrors.updateNotify.notifyTitle`)),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
78
73
|
const getTerminalWidth = () => {
|
|
79
74
|
const width = yargs.terminalWidth();
|
|
80
75
|
if (width >= 100)
|
|
@@ -101,13 +96,13 @@ const performChecks = argv => {
|
|
|
101
96
|
if (argv._[0] === 'config' &&
|
|
102
97
|
argv._[1] === 'set' &&
|
|
103
98
|
argv._[2] === 'default-account') {
|
|
104
|
-
logger.error(i18n(
|
|
99
|
+
logger.error(i18n(`commands.generalErrors.setDefaultAccountMoved`));
|
|
105
100
|
process.exit(EXIT_CODES.ERROR);
|
|
106
101
|
}
|
|
107
102
|
// Require "project" command when running upload/watch inside of a project
|
|
108
103
|
if (argv._.length === 1 && ['upload', 'watch'].includes(argv._[0])) {
|
|
109
104
|
if (getIsInProject(argv.src)) {
|
|
110
|
-
logger.error(i18n(
|
|
105
|
+
logger.error(i18n(`commands.generalErrors.srcIsProject`, {
|
|
111
106
|
src: argv.src || './',
|
|
112
107
|
command: argv._.join(' '),
|
|
113
108
|
}));
|
|
@@ -124,58 +119,6 @@ const performChecks = argv => {
|
|
|
124
119
|
const setRequestHeaders = () => {
|
|
125
120
|
addUserAgentHeader('HubSpot CLI', pkg.version);
|
|
126
121
|
};
|
|
127
|
-
const updateCLIVersion = async () => {
|
|
128
|
-
logger.debug('Checking for CLI updates', notifier);
|
|
129
|
-
if (!process.env.SKIP_HUBSPOT_CLI_AUTO_UPDATES &&
|
|
130
|
-
notifier &&
|
|
131
|
-
notifier.update) {
|
|
132
|
-
let updateInfo;
|
|
133
|
-
try {
|
|
134
|
-
updateInfo = await notifier.fetchInfo();
|
|
135
|
-
}
|
|
136
|
-
catch (e) {
|
|
137
|
-
logger.debug('Error fetching update info', e);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
// Update if the current version is not the latest version.
|
|
141
|
-
// Don't auto-update if the current version is a pre-release
|
|
142
|
-
// or if this would be a major version update
|
|
143
|
-
if (!updateInfo.current.includes('-') &&
|
|
144
|
-
!['major', 'latest'].includes(updateInfo.type)) {
|
|
145
|
-
SpinniesManager.init({
|
|
146
|
-
succeedColor: 'white',
|
|
147
|
-
});
|
|
148
|
-
SpinniesManager.add('cliAutoUpdate', {
|
|
149
|
-
text: `New HubSpot CLI version available. Updating to version ${updateInfo.latest}`,
|
|
150
|
-
});
|
|
151
|
-
let showManualInstallHelp = false;
|
|
152
|
-
try {
|
|
153
|
-
if (await isGloballyInstalled()) {
|
|
154
|
-
await executeInstall(['@hubspot/cli@latest'], '-g');
|
|
155
|
-
SpinniesManager.succeed('cliAutoUpdate', {
|
|
156
|
-
text: `Successfully updated HubSpot CLI to version ${updateInfo.latest}`,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
SpinniesManager.fail('cliAutoUpdate', {
|
|
161
|
-
text: `Cannot auto-update the HubSpot CLI if it is not globall installed with NPM`,
|
|
162
|
-
});
|
|
163
|
-
showManualInstallHelp = true;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (e) {
|
|
167
|
-
logger.debug('Error updating CLI', e);
|
|
168
|
-
SpinniesManager.fail('cliAutoUpdate', {
|
|
169
|
-
text: `Failed to update HubSpot CLI to version ${updateInfo.latest}`,
|
|
170
|
-
});
|
|
171
|
-
showManualInstallHelp = true;
|
|
172
|
-
}
|
|
173
|
-
if (showManualInstallHelp) {
|
|
174
|
-
showUpdateNotification();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
122
|
const isTargetedCommand = (options, commandMap) => {
|
|
180
123
|
const checkCommand = (options, commandMap) => {
|
|
181
124
|
const currentCommand = options._[0];
|
|
@@ -203,7 +146,7 @@ const handleDeprecatedEnvVariables = options => {
|
|
|
203
146
|
if (options.useEnv &&
|
|
204
147
|
process.env.HUBSPOT_PORTAL_ID &&
|
|
205
148
|
!process.env.HUBSPOT_ACCOUNT_ID) {
|
|
206
|
-
uiDeprecatedTag(i18n(
|
|
149
|
+
uiDeprecatedTag(i18n(`commands.generalErrors.handleDeprecatedEnvVariables.portalEnvVarDeprecated`, {
|
|
207
150
|
configPath: getConfigPath(),
|
|
208
151
|
}));
|
|
209
152
|
process.env.HUBSPOT_ACCOUNT_ID = process.env.HUBSPOT_PORTAL_ID;
|
|
@@ -235,7 +178,7 @@ const loadConfigMiddleware = async (options) => {
|
|
|
235
178
|
}
|
|
236
179
|
};
|
|
237
180
|
if (configFileExists(true) && options.config) {
|
|
238
|
-
logger.error(i18n(
|
|
181
|
+
logger.error(i18n(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
239
182
|
configPath: getConfigPath(),
|
|
240
183
|
}));
|
|
241
184
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -299,7 +242,6 @@ const argv = yargs
|
|
|
299
242
|
// loadConfigMiddleware loads the new hidden config for all commands
|
|
300
243
|
.middleware([
|
|
301
244
|
setLogLevel,
|
|
302
|
-
updateCLIVersion,
|
|
303
245
|
setRequestHeaders,
|
|
304
246
|
handleDeprecatedEnvVariables,
|
|
305
247
|
loadConfigMiddleware,
|
|
@@ -19,16 +19,15 @@ const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
|
19
19
|
const table_1 = require("../../lib/ui/table");
|
|
20
20
|
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
21
21
|
const ui_1 = require("../../lib/ui");
|
|
22
|
-
const i18nKey = 'commands.account.subcommands.clean';
|
|
23
22
|
exports.command = 'clean';
|
|
24
|
-
exports.describe = (0, lang_1.i18n)(
|
|
23
|
+
exports.describe = (0, lang_1.i18n)(`commands.account.subcommands.clean.describe`);
|
|
25
24
|
async function handler(args) {
|
|
26
25
|
const { qa } = args;
|
|
27
26
|
(0, usageTracking_1.trackCommandUsage)('accounts-clean');
|
|
28
27
|
const accountsList = (0, config_1.getConfigAccounts)() || [];
|
|
29
28
|
const filteredTestAccounts = accountsList.filter(p => qa ? p.env === 'qa' : p.env !== 'qa');
|
|
30
29
|
if (filteredTestAccounts && filteredTestAccounts.length === 0) {
|
|
31
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
30
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.clean.noResults`));
|
|
32
31
|
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
33
32
|
}
|
|
34
33
|
const accountsToRemove = [];
|
|
@@ -36,7 +35,7 @@ async function handler(args) {
|
|
|
36
35
|
succeedColor: 'white',
|
|
37
36
|
});
|
|
38
37
|
SpinniesManager_1.default.add('accountsClean', {
|
|
39
|
-
text: (0, lang_1.i18n)(
|
|
38
|
+
text: (0, lang_1.i18n)(`commands.account.subcommands.clean.loading.add`),
|
|
40
39
|
});
|
|
41
40
|
for (const account of filteredTestAccounts) {
|
|
42
41
|
try {
|
|
@@ -62,8 +61,8 @@ async function handler(args) {
|
|
|
62
61
|
const oneAccountFound = accountsToRemove.length === 1;
|
|
63
62
|
SpinniesManager_1.default.succeed('accountsClean', {
|
|
64
63
|
text: (0, lang_1.i18n)(oneAccountFound
|
|
65
|
-
?
|
|
66
|
-
:
|
|
64
|
+
? `commands.account.subcommands.clean.inactiveAccountsFound.one`
|
|
65
|
+
: `commands.account.subcommands.clean.inactiveAccountsFound.other`, {
|
|
67
66
|
count: accountsToRemove.length,
|
|
68
67
|
}),
|
|
69
68
|
});
|
|
@@ -75,8 +74,8 @@ async function handler(args) {
|
|
|
75
74
|
name: 'accountsCleanPrompt',
|
|
76
75
|
type: 'confirm',
|
|
77
76
|
message: (0, lang_1.i18n)(oneAccountFound
|
|
78
|
-
?
|
|
79
|
-
:
|
|
77
|
+
? `commands.account.subcommands.clean.confirm.one`
|
|
78
|
+
: `commands.account.subcommands.clean.confirm.other`, {
|
|
80
79
|
count: accountsToRemove.length,
|
|
81
80
|
}),
|
|
82
81
|
},
|
|
@@ -85,7 +84,7 @@ async function handler(args) {
|
|
|
85
84
|
logger_1.logger.log('');
|
|
86
85
|
for (const accountToRemove of accountsToRemove) {
|
|
87
86
|
await (0, config_1.deleteAccount)(accountToRemove.name);
|
|
88
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
87
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.clean.removeSuccess`, {
|
|
89
88
|
accountName: accountToRemove.name,
|
|
90
89
|
}));
|
|
91
90
|
}
|
|
@@ -93,7 +92,7 @@ async function handler(args) {
|
|
|
93
92
|
}
|
|
94
93
|
else {
|
|
95
94
|
SpinniesManager_1.default.succeed('accountsClean', {
|
|
96
|
-
text: (0, lang_1.i18n)(
|
|
95
|
+
text: (0, lang_1.i18n)(`commands.account.subcommands.clean.noResults`),
|
|
97
96
|
});
|
|
98
97
|
}
|
|
99
98
|
logger_1.logger.log('');
|
package/commands/account/info.js
CHANGED
|
@@ -8,8 +8,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
10
|
const table_1 = require("../../lib/ui/table");
|
|
11
|
-
|
|
12
|
-
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
11
|
+
exports.describe = (0, lang_1.i18n)(`commands.account.subcommands.info.describe`);
|
|
13
12
|
exports.command = 'info [account]';
|
|
14
13
|
async function handler(args) {
|
|
15
14
|
const { derivedAccountId } = args;
|
|
@@ -20,25 +19,24 @@ async function handler(args) {
|
|
|
20
19
|
let scopeGroups = [];
|
|
21
20
|
const response = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env, derivedAccountId);
|
|
22
21
|
scopeGroups = response.scopeGroups.map(s => [s]);
|
|
23
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
24
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
25
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
22
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.name`, { name: name }));
|
|
23
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.accountId`, { accountId: derivedAccountId }));
|
|
24
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.scopeGroups`));
|
|
26
25
|
logger_1.logger.log((0, table_1.getTableContents)(scopeGroups, { border: { bodyLeft: ' ' } }));
|
|
27
26
|
}
|
|
28
27
|
else {
|
|
29
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
28
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.errors.notUsingPersonalAccessKey`));
|
|
30
29
|
}
|
|
31
|
-
logger_1.logger.debug('Some debug log that only shows on this version of the CLI');
|
|
32
30
|
}
|
|
33
31
|
function accountInfoBuilder(yargs) {
|
|
34
32
|
yargs.positional('account', {
|
|
35
|
-
describe: (0, lang_1.i18n)(
|
|
33
|
+
describe: (0, lang_1.i18n)(`commands.account.subcommands.info.options.account.describe`),
|
|
36
34
|
type: 'string',
|
|
37
35
|
});
|
|
38
36
|
yargs.example([
|
|
39
|
-
['$0 accounts info', (0, lang_1.i18n)(
|
|
40
|
-
['$0 accounts info MyAccount', (0, lang_1.i18n)(
|
|
41
|
-
['$0 accounts info 1234567', (0, lang_1.i18n)(
|
|
37
|
+
['$0 accounts info', (0, lang_1.i18n)(`commands.account.subcommands.info.examples.default`)],
|
|
38
|
+
['$0 accounts info MyAccount', (0, lang_1.i18n)(`commands.account.subcommands.info.examples.nameBased`)],
|
|
39
|
+
['$0 accounts info 1234567', (0, lang_1.i18n)(`commands.account.subcommands.info.examples.idBased`)],
|
|
42
40
|
]);
|
|
43
41
|
return yargs;
|
|
44
42
|
}
|
package/commands/account/list.js
CHANGED
|
@@ -12,9 +12,8 @@ const usageTracking_1 = require("../../lib/usageTracking");
|
|
|
12
12
|
const accountTypes_1 = require("../../lib/accountTypes");
|
|
13
13
|
const lang_1 = require("../../lib/lang");
|
|
14
14
|
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
15
|
-
const i18nKey = 'commands.account.subcommands.list';
|
|
16
15
|
exports.command = ['list', 'ls'];
|
|
17
|
-
exports.describe = (0, lang_1.i18n)(
|
|
16
|
+
exports.describe = (0, lang_1.i18n)('commands.account.subcommands.list.describe');
|
|
18
17
|
function sortAndMapAccounts(accounts) {
|
|
19
18
|
const mappedAccountData = {};
|
|
20
19
|
// Standard and app developer accounts
|
|
@@ -77,15 +76,15 @@ async function handler(args) {
|
|
|
77
76
|
const mappedAccountData = sortAndMapAccounts(accountsList);
|
|
78
77
|
const accountData = getAccountData(mappedAccountData);
|
|
79
78
|
accountData.unshift((0, table_1.getTableHeader)([
|
|
80
|
-
(0, lang_1.i18n)(
|
|
81
|
-
(0, lang_1.i18n)(
|
|
82
|
-
(0, lang_1.i18n)(
|
|
79
|
+
(0, lang_1.i18n)('commands.account.subcommands.list.labels.name'),
|
|
80
|
+
(0, lang_1.i18n)('commands.account.subcommands.list.labels.accountId'),
|
|
81
|
+
(0, lang_1.i18n)('commands.account.subcommands.list.labels.authType'),
|
|
83
82
|
]));
|
|
84
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
85
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
83
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.list.configPath', { configPath: configPath }));
|
|
84
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.list.defaultAccount', {
|
|
86
85
|
account: (0, config_1.getConfigDefaultAccount)(),
|
|
87
86
|
}));
|
|
88
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
87
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.list.accounts'));
|
|
89
88
|
logger_1.logger.log((0, table_1.getTableContents)(accountData, { border: { bodyLeft: ' ' } }));
|
|
90
89
|
}
|
|
91
90
|
function builder(yargs) {
|
|
@@ -9,32 +9,31 @@ const usageTracking_1 = require("../../lib/usageTracking");
|
|
|
9
9
|
const lang_1 = require("../../lib/lang");
|
|
10
10
|
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
11
11
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
12
|
-
const i18nKey = 'commands.account.subcommands.remove';
|
|
13
12
|
exports.command = 'remove [account]';
|
|
14
|
-
exports.describe = (0, lang_1.i18n)(
|
|
13
|
+
exports.describe = (0, lang_1.i18n)(`commands.account.subcommands.remove.describe`);
|
|
15
14
|
async function handler(args) {
|
|
16
15
|
const { account } = args;
|
|
17
16
|
let accountToRemove = account;
|
|
18
17
|
if (accountToRemove && !(0, config_1.getAccountId)(accountToRemove)) {
|
|
19
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
18
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.account.subcommands.remove.errors.accountNotFound`, {
|
|
20
19
|
specifiedAccount: accountToRemove,
|
|
21
20
|
configPath: (0, config_1.getConfigPath)(),
|
|
22
21
|
}));
|
|
23
22
|
}
|
|
24
23
|
if (!accountToRemove || !(0, config_1.getAccountId)(accountToRemove)) {
|
|
25
|
-
accountToRemove = await (0, accountsPrompt_1.selectAccountFromConfig)((0, lang_1.i18n)(
|
|
24
|
+
accountToRemove = await (0, accountsPrompt_1.selectAccountFromConfig)((0, lang_1.i18n)(`commands.account.subcommands.remove.prompts.selectAccountToRemove`));
|
|
26
25
|
}
|
|
27
26
|
(0, usageTracking_1.trackCommandUsage)('accounts-remove', undefined, (0, config_1.getAccountId)(accountToRemove));
|
|
28
27
|
const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
29
28
|
await (0, config_1.deleteAccount)(accountToRemove);
|
|
30
|
-
logger_1.logger.success((0, lang_1.i18n)(
|
|
29
|
+
logger_1.logger.success((0, lang_1.i18n)(`commands.account.subcommands.remove.success.accountRemoved`, {
|
|
31
30
|
accountName: accountToRemove,
|
|
32
31
|
}));
|
|
33
32
|
// Get updated version of the config
|
|
34
33
|
(0, config_1.loadConfig)((0, config_1.getConfigPath)());
|
|
35
34
|
if (accountToRemove === currentDefaultAccount) {
|
|
36
35
|
logger_1.logger.log();
|
|
37
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
36
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.remove.logs.replaceDefaultAccount`));
|
|
38
37
|
const newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
39
38
|
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
40
39
|
}
|
|
@@ -42,12 +41,12 @@ async function handler(args) {
|
|
|
42
41
|
function builder(yargs) {
|
|
43
42
|
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
44
43
|
yargs.positional('account', {
|
|
45
|
-
describe: (0, lang_1.i18n)(
|
|
44
|
+
describe: (0, lang_1.i18n)(`commands.account.subcommands.remove.options.account.describe`),
|
|
46
45
|
type: 'string',
|
|
47
46
|
});
|
|
48
47
|
yargs.example([
|
|
49
|
-
['$0 accounts remove', (0, lang_1.i18n)(
|
|
50
|
-
['$0 accounts remove MyAccount', (0, lang_1.i18n)(
|
|
48
|
+
['$0 accounts remove', (0, lang_1.i18n)(`commands.account.subcommands.remove.examples.default`)],
|
|
49
|
+
['$0 accounts remove MyAccount', (0, lang_1.i18n)(`commands.account.subcommands.remove.examples.byName`)],
|
|
51
50
|
]);
|
|
52
51
|
return yargs;
|
|
53
52
|
}
|
|
@@ -10,9 +10,8 @@ const usageTracking_1 = require("../../lib/usageTracking");
|
|
|
10
10
|
const lang_1 = require("../../lib/lang");
|
|
11
11
|
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
12
12
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
13
|
-
const i18nKey = 'commands.account.subcommands.rename';
|
|
14
13
|
exports.command = 'rename <account-name> <new-name>';
|
|
15
|
-
exports.describe = (0, lang_1.i18n)(
|
|
14
|
+
exports.describe = (0, lang_1.i18n)(`commands.account.subcommands.rename.describe`);
|
|
16
15
|
async function handler(args) {
|
|
17
16
|
const { accountName, newName, derivedAccountId } = args;
|
|
18
17
|
(0, usageTracking_1.trackCommandUsage)('accounts-rename', undefined, derivedAccountId);
|
|
@@ -23,7 +22,7 @@ async function handler(args) {
|
|
|
23
22
|
(0, errorHandlers_1.logError)(error);
|
|
24
23
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
25
24
|
}
|
|
26
|
-
logger_1.logger.log((0, lang_1.i18n)(
|
|
25
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.rename.success.renamed`, {
|
|
27
26
|
name: accountName,
|
|
28
27
|
newName,
|
|
29
28
|
}));
|
|
@@ -33,11 +32,11 @@ function builder(yargs) {
|
|
|
33
32
|
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
34
33
|
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
35
34
|
yargs.positional('account-name', {
|
|
36
|
-
describe: (0, lang_1.i18n)(
|
|
35
|
+
describe: (0, lang_1.i18n)(`commands.account.subcommands.rename.positionals.accountName.describe`),
|
|
37
36
|
type: 'string',
|
|
38
37
|
});
|
|
39
38
|
yargs.positional('new-name', {
|
|
40
|
-
describe: (0, lang_1.i18n)(
|
|
39
|
+
describe: (0, lang_1.i18n)(`commands.account.subcommands.rename.positionals.newName.describe`),
|
|
41
40
|
type: 'string',
|
|
42
41
|
});
|
|
43
42
|
yargs.example([
|
package/commands/account/use.js
CHANGED
|
@@ -8,16 +8,15 @@ 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 i18nKey = 'commands.account.subcommands.use';
|
|
12
11
|
exports.command = 'use [account]';
|
|
13
|
-
exports.describe = (0, lang_1.i18n)(
|
|
12
|
+
exports.describe = (0, lang_1.i18n)('commands.account.subcommands.use.describe');
|
|
14
13
|
async function handler(args) {
|
|
15
14
|
let newDefaultAccount = args.account;
|
|
16
15
|
if (!newDefaultAccount) {
|
|
17
16
|
newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
18
17
|
}
|
|
19
18
|
else if (!(0, config_1.getAccountId)(newDefaultAccount)) {
|
|
20
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
19
|
+
logger_1.logger.error((0, lang_1.i18n)('commands.account.subcommands.use.errors.accountNotFound', {
|
|
21
20
|
specifiedAccount: newDefaultAccount,
|
|
22
21
|
configPath: (0, config_1.getConfigPath)(),
|
|
23
22
|
}));
|
|
@@ -25,19 +24,19 @@ async function handler(args) {
|
|
|
25
24
|
}
|
|
26
25
|
(0, usageTracking_1.trackCommandUsage)('accounts-use', undefined, (0, config_1.getAccountId)(newDefaultAccount));
|
|
27
26
|
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
28
|
-
return logger_1.logger.success((0, lang_1.i18n)(
|
|
27
|
+
return logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.use.success.defaultAccountUpdated', {
|
|
29
28
|
accountName: newDefaultAccount,
|
|
30
29
|
}));
|
|
31
30
|
}
|
|
32
31
|
function builder(yargs) {
|
|
33
32
|
yargs.positional('account', {
|
|
34
|
-
describe: (0, lang_1.i18n)(
|
|
33
|
+
describe: (0, lang_1.i18n)('commands.account.subcommands.use.options.account.describe'),
|
|
35
34
|
type: 'string',
|
|
36
35
|
});
|
|
37
36
|
yargs.example([
|
|
38
|
-
['$0 accounts use', (0, lang_1.i18n)(
|
|
39
|
-
['$0 accounts use MyAccount', (0, lang_1.i18n)(
|
|
40
|
-
['$0 accounts use 1234567', (0, lang_1.i18n)(
|
|
37
|
+
['$0 accounts use', (0, lang_1.i18n)('commands.account.subcommands.use.examples.default')],
|
|
38
|
+
['$0 accounts use MyAccount', (0, lang_1.i18n)('commands.account.subcommands.use.examples.nameBased')],
|
|
39
|
+
['$0 accounts use 1234567', (0, lang_1.i18n)('commands.account.subcommands.use.examples.idBased')],
|
|
41
40
|
]);
|
|
42
41
|
return yargs;
|
|
43
42
|
}
|
|
@@ -13,11 +13,10 @@ const { FieldsJs, isConvertableFieldJs, } = require('@hubspot/local-dev-lib/cms/
|
|
|
13
13
|
const { trackConvertFieldsUsage } = require('../../lib/usageTracking');
|
|
14
14
|
const { logError } = require('../../lib/errorHandlers/index');
|
|
15
15
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
16
|
-
const i18nKey = 'commands.convertFields';
|
|
17
16
|
exports.command = 'convert-fields';
|
|
18
|
-
exports.describe = i18n(
|
|
17
|
+
exports.describe = i18n(`commands.convertFields.describe`);
|
|
19
18
|
const invalidPath = src => {
|
|
20
|
-
logger.error(i18n(
|
|
19
|
+
logger.error(i18n(`commands.convertFields.errors.invalidPath`, {
|
|
21
20
|
path: src,
|
|
22
21
|
}));
|
|
23
22
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -76,12 +75,12 @@ exports.handler = async (options) => {
|
|
|
76
75
|
};
|
|
77
76
|
exports.builder = yargs => {
|
|
78
77
|
yargs.option('src', {
|
|
79
|
-
describe: i18n(
|
|
78
|
+
describe: i18n(`commands.convertFields.positionals.src.describe`),
|
|
80
79
|
type: 'string',
|
|
81
|
-
demandOption: i18n(
|
|
80
|
+
demandOption: i18n(`commands.convertFields.errors.missingSrc`),
|
|
82
81
|
});
|
|
83
82
|
yargs.option('fieldOptions', {
|
|
84
|
-
describe: i18n(
|
|
83
|
+
describe: i18n(`commands.convertFields.options.options.describe`),
|
|
85
84
|
type: 'array',
|
|
86
85
|
default: [''],
|
|
87
86
|
});
|
|
@@ -11,9 +11,8 @@ const { logError } = require('../../lib/errorHandlers/index');
|
|
|
11
11
|
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
12
12
|
const { listPrompt } = require('../../lib/prompts/promptUtils');
|
|
13
13
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
14
|
-
const i18nKey = 'commands.cms.subcommands.getReactModule';
|
|
15
14
|
exports.command = 'get-react-module [name] [dest]';
|
|
16
|
-
exports.describe = i18n(
|
|
15
|
+
exports.describe = i18n(`commands.cms.subcommands.getReactModule.describe`);
|
|
17
16
|
exports.handler = async (options) => {
|
|
18
17
|
const { name, dest } = options;
|
|
19
18
|
trackCommandUsage('get-react-modules');
|
|
@@ -26,7 +25,7 @@ exports.handler = async (options) => {
|
|
|
26
25
|
catch (e) {
|
|
27
26
|
logError(e);
|
|
28
27
|
}
|
|
29
|
-
const moduleChoice = await listPrompt(i18n(
|
|
28
|
+
const moduleChoice = await listPrompt(i18n(`commands.cms.subcommands.getReactModule.selectModulePrompt`), {
|
|
30
29
|
choices: availableModules.map(module => module.name),
|
|
31
30
|
});
|
|
32
31
|
moduleToRetrieve = moduleChoice;
|
|
@@ -35,21 +34,21 @@ exports.handler = async (options) => {
|
|
|
35
34
|
? path.join(path.resolve(getCwd(), dest), `${moduleToRetrieve}`)
|
|
36
35
|
: path.join(getCwd(), `${moduleToRetrieve}`);
|
|
37
36
|
if (fs.existsSync(destPath)) {
|
|
38
|
-
logger.error(i18n(
|
|
37
|
+
logger.error(i18n(`commands.cms.subcommands.getReactModule.errors.pathExists`, {
|
|
39
38
|
path: destPath,
|
|
40
39
|
}));
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
try {
|
|
44
43
|
await retrieveDefaultModule(moduleToRetrieve, destPath);
|
|
45
|
-
logger.success(i18n(
|
|
44
|
+
logger.success(i18n(`commands.cms.subcommands.getReactModule.success.moduleDownloaded`, {
|
|
46
45
|
moduleName: moduleToRetrieve,
|
|
47
46
|
path: destPath,
|
|
48
47
|
}));
|
|
49
48
|
}
|
|
50
49
|
catch (e) {
|
|
51
50
|
if (e.cause && e.cause.code === 'ERR_BAD_REQUEST') {
|
|
52
|
-
logger.error(i18n(
|
|
51
|
+
logger.error(i18n(`commands.cms.subcommands.getReactModule.errors.invalidName`));
|
|
53
52
|
}
|
|
54
53
|
else {
|
|
55
54
|
logError(e);
|
|
@@ -59,11 +58,11 @@ exports.handler = async (options) => {
|
|
|
59
58
|
};
|
|
60
59
|
exports.builder = yargs => {
|
|
61
60
|
yargs.positional('name', {
|
|
62
|
-
describe: i18n(
|
|
61
|
+
describe: i18n(`commands.cms.subcommands.getReactModule.positionals.name.describe`),
|
|
63
62
|
type: 'string',
|
|
64
63
|
});
|
|
65
64
|
yargs.positional('dest', {
|
|
66
|
-
describe: i18n(
|
|
65
|
+
describe: i18n(`commands.cms.subcommands.getReactModule.positionals.dest.describe`),
|
|
67
66
|
type: 'string',
|
|
68
67
|
});
|
|
69
68
|
return yargs;
|