@hubspot/cli 7.3.0-experimental.2 → 7.4.0-experimental.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +27 -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/app/migrate.d.ts +7 -0
- package/commands/app/migrate.js +94 -0
- package/commands/app.d.ts +6 -0
- package/commands/app.js +23 -0
- 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/cloneApp.d.ts +9 -1
- package/commands/project/cloneApp.js +91 -76
- package/commands/project/migrateApp.d.ts +9 -1
- package/commands/project/migrateApp.js +43 -170
- package/lang/en.lyaml +32 -0
- package/lib/app/migrate.d.ts +7 -0
- package/lib/app/migrate.js +345 -0
- package/lib/dependencyManagement.d.ts +5 -0
- package/lib/dependencyManagement.js +47 -22
- package/lib/doctor/Doctor.js +1 -2
- package/lib/polling.d.ts +4 -0
- package/lib/polling.js +3 -3
- package/lib/prompts/promptUtils.d.ts +6 -4
- package/lib/prompts/promptUtils.js +3 -1
- package/lib/ui/index.d.ts +2 -2
- package/lib/ui/index.js +6 -5
- package/package.json +3 -3
- package/types/Prompts.d.ts +2 -2
- package/types/Yargs.d.ts +10 -0
- 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');
|
|
@@ -45,36 +43,34 @@ const cmsCommand = require('../commands/cms');
|
|
|
45
43
|
const feedbackCommand = require('../commands/feedback');
|
|
46
44
|
const doctorCommand = require('../commands/doctor');
|
|
47
45
|
const completionCommand = require('../commands/completion');
|
|
46
|
+
const appCommand = require('../commands/app');
|
|
48
47
|
const notifier = updateNotifier({
|
|
49
48
|
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
50
49
|
distTag: 'latest',
|
|
51
50
|
shouldNotifyInNpmScript: true,
|
|
52
51
|
});
|
|
53
|
-
const i18nKey = 'commands.generalErrors';
|
|
54
52
|
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
|
-
};
|
|
53
|
+
notifier.notify({
|
|
54
|
+
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
55
|
+
? i18n(`commands.generalErrors.updateNotify.cmsUpdateNotification`, {
|
|
56
|
+
packageName: CMS_CLI_PACKAGE_NAME,
|
|
57
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
58
|
+
})
|
|
59
|
+
: i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
60
|
+
updateCommand: uiCommandReference('{updateCommand}'),
|
|
61
|
+
}),
|
|
62
|
+
defer: false,
|
|
63
|
+
boxenOptions: {
|
|
64
|
+
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
65
|
+
margin: 1,
|
|
66
|
+
padding: 1,
|
|
67
|
+
textAlignment: 'center',
|
|
68
|
+
borderStyle: 'round',
|
|
69
|
+
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
70
|
+
? null
|
|
71
|
+
: chalk.bold(i18n(`commands.generalErrors.updateNotify.notifyTitle`)),
|
|
72
|
+
},
|
|
73
|
+
});
|
|
78
74
|
const getTerminalWidth = () => {
|
|
79
75
|
const width = yargs.terminalWidth();
|
|
80
76
|
if (width >= 100)
|
|
@@ -101,13 +97,13 @@ const performChecks = argv => {
|
|
|
101
97
|
if (argv._[0] === 'config' &&
|
|
102
98
|
argv._[1] === 'set' &&
|
|
103
99
|
argv._[2] === 'default-account') {
|
|
104
|
-
logger.error(i18n(
|
|
100
|
+
logger.error(i18n(`commands.generalErrors.setDefaultAccountMoved`));
|
|
105
101
|
process.exit(EXIT_CODES.ERROR);
|
|
106
102
|
}
|
|
107
103
|
// Require "project" command when running upload/watch inside of a project
|
|
108
104
|
if (argv._.length === 1 && ['upload', 'watch'].includes(argv._[0])) {
|
|
109
105
|
if (getIsInProject(argv.src)) {
|
|
110
|
-
logger.error(i18n(
|
|
106
|
+
logger.error(i18n(`commands.generalErrors.srcIsProject`, {
|
|
111
107
|
src: argv.src || './',
|
|
112
108
|
command: argv._.join(' '),
|
|
113
109
|
}));
|
|
@@ -124,58 +120,6 @@ const performChecks = argv => {
|
|
|
124
120
|
const setRequestHeaders = () => {
|
|
125
121
|
addUserAgentHeader('HubSpot CLI', pkg.version);
|
|
126
122
|
};
|
|
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
123
|
const isTargetedCommand = (options, commandMap) => {
|
|
180
124
|
const checkCommand = (options, commandMap) => {
|
|
181
125
|
const currentCommand = options._[0];
|
|
@@ -203,7 +147,7 @@ const handleDeprecatedEnvVariables = options => {
|
|
|
203
147
|
if (options.useEnv &&
|
|
204
148
|
process.env.HUBSPOT_PORTAL_ID &&
|
|
205
149
|
!process.env.HUBSPOT_ACCOUNT_ID) {
|
|
206
|
-
uiDeprecatedTag(i18n(
|
|
150
|
+
uiDeprecatedTag(i18n(`commands.generalErrors.handleDeprecatedEnvVariables.portalEnvVarDeprecated`, {
|
|
207
151
|
configPath: getConfigPath(),
|
|
208
152
|
}));
|
|
209
153
|
process.env.HUBSPOT_ACCOUNT_ID = process.env.HUBSPOT_PORTAL_ID;
|
|
@@ -235,7 +179,7 @@ const loadConfigMiddleware = async (options) => {
|
|
|
235
179
|
}
|
|
236
180
|
};
|
|
237
181
|
if (configFileExists(true) && options.config) {
|
|
238
|
-
logger.error(i18n(
|
|
182
|
+
logger.error(i18n(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
239
183
|
configPath: getConfigPath(),
|
|
240
184
|
}));
|
|
241
185
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -299,7 +243,6 @@ const argv = yargs
|
|
|
299
243
|
// loadConfigMiddleware loads the new hidden config for all commands
|
|
300
244
|
.middleware([
|
|
301
245
|
setLogLevel,
|
|
302
|
-
updateCLIVersion,
|
|
303
246
|
setRequestHeaders,
|
|
304
247
|
handleDeprecatedEnvVariables,
|
|
305
248
|
loadConfigMiddleware,
|
|
@@ -352,6 +295,7 @@ const argv = yargs
|
|
|
352
295
|
.command(feedbackCommand)
|
|
353
296
|
.command(doctorCommand)
|
|
354
297
|
.command(completionCommand)
|
|
298
|
+
.command(appCommand)
|
|
355
299
|
.help()
|
|
356
300
|
.alias('h', 'help')
|
|
357
301
|
.recommendCommands()
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs';
|
|
2
|
+
import { MigrateAppOptions } from '../../types/Yargs';
|
|
3
|
+
export declare const validMigrationTargets: string[];
|
|
4
|
+
export declare function handler(options: ArgumentsCamelCase<MigrateAppOptions>): Promise<never>;
|
|
5
|
+
export declare function builder(yargs: Argv): Argv<MigrateAppOptions>;
|
|
6
|
+
declare const migrateCommand: CommandModule<unknown, MigrateAppOptions>;
|
|
7
|
+
export default migrateCommand;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validMigrationTargets = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
7
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
8
|
+
const lang_1 = require("../../lib/lang");
|
|
9
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
10
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
11
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
12
|
+
const migrate_1 = require("../../lib/app/migrate");
|
|
13
|
+
const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
14
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
15
|
+
const ui_1 = require("../../lib/ui");
|
|
16
|
+
const { v2023_2, v2025_2, unstable } = projects_1.PLATFORM_VERSIONS;
|
|
17
|
+
exports.validMigrationTargets = [v2023_2, v2025_2, unstable];
|
|
18
|
+
const command = 'migrate';
|
|
19
|
+
const describe = undefined; // uiBetaTag(i18n(`commands.project.subcommands.migrateApp.header.text.describe`), false);
|
|
20
|
+
async function handler(options) {
|
|
21
|
+
const { derivedAccountId, platformVersion } = options;
|
|
22
|
+
await (0, usageTracking_1.trackCommandUsage)('migrate-app', {}, derivedAccountId);
|
|
23
|
+
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
24
|
+
if (!accountConfig) {
|
|
25
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.errors.noAccountConfig`));
|
|
26
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
27
|
+
}
|
|
28
|
+
logger_1.logger.log('');
|
|
29
|
+
logger_1.logger.log((0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.header.text`), false));
|
|
30
|
+
logger_1.logger.log((0, ui_1.uiLink)((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.header.link`), 'https://developers.hubspot.com/docs/platform/migrate-a-public-app-to-projects'));
|
|
31
|
+
logger_1.logger.log('');
|
|
32
|
+
try {
|
|
33
|
+
if (platformVersion === v2025_2 || platformVersion === unstable) {
|
|
34
|
+
await (0, migrate_1.migrateApp2025_2)(derivedAccountId, options);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
await (0, migrate_1.migrateApp2023_2)(derivedAccountId, options, accountConfig);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error &&
|
|
42
|
+
typeof error === 'object' &&
|
|
43
|
+
'errors' in error &&
|
|
44
|
+
Array.isArray(error.errors)) {
|
|
45
|
+
error.errors.forEach(err => (0, errorHandlers_1.logError)(err));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
(0, errorHandlers_1.logError)(error, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId }));
|
|
49
|
+
}
|
|
50
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { successful: false }, derivedAccountId);
|
|
51
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
52
|
+
}
|
|
53
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { successful: true }, derivedAccountId);
|
|
54
|
+
return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
55
|
+
}
|
|
56
|
+
function builder(yargs) {
|
|
57
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
58
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
59
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
60
|
+
yargs.options({
|
|
61
|
+
name: {
|
|
62
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.migrateApp.options.name.describe`),
|
|
63
|
+
type: 'string',
|
|
64
|
+
},
|
|
65
|
+
dest: {
|
|
66
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.migrateApp.options.dest.describe`),
|
|
67
|
+
type: 'string',
|
|
68
|
+
},
|
|
69
|
+
'app-id': {
|
|
70
|
+
describe: (0, lang_1.i18n)(`commands.project.subcommands.migrateApp.options.appId.describe`),
|
|
71
|
+
type: 'number',
|
|
72
|
+
},
|
|
73
|
+
'platform-version': {
|
|
74
|
+
type: 'string',
|
|
75
|
+
choices: exports.validMigrationTargets,
|
|
76
|
+
hidden: true,
|
|
77
|
+
default: '2023.2',
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
yargs.example([
|
|
81
|
+
[
|
|
82
|
+
`$0 app migrate`,
|
|
83
|
+
(0, lang_1.i18n)(`commands.project.subcommands.migrateApp.examples.default`),
|
|
84
|
+
],
|
|
85
|
+
]);
|
|
86
|
+
return yargs;
|
|
87
|
+
}
|
|
88
|
+
const migrateCommand = {
|
|
89
|
+
command,
|
|
90
|
+
describe,
|
|
91
|
+
handler,
|
|
92
|
+
builder,
|
|
93
|
+
};
|
|
94
|
+
exports.default = migrateCommand;
|
package/commands/app.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.describe = exports.command = void 0;
|
|
7
|
+
exports.builder = builder;
|
|
8
|
+
const migrate_1 = __importDefault(require("./app/migrate"));
|
|
9
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
10
|
+
exports.command = ['app', 'apps'];
|
|
11
|
+
// Keep the command hidden for now
|
|
12
|
+
exports.describe = undefined;
|
|
13
|
+
function builder(yargs) {
|
|
14
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
15
|
+
return yargs.command(migrate_1.default).demandCommand(1, '');
|
|
16
|
+
}
|
|
17
|
+
const appCommand = {
|
|
18
|
+
command: exports.command,
|
|
19
|
+
describe: exports.describe,
|
|
20
|
+
builder,
|
|
21
|
+
handler: () => { },
|
|
22
|
+
};
|
|
23
|
+
exports.default = appCommand;
|
|
@@ -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
|
});
|