@hubspot/cli 7.2.4-experimental.0 → 7.3.0-beta.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 +7 -8
- package/commands/account/clean.js +9 -10
- package/commands/account/info.js +9 -10
- 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/customObject.d.ts +1 -1
- 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/mv.d.ts +1 -1
- package/commands/project/add.d.ts +10 -0
- package/commands/project/add.js +64 -52
- package/commands/project/create.js +1 -0
- 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 +3453 -0
- package/lang/en.lyaml +9 -3
- package/lib/DevServerManagerV2.d.ts +1 -2
- package/lib/DevServerManagerV2.js +1 -2
- package/lib/LocalDevManagerV2.js +10 -15
- package/lib/dependencyManagement.js +8 -9
- package/lib/errorHandlers/index.js +17 -0
- package/lib/projects/buildAndDeploy.d.ts +1 -1
- package/lib/projects/buildAndDeploy.js +14 -12
- package/lib/projects/index.d.ts +1 -1
- package/lib/projects/index.js +1 -1
- package/lib/projects/structure.d.ts +1 -2
- package/lib/projects/structure.js +0 -4
- 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 -1
- package/lib/yargsUtils.d.ts +2 -2
- package/lib/yargsUtils.js +2 -2
- package/package.json +5 -5
- package/types/ProjectComponents.d.ts +0 -15
package/bin/cli.js
CHANGED
|
@@ -48,15 +48,14 @@ const notifier = updateNotifier({
|
|
|
48
48
|
distTag: 'latest',
|
|
49
49
|
shouldNotifyInNpmScript: true,
|
|
50
50
|
});
|
|
51
|
-
const i18nKey = 'commands.generalErrors';
|
|
52
51
|
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
53
52
|
notifier.notify({
|
|
54
53
|
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
55
|
-
? i18n(
|
|
54
|
+
? i18n(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
|
|
56
55
|
packageName: CMS_CLI_PACKAGE_NAME,
|
|
57
56
|
updateCommand: uiCommandReference('{updateCommand}'),
|
|
58
57
|
})
|
|
59
|
-
: i18n(
|
|
58
|
+
: i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
60
59
|
updateCommand: uiCommandReference('{updateCommand}'),
|
|
61
60
|
}),
|
|
62
61
|
defer: false,
|
|
@@ -68,7 +67,7 @@ notifier.notify({
|
|
|
68
67
|
borderStyle: 'round',
|
|
69
68
|
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
70
69
|
? null
|
|
71
|
-
: chalk.bold(i18n(
|
|
70
|
+
: chalk.bold(i18n(`commands.generalErrors.updateNotify.notifyTitle`)),
|
|
72
71
|
},
|
|
73
72
|
});
|
|
74
73
|
const getTerminalWidth = () => {
|
|
@@ -97,13 +96,13 @@ const performChecks = argv => {
|
|
|
97
96
|
if (argv._[0] === 'config' &&
|
|
98
97
|
argv._[1] === 'set' &&
|
|
99
98
|
argv._[2] === 'default-account') {
|
|
100
|
-
logger.error(i18n(
|
|
99
|
+
logger.error(i18n(`commands.generalErrors.setDefaultAccountMoved`));
|
|
101
100
|
process.exit(EXIT_CODES.ERROR);
|
|
102
101
|
}
|
|
103
102
|
// Require "project" command when running upload/watch inside of a project
|
|
104
103
|
if (argv._.length === 1 && ['upload', 'watch'].includes(argv._[0])) {
|
|
105
104
|
if (getIsInProject(argv.src)) {
|
|
106
|
-
logger.error(i18n(
|
|
105
|
+
logger.error(i18n(`commands.generalErrors.srcIsProject`, {
|
|
107
106
|
src: argv.src || './',
|
|
108
107
|
command: argv._.join(' '),
|
|
109
108
|
}));
|
|
@@ -147,7 +146,7 @@ const handleDeprecatedEnvVariables = options => {
|
|
|
147
146
|
if (options.useEnv &&
|
|
148
147
|
process.env.HUBSPOT_PORTAL_ID &&
|
|
149
148
|
!process.env.HUBSPOT_ACCOUNT_ID) {
|
|
150
|
-
uiDeprecatedTag(i18n(
|
|
149
|
+
uiDeprecatedTag(i18n(`commands.generalErrors.handleDeprecatedEnvVariables.portalEnvVarDeprecated`, {
|
|
151
150
|
configPath: getConfigPath(),
|
|
152
151
|
}));
|
|
153
152
|
process.env.HUBSPOT_ACCOUNT_ID = process.env.HUBSPOT_PORTAL_ID;
|
|
@@ -179,7 +178,7 @@ const loadConfigMiddleware = async (options) => {
|
|
|
179
178
|
}
|
|
180
179
|
};
|
|
181
180
|
if (configFileExists(true) && options.config) {
|
|
182
|
-
logger.error(i18n(
|
|
181
|
+
logger.error(i18n(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
183
182
|
configPath: getConfigPath(),
|
|
184
183
|
}));
|
|
185
184
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -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,24 +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
30
|
}
|
|
32
31
|
function accountInfoBuilder(yargs) {
|
|
33
32
|
yargs.positional('account', {
|
|
34
|
-
describe: (0, lang_1.i18n)(
|
|
33
|
+
describe: (0, lang_1.i18n)(`commands.account.subcommands.info.options.account.describe`),
|
|
35
34
|
type: 'string',
|
|
36
35
|
});
|
|
37
36
|
yargs.example([
|
|
38
|
-
['$0 accounts info', (0, lang_1.i18n)(
|
|
39
|
-
['$0 accounts info MyAccount', (0, lang_1.i18n)(
|
|
40
|
-
['$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`)],
|
|
41
40
|
]);
|
|
42
41
|
return yargs;
|
|
43
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;
|
|
@@ -12,7 +12,6 @@ const { requestLighthouseScore, getLighthouseScoreStatus, getLighthouseScore, }
|
|
|
12
12
|
const { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } = require('../../lib/constants');
|
|
13
13
|
const { uiLink } = require('../../lib/ui');
|
|
14
14
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
15
|
-
const i18nKey = 'commands.cms.subcommands.lighthouseScore';
|
|
16
15
|
const DEFAULT_TABLE_HEADER = [
|
|
17
16
|
'Accessibility',
|
|
18
17
|
'Best practices',
|
|
@@ -28,7 +27,7 @@ const selectTheme = async (accountId) => {
|
|
|
28
27
|
type: 'list',
|
|
29
28
|
look: false,
|
|
30
29
|
name: 'theme',
|
|
31
|
-
message: i18n(
|
|
30
|
+
message: i18n(`commands.cms.subcommands.lighthouseScore.info.promptMessage`),
|
|
32
31
|
choices: async () => {
|
|
33
32
|
try {
|
|
34
33
|
const { data: result } = await fetchThemes(accountId, {
|
|
@@ -43,7 +42,7 @@ const selectTheme = async (accountId) => {
|
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
catch (err) {
|
|
46
|
-
logger.error(i18n(
|
|
45
|
+
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.errors.failedToFetchThemes`));
|
|
47
46
|
process.exit(EXIT_CODES.ERROR);
|
|
48
47
|
}
|
|
49
48
|
},
|
|
@@ -68,7 +67,7 @@ exports.handler = async (options) => {
|
|
|
68
67
|
isValidTheme = false;
|
|
69
68
|
}
|
|
70
69
|
if (!isValidTheme) {
|
|
71
|
-
logger.error(i18n(
|
|
70
|
+
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.errors.themeNotFound`, { theme: themeToCheck }));
|
|
72
71
|
process.exit(EXIT_CODES.ERROR);
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -88,14 +87,14 @@ exports.handler = async (options) => {
|
|
|
88
87
|
logger.debug(err);
|
|
89
88
|
}
|
|
90
89
|
if (!requestResult || !requestResult.mobileId || !requestResult.desktopId) {
|
|
91
|
-
logger.error(i18n(
|
|
90
|
+
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.errors.failedToGetLighthouseScore`));
|
|
92
91
|
process.exit(EXIT_CODES.ERROR);
|
|
93
92
|
}
|
|
94
93
|
// Poll till scoring is finished
|
|
95
94
|
try {
|
|
96
95
|
SpinniesManager.init();
|
|
97
96
|
SpinniesManager.add('lighthouseScore', {
|
|
98
|
-
text: i18n(
|
|
97
|
+
text: i18n(`commands.cms.subcommands.lighthouseScore.info.generatingScore`, { theme: themeToCheck }),
|
|
99
98
|
});
|
|
100
99
|
const checkScoreStatus = async () => {
|
|
101
100
|
let desktopScoreStatus = 'COMPLETED';
|
|
@@ -157,7 +156,7 @@ exports.handler = async (options) => {
|
|
|
157
156
|
}
|
|
158
157
|
}
|
|
159
158
|
catch (err) {
|
|
160
|
-
logger.error(i18n(
|
|
159
|
+
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.errors.failedToGetLighthouseScore`));
|
|
161
160
|
process.exit(EXIT_CODES.ERROR);
|
|
162
161
|
}
|
|
163
162
|
if (verbose) {
|
|
@@ -176,7 +175,7 @@ exports.handler = async (options) => {
|
|
|
176
175
|
logger.log(getTableContents([tableHeader, averageTableData], {
|
|
177
176
|
border: { bodyLeft: ' ' },
|
|
178
177
|
}));
|
|
179
|
-
logger.log(i18n(
|
|
178
|
+
logger.log(i18n(`commands.cms.subcommands.lighthouseScore.info.pageTemplateScoreTitle`));
|
|
180
179
|
const table2Header = getTableHeader([
|
|
181
180
|
'Template path',
|
|
182
181
|
...DEFAULT_TABLE_HEADER,
|
|
@@ -195,19 +194,19 @@ exports.handler = async (options) => {
|
|
|
195
194
|
logger.log(getTableContents([table2Header, ...templateTableData], {
|
|
196
195
|
border: { bodyLeft: ' ' },
|
|
197
196
|
}));
|
|
198
|
-
logger.log(i18n(
|
|
197
|
+
logger.log(i18n(`commands.cms.subcommands.lighthouseScore.info.lighthouseLinksTitle`));
|
|
199
198
|
scoreResult.scores.forEach(score => {
|
|
200
199
|
logger.log(' ', uiLink(score.templatePath, score.link));
|
|
201
200
|
});
|
|
202
201
|
if (scoreResult.failedTemplatePaths.length) {
|
|
203
202
|
logger.log();
|
|
204
|
-
logger.error(i18n(
|
|
203
|
+
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.info.failedTemplatePathsTitle`));
|
|
205
204
|
scoreResult.failedTemplatePaths.forEach(failedTemplatePath => {
|
|
206
205
|
logger.log(' ', failedTemplatePath);
|
|
207
206
|
});
|
|
208
207
|
}
|
|
209
208
|
logger.log();
|
|
210
|
-
logger.info(i18n(
|
|
209
|
+
logger.info(i18n(`commands.cms.subcommands.lighthouseScore.info.targetDeviceNote`, { target }));
|
|
211
210
|
}
|
|
212
211
|
else {
|
|
213
212
|
logger.log(`Theme: ${themeToCheck}`);
|
|
@@ -230,7 +229,7 @@ exports.handler = async (options) => {
|
|
|
230
229
|
logger.log(getTableContents([tableHeader, ...tableData], {
|
|
231
230
|
border: { bodyLeft: ' ' },
|
|
232
231
|
}));
|
|
233
|
-
logger.info(i18n(
|
|
232
|
+
logger.info(i18n(`commands.cms.subcommands.lighthouseScore.info.verboseOptionNote`));
|
|
234
233
|
}
|
|
235
234
|
logger.log();
|
|
236
235
|
logger.log(`Powered by ${uiLink('Google Lighthouse', 'https://developer.chrome.com/docs/lighthouse/overview/')}.`);
|
|
@@ -238,24 +237,24 @@ exports.handler = async (options) => {
|
|
|
238
237
|
};
|
|
239
238
|
exports.builder = yargs => {
|
|
240
239
|
yargs.option('theme', {
|
|
241
|
-
describe: i18n(
|
|
240
|
+
describe: i18n(`commands.cms.subcommands.lighthouseScore.options.theme.describe`),
|
|
242
241
|
type: 'string',
|
|
243
242
|
});
|
|
244
243
|
yargs.option('target', {
|
|
245
|
-
describe: i18n(
|
|
244
|
+
describe: i18n(`commands.cms.subcommands.lighthouseScore.options.target.describe`),
|
|
246
245
|
type: 'string',
|
|
247
246
|
choices: ['desktop', 'mobile'],
|
|
248
247
|
default: 'desktop',
|
|
249
248
|
});
|
|
250
249
|
yargs.option('verbose', {
|
|
251
|
-
describe: i18n(
|
|
250
|
+
describe: i18n(`commands.cms.subcommands.lighthouseScore.options.verbose.describe`),
|
|
252
251
|
boolean: true,
|
|
253
252
|
default: false,
|
|
254
253
|
});
|
|
255
254
|
yargs.example([
|
|
256
255
|
[
|
|
257
256
|
'$0 cms lighthouse-score --theme=my-theme',
|
|
258
|
-
i18n(
|
|
257
|
+
i18n(`commands.cms.subcommands.lighthouseScore.examples.default`),
|
|
259
258
|
],
|
|
260
259
|
]);
|
|
261
260
|
addConfigOptions(yargs);
|
package/commands/config/set.js
CHANGED
|
@@ -6,9 +6,8 @@ const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
|
6
6
|
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
7
7
|
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
8
8
|
const { setDefaultCmsPublishMode, setHttpTimeout, setAllowUsageTracking, } = require('../../lib/configOptions');
|
|
9
|
-
const i18nKey = 'commands.config.subcommands.set';
|
|
10
9
|
exports.command = 'set';
|
|
11
|
-
exports.describe = i18n(
|
|
10
|
+
exports.describe = i18n(`commands.config.subcommands.set.describe`);
|
|
12
11
|
const selectOptions = async () => {
|
|
13
12
|
const { cmsPublishMode } = await promptUser([
|
|
14
13
|
{
|
|
@@ -16,7 +15,7 @@ const selectOptions = async () => {
|
|
|
16
15
|
look: false,
|
|
17
16
|
name: 'cmsPublishMode',
|
|
18
17
|
pageSize: 20,
|
|
19
|
-
message: i18n(
|
|
18
|
+
message: i18n(`commands.config.subcommands.set.promptMessage`),
|
|
20
19
|
choices: [
|
|
21
20
|
{
|
|
22
21
|
name: 'Default CMS publish mode',
|
|
@@ -59,21 +58,21 @@ exports.builder = yargs => {
|
|
|
59
58
|
yargs
|
|
60
59
|
.options({
|
|
61
60
|
'default-cms-publish-mode': {
|
|
62
|
-
describe: i18n(
|
|
61
|
+
describe: i18n(`commands.config.subcommands.set.options.defaultMode.describe`),
|
|
63
62
|
type: 'string',
|
|
64
63
|
},
|
|
65
64
|
'allow-usage-tracking': {
|
|
66
|
-
describe: i18n(
|
|
65
|
+
describe: i18n(`commands.config.subcommands.set.options.allowUsageTracking.describe`),
|
|
67
66
|
type: 'boolean',
|
|
68
67
|
},
|
|
69
68
|
'http-timeout': {
|
|
70
|
-
describe: i18n(
|
|
69
|
+
describe: i18n(`commands.config.subcommands.set.options.httpTimeout.describe`),
|
|
71
70
|
type: 'string',
|
|
72
71
|
},
|
|
73
72
|
})
|
|
74
73
|
.conflicts('defaultCmsPublishMode', 'allowUsageTracking')
|
|
75
74
|
.conflicts('defaultCmsPublishMode', 'httpTimeout')
|
|
76
75
|
.conflicts('allowUsageTracking', 'httpTimeout')
|
|
77
|
-
.example([['$0 config set', i18n(
|
|
76
|
+
.example([['$0 config set', i18n(`commands.config.subcommands.set.examples.default`)]]);
|
|
78
77
|
return yargs;
|
|
79
78
|
};
|