@hubspot/cli 7.4.8-experimental.0 → 7.5.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 +6 -183
- package/commands/account/info.js +15 -4
- package/commands/account/list.js +3 -1
- package/commands/account/remove.js +8 -2
- package/commands/account/use.js +12 -3
- package/commands/cms/lighthouseScore.js +6 -2
- package/commands/config/set.js +6 -1
- package/commands/create/api-sample.js +3 -1
- package/commands/customObject/schema/delete.js +4 -1
- package/commands/customObject/schema/fetch-all.js +2 -1
- package/commands/customObject/schema/fetch.js +2 -1
- package/commands/project/upload.js +7 -1
- package/lang/en.js +0 -2
- package/lang/en.lyaml +0 -1
- package/lib/app/migrate.js +17 -13
- package/lib/middleware/__test__/configMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/configMiddleware.test.js +194 -0
- package/lib/middleware/__test__/gitMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/gitMiddleware.test.js +76 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/notificationsMiddleware.test.js +10 -0
- package/lib/middleware/__test__/requestMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/requestMiddleware.test.js +20 -0
- package/lib/middleware/__test__/utils.test.d.ts +1 -0
- package/lib/middleware/__test__/utils.test.js +53 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.d.ts +1 -0
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +81 -0
- package/lib/middleware/configMiddleware.d.ts +13 -0
- package/lib/middleware/configMiddleware.js +105 -0
- package/lib/middleware/gitMiddleware.d.ts +2 -0
- package/lib/middleware/gitMiddleware.js +14 -0
- package/lib/middleware/notificationsMiddleware.d.ts +1 -0
- package/lib/middleware/notificationsMiddleware.js +38 -0
- package/lib/middleware/requestMiddleware.d.ts +1 -0
- package/lib/middleware/requestMiddleware.js +11 -0
- package/lib/middleware/utils.d.ts +8 -0
- package/lib/middleware/utils.js +17 -0
- package/lib/middleware/yargsChecksMiddleware.d.ts +4 -0
- package/lib/middleware/yargsChecksMiddleware.js +24 -0
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +3 -3
- package/lib/ui/SpinniesManager.d.ts +1 -1
- package/lib/ui/spinniesUtils.d.ts +5 -5
- package/package.json +4 -4
package/bin/cli.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
const yargs = require('yargs');
|
|
4
|
-
const updateNotifier = require('update-notifier');
|
|
5
|
-
const chalk = require('chalk');
|
|
6
4
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
|
-
const { addUserAgentHeader } = require('@hubspot/local-dev-lib/http');
|
|
8
|
-
const { loadConfig, getAccountId, configFileExists, getConfigPath, validateConfig, } = require('@hubspot/local-dev-lib/config');
|
|
9
5
|
const { logError } = require('../lib/errorHandlers/index');
|
|
10
6
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
11
|
-
const { validateAccount } = require('../lib/validation');
|
|
12
7
|
const { trackHelpUsage, trackConvertFieldsUsage, } = require('../lib/usageTracking');
|
|
13
|
-
const { getIsInProject } = require('../lib/projects');
|
|
14
|
-
const pkg = require('../package.json');
|
|
15
|
-
const { i18n } = require('../lib/lang');
|
|
16
8
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
17
|
-
const {
|
|
18
|
-
const {
|
|
9
|
+
const { loadConfigMiddleware, injectAccountIdMiddleware, validateAccountOptions, handleDeprecatedEnvVariables, } = require('../lib/middleware/configMiddleware');
|
|
10
|
+
const { notifyAboutUpdates, } = require('../lib/middleware/notificationsMiddleware');
|
|
11
|
+
const { checkAndWarnGitInclusionMiddleware, } = require('../lib/middleware/gitMiddleware');
|
|
12
|
+
const { performChecks } = require('../lib/middleware/yargsChecksMiddleware');
|
|
13
|
+
const { setRequestHeaders } = require('../lib/middleware/requestMiddleware');
|
|
19
14
|
const removeCommand = require('../commands/remove');
|
|
20
15
|
const initCommand = require('../commands/init');
|
|
21
16
|
const logsCommand = require('../commands/logs');
|
|
@@ -44,33 +39,7 @@ const feedbackCommand = require('../commands/feedback');
|
|
|
44
39
|
const doctorCommand = require('../commands/doctor');
|
|
45
40
|
const completionCommand = require('../commands/completion');
|
|
46
41
|
const appCommand = require('../commands/app');
|
|
47
|
-
|
|
48
|
-
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
49
|
-
distTag: 'latest',
|
|
50
|
-
shouldNotifyInNpmScript: true,
|
|
51
|
-
});
|
|
52
|
-
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
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
|
-
});
|
|
42
|
+
notifyAboutUpdates();
|
|
74
43
|
const getTerminalWidth = () => {
|
|
75
44
|
const width = yargs.terminalWidth();
|
|
76
45
|
if (width >= 100)
|
|
@@ -92,152 +61,6 @@ const handleFailure = (msg, err, yargs) => {
|
|
|
92
61
|
process.exit(EXIT_CODES.ERROR);
|
|
93
62
|
}
|
|
94
63
|
};
|
|
95
|
-
const performChecks = argv => {
|
|
96
|
-
// "hs config set default-account" has moved to "hs accounts use"
|
|
97
|
-
if (argv._[0] === 'config' &&
|
|
98
|
-
argv._[1] === 'set' &&
|
|
99
|
-
argv._[2] === 'default-account') {
|
|
100
|
-
logger.error(i18n(`commands.generalErrors.setDefaultAccountMoved`));
|
|
101
|
-
process.exit(EXIT_CODES.ERROR);
|
|
102
|
-
}
|
|
103
|
-
// Require "project" command when running upload/watch inside of a project
|
|
104
|
-
if (argv._.length === 1 && ['upload', 'watch'].includes(argv._[0])) {
|
|
105
|
-
if (getIsInProject(argv.src)) {
|
|
106
|
-
logger.error(i18n(`commands.generalErrors.srcIsProject`, {
|
|
107
|
-
src: argv.src || './',
|
|
108
|
-
command: argv._.join(' '),
|
|
109
|
-
}));
|
|
110
|
-
process.exit(EXIT_CODES.ERROR);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const setRequestHeaders = () => {
|
|
121
|
-
addUserAgentHeader('HubSpot CLI', pkg.version);
|
|
122
|
-
};
|
|
123
|
-
const isTargetedCommand = (options, commandMap) => {
|
|
124
|
-
const checkCommand = (options, commandMap) => {
|
|
125
|
-
const currentCommand = options._[0];
|
|
126
|
-
if (!commandMap[currentCommand]) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
if (commandMap[currentCommand].target) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
const subCommands = commandMap[currentCommand].subCommands || {};
|
|
133
|
-
if (options._.length > 1) {
|
|
134
|
-
return checkCommand({ _: options._.slice(1) }, subCommands);
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
};
|
|
138
|
-
return checkCommand(options, commandMap);
|
|
139
|
-
};
|
|
140
|
-
const SKIP_CONFIG_VALIDATION = {
|
|
141
|
-
init: { target: true },
|
|
142
|
-
auth: { target: true },
|
|
143
|
-
};
|
|
144
|
-
const handleDeprecatedEnvVariables = options => {
|
|
145
|
-
// HUBSPOT_PORTAL_ID is deprecated, but we'll still support it for now
|
|
146
|
-
// The HubSpot GH Deploy Action still uses HUBSPOT_PORTAL_ID
|
|
147
|
-
if (options.useEnv &&
|
|
148
|
-
process.env.HUBSPOT_PORTAL_ID &&
|
|
149
|
-
!process.env.HUBSPOT_ACCOUNT_ID) {
|
|
150
|
-
uiDeprecatedTag(i18n(`commands.generalErrors.handleDeprecatedEnvVariables.portalEnvVarDeprecated`, {
|
|
151
|
-
configPath: getConfigPath(),
|
|
152
|
-
}));
|
|
153
|
-
process.env.HUBSPOT_ACCOUNT_ID = process.env.HUBSPOT_PORTAL_ID;
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Auto-injects the derivedAccountId flag into all commands
|
|
158
|
-
*/
|
|
159
|
-
const injectAccountIdMiddleware = async (options) => {
|
|
160
|
-
const { account } = options;
|
|
161
|
-
// Preserves the original --account flag for certain commands.
|
|
162
|
-
options.providedAccountId = account;
|
|
163
|
-
if (options.useEnv && process.env.HUBSPOT_ACCOUNT_ID) {
|
|
164
|
-
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
options.derivedAccountId = getAccountId(account);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
const loadConfigMiddleware = async (options) => {
|
|
171
|
-
// Skip this when no command is provided
|
|
172
|
-
if (!options._.length) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const maybeValidateConfig = () => {
|
|
176
|
-
if (!isTargetedCommand(options, SKIP_CONFIG_VALIDATION) &&
|
|
177
|
-
!validateConfig()) {
|
|
178
|
-
process.exit(EXIT_CODES.ERROR);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
if (configFileExists(true) && options.config) {
|
|
182
|
-
logger.error(i18n(`commands.generalErrors.loadConfigMiddleware.configFileExists`, {
|
|
183
|
-
configPath: getConfigPath(),
|
|
184
|
-
}));
|
|
185
|
-
process.exit(EXIT_CODES.ERROR);
|
|
186
|
-
}
|
|
187
|
-
else if (!isTargetedCommand(options, { init: { target: true } })) {
|
|
188
|
-
const { config: configPath } = options;
|
|
189
|
-
const config = loadConfig(configPath, options);
|
|
190
|
-
// We don't run validateConfig() for auth because users should be able to run it when
|
|
191
|
-
// no accounts are configured, but we still want to exit if the config file is not found
|
|
192
|
-
if (isTargetedCommand(options, { auth: { target: true } }) && !config) {
|
|
193
|
-
process.exit(EXIT_CODES.ERROR);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
maybeValidateConfig();
|
|
197
|
-
};
|
|
198
|
-
const checkAndWarnGitInclusionMiddleware = options => {
|
|
199
|
-
// Skip this when no command is provided
|
|
200
|
-
if (!options._.length) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
checkAndWarnGitInclusion(getConfigPath());
|
|
204
|
-
};
|
|
205
|
-
const accountsSubCommands = {
|
|
206
|
-
target: false,
|
|
207
|
-
subCommands: {
|
|
208
|
-
clean: { target: true },
|
|
209
|
-
list: { target: true },
|
|
210
|
-
ls: { target: true },
|
|
211
|
-
remove: { target: true },
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
const sandboxesSubCommands = {
|
|
215
|
-
target: false,
|
|
216
|
-
subCommands: {
|
|
217
|
-
delete: { target: true },
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
const SKIP_ACCOUNT_VALIDATION = {
|
|
221
|
-
init: { target: true },
|
|
222
|
-
auth: { target: true },
|
|
223
|
-
account: accountsSubCommands,
|
|
224
|
-
accounts: accountsSubCommands,
|
|
225
|
-
sandbox: sandboxesSubCommands,
|
|
226
|
-
sandboxes: sandboxesSubCommands,
|
|
227
|
-
};
|
|
228
|
-
const validateAccountOptions = async (options) => {
|
|
229
|
-
// Skip this when no command is provided
|
|
230
|
-
if (!options._.length) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
let validAccount = true;
|
|
234
|
-
if (!isTargetedCommand(options, SKIP_ACCOUNT_VALIDATION)) {
|
|
235
|
-
validAccount = await validateAccount(options);
|
|
236
|
-
}
|
|
237
|
-
if (!validAccount) {
|
|
238
|
-
process.exit(EXIT_CODES.ERROR);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
64
|
const argv = yargs
|
|
242
65
|
.usage('The command line interface to interact with HubSpot.')
|
|
243
66
|
// loadConfigMiddleware loads the new hidden config for all commands
|
package/commands/account/info.js
CHANGED
|
@@ -20,7 +20,9 @@ async function handler(args) {
|
|
|
20
20
|
const response = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env, derivedAccountId);
|
|
21
21
|
scopeGroups = response.scopeGroups.map(s => [s]);
|
|
22
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`, {
|
|
23
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.accountId`, {
|
|
24
|
+
accountId: derivedAccountId,
|
|
25
|
+
}));
|
|
24
26
|
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.scopeGroups`));
|
|
25
27
|
logger_1.logger.log((0, table_1.getTableContents)(scopeGroups, { border: { bodyLeft: ' ' } }));
|
|
26
28
|
}
|
|
@@ -34,9 +36,18 @@ function accountInfoBuilder(yargs) {
|
|
|
34
36
|
type: 'string',
|
|
35
37
|
});
|
|
36
38
|
yargs.example([
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
[
|
|
40
|
+
'$0 accounts info',
|
|
41
|
+
(0, lang_1.i18n)(`commands.account.subcommands.info.examples.default`),
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
'$0 accounts info MyAccount',
|
|
45
|
+
(0, lang_1.i18n)(`commands.account.subcommands.info.examples.nameBased`),
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
'$0 accounts info 1234567',
|
|
49
|
+
(0, lang_1.i18n)(`commands.account.subcommands.info.examples.idBased`),
|
|
50
|
+
],
|
|
40
51
|
]);
|
|
41
52
|
return yargs;
|
|
42
53
|
}
|
package/commands/account/list.js
CHANGED
|
@@ -80,7 +80,9 @@ async function handler(args) {
|
|
|
80
80
|
(0, lang_1.i18n)('commands.account.subcommands.list.labels.accountId'),
|
|
81
81
|
(0, lang_1.i18n)('commands.account.subcommands.list.labels.authType'),
|
|
82
82
|
]));
|
|
83
|
-
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.list.configPath', {
|
|
83
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.list.configPath', {
|
|
84
|
+
configPath: configPath,
|
|
85
|
+
}));
|
|
84
86
|
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.list.defaultAccount', {
|
|
85
87
|
account: (0, config_1.getConfigDefaultAccount)(),
|
|
86
88
|
}));
|
|
@@ -45,8 +45,14 @@ function builder(yargs) {
|
|
|
45
45
|
type: 'string',
|
|
46
46
|
});
|
|
47
47
|
yargs.example([
|
|
48
|
-
[
|
|
49
|
-
|
|
48
|
+
[
|
|
49
|
+
'$0 accounts remove',
|
|
50
|
+
(0, lang_1.i18n)(`commands.account.subcommands.remove.examples.default`),
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
'$0 accounts remove MyAccount',
|
|
54
|
+
(0, lang_1.i18n)(`commands.account.subcommands.remove.examples.byName`),
|
|
55
|
+
],
|
|
50
56
|
]);
|
|
51
57
|
return yargs;
|
|
52
58
|
}
|
package/commands/account/use.js
CHANGED
|
@@ -34,9 +34,18 @@ function builder(yargs) {
|
|
|
34
34
|
type: 'string',
|
|
35
35
|
});
|
|
36
36
|
yargs.example([
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
[
|
|
38
|
+
'$0 accounts use',
|
|
39
|
+
(0, lang_1.i18n)('commands.account.subcommands.use.examples.default'),
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
'$0 accounts use MyAccount',
|
|
43
|
+
(0, lang_1.i18n)('commands.account.subcommands.use.examples.nameBased'),
|
|
44
|
+
],
|
|
45
|
+
[
|
|
46
|
+
'$0 accounts use 1234567',
|
|
47
|
+
(0, lang_1.i18n)('commands.account.subcommands.use.examples.idBased'),
|
|
48
|
+
],
|
|
40
49
|
]);
|
|
41
50
|
return yargs;
|
|
42
51
|
}
|
|
@@ -67,7 +67,9 @@ exports.handler = async (options) => {
|
|
|
67
67
|
isValidTheme = false;
|
|
68
68
|
}
|
|
69
69
|
if (!isValidTheme) {
|
|
70
|
-
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.errors.themeNotFound`, {
|
|
70
|
+
logger.error(i18n(`commands.cms.subcommands.lighthouseScore.errors.themeNotFound`, {
|
|
71
|
+
theme: themeToCheck,
|
|
72
|
+
}));
|
|
71
73
|
process.exit(EXIT_CODES.ERROR);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
@@ -206,7 +208,9 @@ exports.handler = async (options) => {
|
|
|
206
208
|
});
|
|
207
209
|
}
|
|
208
210
|
logger.log();
|
|
209
|
-
logger.info(i18n(`commands.cms.subcommands.lighthouseScore.info.targetDeviceNote`, {
|
|
211
|
+
logger.info(i18n(`commands.cms.subcommands.lighthouseScore.info.targetDeviceNote`, {
|
|
212
|
+
target,
|
|
213
|
+
}));
|
|
210
214
|
}
|
|
211
215
|
else {
|
|
212
216
|
logger.log(`Theme: ${themeToCheck}`);
|
package/commands/config/set.js
CHANGED
|
@@ -73,6 +73,11 @@ exports.builder = yargs => {
|
|
|
73
73
|
.conflicts('defaultCmsPublishMode', 'allowUsageTracking')
|
|
74
74
|
.conflicts('defaultCmsPublishMode', 'httpTimeout')
|
|
75
75
|
.conflicts('allowUsageTracking', 'httpTimeout')
|
|
76
|
-
.example([
|
|
76
|
+
.example([
|
|
77
|
+
[
|
|
78
|
+
'$0 config set',
|
|
79
|
+
i18n(`commands.config.subcommands.set.examples.default`),
|
|
80
|
+
],
|
|
81
|
+
]);
|
|
77
82
|
return yargs;
|
|
78
83
|
};
|
|
@@ -24,7 +24,9 @@ module.exports = {
|
|
|
24
24
|
execute: async ({ dest, name, assetType, options }) => {
|
|
25
25
|
const filePath = path.join(dest, name);
|
|
26
26
|
if (fs.existsSync(filePath)) {
|
|
27
|
-
const overwrite = await confirmPrompt(i18n(`commands.create.subcommands.apiSample.folderOverwritePrompt`, {
|
|
27
|
+
const overwrite = await confirmPrompt(i18n(`commands.create.subcommands.apiSample.folderOverwritePrompt`, {
|
|
28
|
+
folderName: filePath,
|
|
29
|
+
}), { defaultAnswer: false });
|
|
28
30
|
if (overwrite) {
|
|
29
31
|
fs.rmdirSync(filePath, { recursive: true });
|
|
30
32
|
}
|
|
@@ -50,7 +50,10 @@ function builder(yargs) {
|
|
|
50
50
|
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
51
51
|
yargs
|
|
52
52
|
.example([
|
|
53
|
-
[
|
|
53
|
+
[
|
|
54
|
+
'$0 schema delete schemaName',
|
|
55
|
+
(0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.delete.examples.default`),
|
|
56
|
+
],
|
|
54
57
|
])
|
|
55
58
|
.positional('name', {
|
|
56
59
|
describe: (0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.delete.positionals.name.describe`),
|
|
@@ -17,7 +17,8 @@ async function handler(args) {
|
|
|
17
17
|
const { derivedAccountId, dest: providedDest } = args;
|
|
18
18
|
(0, usageTracking_1.trackCommandUsage)('custom-object-schema-fetch-all', {}, derivedAccountId);
|
|
19
19
|
try {
|
|
20
|
-
const dest = providedDest ||
|
|
20
|
+
const dest = providedDest ||
|
|
21
|
+
(await (0, promptUtils_1.inputPrompt)((0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.fetchAll.inputDest`)));
|
|
21
22
|
const schemas = await (0, customObjects_1.downloadSchemas)(derivedAccountId, dest);
|
|
22
23
|
(0, schema_1.logSchemas)(schemas);
|
|
23
24
|
logger_1.logger.success((0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.fetchAll.success.fetch`, {
|
|
@@ -25,7 +25,8 @@ async function handler(args) {
|
|
|
25
25
|
(await (0, promptUtils_1.listPrompt)((0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.fetch.selectSchema`), {
|
|
26
26
|
choices: schemaNames,
|
|
27
27
|
}));
|
|
28
|
-
const dest = providedDest ||
|
|
28
|
+
const dest = providedDest ||
|
|
29
|
+
(await (0, promptUtils_1.inputPrompt)((0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.fetch.inputDest`)));
|
|
29
30
|
await (0, customObjects_2.downloadSchema)(derivedAccountId, name, dest);
|
|
30
31
|
logger_1.logger.success((0, lang_1.i18n)(`commands.customObject.subcommands.schema.subcommands.fetch.success.savedToPath`, {
|
|
31
32
|
path: (0, customObjects_2.getResolvedPath)(dest, name),
|
|
@@ -31,7 +31,8 @@ exports.handler = async (options) => {
|
|
|
31
31
|
uploadCommand: true,
|
|
32
32
|
});
|
|
33
33
|
try {
|
|
34
|
-
|
|
34
|
+
console.log('options.env', options.env);
|
|
35
|
+
const { result, uploadError } = await handleProjectUpload(derivedAccountId, projectConfig, projectDir, pollProjectBuildAndDeploy, message, useV3Api(projectConfig?.platformVersion), skipValidation, options.env);
|
|
35
36
|
if (uploadError) {
|
|
36
37
|
if (isSpecifiedError(uploadError, {
|
|
37
38
|
subCategory: PROJECT_ERROR_TYPES.PROJECT_LOCKED,
|
|
@@ -86,6 +87,11 @@ exports.builder = yargs => {
|
|
|
86
87
|
hidden: true,
|
|
87
88
|
default: false,
|
|
88
89
|
},
|
|
90
|
+
env: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
describe: i18n(`${i18nKey}.options.env.describe`),
|
|
93
|
+
hidden: true,
|
|
94
|
+
},
|
|
89
95
|
});
|
|
90
96
|
yargs.example([['$0 project upload', i18n(`${i18nKey}.examples.default`)]]);
|
|
91
97
|
addConfigOptions(yargs);
|
package/lang/en.js
CHANGED
|
@@ -11,8 +11,6 @@ export const commands = {
|
|
|
11
11
|
},
|
|
12
12
|
srcIsProject: (src, command) =>
|
|
13
13
|
`"${src}" is in a project folder. Did you mean "hs project ${command}"?`,
|
|
14
|
-
setDefaultAccountMoved:
|
|
15
|
-
'This command has moved. Try `hs accounts use` instead',
|
|
16
14
|
handleDeprecatedEnvVariables: {
|
|
17
15
|
portalEnvVarDeprecated:
|
|
18
16
|
'The HUBSPOT_PORTAL_ID environment variable is deprecated. Please use HUBSPOT_ACCOUNT_ID instead.',
|
package/lang/en.lyaml
CHANGED
|
@@ -6,7 +6,6 @@ en:
|
|
|
6
6
|
cmsUpdateNotification: "{{#bold}}The CMS CLI is now the HubSpot CLI{{/bold}}\n\nTo upgrade, uninstall {{#bold}}{{ packageName }}{{/bold}}\nand then run {{ updateCommand }}"
|
|
7
7
|
cliUpdateNotification: "HubSpot CLI version {{#cyan}}{{#bold}}{currentVersion}{{/bold}}{{/cyan}} is outdated.\nRun {{ updateCommand }} to upgrade to version {{#cyan}}{{#bold}}{latestVersion}{{/bold}}{{/cyan}}"
|
|
8
8
|
srcIsProject: "\"{{ src }}\" is in a project folder. Did you mean \"hs project {{command}}\"?"
|
|
9
|
-
setDefaultAccountMoved: "This command has moved. Try `hs accounts use` instead"
|
|
10
9
|
handleDeprecatedEnvVariables:
|
|
11
10
|
portalEnvVarDeprecated: "The HUBSPOT_PORTAL_ID environment variable is deprecated. Please use HUBSPOT_ACCOUNT_ID instead."
|
|
12
11
|
loadConfigMiddleware:
|
package/lib/app/migrate.js
CHANGED
|
@@ -39,24 +39,28 @@ function getUnmigratableReason(reasonCode) {
|
|
|
39
39
|
}
|
|
40
40
|
async function handleMigrationSetup(derivedAccountId, options) {
|
|
41
41
|
const { name, dest, appId } = options;
|
|
42
|
-
const { data } = await (0, migrate_1.listAppsForMigration)(derivedAccountId);
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const { data: { migratableApps, unmigratableApps }, } = await (0, migrate_1.listAppsForMigration)(derivedAccountId);
|
|
43
|
+
const migratableAppsWithoutProject = migratableApps.filter((app) => !app.projectName);
|
|
44
|
+
const unmigratableAppsWithoutProject = unmigratableApps.filter((app) => !app.projectName);
|
|
45
|
+
const allAppsWithoutProject = [
|
|
46
|
+
...migratableAppsWithoutProject,
|
|
47
|
+
...unmigratableAppsWithoutProject,
|
|
48
|
+
];
|
|
49
|
+
if (allAppsWithoutProject.length === 0) {
|
|
50
|
+
const reasons = unmigratableAppsWithoutProject.map(app => `${chalk_1.default.bold(app.appName)}: ${getUnmigratableReason(app.unmigratableReason)}`);
|
|
47
51
|
throw new Error(`${(0, lang_1.i18n)(`commands.project.subcommands.migrateApp.errors.noAppsEligible`, {
|
|
48
|
-
accountId: derivedAccountId,
|
|
49
|
-
})}
|
|
52
|
+
accountId: (0, ui_1.uiAccountDescription)(derivedAccountId),
|
|
53
|
+
})}${reasons.length ? `\n - ${reasons.join('\n - ')}` : ''}`);
|
|
50
54
|
}
|
|
51
55
|
if (appId &&
|
|
52
|
-
!
|
|
56
|
+
!allAppsWithoutProject.some(app => {
|
|
53
57
|
return app.appId === appId;
|
|
54
58
|
})) {
|
|
55
59
|
throw new Error((0, lang_1.i18n)('commands.project.subcommands.migrateApp.prompt.chooseApp', {
|
|
56
60
|
appId,
|
|
57
61
|
}));
|
|
58
62
|
}
|
|
59
|
-
const appChoices =
|
|
63
|
+
const appChoices = allAppsWithoutProject.map(app => ({
|
|
60
64
|
name: app.isMigratable
|
|
61
65
|
? app.appName
|
|
62
66
|
: `[${chalk_1.default.yellow('DISABLED')}] ${app.appName} `,
|
|
@@ -72,7 +76,7 @@ async function handleMigrationSetup(derivedAccountId, options) {
|
|
|
72
76
|
});
|
|
73
77
|
appIdToMigrate = selectedAppId;
|
|
74
78
|
}
|
|
75
|
-
const selectedApp =
|
|
79
|
+
const selectedApp = allAppsWithoutProject.find(app => app.appId === appIdToMigrate);
|
|
76
80
|
const migratableComponents = [];
|
|
77
81
|
const unmigratableComponents = [];
|
|
78
82
|
selectedApp?.migrationComponents.forEach(component => {
|
|
@@ -133,8 +137,8 @@ async function beginMigration(derivedAccountId, appId, platformVersion) {
|
|
|
133
137
|
const { componentHint, componentType } = component;
|
|
134
138
|
uidMap[componentId] = await (0, promptUtils_1.inputPrompt)((0, lang_1.i18n)('commands.project.subcommands.migrateApp.prompt.uidForComponent', {
|
|
135
139
|
componentName: componentHint
|
|
136
|
-
? `${componentHint} [${componentType}]`
|
|
137
|
-
: componentType,
|
|
140
|
+
? `${componentHint} [${(0, transform_1.mapToUserFacingType)(componentType)}]`
|
|
141
|
+
: (0, transform_1.mapToUserFacingType)(componentType),
|
|
138
142
|
}), {
|
|
139
143
|
validate: (uid) => {
|
|
140
144
|
const result = (0, project_parsing_lib_1.validateUid)(uid);
|
|
@@ -199,7 +203,7 @@ async function downloadProjectFiles(derivedAccountId, projectName, buildId, proj
|
|
|
199
203
|
: (0, path_2.getCwd)();
|
|
200
204
|
await (0, archive_1.extractZipArchive)(zippedProject, (0, path_2.sanitizeFileName)(projectName), absoluteDestPath, {
|
|
201
205
|
includesRootDir: true,
|
|
202
|
-
hideLogs:
|
|
206
|
+
hideLogs: true,
|
|
203
207
|
});
|
|
204
208
|
SpinniesManager_1.default.succeed('fetchingMigratedProject', {
|
|
205
209
|
text: (0, lang_1.i18n)(`commands.project.subcommands.migrateApp.spinners.downloadingProjectContentsComplete`),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|