@hubspot/cli 7.1.0 → 7.1.1-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/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 +21 -19
- 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/init.js +1 -0
- package/lib/sandboxes.d.ts +1 -0
- package/lib/sandboxes.js +1 -0
- package/package.json +1 -1
|
@@ -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 <accountName> <newName>";
|
|
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,36 @@
|
|
|
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");
|
|
9
11
|
const i18nKey = 'commands.account.subcommands.rename';
|
|
10
12
|
exports.command = 'rename <accountName> <newName>';
|
|
11
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
12
|
-
|
|
13
|
-
const { accountName, newName, derivedAccountId } =
|
|
14
|
-
trackCommandUsage('accounts-rename',
|
|
15
|
-
await renameAccount(accountName, newName);
|
|
16
|
-
return logger.log(i18n(`${i18nKey}.success.renamed`, {
|
|
13
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
14
|
+
async function handler(args) {
|
|
15
|
+
const { accountName, newName, derivedAccountId } = args;
|
|
16
|
+
(0, usageTracking_1.trackCommandUsage)('accounts-rename', undefined, derivedAccountId);
|
|
17
|
+
await (0, config_1.renameAccount)(accountName, newName);
|
|
18
|
+
return logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.success.renamed`, {
|
|
17
19
|
name: accountName,
|
|
18
20
|
newName,
|
|
19
21
|
}));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
addConfigOptions(yargs);
|
|
23
|
-
addAccountOptions(yargs);
|
|
22
|
+
}
|
|
23
|
+
function builder(yargs) {
|
|
24
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
25
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
24
26
|
yargs.positional('accountName', {
|
|
25
|
-
describe: i18n(`${i18nKey}.positionals.accountName.describe`),
|
|
27
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.accountName.describe`),
|
|
26
28
|
type: 'string',
|
|
27
29
|
});
|
|
28
30
|
yargs.positional('newName', {
|
|
29
|
-
describe: i18n(`${i18nKey}.positionals.newName.describe`),
|
|
31
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.positionals.newName.describe`),
|
|
30
32
|
type: 'string',
|
|
31
33
|
});
|
|
32
34
|
yargs.example([['$0 accounts rename myExistingPortalName myNewPortalName']]);
|
|
33
35
|
return yargs;
|
|
34
|
-
}
|
|
36
|
+
}
|
|
@@ -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
package/commands/account.js
CHANGED
|
@@ -1,19 +1,53 @@
|
|
|
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
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
36
|
+
exports.describe = exports.command = void 0;
|
|
37
|
+
exports.builder = builder;
|
|
38
|
+
const commonOpts_1 = require("../lib/commonOpts");
|
|
39
|
+
const lang_1 = require("../lib/lang");
|
|
40
|
+
const list = __importStar(require("./account/list"));
|
|
41
|
+
const rename = __importStar(require("./account/rename"));
|
|
42
|
+
const use = __importStar(require("./account/use"));
|
|
43
|
+
const info = __importStar(require("./account/info"));
|
|
44
|
+
const remove = __importStar(require("./account/remove"));
|
|
45
|
+
const clean = __importStar(require("./account/clean"));
|
|
12
46
|
const i18nKey = 'commands.account';
|
|
13
47
|
exports.command = ['account', 'accounts'];
|
|
14
|
-
exports.describe = i18n(`${i18nKey}.describe`);
|
|
15
|
-
|
|
16
|
-
addGlobalOptions(yargs);
|
|
48
|
+
exports.describe = (0, lang_1.i18n)(`${i18nKey}.describe`);
|
|
49
|
+
function builder(yargs) {
|
|
50
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
17
51
|
yargs
|
|
18
52
|
.command(list)
|
|
19
53
|
.command(rename)
|
|
@@ -23,4 +57,4 @@ exports.builder = yargs => {
|
|
|
23
57
|
.command(clean)
|
|
24
58
|
.demandCommand(1, '');
|
|
25
59
|
return yargs;
|
|
26
|
-
}
|
|
60
|
+
}
|
package/commands/init.js
CHANGED
package/lib/sandboxes.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export declare const SANDBOX_API_TYPE_MAP: {
|
|
|
15
15
|
readonly DEVELOPMENT_SANDBOX: 2;
|
|
16
16
|
};
|
|
17
17
|
export declare function getSandboxTypeAsString(accountType?: AccountType): string;
|
|
18
|
+
export declare function getHasSandboxesByType(parentAccountConfig: CLIAccount, type: AccountType): boolean;
|
|
18
19
|
export declare function getAvailableSyncTypes(parentAccountConfig: CLIAccount, config: CLIAccount): Promise<Array<SandboxSyncTask>>;
|
|
19
20
|
export declare function validateSandboxUsageLimits(accountConfig: CLIAccount, sandboxType: AccountType, env: Environment): Promise<void>;
|
|
20
21
|
export declare function handleSandboxCreateError(err: unknown, env: Environment, name: string, accountId: number): never;
|
package/lib/sandboxes.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SANDBOX_API_TYPE_MAP = exports.SANDBOX_TYPE_MAP = exports.SYNC_TYPES = void 0;
|
|
4
4
|
exports.getSandboxTypeAsString = getSandboxTypeAsString;
|
|
5
|
+
exports.getHasSandboxesByType = getHasSandboxesByType;
|
|
5
6
|
exports.getAvailableSyncTypes = getAvailableSyncTypes;
|
|
6
7
|
exports.validateSandboxUsageLimits = validateSandboxUsageLimits;
|
|
7
8
|
exports.handleSandboxCreateError = handleSandboxCreateError;
|