@hubspot/cli 7.1.0-beta.0 → 7.1.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/commands/account/clean.d.ts +9 -0
- package/commands/account/clean.js +51 -45
- package/commands/account/list.d.ts +7 -0
- package/commands/account/list.js +69 -60
- package/commands/account/remove.d.ts +9 -0
- package/commands/account/remove.js +33 -31
- package/commands/account/rename.d.ts +10 -0
- package/commands/account/rename.js +36 -23
- package/commands/account/use.d.ts +9 -0
- package/commands/account/use.js +26 -24
- package/commands/account.d.ts +4 -1
- package/commands/account.js +47 -13
- 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/hubdb/clear.d.ts +11 -0
- package/commands/hubdb/clear.js +33 -30
- package/commands/hubdb/create.d.ts +10 -0
- package/commands/hubdb/create.js +46 -40
- package/commands/hubdb/delete.d.ts +10 -0
- package/commands/hubdb/delete.js +38 -35
- package/commands/hubdb/fetch.d.ts +11 -0
- package/commands/hubdb/fetch.js +30 -27
- package/commands/hubdb.d.ts +4 -1
- package/commands/hubdb.js +45 -11
- package/commands/init.js +2 -1
- package/commands/project/add.js +62 -16
- package/commands/project/cloneApp.js +3 -3
- package/commands/project/create.js +70 -15
- package/commands/project/dev/deprecatedFlow.d.ts +5 -0
- package/commands/project/dev/deprecatedFlow.js +137 -0
- package/commands/project/dev/index.d.ts +6 -0
- package/commands/project/dev/index.js +52 -0
- package/commands/project/dev/unifiedFlow.d.ts +5 -0
- package/commands/project/dev/unifiedFlow.js +110 -0
- package/commands/project/migrateApp.js +3 -3
- package/commands/project/upload.js +7 -2
- 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/secret/addSecret.d.ts +10 -0
- package/commands/secret/addSecret.js +32 -31
- package/commands/secret/deleteSecret.d.ts +11 -0
- package/commands/secret/deleteSecret.js +31 -29
- package/commands/secret/listSecret.d.ts +9 -0
- package/commands/secret/listSecret.js +41 -0
- package/commands/secret/updateSecret.d.ts +10 -0
- package/commands/secret/updateSecret.js +33 -31
- package/commands/secret.d.ts +4 -1
- package/commands/secret.js +46 -12
- 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 +36 -16
- package/lib/DevServerManagerV2.d.ts +34 -0
- package/lib/DevServerManagerV2.js +85 -0
- package/lib/LocalDevManager.d.ts +2 -2
- package/lib/LocalDevManagerV2.d.ts +64 -0
- package/lib/LocalDevManagerV2.js +382 -0
- package/lib/buildAccount.d.ts +2 -3
- package/lib/constants.d.ts +12 -3
- package/lib/constants.js +13 -4
- package/lib/customObject.d.ts +3 -0
- package/lib/customObject.js +15 -0
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +6 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +5 -0
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +10 -0
- package/lib/localDev.d.ts +2 -1
- package/lib/marketplaceValidate.d.ts +2 -2
- package/lib/process.d.ts +1 -0
- package/lib/process.js +11 -10
- 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/projects/structure.d.ts +4 -0
- package/lib/projects/structure.js +9 -0
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +2 -2
- 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/sandboxesPrompt.d.ts +3 -2
- package/lib/prompts/sandboxesPrompt.js +1 -1
- package/lib/sandboxSync.js +6 -2
- package/lib/sandboxes.d.ts +3 -5
- package/lib/sandboxes.js +1 -0
- package/lib/testUtils.d.ts +12 -0
- package/lib/testUtils.js +10 -0
- package/lib/ui/index.d.ts +2 -2
- package/lib/ui/index.js +1 -0
- package/lib/upload.d.ts +1 -1
- package/lib/upload.js +20 -20
- package/lib/validation.d.ts +1 -1
- package/package.json +6 -5
- package/types/ProjectComponents.d.ts +38 -0
- package/types/ProjectComponents.js +3 -0
- package/types/Projects.d.ts +1 -6
- package/types/Prompts.d.ts +7 -0
- package/types/Sandboxes.d.ts +2 -0
- package/types/Yargs.d.ts +15 -0
- package/commands/project/dev.d.ts +0 -1
- package/commands/project/dev.js +0 -146
- package/commands/secret/listSecrets.d.ts +0 -1
- package/commands/secret/listSecrets.js +0 -39
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "clean";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type AccountCleanArgs = CommonArgs & ConfigArgs & {
|
|
6
|
+
qa?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<AccountCleanArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<AccountCleanArgs>;
|
|
1
10
|
export {};
|
|
@@ -1,49 +1,55 @@
|
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
6
|
+
exports.describe = exports.command = void 0;
|
|
7
|
+
exports.handler = handler;
|
|
8
|
+
exports.builder = builder;
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
11
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
12
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
13
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
14
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
15
|
+
const lang_1 = require("../../lib/lang");
|
|
16
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
17
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
18
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
19
|
+
const table_1 = require("../../lib/ui/table");
|
|
20
|
+
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
21
|
+
const ui_1 = require("../../lib/ui");
|
|
17
22
|
const i18nKey = 'commands.account.subcommands.clean';
|
|
18
23
|
exports.command = 'clean';
|
|
19
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
20
|
-
|
|
21
|
-
const { qa } =
|
|
22
|
-
trackCommandUsage('accounts-clean'
|
|
23
|
-
const accountsList = getConfigAccounts();
|
|
24
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
25
|
+
async function handler(args) {
|
|
26
|
+
const { qa } = args;
|
|
27
|
+
(0, usageTracking_1.trackCommandUsage)('accounts-clean');
|
|
28
|
+
const accountsList = (0, config_1.getConfigAccounts)() || [];
|
|
24
29
|
const filteredTestAccounts = accountsList.filter(p => qa ? p.env === 'qa' : p.env !== 'qa');
|
|
25
30
|
if (filteredTestAccounts && filteredTestAccounts.length === 0) {
|
|
26
|
-
logger.log(i18n(`${i18nKey}.noResults`));
|
|
27
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
31
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.noResults`));
|
|
32
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
28
33
|
}
|
|
29
34
|
const accountsToRemove = [];
|
|
30
|
-
|
|
35
|
+
SpinniesManager_1.default.init({
|
|
31
36
|
succeedColor: 'white',
|
|
32
37
|
});
|
|
33
|
-
|
|
34
|
-
text: i18n(`${i18nKey}.loading.add`),
|
|
38
|
+
SpinniesManager_1.default.add('accountsClean', {
|
|
39
|
+
text: (0, lang_1.i18n)(`${i18nKey}.loading.add`),
|
|
35
40
|
});
|
|
36
41
|
for (const account of filteredTestAccounts) {
|
|
37
42
|
try {
|
|
38
|
-
|
|
43
|
+
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(account);
|
|
44
|
+
await (0, personalAccessKey_1.accessTokenForPersonalAccessKey)(accountId, true);
|
|
39
45
|
}
|
|
40
46
|
catch (error) {
|
|
41
|
-
if (isSpecifiedError(error, {
|
|
47
|
+
if ((0, index_1.isSpecifiedError)(error, {
|
|
42
48
|
statusCode: 401,
|
|
43
49
|
category: 'INVALID_AUTHENTICATION',
|
|
44
50
|
subCategory: 'LocalDevAuthErrorType.PORTAL_NOT_ACTIVE',
|
|
45
51
|
}) ||
|
|
46
|
-
isSpecifiedError(error, {
|
|
52
|
+
(0, index_1.isSpecifiedError)(error, {
|
|
47
53
|
statusCode: 404,
|
|
48
54
|
category: 'INVALID_AUTHENTICATION',
|
|
49
55
|
subCategory: 'LocalDevAuthErrorType.INVALID_PORTAL_ID',
|
|
@@ -54,21 +60,21 @@ exports.handler = async (options) => {
|
|
|
54
60
|
}
|
|
55
61
|
if (accountsToRemove.length > 0) {
|
|
56
62
|
const oneAccountFound = accountsToRemove.length === 1;
|
|
57
|
-
|
|
58
|
-
text: i18n(oneAccountFound
|
|
63
|
+
SpinniesManager_1.default.succeed('accountsClean', {
|
|
64
|
+
text: (0, lang_1.i18n)(oneAccountFound
|
|
59
65
|
? `${i18nKey}.inactiveAccountsFound.one`
|
|
60
66
|
: `${i18nKey}.inactiveAccountsFound.other`, {
|
|
61
67
|
count: accountsToRemove.length,
|
|
62
68
|
}),
|
|
63
69
|
});
|
|
64
|
-
logger.log(getTableContents(accountsToRemove.map(p => [
|
|
65
|
-
uiAccountDescription(getAccountIdentifier(p)),
|
|
70
|
+
logger_1.logger.log((0, table_1.getTableContents)(accountsToRemove.map(p => [
|
|
71
|
+
(0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(p)),
|
|
66
72
|
]), { border: { bodyLeft: ' ' } }));
|
|
67
|
-
const { accountsCleanPrompt } = await promptUser([
|
|
73
|
+
const { accountsCleanPrompt } = await (0, promptUtils_1.promptUser)([
|
|
68
74
|
{
|
|
69
75
|
name: 'accountsCleanPrompt',
|
|
70
76
|
type: 'confirm',
|
|
71
|
-
message: i18n(oneAccountFound
|
|
77
|
+
message: (0, lang_1.i18n)(oneAccountFound
|
|
72
78
|
? `${i18nKey}.confirm.one`
|
|
73
79
|
: `${i18nKey}.confirm.other`, {
|
|
74
80
|
count: accountsToRemove.length,
|
|
@@ -76,26 +82,26 @@ exports.handler = async (options) => {
|
|
|
76
82
|
},
|
|
77
83
|
]);
|
|
78
84
|
if (accountsCleanPrompt) {
|
|
79
|
-
logger.log('');
|
|
85
|
+
logger_1.logger.log('');
|
|
80
86
|
for (const accountToRemove of accountsToRemove) {
|
|
81
|
-
await deleteAccount(accountToRemove.name);
|
|
82
|
-
logger.log(i18n(`${i18nKey}.removeSuccess`, {
|
|
87
|
+
await (0, config_1.deleteAccount)(accountToRemove.name);
|
|
88
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.removeSuccess`, {
|
|
83
89
|
accountName: accountToRemove.name,
|
|
84
90
|
}));
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
}
|
|
88
94
|
else {
|
|
89
|
-
|
|
90
|
-
text: i18n(`${i18nKey}.noResults`),
|
|
95
|
+
SpinniesManager_1.default.succeed('accountsClean', {
|
|
96
|
+
text: (0, lang_1.i18n)(`${i18nKey}.noResults`),
|
|
91
97
|
});
|
|
92
98
|
}
|
|
93
|
-
logger.log('');
|
|
94
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
addConfigOptions(yargs);
|
|
98
|
-
addTestingOptions(yargs);
|
|
99
|
+
logger_1.logger.log('');
|
|
100
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
101
|
+
}
|
|
102
|
+
function builder(yargs) {
|
|
103
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
104
|
+
(0, commonOpts_1.addTestingOptions)(yargs);
|
|
99
105
|
yargs.example([['$0 accounts clean']]);
|
|
100
106
|
return yargs;
|
|
101
|
-
}
|
|
107
|
+
}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command: string[];
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type AccountListArgs = CommonArgs & ConfigArgs;
|
|
6
|
+
export declare function handler(args: ArgumentsCamelCase<AccountListArgs>): Promise<void>;
|
|
7
|
+
export declare function builder(yargs: Argv): Argv<AccountListArgs>;
|
|
1
8
|
export {};
|
package/commands/account/list.js
CHANGED
|
@@ -1,86 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
9
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
|
+
const table_1 = require("../../lib/ui/table");
|
|
11
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
12
|
+
const accountTypes_1 = require("../../lib/accountTypes");
|
|
13
|
+
const lang_1 = require("../../lib/lang");
|
|
14
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
13
15
|
const i18nKey = 'commands.account.subcommands.list';
|
|
14
16
|
exports.command = ['list', 'ls'];
|
|
15
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
// Standard and app developer
|
|
19
|
-
|
|
17
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
18
|
+
function sortAndMapAccounts(accounts) {
|
|
19
|
+
const mappedAccountData = {};
|
|
20
|
+
// Standard and app developer accounts
|
|
21
|
+
accounts
|
|
20
22
|
.filter(p => p.accountType &&
|
|
21
|
-
(p.accountType === HUBSPOT_ACCOUNT_TYPES.STANDARD ||
|
|
22
|
-
p.accountType === HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER))
|
|
23
|
-
.forEach(
|
|
24
|
-
|
|
23
|
+
(p.accountType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD ||
|
|
24
|
+
p.accountType === config_2.HUBSPOT_ACCOUNT_TYPES.APP_DEVELOPER))
|
|
25
|
+
.forEach(account => {
|
|
26
|
+
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(account);
|
|
27
|
+
if (accountId) {
|
|
28
|
+
mappedAccountData[accountId] = [account];
|
|
29
|
+
}
|
|
25
30
|
});
|
|
26
|
-
// Non-standard
|
|
27
|
-
|
|
28
|
-
.filter(p => p.accountType && (isSandbox(p) || isDeveloperTestAccount(p)))
|
|
31
|
+
// Non-standard accounts (sandbox, developer test account)
|
|
32
|
+
accounts
|
|
33
|
+
.filter(p => p.accountType && ((0, accountTypes_1.isSandbox)(p) || (0, accountTypes_1.isDeveloperTestAccount)(p)))
|
|
29
34
|
.forEach(p => {
|
|
30
35
|
if (p.parentAccountId) {
|
|
31
|
-
|
|
32
|
-
...(
|
|
36
|
+
mappedAccountData[p.parentAccountId] = [
|
|
37
|
+
...(mappedAccountData[p.parentAccountId] || []),
|
|
33
38
|
p,
|
|
34
39
|
];
|
|
35
40
|
}
|
|
36
41
|
else {
|
|
37
|
-
|
|
42
|
+
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(p);
|
|
43
|
+
if (accountId) {
|
|
44
|
+
mappedAccountData[accountId] = [p];
|
|
45
|
+
}
|
|
38
46
|
}
|
|
39
47
|
});
|
|
40
|
-
return
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
set.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
return mappedAccountData;
|
|
49
|
+
}
|
|
50
|
+
function getAccountData(mappedAccountData) {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
const accountData = [];
|
|
53
|
+
Object.entries(mappedAccountData).forEach(([key, set]) => {
|
|
54
|
+
const hasParentAccount = set.filter(p => (0, getAccountIdentifier_1.getAccountIdentifier)(p) === parseInt(key, 10))[0];
|
|
55
|
+
set.forEach(account => {
|
|
56
|
+
let name = `${account.name} [${config_2.HUBSPOT_ACCOUNT_TYPE_STRINGS[account.accountType]}]`;
|
|
57
|
+
if ((0, accountTypes_1.isSandbox)(account)) {
|
|
58
|
+
if (hasParentAccount && set.length > 1) {
|
|
50
59
|
name = `↳ ${name}`;
|
|
51
60
|
}
|
|
52
61
|
}
|
|
53
|
-
else if (isDeveloperTestAccount(
|
|
54
|
-
if (
|
|
62
|
+
else if ((0, accountTypes_1.isDeveloperTestAccount)(account)) {
|
|
63
|
+
if (hasParentAccount && set.length > 1) {
|
|
55
64
|
name = `↳ ${name}`;
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
|
-
|
|
67
|
+
accountData.push([name, (0, getAccountIdentifier_1.getAccountIdentifier)(account), account.authType]);
|
|
59
68
|
});
|
|
60
69
|
});
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const { derivedAccountId } =
|
|
65
|
-
trackCommandUsage('accounts-list',
|
|
66
|
-
const configPath = getConfigPath();
|
|
67
|
-
const accountsList = getConfigAccounts();
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
i18n(`${i18nKey}.labels.name`),
|
|
72
|
-
i18n(`${i18nKey}.labels.accountId`),
|
|
73
|
-
i18n(`${i18nKey}.labels.authType`),
|
|
70
|
+
return accountData;
|
|
71
|
+
}
|
|
72
|
+
async function handler(args) {
|
|
73
|
+
const { derivedAccountId } = args;
|
|
74
|
+
(0, usageTracking_1.trackCommandUsage)('accounts-list', undefined, derivedAccountId);
|
|
75
|
+
const configPath = (0, config_1.getConfigPath)();
|
|
76
|
+
const accountsList = (0, config_1.getConfigAccounts)() || [];
|
|
77
|
+
const mappedAccountData = sortAndMapAccounts(accountsList);
|
|
78
|
+
const accountData = getAccountData(mappedAccountData);
|
|
79
|
+
accountData.unshift((0, table_1.getTableHeader)([
|
|
80
|
+
(0, lang_1.i18n)(`${i18nKey}.labels.name`),
|
|
81
|
+
(0, lang_1.i18n)(`${i18nKey}.labels.accountId`),
|
|
82
|
+
(0, lang_1.i18n)(`${i18nKey}.labels.authType`),
|
|
74
83
|
]));
|
|
75
|
-
logger.log(i18n(`${i18nKey}.configPath`, { configPath }));
|
|
76
|
-
logger.log(i18n(`${i18nKey}.defaultAccount`, {
|
|
77
|
-
account: getConfigDefaultAccount(),
|
|
84
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.configPath`, { configPath: configPath }));
|
|
85
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.defaultAccount`, {
|
|
86
|
+
account: (0, config_1.getConfigDefaultAccount)(),
|
|
78
87
|
}));
|
|
79
|
-
logger.log(i18n(`${i18nKey}.accounts`));
|
|
80
|
-
logger.log(getTableContents(
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
addConfigOptions(yargs);
|
|
88
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.accounts`));
|
|
89
|
+
logger_1.logger.log((0, table_1.getTableContents)(accountData, { border: { bodyLeft: ' ' } }));
|
|
90
|
+
}
|
|
91
|
+
function builder(yargs) {
|
|
92
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
84
93
|
yargs.example([['$0 accounts list']]);
|
|
85
94
|
return yargs;
|
|
86
|
-
}
|
|
95
|
+
}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "remove [account]";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type AccountRemoveArgs = CommonArgs & ConfigArgs & {
|
|
6
|
+
account?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<AccountRemoveArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<AccountRemoveArgs>;
|
|
1
10
|
export {};
|
|
@@ -1,51 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
9
|
+
const lang_1 = require("../../lib/lang");
|
|
10
|
+
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
11
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
10
12
|
const i18nKey = 'commands.account.subcommands.remove';
|
|
11
13
|
exports.command = 'remove [account]';
|
|
12
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
13
|
-
|
|
14
|
-
const { account } =
|
|
14
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
15
|
+
async function handler(args) {
|
|
16
|
+
const { account } = args;
|
|
15
17
|
let accountToRemove = account;
|
|
16
|
-
if (accountToRemove && !getAccountId(accountToRemove)) {
|
|
17
|
-
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
18
|
+
if (accountToRemove && !(0, config_1.getAccountId)(accountToRemove)) {
|
|
19
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountNotFound`, {
|
|
18
20
|
specifiedAccount: accountToRemove,
|
|
19
|
-
configPath: getConfigPath(),
|
|
21
|
+
configPath: (0, config_1.getConfigPath)(),
|
|
20
22
|
}));
|
|
21
23
|
}
|
|
22
|
-
if (!accountToRemove || !getAccountId(accountToRemove)) {
|
|
23
|
-
accountToRemove = await selectAccountFromConfig(i18n(`${i18nKey}.prompts.selectAccountToRemove`));
|
|
24
|
+
if (!accountToRemove || !(0, config_1.getAccountId)(accountToRemove)) {
|
|
25
|
+
accountToRemove = await (0, accountsPrompt_1.selectAccountFromConfig)((0, lang_1.i18n)(`${i18nKey}.prompts.selectAccountToRemove`));
|
|
24
26
|
}
|
|
25
|
-
trackCommandUsage('accounts-remove',
|
|
26
|
-
const currentDefaultAccount = getConfigDefaultAccount();
|
|
27
|
-
await deleteAccount(accountToRemove);
|
|
28
|
-
logger.success(i18n(`${i18nKey}.success.accountRemoved`, {
|
|
27
|
+
(0, usageTracking_1.trackCommandUsage)('accounts-remove', undefined, (0, config_1.getAccountId)(accountToRemove));
|
|
28
|
+
const currentDefaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
29
|
+
await (0, config_1.deleteAccount)(accountToRemove);
|
|
30
|
+
logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.accountRemoved`, {
|
|
29
31
|
accountName: accountToRemove,
|
|
30
32
|
}));
|
|
31
33
|
// Get updated version of the config
|
|
32
|
-
loadConfig(
|
|
34
|
+
(0, config_1.loadConfig)((0, config_1.getConfigPath)());
|
|
33
35
|
if (accountToRemove === currentDefaultAccount) {
|
|
34
|
-
logger.log();
|
|
35
|
-
logger.log(i18n(`${i18nKey}.logs.replaceDefaultAccount`));
|
|
36
|
-
const newDefaultAccount = await selectAccountFromConfig();
|
|
37
|
-
updateDefaultAccount(newDefaultAccount);
|
|
36
|
+
logger_1.logger.log();
|
|
37
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.logs.replaceDefaultAccount`));
|
|
38
|
+
const newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
39
|
+
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
38
40
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
addConfigOptions(yargs);
|
|
41
|
+
}
|
|
42
|
+
function builder(yargs) {
|
|
43
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
42
44
|
yargs.positional('account', {
|
|
43
|
-
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
45
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
44
46
|
type: 'string',
|
|
45
47
|
});
|
|
46
48
|
yargs.example([
|
|
47
|
-
['$0 accounts remove', i18n(`${i18nKey}.examples.default`)],
|
|
48
|
-
['$0 accounts remove MyAccount', i18n(`${i18nKey}.examples.byName`)],
|
|
49
|
+
['$0 accounts remove', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
50
|
+
['$0 accounts remove MyAccount', (0, lang_1.i18n)(`${i18nKey}.examples.byName`)],
|
|
49
51
|
]);
|
|
50
52
|
return yargs;
|
|
51
|
-
}
|
|
53
|
+
}
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "rename <account-name> <new-name>";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
type AccountRenameArgs = CommonArgs & ConfigArgs & {
|
|
6
|
+
accountName: string;
|
|
7
|
+
newName: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function handler(args: ArgumentsCamelCase<AccountRenameArgs>): Promise<void>;
|
|
10
|
+
export declare function builder(yargs: Argv): Argv<AccountRenameArgs>;
|
|
1
11
|
export {};
|
|
@@ -1,34 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
9
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
10
|
+
const lang_1 = require("../../lib/lang");
|
|
11
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
12
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
9
13
|
const i18nKey = 'commands.account.subcommands.rename';
|
|
10
|
-
exports.command = 'rename <
|
|
11
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
-
|
|
13
|
-
const { accountName, newName, derivedAccountId } =
|
|
14
|
-
trackCommandUsage('accounts-rename',
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
exports.command = 'rename <account-name> <new-name>';
|
|
15
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
16
|
+
async function handler(args) {
|
|
17
|
+
const { accountName, newName, derivedAccountId } = args;
|
|
18
|
+
(0, usageTracking_1.trackCommandUsage)('accounts-rename', undefined, derivedAccountId);
|
|
19
|
+
try {
|
|
20
|
+
await (0, config_1.renameAccount)(accountName, newName);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
(0, errorHandlers_1.logError)(error);
|
|
24
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
25
|
+
}
|
|
26
|
+
logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.success.renamed`, {
|
|
17
27
|
name: accountName,
|
|
18
28
|
newName,
|
|
19
29
|
}));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
31
|
+
}
|
|
32
|
+
function builder(yargs) {
|
|
33
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
34
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
35
|
+
yargs.positional('account-name', {
|
|
36
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.accountName.describe`),
|
|
26
37
|
type: 'string',
|
|
27
38
|
});
|
|
28
|
-
yargs.positional('
|
|
29
|
-
describe: i18n(`${i18nKey}.positionals.newName.describe`),
|
|
39
|
+
yargs.positional('new-name', {
|
|
40
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.newName.describe`),
|
|
30
41
|
type: 'string',
|
|
31
42
|
});
|
|
32
|
-
yargs.example([
|
|
43
|
+
yargs.example([
|
|
44
|
+
['$0 accounts rename myExistingAccountName myNewAccountName'],
|
|
45
|
+
]);
|
|
33
46
|
return yargs;
|
|
34
|
-
}
|
|
47
|
+
}
|
|
@@ -1 +1,10 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "use [account]";
|
|
4
|
+
export declare const describe: string;
|
|
5
|
+
interface AccountUseArgs extends CommonArgs {
|
|
6
|
+
account?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<AccountUseArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<AccountUseArgs>;
|
|
1
10
|
export {};
|
package/commands/account/use.js
CHANGED
|
@@ -1,41 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
7
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
8
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
9
|
+
const lang_1 = require("../../lib/lang");
|
|
10
|
+
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
9
11
|
const i18nKey = 'commands.account.subcommands.use';
|
|
10
12
|
exports.command = 'use [account]';
|
|
11
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
-
|
|
13
|
-
let newDefaultAccount =
|
|
13
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
14
|
+
async function handler(args) {
|
|
15
|
+
let newDefaultAccount = args.account;
|
|
14
16
|
if (!newDefaultAccount) {
|
|
15
|
-
newDefaultAccount = await selectAccountFromConfig();
|
|
17
|
+
newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
16
18
|
}
|
|
17
|
-
else if (!getAccountId(newDefaultAccount)) {
|
|
18
|
-
logger.error(i18n(`${i18nKey}.errors.accountNotFound`, {
|
|
19
|
+
else if (!(0, config_1.getAccountId)(newDefaultAccount)) {
|
|
20
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.errors.accountNotFound`, {
|
|
19
21
|
specifiedAccount: newDefaultAccount,
|
|
20
|
-
configPath: getConfigPath(),
|
|
22
|
+
configPath: (0, config_1.getConfigPath)(),
|
|
21
23
|
}));
|
|
22
|
-
newDefaultAccount = await selectAccountFromConfig();
|
|
24
|
+
newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
23
25
|
}
|
|
24
|
-
trackCommandUsage('accounts-use',
|
|
25
|
-
updateDefaultAccount(newDefaultAccount);
|
|
26
|
-
return logger.success(i18n(`${i18nKey}.success.defaultAccountUpdated`, {
|
|
26
|
+
(0, usageTracking_1.trackCommandUsage)('accounts-use', undefined, (0, config_1.getAccountId)(newDefaultAccount));
|
|
27
|
+
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
28
|
+
return logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.success.defaultAccountUpdated`, {
|
|
27
29
|
accountName: newDefaultAccount,
|
|
28
30
|
}));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
+
}
|
|
32
|
+
function builder(yargs) {
|
|
31
33
|
yargs.positional('account', {
|
|
32
|
-
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
34
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
33
35
|
type: 'string',
|
|
34
36
|
});
|
|
35
37
|
yargs.example([
|
|
36
|
-
['$0 accounts use', i18n(`${i18nKey}.examples.default`)],
|
|
37
|
-
['$0 accounts use MyAccount', i18n(`${i18nKey}.examples.nameBased`)],
|
|
38
|
-
['$0 accounts use 1234567', i18n(`${i18nKey}.examples.idBased`)],
|
|
38
|
+
['$0 accounts use', (0, lang_1.i18n)(`${i18nKey}.examples.default`)],
|
|
39
|
+
['$0 accounts use MyAccount', (0, lang_1.i18n)(`${i18nKey}.examples.nameBased`)],
|
|
40
|
+
['$0 accounts use 1234567', (0, lang_1.i18n)(`${i18nKey}.examples.idBased`)],
|
|
39
41
|
]);
|
|
40
42
|
return yargs;
|
|
41
|
-
}
|
|
43
|
+
}
|
package/commands/account.d.ts
CHANGED