@hubspot/cli 7.4.5-experimental.0 → 7.4.6-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/api/migrate.d.ts +14 -4
- package/api/migrate.js +16 -2
- package/bin/cli.js +8 -183
- package/commands/account/auth.d.ts +10 -0
- package/commands/account/auth.js +188 -0
- package/commands/account/clean.js +38 -5
- package/commands/account/createOverride.d.ts +10 -0
- package/commands/account/createOverride.js +104 -0
- package/commands/account/info.js +38 -4
- package/commands/account/list.js +23 -5
- package/commands/account/remove.js +36 -2
- package/commands/account/removeOverride.d.ts +10 -0
- package/commands/account/removeOverride.js +76 -0
- package/commands/account/use.js +25 -3
- package/commands/account.js +7 -2
- package/commands/app/migrate.d.ts +5 -6
- package/commands/app/migrate.js +27 -14
- package/commands/app.js +0 -2
- package/commands/auth.js +14 -11
- package/commands/cms/lighthouseScore.js +6 -2
- package/commands/cms.js +1 -2
- package/commands/completion.js +2 -3
- package/commands/config/migrate.d.ts +10 -0
- package/commands/config/migrate.js +84 -0
- package/commands/config/set.d.ts +10 -0
- package/commands/config/set.js +34 -29
- package/commands/config.d.ts +4 -1
- package/commands/config.js +45 -11
- package/commands/create/api-sample.js +3 -1
- package/commands/create/website-theme.js +1 -1
- package/commands/create.js +7 -8
- 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/customObject.js +3 -4
- package/commands/doctor.js +5 -6
- package/commands/feedback.js +7 -8
- package/commands/fetch.js +6 -7
- package/commands/filemanager.js +1 -2
- package/commands/function.js +1 -2
- package/commands/hubdb/clear.js +5 -6
- package/commands/hubdb/create.js +7 -8
- package/commands/hubdb/delete.js +8 -7
- package/commands/hubdb/fetch.js +4 -5
- package/commands/hubdb.js +1 -2
- package/commands/init.js +18 -20
- package/commands/lint.js +3 -4
- package/commands/list.js +5 -6
- package/commands/logs.js +12 -13
- package/commands/module/marketplace-validate.js +5 -6
- package/commands/module.js +1 -3
- package/commands/mv.js +4 -5
- package/commands/open.js +4 -5
- package/commands/project/add.d.ts +3 -7
- package/commands/project/add.js +28 -23
- package/commands/project/cloneApp.d.ts +6 -8
- package/commands/project/cloneApp.js +49 -45
- package/commands/project/create.d.ts +10 -1
- package/commands/project/create.js +85 -63
- package/commands/project/deploy.d.ts +3 -6
- package/commands/project/deploy.js +27 -25
- package/commands/project/dev/deprecatedFlow.js +32 -25
- package/commands/project/dev/index.d.ts +4 -2
- package/commands/project/dev/index.js +31 -18
- package/commands/project/dev/unifiedFlow.js +10 -11
- package/commands/project/download.d.ts +3 -7
- package/commands/project/download.js +18 -19
- package/commands/project/installDeps.d.ts +6 -1
- package/commands/project/installDeps.js +48 -32
- package/commands/project/listBuilds.d.ts +3 -7
- package/commands/project/listBuilds.js +32 -27
- package/commands/project/logs.d.ts +10 -1
- package/commands/project/logs.js +73 -65
- package/commands/project/migrate.d.ts +6 -0
- package/commands/project/migrate.js +66 -0
- package/commands/project/migrateApp.d.ts +3 -8
- package/commands/project/migrateApp.js +22 -20
- package/commands/project/open.d.ts +3 -7
- package/commands/project/open.js +29 -21
- package/commands/project/upload.d.ts +9 -1
- package/commands/project/upload.js +70 -51
- package/commands/project/watch.d.ts +6 -1
- package/commands/project/watch.js +90 -61
- package/commands/project.d.ts +3 -1
- package/commands/project.js +47 -35
- package/commands/remove.js +7 -5
- package/commands/sandbox/create.js +10 -11
- package/commands/sandbox/delete.js +18 -19
- package/commands/sandbox.js +1 -2
- package/commands/secret/addSecret.js +5 -6
- package/commands/secret/deleteSecret.js +12 -9
- package/commands/secret/listSecret.js +3 -4
- package/commands/secret/updateSecret.js +9 -8
- package/commands/secret.js +1 -2
- package/commands/theme/generate-selectors.js +5 -6
- package/commands/theme/marketplace-validate.js +5 -6
- package/commands/theme/preview.js +16 -16
- package/commands/theme.js +1 -2
- package/commands/upload.js +23 -24
- package/commands/watch.js +18 -19
- package/lang/en.d.ts +2801 -0
- package/lang/en.js +2656 -3300
- package/lang/en.lyaml +101 -43
- package/lib/accountTypes.d.ts +1 -0
- package/lib/accountTypes.js +12 -0
- package/lib/app/migrate.d.ts +10 -4
- package/lib/app/migrate.js +207 -93
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/app/migrate_legacy.js +10 -7
- package/lib/buildAccount.d.ts +1 -2
- package/lib/buildAccount.js +7 -5
- package/lib/commonOpts.d.ts +3 -4
- package/lib/commonOpts.js +39 -10
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +104 -0
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +5 -1
- package/lib/dependencyManagement.js +2 -2
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +10 -6
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +2 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +10 -9
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +18 -0
- package/lib/hasFeature.d.ts +3 -1
- 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 +116 -0
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +137 -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/ProjectLogsManager.d.ts +1 -1
- package/lib/projects/ProjectLogsManager.js +15 -20
- package/lib/projects/buildAndDeploy.js +15 -26
- package/lib/projects/config.d.ts +9 -0
- package/lib/projects/config.js +79 -0
- package/lib/projects/create.js +4 -5
- package/lib/projects/ensureProjectExists.d.ts +11 -0
- package/lib/projects/ensureProjectExists.js +97 -0
- package/lib/{DevServerManager.d.ts → projects/localDev/DevServerManager.d.ts} +1 -1
- package/lib/{DevServerManager.js → projects/localDev/DevServerManager.js} +5 -6
- package/lib/{DevServerManagerV2.d.ts → projects/localDev/DevServerManagerV2.d.ts} +1 -1
- package/lib/{DevServerManagerV2.js → projects/localDev/DevServerManagerV2.js} +3 -4
- package/lib/{LocalDevManager.d.ts → projects/localDev/LocalDevManager.d.ts} +1 -1
- package/lib/{LocalDevManager.js → projects/localDev/LocalDevManager.js} +42 -76
- package/lib/{LocalDevManagerV2.d.ts → projects/localDev/LocalDevManagerV2.d.ts} +2 -2
- package/lib/{LocalDevManagerV2.js → projects/localDev/LocalDevManagerV2.js} +37 -70
- package/lib/{localDev.d.ts → projects/localDev/helpers.d.ts} +4 -3
- package/lib/{localDev.js → projects/localDev/helpers.js} +72 -99
- package/lib/projects/ui.d.ts +1 -0
- package/lib/projects/ui.js +15 -0
- package/lib/projects/upload.d.ts +2 -2
- package/lib/projects/upload.js +10 -31
- package/lib/projects/urls.d.ts +1 -0
- package/lib/projects/urls.js +6 -0
- package/lib/projects/watch.d.ts +1 -1
- package/lib/projects/watch.js +18 -15
- package/lib/prompts/createProjectPrompt.d.ts +11 -4
- package/lib/prompts/createProjectPrompt.js +6 -0
- package/lib/prompts/projectNamePrompt.js +2 -2
- package/lib/prompts/promptUtils.d.ts +1 -1
- package/lib/ui/SpinniesManager.d.ts +1 -1
- package/lib/ui/index.d.ts +4 -2
- package/lib/ui/index.js +6 -0
- package/lib/ui/spinniesUtils.d.ts +5 -5
- package/lib/yargsUtils.d.ts +1 -1
- package/package.json +7 -6
- package/types/Yargs.d.ts +5 -11
- package/lib/projects/index.d.ts +0 -20
- package/lib/projects/index.js +0 -199
|
@@ -0,0 +1,104 @@
|
|
|
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.command = exports.describe = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
12
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
13
|
+
const config_1 = require("@hubspot/local-dev-lib/constants/config");
|
|
14
|
+
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
15
|
+
const lang_1 = require("../../lib/lang");
|
|
16
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
17
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
18
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
19
|
+
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
20
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
21
|
+
exports.describe = (0, lang_1.i18n)('commands.account.subcommands.createOverride.describe', {
|
|
22
|
+
hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
23
|
+
});
|
|
24
|
+
exports.command = 'create-override [account]';
|
|
25
|
+
async function handler(args) {
|
|
26
|
+
let overrideDefaultAccount = args.account;
|
|
27
|
+
const accountOverride = (0, config_2.getCWDAccountOverride)();
|
|
28
|
+
const overrideFilePath = (0, config_2.getDefaultAccountOverrideFilePath)();
|
|
29
|
+
if (accountOverride && overrideFilePath) {
|
|
30
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.createOverride.accountOverride', {
|
|
31
|
+
accountOverride,
|
|
32
|
+
overrideFilePath,
|
|
33
|
+
}));
|
|
34
|
+
const { replaceOverrideFile } = await (0, promptUtils_1.promptUser)({
|
|
35
|
+
type: 'confirm',
|
|
36
|
+
name: 'replaceOverrideFile',
|
|
37
|
+
message: (0, lang_1.i18n)('commands.account.subcommands.createOverride.prompts.replaceOverrideFile'),
|
|
38
|
+
});
|
|
39
|
+
logger_1.logger.log('');
|
|
40
|
+
if (!replaceOverrideFile) {
|
|
41
|
+
const accountId = (0, config_2.getAccountId)(accountOverride) || undefined;
|
|
42
|
+
(0, usageTracking_1.trackCommandMetadataUsage)('account-createOverride', {
|
|
43
|
+
command: 'hs account create-override',
|
|
44
|
+
step: 'Reject overwriting an override via prompt',
|
|
45
|
+
}, accountId);
|
|
46
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!overrideDefaultAccount) {
|
|
50
|
+
overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
51
|
+
}
|
|
52
|
+
else if (!(0, config_2.getAccountId)(overrideDefaultAccount)) {
|
|
53
|
+
logger_1.logger.error((0, lang_1.i18n)('commands.account.subcommands.createOverride.errors.accountNotFound', {
|
|
54
|
+
configPath: (0, config_2.getConfigPath)() || '',
|
|
55
|
+
}));
|
|
56
|
+
overrideDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
57
|
+
}
|
|
58
|
+
const accountId = (0, config_2.getAccountId)(overrideDefaultAccount);
|
|
59
|
+
try {
|
|
60
|
+
const overrideFilePath = path_1.default.join((0, path_2.getCwd)(), config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME);
|
|
61
|
+
await fs_extra_1.default.writeFile(overrideFilePath, accountId.toString(), 'utf8');
|
|
62
|
+
logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.createOverride.success', {
|
|
63
|
+
overrideFilePath,
|
|
64
|
+
}));
|
|
65
|
+
const trackingId = accountId || undefined;
|
|
66
|
+
(0, usageTracking_1.trackCommandMetadataUsage)('config-migrate', {
|
|
67
|
+
command: 'hs config migrate',
|
|
68
|
+
step: 'Confirm overwriting an override via prompt',
|
|
69
|
+
successful: true,
|
|
70
|
+
}, trackingId);
|
|
71
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
(0, index_1.logError)(e);
|
|
75
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function builder(yargs) {
|
|
79
|
+
yargs.positional('account', {
|
|
80
|
+
describe: (0, lang_1.i18n)('commands.account.subcommands.createOverride.options.account.describe'),
|
|
81
|
+
type: 'string',
|
|
82
|
+
});
|
|
83
|
+
yargs.example([
|
|
84
|
+
[
|
|
85
|
+
'$0 account create-override',
|
|
86
|
+
(0, lang_1.i18n)('commands.account.subcommands.createOverride.examples.default', {
|
|
87
|
+
hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
88
|
+
}),
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
'$0 account create-override 12345678',
|
|
92
|
+
(0, lang_1.i18n)('commands.account.subcommands.createOverride.examples.idBased', {
|
|
93
|
+
hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
94
|
+
}),
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
'$0 account create-override MyAccount',
|
|
98
|
+
(0, lang_1.i18n)('commands.account.subcommands.createOverride.examples.nameBased', {
|
|
99
|
+
hsAccountFileName: config_1.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
100
|
+
}),
|
|
101
|
+
],
|
|
102
|
+
]);
|
|
103
|
+
return yargs;
|
|
104
|
+
}
|
package/commands/account/info.js
CHANGED
|
@@ -7,6 +7,7 @@ const config_1 = require("@hubspot/local-dev-lib/config");
|
|
|
7
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
|
+
const index_1 = require("../../lib/ui/index");
|
|
10
11
|
const table_1 = require("../../lib/ui/table");
|
|
11
12
|
exports.describe = (0, lang_1.i18n)(`commands.account.subcommands.info.describe`);
|
|
12
13
|
exports.command = 'info [account]';
|
|
@@ -19,8 +20,32 @@ async function handler(args) {
|
|
|
19
20
|
let scopeGroups = [];
|
|
20
21
|
const response = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env, derivedAccountId);
|
|
21
22
|
scopeGroups = response.scopeGroups.map(s => [s]);
|
|
23
|
+
// If a default account is present in the config, display it
|
|
24
|
+
const configPath = (0, config_1.getConfigPath)();
|
|
25
|
+
if (configPath) {
|
|
26
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.defaultAccountTitle`));
|
|
27
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.info.configPath`, {
|
|
28
|
+
configPath,
|
|
29
|
+
})}`);
|
|
30
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.info.defaultAccount`, {
|
|
31
|
+
account: (0, config_1.getDisplayDefaultAccount)(),
|
|
32
|
+
})}`);
|
|
33
|
+
}
|
|
34
|
+
// If a default account override is present, display it
|
|
35
|
+
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
36
|
+
if (overrideFilePath) {
|
|
37
|
+
logger_1.logger.log('');
|
|
38
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.overrideFilePathTitle`));
|
|
39
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.info.overrideFilePath`, { overrideFilePath })}`);
|
|
40
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.info.overrideAccount`, {
|
|
41
|
+
account: (0, config_1.getConfigDefaultAccount)(),
|
|
42
|
+
})}`);
|
|
43
|
+
}
|
|
44
|
+
logger_1.logger.log('');
|
|
22
45
|
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`, {
|
|
46
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.accountId`, {
|
|
47
|
+
accountId: derivedAccountId,
|
|
48
|
+
}));
|
|
24
49
|
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.scopeGroups`));
|
|
25
50
|
logger_1.logger.log((0, table_1.getTableContents)(scopeGroups, { border: { bodyLeft: ' ' } }));
|
|
26
51
|
}
|
|
@@ -34,9 +59,18 @@ function accountInfoBuilder(yargs) {
|
|
|
34
59
|
type: 'string',
|
|
35
60
|
});
|
|
36
61
|
yargs.example([
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
62
|
+
[
|
|
63
|
+
'$0 accounts info',
|
|
64
|
+
(0, lang_1.i18n)(`commands.account.subcommands.info.examples.default`),
|
|
65
|
+
],
|
|
66
|
+
[
|
|
67
|
+
'$0 accounts info MyAccount',
|
|
68
|
+
(0, lang_1.i18n)(`commands.account.subcommands.info.examples.nameBased`),
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
'$0 accounts info 1234567',
|
|
72
|
+
(0, lang_1.i18n)(`commands.account.subcommands.info.examples.idBased`),
|
|
73
|
+
],
|
|
40
74
|
]);
|
|
41
75
|
return yargs;
|
|
42
76
|
}
|
package/commands/account/list.js
CHANGED
|
@@ -7,6 +7,7 @@ const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
|
7
7
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
8
|
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
9
9
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
|
+
const index_1 = require("../../lib/ui/index");
|
|
10
11
|
const table_1 = require("../../lib/ui/table");
|
|
11
12
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
12
13
|
const accountTypes_1 = require("../../lib/accountTypes");
|
|
@@ -80,11 +81,28 @@ async function handler(args) {
|
|
|
80
81
|
(0, lang_1.i18n)('commands.account.subcommands.list.labels.accountId'),
|
|
81
82
|
(0, lang_1.i18n)('commands.account.subcommands.list.labels.authType'),
|
|
82
83
|
]));
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
// If a default account is present in the config, display it
|
|
85
|
+
if (configPath) {
|
|
86
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.list.defaultAccountTitle`));
|
|
87
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.list.configPath`, {
|
|
88
|
+
configPath,
|
|
89
|
+
})}`);
|
|
90
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.list.defaultAccount`, {
|
|
91
|
+
account: (0, config_1.getDisplayDefaultAccount)(),
|
|
92
|
+
})}`);
|
|
93
|
+
logger_1.logger.log('');
|
|
94
|
+
}
|
|
95
|
+
// If a default account override is present, display it
|
|
96
|
+
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
97
|
+
if (overrideFilePath) {
|
|
98
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.list.overrideFilePathTitle`));
|
|
99
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.list.overrideFilePath`, { overrideFilePath })}`);
|
|
100
|
+
logger_1.logger.log(`${(0, index_1.indent)(1)}${(0, lang_1.i18n)(`commands.account.subcommands.list.overrideAccount`, {
|
|
101
|
+
account: (0, config_1.getConfigDefaultAccount)(),
|
|
102
|
+
})}`);
|
|
103
|
+
logger_1.logger.log('');
|
|
104
|
+
}
|
|
105
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.list.accounts`));
|
|
88
106
|
logger_1.logger.log((0, table_1.getTableContents)(accountData, { border: { bodyLeft: ' ' } }));
|
|
89
107
|
}
|
|
90
108
|
function builder(yargs) {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.describe = exports.command = void 0;
|
|
4
7
|
exports.handler = handler;
|
|
5
8
|
exports.builder = builder;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
6
10
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
11
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
12
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
9
13
|
const lang_1 = require("../../lib/lang");
|
|
14
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
15
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
10
16
|
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
11
17
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
12
18
|
exports.command = 'remove [account]';
|
|
@@ -25,6 +31,28 @@ async function handler(args) {
|
|
|
25
31
|
}
|
|
26
32
|
(0, usageTracking_1.trackCommandUsage)('accounts-remove', undefined, (0, config_1.getAccountId)(accountToRemove));
|
|
27
33
|
const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
34
|
+
const accountOverride = (0, config_1.getCWDAccountOverride)();
|
|
35
|
+
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
36
|
+
if (overrideFilePath &&
|
|
37
|
+
accountOverride &&
|
|
38
|
+
accountOverride === accountToRemove) {
|
|
39
|
+
const { deleteOverrideFile } = await (0, promptUtils_1.promptUser)({
|
|
40
|
+
type: 'confirm',
|
|
41
|
+
name: 'deleteOverrideFile',
|
|
42
|
+
message: (0, lang_1.i18n)(`commands.account.subcommands.remove.prompts.deleteOverrideFile`, {
|
|
43
|
+
overrideFilePath,
|
|
44
|
+
accountName: accountToRemove,
|
|
45
|
+
}),
|
|
46
|
+
});
|
|
47
|
+
try {
|
|
48
|
+
if (deleteOverrideFile) {
|
|
49
|
+
fs_1.default.unlinkSync(overrideFilePath);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
(0, errorHandlers_1.logError)(error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
28
56
|
await (0, config_1.deleteAccount)(accountToRemove);
|
|
29
57
|
logger_1.logger.success((0, lang_1.i18n)(`commands.account.subcommands.remove.success.accountRemoved`, {
|
|
30
58
|
accountName: accountToRemove,
|
|
@@ -45,8 +73,14 @@ function builder(yargs) {
|
|
|
45
73
|
type: 'string',
|
|
46
74
|
});
|
|
47
75
|
yargs.example([
|
|
48
|
-
[
|
|
49
|
-
|
|
76
|
+
[
|
|
77
|
+
'$0 accounts remove',
|
|
78
|
+
(0, lang_1.i18n)(`commands.account.subcommands.remove.examples.default`),
|
|
79
|
+
],
|
|
80
|
+
[
|
|
81
|
+
'$0 accounts remove MyAccount',
|
|
82
|
+
(0, lang_1.i18n)(`commands.account.subcommands.remove.examples.byName`),
|
|
83
|
+
],
|
|
50
84
|
]);
|
|
51
85
|
return yargs;
|
|
52
86
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const describe: string;
|
|
4
|
+
export declare const command = "remove-override";
|
|
5
|
+
type RemoveOverrideArgs = CommonArgs & {
|
|
6
|
+
force?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<RemoveOverrideArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<RemoveOverrideArgs>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
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.command = exports.describe = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
10
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
11
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
12
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
13
|
+
const lang_1 = require("../../lib/lang");
|
|
14
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
15
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
16
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
17
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
18
|
+
exports.describe = (0, lang_1.i18n)('commands.account.subcommands.removeOverride.describe', {
|
|
19
|
+
overrideFile: config_2.DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
20
|
+
});
|
|
21
|
+
exports.command = 'remove-override';
|
|
22
|
+
async function handler(args) {
|
|
23
|
+
const { force } = args;
|
|
24
|
+
const accountOverride = (0, config_1.getCWDAccountOverride)();
|
|
25
|
+
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
26
|
+
if (accountOverride && overrideFilePath) {
|
|
27
|
+
const accountId = (0, config_1.getAccountId)(accountOverride) || undefined;
|
|
28
|
+
if (!force) {
|
|
29
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.removeOverride.accountOverride', {
|
|
30
|
+
accountOverride,
|
|
31
|
+
overrideFilePath,
|
|
32
|
+
}));
|
|
33
|
+
const { deleteOverrideFile } = await (0, promptUtils_1.promptUser)({
|
|
34
|
+
type: 'confirm',
|
|
35
|
+
name: 'deleteOverrideFile',
|
|
36
|
+
message: (0, lang_1.i18n)('commands.account.subcommands.removeOverride.prompts.deleteOverrideFile', {
|
|
37
|
+
accountOverride,
|
|
38
|
+
overrideFilePath,
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
logger_1.logger.log('');
|
|
42
|
+
if (!deleteOverrideFile) {
|
|
43
|
+
(0, usageTracking_1.trackCommandMetadataUsage)('account-removeOverride', {
|
|
44
|
+
command: 'hs account remove-override',
|
|
45
|
+
step: 'Reject removing override via prompt',
|
|
46
|
+
}, accountId);
|
|
47
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
fs_extra_1.default.unlinkSync(overrideFilePath);
|
|
52
|
+
logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.removeOverride.success'));
|
|
53
|
+
(0, usageTracking_1.trackCommandMetadataUsage)('account-removeOverride', {
|
|
54
|
+
command: 'hs account remove-override',
|
|
55
|
+
step: 'Confirm removing override file (via prompt/force)',
|
|
56
|
+
successful: true,
|
|
57
|
+
}, accountId);
|
|
58
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
(0, index_1.logError)(error);
|
|
62
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
logger_1.logger.log((0, lang_1.i18n)('commands.account.subcommands.removeOverride.noOverrideFile'));
|
|
67
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function builder(yargs) {
|
|
71
|
+
yargs.options('force', {
|
|
72
|
+
describe: (0, lang_1.i18n)('commands.account.subcommands.removeOverride.options.force.describe'),
|
|
73
|
+
type: 'boolean',
|
|
74
|
+
});
|
|
75
|
+
return yargs;
|
|
76
|
+
}
|
package/commands/account/use.js
CHANGED
|
@@ -8,6 +8,7 @@ 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 ui_1 = require("../../lib/ui");
|
|
11
12
|
exports.command = 'use [account]';
|
|
12
13
|
exports.describe = (0, lang_1.i18n)('commands.account.subcommands.use.describe');
|
|
13
14
|
async function handler(args) {
|
|
@@ -23,6 +24,18 @@ async function handler(args) {
|
|
|
23
24
|
newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
24
25
|
}
|
|
25
26
|
(0, usageTracking_1.trackCommandUsage)('accounts-use', undefined, (0, config_1.getAccountId)(newDefaultAccount));
|
|
27
|
+
const accountOverride = (0, config_1.getCWDAccountOverride)();
|
|
28
|
+
const overrideFilePath = (0, config_1.getDefaultAccountOverrideFilePath)();
|
|
29
|
+
if (accountOverride && overrideFilePath) {
|
|
30
|
+
logger_1.logger.warn((0, lang_1.i18n)(`commands.account.subcommands.use.accountOverride`, {
|
|
31
|
+
accountOverride,
|
|
32
|
+
}));
|
|
33
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.use.accountOverrideCommands`, {
|
|
34
|
+
createOverrideCommand: (0, ui_1.uiCommandReference)('hs account create-override'),
|
|
35
|
+
removeOverrideCommand: (0, ui_1.uiCommandReference)('hs account remove-override'),
|
|
36
|
+
}));
|
|
37
|
+
logger_1.logger.log('');
|
|
38
|
+
}
|
|
26
39
|
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
27
40
|
return logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.use.success.defaultAccountUpdated', {
|
|
28
41
|
accountName: newDefaultAccount,
|
|
@@ -34,9 +47,18 @@ function builder(yargs) {
|
|
|
34
47
|
type: 'string',
|
|
35
48
|
});
|
|
36
49
|
yargs.example([
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
[
|
|
51
|
+
'$0 accounts use',
|
|
52
|
+
(0, lang_1.i18n)('commands.account.subcommands.use.examples.default'),
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
'$0 accounts use MyAccount',
|
|
56
|
+
(0, lang_1.i18n)('commands.account.subcommands.use.examples.nameBased'),
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
'$0 accounts use 1234567',
|
|
60
|
+
(0, lang_1.i18n)('commands.account.subcommands.use.examples.idBased'),
|
|
61
|
+
],
|
|
40
62
|
]);
|
|
41
63
|
return yargs;
|
|
42
64
|
}
|
package/commands/account.js
CHANGED
|
@@ -37,24 +37,29 @@ 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"));
|
|
40
41
|
const list = __importStar(require("./account/list"));
|
|
41
42
|
const rename = __importStar(require("./account/rename"));
|
|
42
43
|
const use = __importStar(require("./account/use"));
|
|
43
44
|
const info = __importStar(require("./account/info"));
|
|
44
45
|
const remove = __importStar(require("./account/remove"));
|
|
45
46
|
const clean = __importStar(require("./account/clean"));
|
|
46
|
-
const
|
|
47
|
+
const createOverride = __importStar(require("./account/createOverride"));
|
|
48
|
+
const removeOverride = __importStar(require("./account/removeOverride"));
|
|
47
49
|
exports.command = ['account', 'accounts'];
|
|
48
|
-
exports.describe = (0, lang_1.i18n)(
|
|
50
|
+
exports.describe = (0, lang_1.i18n)('commands.account.describe');
|
|
49
51
|
function builder(yargs) {
|
|
50
52
|
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
51
53
|
yargs
|
|
54
|
+
.command(auth)
|
|
52
55
|
.command(list)
|
|
53
56
|
.command(rename)
|
|
54
57
|
.command(use)
|
|
55
58
|
.command(info)
|
|
56
59
|
.command(remove)
|
|
57
60
|
.command(clean)
|
|
61
|
+
.command(createOverride)
|
|
62
|
+
.command(removeOverride)
|
|
58
63
|
.demandCommand(1, '');
|
|
59
64
|
return yargs;
|
|
60
65
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ArgumentsCamelCase
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function handler(options: ArgumentsCamelCase<
|
|
5
|
-
|
|
6
|
-
declare const migrateCommand: CommandModule<unknown, MigrateAppOptions>;
|
|
1
|
+
import { ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { YargsCommandModule } from '../../types/Yargs';
|
|
3
|
+
import { MigrateAppArgs } from '../../lib/app/migrate';
|
|
4
|
+
export declare function handler(options: ArgumentsCamelCase<MigrateAppArgs>): Promise<never>;
|
|
5
|
+
declare const migrateCommand: YargsCommandModule<unknown, MigrateAppArgs>;
|
|
7
6
|
export default migrateCommand;
|
package/commands/app/migrate.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validMigrationTargets = void 0;
|
|
4
3
|
exports.handler = handler;
|
|
5
|
-
exports.builder = builder;
|
|
6
4
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
5
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
6
|
const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
9
|
-
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
7
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
11
8
|
const lang_1 = require("../../lib/lang");
|
|
12
9
|
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
@@ -14,12 +11,13 @@ const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
|
14
11
|
const migrate_1 = require("../../lib/app/migrate");
|
|
15
12
|
const ui_1 = require("../../lib/ui");
|
|
16
13
|
const migrate_legacy_1 = require("../../lib/app/migrate_legacy");
|
|
17
|
-
const
|
|
18
|
-
|
|
14
|
+
const config_2 = require("../../lib/projects/config");
|
|
15
|
+
const yargsUtils_1 = require("../../lib/yargsUtils");
|
|
16
|
+
const { v2023_2, v2025_2 } = projects_1.PLATFORM_VERSIONS;
|
|
19
17
|
const command = 'migrate';
|
|
20
18
|
const describe = undefined; // uiBetaTag(i18n(`commands.project.subcommands.migrateApp.header.text.describe`), false);
|
|
21
19
|
async function handler(options) {
|
|
22
|
-
const { derivedAccountId, platformVersion } = options;
|
|
20
|
+
const { derivedAccountId, platformVersion, unstable } = options;
|
|
23
21
|
await (0, usageTracking_1.trackCommandUsage)('migrate-app', {}, derivedAccountId);
|
|
24
22
|
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
25
23
|
if (!accountConfig) {
|
|
@@ -31,7 +29,14 @@ async function handler(options) {
|
|
|
31
29
|
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'));
|
|
32
30
|
logger_1.logger.log('');
|
|
33
31
|
try {
|
|
34
|
-
if (platformVersion === v2025_2 ||
|
|
32
|
+
if (platformVersion === v2025_2 || unstable) {
|
|
33
|
+
if ((0, config_2.getIsInProject)()) {
|
|
34
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.errors.notAllowedWithinProject`, { command: (0, ui_1.uiCommandReference)('hs project migrate') }));
|
|
35
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
36
|
+
}
|
|
37
|
+
options.platformVersion = unstable
|
|
38
|
+
? projects_1.PLATFORM_VERSIONS.unstable
|
|
39
|
+
: platformVersion;
|
|
35
40
|
await (0, migrate_1.migrateApp2025_2)(derivedAccountId, options);
|
|
36
41
|
}
|
|
37
42
|
else {
|
|
@@ -49,15 +54,12 @@ async function handler(options) {
|
|
|
49
54
|
(0, errorHandlers_1.logError)(error, new errorHandlers_1.ApiErrorContext({ accountId: derivedAccountId }));
|
|
50
55
|
}
|
|
51
56
|
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { successful: false }, derivedAccountId);
|
|
52
|
-
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
57
|
+
return process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
58
|
}
|
|
54
59
|
await (0, usageTracking_1.trackCommandMetadataUsage)('migrate-app', { successful: true }, derivedAccountId);
|
|
55
60
|
return process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
56
61
|
}
|
|
57
|
-
function
|
|
58
|
-
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
59
|
-
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
60
|
-
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
62
|
+
function appMigrateBuilder(yargs) {
|
|
61
63
|
yargs.options({
|
|
62
64
|
name: {
|
|
63
65
|
describe: (0, lang_1.i18n)(`commands.project.subcommands.migrateApp.options.name.describe`),
|
|
@@ -73,9 +75,14 @@ function builder(yargs) {
|
|
|
73
75
|
},
|
|
74
76
|
'platform-version': {
|
|
75
77
|
type: 'string',
|
|
76
|
-
choices:
|
|
78
|
+
choices: [v2023_2, v2025_2],
|
|
79
|
+
hidden: true,
|
|
80
|
+
default: v2025_2,
|
|
81
|
+
},
|
|
82
|
+
unstable: {
|
|
83
|
+
type: 'boolean',
|
|
84
|
+
default: false,
|
|
77
85
|
hidden: true,
|
|
78
|
-
default: '2023.2',
|
|
79
86
|
},
|
|
80
87
|
});
|
|
81
88
|
yargs.example([
|
|
@@ -86,6 +93,12 @@ function builder(yargs) {
|
|
|
86
93
|
]);
|
|
87
94
|
return yargs;
|
|
88
95
|
}
|
|
96
|
+
const builder = (0, yargsUtils_1.makeYargsBuilder)(appMigrateBuilder, command, (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`commands.project.subcommands.migrateApp.describe`), false), {
|
|
97
|
+
useGlobalOptions: true,
|
|
98
|
+
useConfigOptions: true,
|
|
99
|
+
useAccountOptions: true,
|
|
100
|
+
useEnvironmentOptions: true,
|
|
101
|
+
});
|
|
89
102
|
const migrateCommand = {
|
|
90
103
|
command,
|
|
91
104
|
describe,
|
package/commands/app.js
CHANGED
|
@@ -6,12 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.describe = exports.command = void 0;
|
|
7
7
|
exports.builder = builder;
|
|
8
8
|
const migrate_1 = __importDefault(require("./app/migrate"));
|
|
9
|
-
const commonOpts_1 = require("../lib/commonOpts");
|
|
10
9
|
exports.command = ['app', 'apps'];
|
|
11
10
|
// Keep the command hidden for now
|
|
12
11
|
exports.describe = undefined;
|
|
13
12
|
function builder(yargs) {
|
|
14
|
-
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
15
13
|
return yargs.command(migrate_1.default).demandCommand(1, '');
|
|
16
14
|
}
|
|
17
15
|
const appCommand = {
|
package/commands/auth.js
CHANGED
|
@@ -22,7 +22,6 @@ const oauth_1 = require("../lib/oauth");
|
|
|
22
22
|
const exitCodes_1 = require("../lib/enums/exitCodes");
|
|
23
23
|
const ui_1 = require("../lib/ui");
|
|
24
24
|
const index_1 = require("../lib/errorHandlers/index");
|
|
25
|
-
const i18nKey = 'commands.auth';
|
|
26
25
|
const TRACKING_STATUS = {
|
|
27
26
|
STARTED: 'started',
|
|
28
27
|
ERROR: 'error',
|
|
@@ -34,7 +33,7 @@ const ALLOWED_AUTH_METHODS = [
|
|
|
34
33
|
];
|
|
35
34
|
const SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT = (0, text_1.commaSeparatedValues)(ALLOWED_AUTH_METHODS);
|
|
36
35
|
exports.command = 'auth';
|
|
37
|
-
exports.describe = (0, lang_1.i18n)(
|
|
36
|
+
exports.describe = (0, lang_1.i18n)('commands.auth.describe');
|
|
38
37
|
async function handler(args) {
|
|
39
38
|
const { authType: authTypeFlagValue, config: configFlagValue, qa, providedAccountId, } = args;
|
|
40
39
|
const authType = (authTypeFlagValue && authTypeFlagValue.toLowerCase()) ||
|
|
@@ -47,8 +46,12 @@ async function handler(args) {
|
|
|
47
46
|
if (configPath) {
|
|
48
47
|
(0, git_1.checkAndWarnGitInclusion)(configPath);
|
|
49
48
|
}
|
|
50
|
-
if (
|
|
51
|
-
|
|
49
|
+
if ((0, config_2.configFileExists)(true)) {
|
|
50
|
+
const globalConfigPath = (0, config_2.getConfigPath)('', true);
|
|
51
|
+
logger_1.logger.error((0, lang_1.i18n)(`commands.auth.errors.globalConfigFileExists`, {
|
|
52
|
+
configPath: globalConfigPath,
|
|
53
|
+
authCommand: (0, ui_1.uiCommandReference)('hs account auth'),
|
|
54
|
+
}));
|
|
52
55
|
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
53
56
|
}
|
|
54
57
|
(0, usageTracking_1.trackCommandUsage)('auth');
|
|
@@ -99,7 +102,7 @@ async function handler(args) {
|
|
|
99
102
|
successAuthMethod = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.name;
|
|
100
103
|
break;
|
|
101
104
|
default:
|
|
102
|
-
logger_1.logger.error((0, lang_1.i18n)(
|
|
105
|
+
logger_1.logger.error((0, lang_1.i18n)('commands.auth.errors.unsupportedAuthType', {
|
|
103
106
|
supportedProtocols: SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT,
|
|
104
107
|
type: authType,
|
|
105
108
|
}));
|
|
@@ -114,16 +117,16 @@ async function handler(args) {
|
|
|
114
117
|
const setAsDefault = await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(accountName);
|
|
115
118
|
logger_1.logger.log('');
|
|
116
119
|
if (setAsDefault) {
|
|
117
|
-
logger_1.logger.success((0, lang_1.i18n)(
|
|
120
|
+
logger_1.logger.success((0, lang_1.i18n)('lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount', {
|
|
118
121
|
accountName,
|
|
119
122
|
}));
|
|
120
123
|
}
|
|
121
124
|
else {
|
|
122
|
-
logger_1.logger.info((0, lang_1.i18n)(
|
|
125
|
+
logger_1.logger.info((0, lang_1.i18n)('lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault', {
|
|
123
126
|
accountName: (0, config_2.getConfigDefaultAccount)(),
|
|
124
127
|
}));
|
|
125
128
|
}
|
|
126
|
-
logger_1.logger.success((0, lang_1.i18n)(
|
|
129
|
+
logger_1.logger.success((0, lang_1.i18n)('commands.auth.success.configFileUpdated', {
|
|
127
130
|
configFilename: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
128
131
|
authType: successAuthMethod,
|
|
129
132
|
accountName,
|
|
@@ -140,7 +143,7 @@ async function handler(args) {
|
|
|
140
143
|
function authBuilder(yargs) {
|
|
141
144
|
yargs.options({
|
|
142
145
|
'auth-type': {
|
|
143
|
-
describe: (0, lang_1.i18n)(
|
|
146
|
+
describe: (0, lang_1.i18n)('commands.auth.options.authType.describe'),
|
|
144
147
|
type: 'string',
|
|
145
148
|
choices: [
|
|
146
149
|
`${auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value}`,
|
|
@@ -149,14 +152,14 @@ function authBuilder(yargs) {
|
|
|
149
152
|
default: auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
150
153
|
},
|
|
151
154
|
account: {
|
|
152
|
-
describe: (0, lang_1.i18n)(
|
|
155
|
+
describe: (0, lang_1.i18n)('commands.auth.options.account.describe'),
|
|
153
156
|
type: 'string',
|
|
154
157
|
alias: 'a',
|
|
155
158
|
},
|
|
156
159
|
});
|
|
157
160
|
return yargs;
|
|
158
161
|
}
|
|
159
|
-
exports.builder = (0, yargsUtils_1.makeYargsBuilder)(authBuilder, exports.command, (0, lang_1.i18n)(
|
|
162
|
+
exports.builder = (0, yargsUtils_1.makeYargsBuilder)(authBuilder, exports.command, (0, lang_1.i18n)('commands.auth.verboseDescribe', {
|
|
160
163
|
authMethod: auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value,
|
|
161
164
|
configName: config_1.DEFAULT_HUBSPOT_CONFIG_YAML_FILE_NAME,
|
|
162
165
|
}), {
|