@hubspot/cli 7.5.2-experimental.0 → 7.5.4-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/api/migrate.d.ts +1 -2
- package/api/migrate.js +0 -7
- package/bin/cli.js +2 -0
- package/commands/account/auth.d.ts +10 -0
- package/commands/account/auth.js +168 -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 +23 -0
- package/commands/account/list.js +23 -7
- package/commands/account/remove.js +28 -0
- package/commands/account/removeOverride.d.ts +10 -0
- package/commands/account/removeOverride.js +76 -0
- package/commands/account/use.js +13 -0
- package/commands/account.js +7 -2
- package/commands/auth.js +6 -2
- 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 +29 -29
- package/commands/config.d.ts +4 -1
- package/commands/config.js +45 -11
- package/commands/init.js +9 -10
- package/commands/project.js +0 -2
- package/lang/en.js +5 -0
- package/lang/en.lyaml +89 -16
- package/lib/app/migrate.d.ts +2 -2
- package/lib/app/migrate.js +35 -75
- package/lib/app/migrate_legacy.js +3 -5
- package/lib/configMigrate.d.ts +2 -0
- package/lib/configMigrate.js +104 -0
- package/lib/doctor/Diagnosis.d.ts +1 -2
- package/lib/doctor/Diagnosis.js +10 -6
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -0
- package/lib/doctor/DiagnosticInfoBuilder.js +1 -0
- package/lib/doctor/Doctor.d.ts +1 -0
- package/lib/doctor/Doctor.js +18 -0
- package/lib/middleware/configMiddleware.js +5 -1
- package/lib/middleware/fireAlarmMiddleware.d.ts +4 -0
- package/lib/middleware/fireAlarmMiddleware.js +137 -0
- package/lib/projects/index.d.ts +2 -3
- package/lib/ui/index.d.ts +1 -0
- package/lib/ui/index.js +5 -0
- package/package.json +5 -4
- package/types/Yargs.d.ts +3 -6
- package/commands/project/migrate.d.ts +0 -8
- package/commands/project/migrate.js +0 -48
package/api/migrate.d.ts
CHANGED
|
@@ -50,11 +50,10 @@ export interface MigrationSuccess extends MigrationBaseStatus {
|
|
|
50
50
|
}
|
|
51
51
|
export interface MigrationFailed extends MigrationBaseStatus {
|
|
52
52
|
status: typeof MIGRATION_STATUS.FAILURE;
|
|
53
|
-
|
|
53
|
+
projectErrorsDetail?: string;
|
|
54
54
|
componentErrorDetails: Record<string, string>;
|
|
55
55
|
}
|
|
56
56
|
export type MigrationStatus = MigrationInProgress | MigrationInputRequired | MigrationSuccess | MigrationFailed;
|
|
57
|
-
export declare function isMigrationStatus(error: unknown): error is MigrationStatus;
|
|
58
57
|
export declare function listAppsForMigration(accountId: number): HubSpotPromise<ListAppsResponse>;
|
|
59
58
|
export declare function initializeMigration(accountId: number, applicationId: number, platformVersion: string): HubSpotPromise<InitializeMigrationResponse>;
|
|
60
59
|
export declare function continueMigration(portalId: number, migrationId: number, componentUids: Record<string, string>, projectName: string): HubSpotPromise<ContinueMigrationResponse>;
|
package/api/migrate.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMigrationStatus = isMigrationStatus;
|
|
4
3
|
exports.listAppsForMigration = listAppsForMigration;
|
|
5
4
|
exports.initializeMigration = initializeMigration;
|
|
6
5
|
exports.continueMigration = continueMigration;
|
|
@@ -8,12 +7,6 @@ exports.checkMigrationStatusV2 = checkMigrationStatusV2;
|
|
|
8
7
|
const projects_1 = require("@hubspot/local-dev-lib/constants/projects");
|
|
9
8
|
const http_1 = require("@hubspot/local-dev-lib/http");
|
|
10
9
|
const MIGRATIONS_API_PATH_V2 = 'dfs/migrations/v2';
|
|
11
|
-
function isMigrationStatus(error) {
|
|
12
|
-
return (typeof error === 'object' &&
|
|
13
|
-
error !== null &&
|
|
14
|
-
'id' in error &&
|
|
15
|
-
'status' in error);
|
|
16
|
-
}
|
|
17
10
|
async function listAppsForMigration(accountId) {
|
|
18
11
|
return http_1.http.get(accountId, {
|
|
19
12
|
url: `${MIGRATIONS_API_PATH_V2}/list-apps`,
|
package/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ const { notifyAboutUpdates, } = require('../lib/middleware/notificationsMiddlewa
|
|
|
11
11
|
const { checkAndWarnGitInclusionMiddleware, } = require('../lib/middleware/gitMiddleware');
|
|
12
12
|
const { performChecks } = require('../lib/middleware/yargsChecksMiddleware');
|
|
13
13
|
const { setRequestHeaders } = require('../lib/middleware/requestMiddleware');
|
|
14
|
+
const { checkFireAlarms } = require('../lib/middleware/fireAlarmMiddleware');
|
|
14
15
|
const removeCommand = require('../commands/remove');
|
|
15
16
|
const initCommand = require('../commands/init');
|
|
16
17
|
const logsCommand = require('../commands/logs');
|
|
@@ -72,6 +73,7 @@ const argv = yargs
|
|
|
72
73
|
injectAccountIdMiddleware,
|
|
73
74
|
checkAndWarnGitInclusionMiddleware,
|
|
74
75
|
validateAccountOptions,
|
|
76
|
+
checkFireAlarms,
|
|
75
77
|
])
|
|
76
78
|
.exitProcess(false)
|
|
77
79
|
.fail(handleFailure)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const describe: string;
|
|
4
|
+
export declare const command = "auth";
|
|
5
|
+
type AccountAuthArgs = CommonArgs & ConfigArgs & {
|
|
6
|
+
disableTracking?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<AccountAuthArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<AccountAuthArgs>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = exports.describe = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
7
|
+
const migrate_1 = require("@hubspot/local-dev-lib/config/migrate");
|
|
8
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
9
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
|
+
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
11
|
+
const environments_1 = require("@hubspot/local-dev-lib/constants/environments");
|
|
12
|
+
const text_1 = require("@hubspot/local-dev-lib/text");
|
|
13
|
+
const auth_1 = require("@hubspot/local-dev-lib/constants/auth");
|
|
14
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
15
|
+
const configMigrate_1 = require("../../lib/configMigrate");
|
|
16
|
+
const process_1 = require("../../lib/process");
|
|
17
|
+
const index_1 = require("../../lib/errorHandlers/index");
|
|
18
|
+
const lang_1 = require("../../lib/lang");
|
|
19
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
20
|
+
const personalAccessKeyPrompt_1 = require("../../lib/prompts/personalAccessKeyPrompt");
|
|
21
|
+
const accountNamePrompt_1 = require("../../lib/prompts/accountNamePrompt");
|
|
22
|
+
const setAsDefaultAccountPrompt_1 = require("../../lib/prompts/setAsDefaultAccountPrompt");
|
|
23
|
+
const index_2 = require("../../lib/errorHandlers/index");
|
|
24
|
+
const usageTracking_2 = require("../../lib/usageTracking");
|
|
25
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
26
|
+
const ui_1 = require("../../lib/ui");
|
|
27
|
+
const TRACKING_STATUS = {
|
|
28
|
+
STARTED: 'started',
|
|
29
|
+
ERROR: 'error',
|
|
30
|
+
COMPLETE: 'complete',
|
|
31
|
+
};
|
|
32
|
+
async function updateConfig(env, doesConfigExist, disableTracking, authType, account) {
|
|
33
|
+
try {
|
|
34
|
+
const { personalAccessKey } = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
|
|
35
|
+
env,
|
|
36
|
+
account,
|
|
37
|
+
});
|
|
38
|
+
const token = await (0, personalAccessKey_1.getAccessToken)(personalAccessKey, env);
|
|
39
|
+
const defaultName = token.hubName ? (0, text_1.toKebabCase)(token.hubName) : undefined;
|
|
40
|
+
const name = doesConfigExist
|
|
41
|
+
? undefined
|
|
42
|
+
: (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
|
|
43
|
+
const updatedConfig = await (0, personalAccessKey_1.updateConfigWithAccessToken)(token, personalAccessKey, env, name, !doesConfigExist);
|
|
44
|
+
if (!updatedConfig)
|
|
45
|
+
return null;
|
|
46
|
+
if (doesConfigExist && !updatedConfig.name) {
|
|
47
|
+
updatedConfig.name = (await (0, accountNamePrompt_1.cliAccountNamePrompt)(defaultName)).name;
|
|
48
|
+
(0, config_1.updateAccountConfig)({
|
|
49
|
+
...updatedConfig,
|
|
50
|
+
});
|
|
51
|
+
(0, config_1.writeConfig)();
|
|
52
|
+
}
|
|
53
|
+
return updatedConfig;
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
if (!disableTracking) {
|
|
57
|
+
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.ERROR);
|
|
58
|
+
}
|
|
59
|
+
(0, index_1.debugError)(e);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.describe = (0, lang_1.i18n)('commands.account.subcommands.auth.describe');
|
|
64
|
+
exports.command = 'auth';
|
|
65
|
+
async function handler(args) {
|
|
66
|
+
const { providedAccountId, disableTracking } = args;
|
|
67
|
+
const authType = auth_1.PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
68
|
+
const deprecatedConfigExists = (0, migrate_1.configFileExists)(false);
|
|
69
|
+
const globalConfigExists = (0, migrate_1.configFileExists)(true);
|
|
70
|
+
if (deprecatedConfigExists) {
|
|
71
|
+
if (globalConfigExists) {
|
|
72
|
+
try {
|
|
73
|
+
await (0, configMigrate_1.handleMerge)(providedAccountId);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
(0, index_2.logError)(error);
|
|
77
|
+
(0, usageTracking_2.trackCommandMetadataUsage)('account-auth', {
|
|
78
|
+
command: 'hs account auth',
|
|
79
|
+
type: 'Merge configs',
|
|
80
|
+
successful: false,
|
|
81
|
+
}, providedAccountId);
|
|
82
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
try {
|
|
87
|
+
await (0, configMigrate_1.handleMigration)(providedAccountId);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
(0, index_2.logError)(error);
|
|
91
|
+
(0, usageTracking_2.trackCommandMetadataUsage)('account-auth', {
|
|
92
|
+
command: 'hs account auth',
|
|
93
|
+
type: 'Migrate a single config',
|
|
94
|
+
successful: false,
|
|
95
|
+
}, providedAccountId);
|
|
96
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (!disableTracking) {
|
|
101
|
+
(0, usageTracking_1.trackCommandUsage)('account-auth', {}, providedAccountId);
|
|
102
|
+
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.STARTED);
|
|
103
|
+
}
|
|
104
|
+
const env = args.qa ? environments_1.ENVIRONMENTS.QA : environments_1.ENVIRONMENTS.PROD;
|
|
105
|
+
const configAlreadyExists = (0, migrate_1.configFileExists)(true);
|
|
106
|
+
if (!configAlreadyExists) {
|
|
107
|
+
(0, config_1.createEmptyConfigFile)({}, true);
|
|
108
|
+
}
|
|
109
|
+
(0, config_1.loadConfig)('');
|
|
110
|
+
(0, process_1.handleExit)(config_1.deleteEmptyConfigFile);
|
|
111
|
+
const updatedConfig = await updateConfig(env, configAlreadyExists, disableTracking, authType, providedAccountId);
|
|
112
|
+
if (!updatedConfig) {
|
|
113
|
+
logger_1.logger.error((0, lang_1.i18n)('commands.account.subcommands.auth.errors.failedToUpdateConfig'));
|
|
114
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
115
|
+
}
|
|
116
|
+
const { name } = updatedConfig;
|
|
117
|
+
const accountId = (0, getAccountIdentifier_1.getAccountIdentifier)(updatedConfig);
|
|
118
|
+
// If the config file was just created, we don't need to prompt the user to set as default
|
|
119
|
+
if (!configAlreadyExists) {
|
|
120
|
+
logger_1.logger.log('');
|
|
121
|
+
logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.auth.success.configFileCreated', {
|
|
122
|
+
configPath: (0, config_1.getConfigPath)('', true),
|
|
123
|
+
}));
|
|
124
|
+
logger_1.logger.success((0, lang_1.i18n)('commands.account.subcommands.auth.success.configFileUpdated', {
|
|
125
|
+
account: name || accountId || '',
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const setAsDefault = await (0, setAsDefaultAccountPrompt_1.setAsDefaultAccountPrompt)(name);
|
|
130
|
+
logger_1.logger.log('');
|
|
131
|
+
if (setAsDefault) {
|
|
132
|
+
logger_1.logger.success((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.setAsDefaultAccount`, {
|
|
133
|
+
accountName: name,
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
logger_1.logger.info((0, lang_1.i18n)(`lib.prompts.setAsDefaultAccountPrompt.keepingCurrentDefault`, {
|
|
138
|
+
accountName: (0, config_1.getConfigDefaultAccount)(),
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
(0, ui_1.uiFeatureHighlight)([
|
|
143
|
+
'helpCommand',
|
|
144
|
+
'accountAuthCommand',
|
|
145
|
+
'accountsListCommand',
|
|
146
|
+
]);
|
|
147
|
+
if (!disableTracking) {
|
|
148
|
+
await (0, usageTracking_1.trackAuthAction)('account-auth', authType, TRACKING_STATUS.COMPLETE, accountId);
|
|
149
|
+
}
|
|
150
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
151
|
+
}
|
|
152
|
+
function builder(yargs) {
|
|
153
|
+
yargs.options({
|
|
154
|
+
account: {
|
|
155
|
+
describe: (0, lang_1.i18n)('commands.account.subcommands.auth.options.account.describe'),
|
|
156
|
+
type: 'string',
|
|
157
|
+
alias: 'a',
|
|
158
|
+
},
|
|
159
|
+
'disable-tracking': {
|
|
160
|
+
type: 'boolean',
|
|
161
|
+
hidden: true,
|
|
162
|
+
default: false,
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
(0, commonOpts_1.addTestingOptions)(yargs);
|
|
166
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
167
|
+
return yargs;
|
|
168
|
+
}
|
|
@@ -6,19 +6,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.describe = exports.command = void 0;
|
|
7
7
|
exports.handler = handler;
|
|
8
8
|
exports.builder = builder;
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
10
|
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
10
11
|
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
11
12
|
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
12
13
|
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
13
14
|
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
15
|
+
const config_2 = require("@hubspot/local-dev-lib/config");
|
|
14
16
|
const usageTracking_1 = require("../../lib/usageTracking");
|
|
15
17
|
const lang_1 = require("../../lib/lang");
|
|
16
18
|
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
17
19
|
const commonOpts_1 = require("../../lib/commonOpts");
|
|
18
20
|
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
21
|
+
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
19
22
|
const table_1 = require("../../lib/ui/table");
|
|
20
23
|
const SpinniesManager_1 = __importDefault(require("../../lib/ui/SpinniesManager"));
|
|
21
24
|
const ui_1 = require("../../lib/ui");
|
|
25
|
+
const errorHandlers_1 = require("../../lib/errorHandlers");
|
|
22
26
|
exports.command = 'clean';
|
|
23
27
|
exports.describe = (0, lang_1.i18n)(`commands.account.subcommands.clean.describe`);
|
|
24
28
|
async function handler(args) {
|
|
@@ -69,25 +73,54 @@ async function handler(args) {
|
|
|
69
73
|
logger_1.logger.log((0, table_1.getTableContents)(accountsToRemove.map(p => [
|
|
70
74
|
(0, ui_1.uiAccountDescription)((0, getAccountIdentifier_1.getAccountIdentifier)(p)),
|
|
71
75
|
]), { border: { bodyLeft: ' ' } }));
|
|
76
|
+
let promptMessage = (0, lang_1.i18n)(oneAccountFound
|
|
77
|
+
? `commands.account.subcommands.clean.confirm.one`
|
|
78
|
+
: `commands.account.subcommands.clean.confirm.other`, {
|
|
79
|
+
count: accountsToRemove.length,
|
|
80
|
+
});
|
|
81
|
+
const accountOverride = (0, config_2.getCWDAccountOverride)();
|
|
82
|
+
const overrideFilePath = (0, config_2.getDefaultAccountOverrideFilePath)();
|
|
83
|
+
const accountOverrideMatches = accountsToRemove.some(account => account.name === accountOverride ||
|
|
84
|
+
// @ts-expect-error: Default account override files can only exist with global config
|
|
85
|
+
account.accountId === accountOverride);
|
|
86
|
+
if (overrideFilePath && accountOverride && accountOverrideMatches) {
|
|
87
|
+
promptMessage = `${promptMessage}${(0, lang_1.i18n)(`commands.account.subcommands.clean.defaultAccountOverride`, {
|
|
88
|
+
overrideFilePath,
|
|
89
|
+
})}`;
|
|
90
|
+
}
|
|
72
91
|
const { accountsCleanPrompt } = await (0, promptUtils_1.promptUser)([
|
|
73
92
|
{
|
|
74
93
|
name: 'accountsCleanPrompt',
|
|
75
94
|
type: 'confirm',
|
|
76
|
-
message:
|
|
77
|
-
? `commands.account.subcommands.clean.confirm.one`
|
|
78
|
-
: `commands.account.subcommands.clean.confirm.other`, {
|
|
79
|
-
count: accountsToRemove.length,
|
|
80
|
-
}),
|
|
95
|
+
message: promptMessage,
|
|
81
96
|
},
|
|
82
97
|
]);
|
|
83
98
|
if (accountsCleanPrompt) {
|
|
84
99
|
logger_1.logger.log('');
|
|
100
|
+
try {
|
|
101
|
+
if (overrideFilePath) {
|
|
102
|
+
fs_1.default.unlinkSync(overrideFilePath);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
(0, errorHandlers_1.logError)(error);
|
|
107
|
+
}
|
|
85
108
|
for (const accountToRemove of accountsToRemove) {
|
|
86
109
|
await (0, config_1.deleteAccount)(accountToRemove.name);
|
|
87
110
|
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.clean.removeSuccess`, {
|
|
88
111
|
accountName: accountToRemove.name,
|
|
89
112
|
}));
|
|
90
113
|
}
|
|
114
|
+
// Get updated version of the config
|
|
115
|
+
(0, config_1.loadConfig)((0, config_1.getConfigPath)());
|
|
116
|
+
const defaultAccount = (0, config_1.getConfigDefaultAccount)();
|
|
117
|
+
if (defaultAccount &&
|
|
118
|
+
accountsToRemove.some(p => p.name === defaultAccount)) {
|
|
119
|
+
logger_1.logger.log();
|
|
120
|
+
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.clean.replaceDefaultAccount`));
|
|
121
|
+
const newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
122
|
+
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
123
|
+
}
|
|
91
124
|
}
|
|
92
125
|
}
|
|
93
126
|
else {
|
|
@@ -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 = "create-override [account]";
|
|
5
|
+
type AccountCreateOverrideArgs = CommonArgs & {
|
|
6
|
+
account: string | number;
|
|
7
|
+
};
|
|
8
|
+
export declare function handler(args: ArgumentsCamelCase<AccountCreateOverrideArgs>): Promise<void>;
|
|
9
|
+
export declare function builder(yargs: Argv): Argv<AccountCreateOverrideArgs>;
|
|
10
|
+
export {};
|
|
@@ -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,6 +20,28 @@ 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
46
|
logger_1.logger.log((0, lang_1.i18n)(`commands.account.subcommands.info.accountId`, {
|
|
24
47
|
accountId: derivedAccountId,
|
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,13 +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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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`));
|
|
90
106
|
logger_1.logger.log((0, table_1.getTableContents)(accountData, { border: { bodyLeft: ' ' } }));
|
|
91
107
|
}
|
|
92
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,
|
|
@@ -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
|
+
}
|