@hubspot/cli 7.2.2-experimental.0 → 7.2.3-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 +5 -52
- package/commands/account/list.js +0 -4
- package/commands/account.js +0 -4
- package/commands/app/migrate.d.ts +6 -0
- package/commands/app/migrate.js +80 -0
- package/commands/app.d.ts +4 -0
- package/commands/app.js +47 -0
- package/commands/auth.js +5 -9
- package/commands/config/set.d.ts +0 -12
- package/commands/config/set.js +29 -30
- package/commands/config.d.ts +1 -4
- package/commands/config.js +10 -45
- package/commands/create/api-sample.js +14 -4
- package/commands/customObject/create.d.ts +11 -0
- package/commands/customObject/create.js +37 -28
- package/commands/customObject/schema/create.d.ts +10 -0
- package/commands/customObject/schema/create.js +40 -42
- package/commands/customObject/schema/delete.d.ts +11 -0
- package/commands/customObject/schema/delete.js +34 -27
- package/commands/customObject/schema/fetch-all.d.ts +10 -0
- package/commands/customObject/schema/fetch-all.js +31 -24
- package/commands/customObject/schema/fetch.d.ts +11 -0
- package/commands/customObject/schema/fetch.js +34 -42
- package/commands/customObject/schema/list.d.ts +7 -0
- package/commands/customObject/schema/list.js +23 -14
- package/commands/customObject/schema/update.d.ts +11 -0
- package/commands/customObject/schema/update.js +44 -46
- package/commands/customObject/schema.d.ts +5 -1
- package/commands/customObject/schema.js +49 -11
- package/commands/customObject.d.ts +4 -1
- package/commands/customObject.js +54 -21
- package/commands/filemanager/fetch.d.ts +12 -0
- package/commands/filemanager/fetch.js +33 -30
- package/commands/filemanager/upload.d.ts +11 -0
- package/commands/filemanager/upload.js +53 -47
- package/commands/filemanager.d.ts +4 -1
- package/commands/filemanager.js +41 -7
- package/commands/init.js +26 -15
- package/commands/project/add.js +62 -16
- package/commands/project/cloneApp.d.ts +5 -1
- package/commands/project/cloneApp.js +80 -77
- package/commands/project/create.js +70 -15
- package/commands/project/dev.d.ts +7 -0
- package/commands/project/dev.js +96 -75
- package/commands/project/migrateApp.d.ts +6 -1
- package/commands/project/migrateApp.js +17 -184
- package/commands/sandbox/create.d.ts +12 -0
- package/commands/sandbox/create.js +90 -72
- package/commands/sandbox/delete.d.ts +11 -0
- package/commands/sandbox/delete.js +112 -95
- package/commands/sandbox.d.ts +4 -1
- package/commands/sandbox.js +44 -10
- package/commands/theme/generate-selectors.d.ts +9 -0
- package/commands/theme/generate-selectors.js +61 -43
- package/commands/theme/marketplace-validate.d.ts +10 -0
- package/commands/theme/marketplace-validate.js +32 -26
- package/commands/theme/preview.d.ts +16 -0
- package/commands/theme/preview.js +104 -97
- package/commands/theme.d.ts +4 -1
- package/commands/theme.js +44 -10
- package/lang/en.lyaml +62 -67
- package/lib/LocalDevManager.d.ts +2 -2
- package/lib/app/migrate.d.ts +6 -0
- package/lib/app/migrate.js +277 -0
- package/lib/buildAccount.d.ts +2 -3
- package/lib/constants.d.ts +0 -3
- package/lib/constants.js +1 -4
- package/lib/customObject.d.ts +3 -0
- package/lib/customObject.js +15 -0
- package/lib/doctor/Diagnosis.d.ts +0 -1
- package/lib/doctor/Diagnosis.js +0 -7
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +0 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +0 -1
- package/lib/doctor/Doctor.d.ts +0 -1
- package/lib/doctor/Doctor.js +0 -18
- package/lib/localDev.d.ts +2 -1
- package/lib/marketplaceValidate.d.ts +2 -2
- package/lib/projects/buildAndDeploy.js +4 -1
- package/lib/projects/create.d.ts +5 -0
- package/lib/projects/create.js +51 -0
- package/lib/projects/index.d.ts +1 -5
- package/lib/projects/index.js +1 -62
- package/lib/prompts/accountNamePrompt.d.ts +1 -1
- package/lib/prompts/createProjectPrompt.d.ts +6 -8
- package/lib/prompts/createProjectPrompt.js +26 -54
- package/lib/prompts/projectAddPrompt.d.ts +3 -3
- package/lib/prompts/projectAddPrompt.js +16 -6
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -2
- package/lib/prompts/promptUtils.d.ts +3 -3
- package/lib/prompts/sandboxesPrompt.d.ts +3 -2
- package/lib/prompts/sandboxesPrompt.js +1 -1
- package/lib/sandboxSync.js +6 -2
- package/lib/sandboxes.d.ts +2 -5
- package/lib/testUtils.d.ts +12 -0
- package/lib/testUtils.js +10 -0
- package/lib/ui/index.d.ts +3 -3
- package/lib/ui/index.js +8 -4
- package/lib/upload.d.ts +1 -1
- package/lib/upload.js +20 -20
- package/lib/usageTracking.d.ts +2 -1
- package/lib/validation.d.ts +1 -1
- package/package.json +4 -3
- package/types/Projects.d.ts +1 -6
- package/types/Prompts.d.ts +9 -2
- package/types/Sandboxes.d.ts +2 -0
- package/types/Yargs.d.ts +13 -0
- package/commands/account/auth.d.ts +0 -10
- package/commands/account/auth.js +0 -154
- package/commands/account/createOverride.d.ts +0 -10
- package/commands/account/createOverride.js +0 -62
- package/commands/config/migrate.d.ts +0 -10
- package/commands/config/migrate.js +0 -86
- package/lib/configMigrate.d.ts +0 -2
- package/lib/configMigrate.js +0 -83
package/bin/cli.js
CHANGED
|
@@ -6,7 +6,6 @@ const chalk = require('chalk');
|
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const { addUserAgentHeader } = require('@hubspot/local-dev-lib/http');
|
|
8
8
|
const { loadConfig, getAccountId, configFileExists, getConfigPath, validateConfig, } = require('@hubspot/local-dev-lib/config');
|
|
9
|
-
const { DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID, DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND, DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME, } = require('@hubspot/local-dev-lib/constants/config');
|
|
10
9
|
const { logError } = require('../lib/errorHandlers/index');
|
|
11
10
|
const { setLogLevel, getCommandName } = require('../lib/commonOpts');
|
|
12
11
|
const { validateAccount } = require('../lib/validation');
|
|
@@ -44,6 +43,7 @@ const cmsCommand = require('../commands/cms');
|
|
|
44
43
|
const feedbackCommand = require('../commands/feedback');
|
|
45
44
|
const doctorCommand = require('../commands/doctor');
|
|
46
45
|
const completionCommand = require('../commands/completion');
|
|
46
|
+
const appCommand = require('../commands/app');
|
|
47
47
|
const notifier = updateNotifier({
|
|
48
48
|
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
49
49
|
distTag: 'latest',
|
|
@@ -138,17 +138,9 @@ const isTargetedCommand = (options, commandMap) => {
|
|
|
138
138
|
};
|
|
139
139
|
return checkCommand(options, commandMap);
|
|
140
140
|
};
|
|
141
|
-
const skipConfigAccountsSubCommands = {
|
|
142
|
-
target: false,
|
|
143
|
-
subCommands: {
|
|
144
|
-
auth: { target: true },
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
141
|
const SKIP_CONFIG_VALIDATION = {
|
|
148
142
|
init: { target: true },
|
|
149
143
|
auth: { target: true },
|
|
150
|
-
accounts: skipConfigAccountsSubCommands,
|
|
151
|
-
account: skipConfigAccountsSubCommands,
|
|
152
144
|
};
|
|
153
145
|
const handleDeprecatedEnvVariables = options => {
|
|
154
146
|
// HUBSPOT_PORTAL_ID is deprecated, but we'll still support it for now
|
|
@@ -173,39 +165,9 @@ const injectAccountIdMiddleware = async (options) => {
|
|
|
173
165
|
options.derivedAccountId = parseInt(process.env.HUBSPOT_ACCOUNT_ID, 10);
|
|
174
166
|
}
|
|
175
167
|
else {
|
|
176
|
-
|
|
177
|
-
options.derivedAccountId = getAccountId(account);
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
logError(error);
|
|
181
|
-
if (error.cause === DEFAULT_ACCOUNT_OVERRIDE_ERROR_INVALID_ID) {
|
|
182
|
-
logger.log(i18n(`${i18nKey}.injectAccountIdMiddleware.invalidAccountId`, {
|
|
183
|
-
overrideCommand: uiCommandReference('hs account create-override'),
|
|
184
|
-
hsAccountFileName: DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
185
|
-
}));
|
|
186
|
-
}
|
|
187
|
-
if (error.cause === DEFAULT_ACCOUNT_OVERRIDE_ERROR_ACCOUNT_NOT_FOUND) {
|
|
188
|
-
logger.log(i18n(`${i18nKey}.injectAccountIdMiddleware.accountNotFound`, {
|
|
189
|
-
configPath: getConfigPath(),
|
|
190
|
-
authCommand: uiCommandReference('hs account auth'),
|
|
191
|
-
hsAccountFileName: DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
process.exit(EXIT_CODES.ERROR);
|
|
195
|
-
}
|
|
168
|
+
options.derivedAccountId = getAccountId(account);
|
|
196
169
|
}
|
|
197
170
|
};
|
|
198
|
-
const skipLoadConfigAccountSubCommands = {
|
|
199
|
-
target: false,
|
|
200
|
-
subCommands: { auth: { target: true } },
|
|
201
|
-
};
|
|
202
|
-
const SKIP_LOAD_CONFIG = {
|
|
203
|
-
account: skipLoadConfigAccountSubCommands,
|
|
204
|
-
accounts: skipLoadConfigAccountSubCommands,
|
|
205
|
-
};
|
|
206
|
-
const SKIP_CONFIG_FLAG_VALIDATION = {
|
|
207
|
-
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
208
|
-
};
|
|
209
171
|
const loadConfigMiddleware = async (options) => {
|
|
210
172
|
// Skip this when no command is provided
|
|
211
173
|
if (!options._.length) {
|
|
@@ -217,21 +179,13 @@ const loadConfigMiddleware = async (options) => {
|
|
|
217
179
|
process.exit(EXIT_CODES.ERROR);
|
|
218
180
|
}
|
|
219
181
|
};
|
|
220
|
-
if (configFileExists(true) &&
|
|
221
|
-
options.config &&
|
|
222
|
-
!isTargetedCommand(options, SKIP_CONFIG_FLAG_VALIDATION)) {
|
|
182
|
+
if (configFileExists(true) && options.config) {
|
|
223
183
|
logger.error(i18n(`${i18nKey}.loadConfigMiddleware.configFileExists`, {
|
|
224
184
|
configPath: getConfigPath(),
|
|
225
185
|
}));
|
|
226
186
|
process.exit(EXIT_CODES.ERROR);
|
|
227
187
|
}
|
|
228
|
-
|
|
229
|
-
// 1. `hs init`
|
|
230
|
-
// 2. `hs account auth` only if the global config file does not exist
|
|
231
|
-
if (!isTargetedCommand(options, {
|
|
232
|
-
init: { target: true },
|
|
233
|
-
}) &&
|
|
234
|
-
!(isTargetedCommand(options, SKIP_LOAD_CONFIG) && !configFileExists(true))) {
|
|
188
|
+
else if (!isTargetedCommand(options, { init: { target: true } })) {
|
|
235
189
|
const { config: configPath } = options;
|
|
236
190
|
const config = loadConfig(configPath, options);
|
|
237
191
|
// We don't run validateConfig() for auth because users should be able to run it when
|
|
@@ -252,7 +206,6 @@ const checkAndWarnGitInclusionMiddleware = options => {
|
|
|
252
206
|
const accountsSubCommands = {
|
|
253
207
|
target: false,
|
|
254
208
|
subCommands: {
|
|
255
|
-
auth: { target: true },
|
|
256
209
|
clean: { target: true },
|
|
257
210
|
list: { target: true },
|
|
258
211
|
ls: { target: true },
|
|
@@ -268,7 +221,6 @@ const sandboxesSubCommands = {
|
|
|
268
221
|
const SKIP_ACCOUNT_VALIDATION = {
|
|
269
222
|
init: { target: true },
|
|
270
223
|
auth: { target: true },
|
|
271
|
-
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
272
224
|
account: accountsSubCommands,
|
|
273
225
|
accounts: accountsSubCommands,
|
|
274
226
|
sandbox: sandboxesSubCommands,
|
|
@@ -344,6 +296,7 @@ const argv = yargs
|
|
|
344
296
|
.command(feedbackCommand)
|
|
345
297
|
.command(doctorCommand)
|
|
346
298
|
.command(completionCommand)
|
|
299
|
+
.command(appCommand)
|
|
347
300
|
.help()
|
|
348
301
|
.alias('h', 'help')
|
|
349
302
|
.recommendCommands()
|
package/commands/account/list.js
CHANGED
|
@@ -73,7 +73,6 @@ async function handler(args) {
|
|
|
73
73
|
const { derivedAccountId } = args;
|
|
74
74
|
(0, usageTracking_1.trackCommandUsage)('accounts-list', undefined, derivedAccountId);
|
|
75
75
|
const configPath = (0, config_1.getConfigPath)();
|
|
76
|
-
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
77
76
|
const accountsList = (0, config_1.getConfigAccounts)() || [];
|
|
78
77
|
const mappedAccountData = sortAndMapAccounts(accountsList);
|
|
79
78
|
const accountData = getAccountData(mappedAccountData);
|
|
@@ -83,9 +82,6 @@ async function handler(args) {
|
|
|
83
82
|
(0, lang_1.i18n)(`${i18nKey}.labels.authType`),
|
|
84
83
|
]));
|
|
85
84
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.configPath`, { configPath: configPath }));
|
|
86
|
-
if (overrideFilePath) {
|
|
87
|
-
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.overrideFilePath`, { overrideFilePath }));
|
|
88
|
-
}
|
|
89
85
|
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.defaultAccount`, {
|
|
90
86
|
account: (0, config_1.getConfigDefaultAccount)(),
|
|
91
87
|
}));
|
package/commands/account.js
CHANGED
|
@@ -37,28 +37,24 @@ exports.describe = exports.command = void 0;
|
|
|
37
37
|
exports.builder = builder;
|
|
38
38
|
const commonOpts_1 = require("../lib/commonOpts");
|
|
39
39
|
const lang_1 = require("../lib/lang");
|
|
40
|
-
const auth = __importStar(require("./account/auth"));
|
|
41
40
|
const list = __importStar(require("./account/list"));
|
|
42
41
|
const rename = __importStar(require("./account/rename"));
|
|
43
42
|
const use = __importStar(require("./account/use"));
|
|
44
43
|
const info = __importStar(require("./account/info"));
|
|
45
44
|
const remove = __importStar(require("./account/remove"));
|
|
46
45
|
const clean = __importStar(require("./account/clean"));
|
|
47
|
-
const createOverride = __importStar(require("./account/createOverride"));
|
|
48
46
|
const i18nKey = 'commands.account';
|
|
49
47
|
exports.command = ['account', 'accounts'];
|
|
50
48
|
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
51
49
|
function builder(yargs) {
|
|
52
50
|
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
53
51
|
yargs
|
|
54
|
-
.command(auth)
|
|
55
52
|
.command(list)
|
|
56
53
|
.command(rename)
|
|
57
54
|
.command(use)
|
|
58
55
|
.command(info)
|
|
59
56
|
.command(remove)
|
|
60
57
|
.command(clean)
|
|
61
|
-
.command(createOverride)
|
|
62
58
|
.demandCommand(1, '');
|
|
63
59
|
return yargs;
|
|
64
60
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
import { MigrateAppOptions } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "migrate";
|
|
4
|
+
export declare const describe: null;
|
|
5
|
+
export declare function handler(options: ArgumentsCamelCase<MigrateAppOptions>): Promise<void>;
|
|
6
|
+
export declare function builder(yargs: Argv): Promise<Argv<{}>>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describe = exports.command = 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 platformVersion_1 = require("@hubspot/local-dev-lib/constants/platformVersion");
|
|
14
|
+
const { v2023_2, v2025_2, unstable } = platformVersion_1.PLATFORM_VERSIONS;
|
|
15
|
+
const validMigrationTargets = [v2023_2, v2025_2, unstable];
|
|
16
|
+
const i18nKey = 'commands.project.subcommands.migrateApp';
|
|
17
|
+
exports.command = 'migrate';
|
|
18
|
+
exports.describe = null; // uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
19
|
+
async function handler(options) {
|
|
20
|
+
const { derivedAccountId, platformVersion } = options;
|
|
21
|
+
await (0, usageTracking_1.trackCommandUsage)('migrate-app', {}, derivedAccountId);
|
|
22
|
+
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
23
|
+
if (!accountConfig) {
|
|
24
|
+
throw new Error('Account is not configured');
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
if (platformVersion === v2025_2 || platformVersion === unstable) {
|
|
28
|
+
await (0, migrate_1.migrateApp2025_2)(derivedAccountId, options);
|
|
29
|
+
}
|
|
30
|
+
else if (platformVersion === v2023_2) {
|
|
31
|
+
await (0, migrate_1.migrateApp2023_2)(derivedAccountId, options, accountConfig);
|
|
32
|
+
}
|
|
33
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { status: 'SUCCESS' }, derivedAccountId);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error &&
|
|
37
|
+
typeof error === 'object' &&
|
|
38
|
+
'errors' in error &&
|
|
39
|
+
Array.isArray(error.errors)) {
|
|
40
|
+
error.errors.forEach(err => (0, errorHandlers_1.logError)(err));
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
(0, errorHandlers_1.logError)(error, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId }));
|
|
44
|
+
}
|
|
45
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { status: 'FAILURE' }, derivedAccountId);
|
|
46
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
47
|
+
}
|
|
48
|
+
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { status: 'SUCCESS' }, derivedAccountId);
|
|
49
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
50
|
+
}
|
|
51
|
+
async function builder(yargs) {
|
|
52
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
53
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
54
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
55
|
+
yargs.options({
|
|
56
|
+
name: {
|
|
57
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.name.describe`),
|
|
58
|
+
type: 'string',
|
|
59
|
+
},
|
|
60
|
+
dest: {
|
|
61
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.dest.describe`),
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
64
|
+
'app-id': {
|
|
65
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.appId.describe`),
|
|
66
|
+
type: 'number',
|
|
67
|
+
},
|
|
68
|
+
'platform-version': {
|
|
69
|
+
type: 'string',
|
|
70
|
+
choices: validMigrationTargets,
|
|
71
|
+
hidden: true,
|
|
72
|
+
default: '2023.2',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
// This is a hack so we can use the same function for both the app migrate and project migrate-app commands
|
|
76
|
+
// and have the examples be correct. If we don't can about that we can remove this.
|
|
77
|
+
const { _ } = await yargs.argv;
|
|
78
|
+
yargs.example([[`$0 ${_.join(' ')}`, (0, lang_1.i18n)(`${i18nKey}.examples.default`)]]);
|
|
79
|
+
return yargs;
|
|
80
|
+
}
|
package/commands/app.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.describe = exports.command = void 0;
|
|
37
|
+
exports.builder = builder;
|
|
38
|
+
const migrateCommand = __importStar(require("./app/migrate"));
|
|
39
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
40
|
+
exports.command = ['app', 'apps'];
|
|
41
|
+
exports.describe = null;
|
|
42
|
+
function builder(yargs) {
|
|
43
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
yargs.command(migrateCommand).demandCommand(1, '');
|
|
46
|
+
return yargs;
|
|
47
|
+
}
|
package/commands/auth.js
CHANGED
|
@@ -8,7 +8,7 @@ const { ENVIRONMENTS, } = require('@hubspot/local-dev-lib/constants/environments
|
|
|
8
8
|
const { DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME, } = require('@hubspot/local-dev-lib/constants/config');
|
|
9
9
|
const { i18n } = require('../lib/lang');
|
|
10
10
|
const { getAccessToken, updateConfigWithAccessToken, } = require('@hubspot/local-dev-lib/personalAccessKey');
|
|
11
|
-
const { updateAccountConfig, writeConfig, getConfigPath, loadConfig, getConfigDefaultAccount, getAccountId,
|
|
11
|
+
const { updateAccountConfig, writeConfig, getConfigPath, loadConfig, getConfigDefaultAccount, getAccountId, } = require('@hubspot/local-dev-lib/config');
|
|
12
12
|
const { commaSeparatedValues, toKebabCase, } = require('@hubspot/local-dev-lib/text');
|
|
13
13
|
const { promptUser } = require('../lib/prompts/promptUtils');
|
|
14
14
|
const { personalAccessKeyPrompt, OAUTH_FLOW, } = require('../lib/prompts/personalAccessKeyPrompt');
|
|
@@ -18,7 +18,7 @@ const { addConfigOptions, setLogLevel, addTestingOptions, addGlobalOptions, } =
|
|
|
18
18
|
const { trackAuthAction, trackCommandUsage } = require('../lib/usageTracking');
|
|
19
19
|
const { authenticateWithOauth } = require('../lib/oauth');
|
|
20
20
|
const { EXIT_CODES } = require('../lib/enums/exitCodes');
|
|
21
|
-
const { uiFeatureHighlight
|
|
21
|
+
const { uiFeatureHighlight } = require('../lib/ui');
|
|
22
22
|
const { logError } = require('../lib/errorHandlers/index');
|
|
23
23
|
const i18nKey = 'commands.auth';
|
|
24
24
|
const TRACKING_STATUS = {
|
|
@@ -43,13 +43,9 @@ exports.handler = async (options) => {
|
|
|
43
43
|
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
44
44
|
// Needed to load deprecated config
|
|
45
45
|
loadConfig(configFlagValue);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
logger.error(i18n(`${i18nKey}.errors.globalConfigFileExists`, {
|
|
50
|
-
configPath,
|
|
51
|
-
authCommand: uiCommandReference('hs account auth'),
|
|
52
|
-
}));
|
|
46
|
+
checkAndWarnGitInclusion(getConfigPath());
|
|
47
|
+
if (!getConfigPath(configFlagValue)) {
|
|
48
|
+
logger.error(i18n(`${i18nKey}.errors.noConfigFileFound`));
|
|
53
49
|
process.exit(EXIT_CODES.ERROR);
|
|
54
50
|
}
|
|
55
51
|
trackCommandUsage('auth');
|
package/commands/config/set.d.ts
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
import { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
-
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
-
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
4
|
-
export declare const command = "set";
|
|
5
|
-
export declare const describe: string;
|
|
6
|
-
type ConfigSetArgs = CommonArgs & {
|
|
7
|
-
defaultCmsPublishMode: CmsPublishMode;
|
|
8
|
-
allowUsageTracking?: boolean;
|
|
9
|
-
httpTimeout?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function handler(args: ArgumentsCamelCase<ConfigSetArgs>): Promise<void>;
|
|
12
|
-
export declare function builder(yargs: Argv): Argv<ConfigSetArgs>;
|
|
13
1
|
export {};
|
package/commands/config/set.js
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
10
|
-
const configOptions_1 = require("../../lib/configOptions");
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const { i18n } = require('../../lib/lang');
|
|
5
|
+
const { trackCommandUsage } = require('../../lib/usageTracking');
|
|
6
|
+
const { promptUser } = require('../../lib/prompts/promptUtils');
|
|
7
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
8
|
+
const { setDefaultCmsPublishMode, setHttpTimeout, setAllowUsageTracking, } = require('../../lib/configOptions');
|
|
11
9
|
const i18nKey = 'commands.config.subcommands.set';
|
|
12
10
|
exports.command = 'set';
|
|
13
|
-
exports.describe =
|
|
14
|
-
async
|
|
15
|
-
const { cmsPublishMode } = await
|
|
11
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
+
const selectOptions = async () => {
|
|
13
|
+
const { cmsPublishMode } = await promptUser([
|
|
16
14
|
{
|
|
17
15
|
type: 'list',
|
|
16
|
+
look: false,
|
|
18
17
|
name: 'cmsPublishMode',
|
|
19
18
|
pageSize: 20,
|
|
20
|
-
message:
|
|
19
|
+
message: i18n(`${i18nKey}.promptMessage`),
|
|
21
20
|
choices: [
|
|
22
21
|
{
|
|
23
22
|
name: 'Default CMS publish mode',
|
|
@@ -29,52 +28,52 @@ async function selectOptions() {
|
|
|
29
28
|
},
|
|
30
29
|
]);
|
|
31
30
|
return cmsPublishMode;
|
|
32
|
-
}
|
|
33
|
-
async
|
|
31
|
+
};
|
|
32
|
+
const handleConfigUpdate = async (accountId, options) => {
|
|
34
33
|
const { allowUsageTracking, defaultCmsPublishMode, httpTimeout } = options;
|
|
35
34
|
if (typeof defaultCmsPublishMode !== 'undefined') {
|
|
36
|
-
await
|
|
35
|
+
await setDefaultCmsPublishMode({ defaultCmsPublishMode, accountId });
|
|
37
36
|
return true;
|
|
38
37
|
}
|
|
39
38
|
else if (typeof httpTimeout !== 'undefined') {
|
|
40
|
-
await
|
|
39
|
+
await setHttpTimeout({ httpTimeout, accountId });
|
|
41
40
|
return true;
|
|
42
41
|
}
|
|
43
42
|
else if (typeof allowUsageTracking !== 'undefined') {
|
|
44
|
-
await
|
|
43
|
+
await setAllowUsageTracking({ allowUsageTracking, accountId });
|
|
45
44
|
return true;
|
|
46
45
|
}
|
|
47
46
|
return false;
|
|
48
|
-
}
|
|
49
|
-
async
|
|
50
|
-
const { derivedAccountId } =
|
|
51
|
-
|
|
52
|
-
const configUpdated = await handleConfigUpdate(derivedAccountId,
|
|
47
|
+
};
|
|
48
|
+
exports.handler = async (options) => {
|
|
49
|
+
const { derivedAccountId } = options;
|
|
50
|
+
trackCommandUsage('config-set', null, derivedAccountId);
|
|
51
|
+
const configUpdated = await handleConfigUpdate(derivedAccountId, options);
|
|
53
52
|
if (!configUpdated) {
|
|
54
53
|
const selectedOptions = await selectOptions();
|
|
55
54
|
await handleConfigUpdate(derivedAccountId, selectedOptions);
|
|
56
55
|
}
|
|
57
|
-
process.exit(
|
|
58
|
-
}
|
|
59
|
-
|
|
56
|
+
process.exit(EXIT_CODES.SUCCESS);
|
|
57
|
+
};
|
|
58
|
+
exports.builder = yargs => {
|
|
60
59
|
yargs
|
|
61
60
|
.options({
|
|
62
61
|
'default-cms-publish-mode': {
|
|
63
|
-
describe:
|
|
62
|
+
describe: i18n(`${i18nKey}.options.defaultMode.describe`),
|
|
64
63
|
type: 'string',
|
|
65
64
|
},
|
|
66
65
|
'allow-usage-tracking': {
|
|
67
|
-
describe:
|
|
66
|
+
describe: i18n(`${i18nKey}.options.allowUsageTracking.describe`),
|
|
68
67
|
type: 'boolean',
|
|
69
68
|
},
|
|
70
69
|
'http-timeout': {
|
|
71
|
-
describe:
|
|
70
|
+
describe: i18n(`${i18nKey}.options.httpTimeout.describe`),
|
|
72
71
|
type: 'string',
|
|
73
72
|
},
|
|
74
73
|
})
|
|
75
74
|
.conflicts('defaultCmsPublishMode', 'allowUsageTracking')
|
|
76
75
|
.conflicts('defaultCmsPublishMode', 'httpTimeout')
|
|
77
76
|
.conflicts('allowUsageTracking', 'httpTimeout')
|
|
78
|
-
.example([['$0 config set',
|
|
77
|
+
.example([['$0 config set', i18n(`${i18nKey}.examples.default`)]]);
|
|
79
78
|
return yargs;
|
|
80
|
-
}
|
|
79
|
+
};
|
package/commands/config.d.ts
CHANGED
package/commands/config.js
CHANGED
|
@@ -1,50 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const set = __importStar(require("./config/set"));
|
|
41
|
-
const migrate = __importStar(require("./config/migrate"));
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
const { addConfigOptions, addGlobalOptions } = require('../lib/commonOpts');
|
|
5
|
+
const { i18n } = require('../lib/lang');
|
|
6
|
+
const set = require('./config/set');
|
|
42
7
|
const i18nKey = 'commands.config';
|
|
43
8
|
exports.command = 'config';
|
|
44
|
-
exports.describe =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
yargs.command(set).
|
|
9
|
+
exports.describe = i18n(`${i18nKey}.describe`);
|
|
10
|
+
exports.builder = yargs => {
|
|
11
|
+
addConfigOptions(yargs);
|
|
12
|
+
addGlobalOptions(yargs);
|
|
13
|
+
yargs.command(set).demandCommand(1, '');
|
|
49
14
|
return yargs;
|
|
50
|
-
}
|
|
15
|
+
};
|
|
@@ -6,8 +6,11 @@ const { confirmPrompt } = require('../../lib/prompts/promptUtils');
|
|
|
6
6
|
const { logger } = require('@hubspot/local-dev-lib/logger');
|
|
7
7
|
const path = require('path');
|
|
8
8
|
const fs = require('fs-extra');
|
|
9
|
-
const {
|
|
9
|
+
const { fetchRepoFile } = require('@hubspot/local-dev-lib/api/github');
|
|
10
|
+
const { cloneGithubRepo } = require('@hubspot/local-dev-lib/github');
|
|
10
11
|
const { i18n } = require('../../lib/lang');
|
|
12
|
+
const { debugError } = require('../../lib/errorHandlers');
|
|
13
|
+
const { EXIT_CODES } = require('../../lib/enums/exitCodes');
|
|
11
14
|
const i18nKey = 'commands.create.subcommands.apiSample';
|
|
12
15
|
module.exports = {
|
|
13
16
|
hidden: true,
|
|
@@ -30,15 +33,22 @@ module.exports = {
|
|
|
30
33
|
return;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
33
|
-
|
|
36
|
+
let samplesConfig;
|
|
37
|
+
try {
|
|
38
|
+
const { data } = await fetchRepoFile('HubSpot/sample-apps-list', 'samples.json', 'main');
|
|
39
|
+
samplesConfig = data;
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
debugError(err);
|
|
43
|
+
}
|
|
34
44
|
if (!samplesConfig) {
|
|
35
45
|
logger.error(i18n(`${i18nKey}.errors.noSamples`));
|
|
36
|
-
|
|
46
|
+
process.exit(EXIT_CODES.ERROR);
|
|
37
47
|
}
|
|
38
48
|
const { sampleType, sampleLanguage } = await createApiSamplePrompt(samplesConfig);
|
|
39
49
|
if (!sampleType || !sampleLanguage) {
|
|
40
50
|
logger.error(i18n(`${i18nKey}.errors.noSamples`));
|
|
41
|
-
|
|
51
|
+
process.exit(EXIT_CODES.ERROR);
|
|
42
52
|
}
|
|
43
53
|
logger.info(i18n(`${i18nKey}.info.sampleChosen`, {
|
|
44
54
|
sampleType,
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "create [name]";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type CombinedArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs;
|
|
6
|
+
type CustomObjectCreateArgs = CombinedArgs & {
|
|
7
|
+
name?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function handler(args: ArgumentsCamelCase<CustomObjectCreateArgs>): Promise<void>;
|
|
11
|
+
export declare function builder(yargs: Argv): Argv<CustomObjectCreateArgs>;
|
|
1
12
|
export {};
|