@hubspot/cli 7.1.1 → 7.2.0-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/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/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 +112 -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 +3 -2
- package/lib/localDev.js +2 -2
- 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 +2 -5
- 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,157 +1,175 @@
|
|
|
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
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
3
|
+
exports.describe = exports.command = void 0;
|
|
4
|
+
exports.handler = handler;
|
|
5
|
+
exports.builder = builder;
|
|
6
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
7
|
+
const logger_1 = require("@hubspot/local-dev-lib/logger");
|
|
8
|
+
const index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
9
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
10
|
+
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
11
|
+
const environment_1 = require("@hubspot/local-dev-lib/environment");
|
|
12
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
13
|
+
const lang_1 = require("../../lib/lang");
|
|
14
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
15
|
+
const ui_1 = require("../../lib/ui");
|
|
16
|
+
const sandboxes_1 = require("../../lib/sandboxes");
|
|
17
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
18
|
+
const sandboxesPrompt_1 = require("../../lib/prompts/sandboxesPrompt");
|
|
19
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
20
|
+
const sandboxSync_1 = require("../../lib/sandboxSync");
|
|
21
|
+
const index_2 = require("../../lib/errorHandlers/index");
|
|
22
|
+
const buildAccount_1 = require("../../lib/buildAccount");
|
|
23
|
+
const accountNamePrompt_1 = require("../../lib/prompts/accountNamePrompt");
|
|
22
24
|
const i18nKey = 'commands.sandbox.subcommands.create';
|
|
23
25
|
exports.command = 'create';
|
|
24
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
25
|
-
|
|
26
|
-
const { name, type, force, derivedAccountId } =
|
|
27
|
-
const accountConfig = getAccountConfig(derivedAccountId);
|
|
28
|
-
const env = getValidEnv(getEnv(derivedAccountId));
|
|
29
|
-
trackCommandUsage('sandbox-create',
|
|
26
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
27
|
+
async function handler(args) {
|
|
28
|
+
const { name, type, force, derivedAccountId } = args;
|
|
29
|
+
const accountConfig = (0, config_1.getAccountConfig)(derivedAccountId);
|
|
30
|
+
const env = (0, environment_1.getValidEnv)((0, config_1.getEnv)(derivedAccountId));
|
|
31
|
+
(0, usageTracking_1.trackCommandUsage)('sandbox-create', {}, derivedAccountId);
|
|
32
|
+
// Check if account config exists
|
|
33
|
+
if (!accountConfig) {
|
|
34
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noAccountConfig`, {
|
|
35
|
+
accountId: derivedAccountId,
|
|
36
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
37
|
+
}));
|
|
38
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
39
|
+
}
|
|
30
40
|
// Default account is not a production portal
|
|
31
41
|
if (accountConfig.accountType &&
|
|
32
|
-
accountConfig.accountType !== HUBSPOT_ACCOUNT_TYPES.STANDARD) {
|
|
33
|
-
logger.error(i18n(`${i18nKey}.failure.invalidAccountType`, {
|
|
34
|
-
accountType: HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]],
|
|
35
|
-
accountName: accountConfig.name,
|
|
42
|
+
accountConfig.accountType !== config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD) {
|
|
43
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.invalidAccountType`, {
|
|
44
|
+
accountType: config_2.HUBSPOT_ACCOUNT_TYPE_STRINGS[config_2.HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]],
|
|
45
|
+
accountName: accountConfig.name || '',
|
|
36
46
|
}));
|
|
37
|
-
process.exit(EXIT_CODES.ERROR);
|
|
47
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
38
48
|
}
|
|
39
49
|
let typePrompt;
|
|
40
50
|
let namePrompt;
|
|
41
|
-
if ((type && !
|
|
51
|
+
if ((type && !(type.toLowerCase() in sandboxes_1.SANDBOX_TYPE_MAP)) || !type) {
|
|
42
52
|
if (!force) {
|
|
43
|
-
typePrompt = await sandboxTypePrompt();
|
|
53
|
+
typePrompt = await (0, sandboxesPrompt_1.sandboxTypePrompt)();
|
|
44
54
|
}
|
|
45
55
|
else {
|
|
46
|
-
logger.error(i18n(`${i18nKey}.failure.optionMissing.type`));
|
|
47
|
-
process.exit(EXIT_CODES.ERROR);
|
|
56
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.optionMissing.type`));
|
|
57
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
const sandboxType = type
|
|
51
|
-
? SANDBOX_TYPE_MAP[type.toLowerCase()]
|
|
61
|
+
? sandboxes_1.SANDBOX_TYPE_MAP[type.toLowerCase()]
|
|
52
62
|
: typePrompt.type;
|
|
53
63
|
// Check usage limits and exit if parent portal has no available sandboxes for the selected type
|
|
54
64
|
try {
|
|
55
|
-
await validateSandboxUsageLimits(accountConfig, sandboxType, env);
|
|
65
|
+
await (0, sandboxes_1.validateSandboxUsageLimits)(accountConfig, sandboxType, env);
|
|
56
66
|
}
|
|
57
67
|
catch (err) {
|
|
58
|
-
if (isMissingScopeError(err)) {
|
|
59
|
-
logger.error(i18n('lib.sandbox.create.failure.scopes.message', {
|
|
68
|
+
if ((0, index_1.isMissingScopeError)(err)) {
|
|
69
|
+
logger_1.logger.error((0, lang_1.i18n)('lib.sandbox.create.failure.scopes.message', {
|
|
60
70
|
accountName: accountConfig.name || derivedAccountId,
|
|
61
71
|
}));
|
|
62
|
-
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
72
|
+
const websiteOrigin = (0, urls_1.getHubSpotWebsiteOrigin)(env);
|
|
63
73
|
const url = `${websiteOrigin}/personal-access-key/${derivedAccountId}`;
|
|
64
|
-
logger.info(i18n('lib.sandbox.create.failure.scopes.instructions', {
|
|
74
|
+
logger_1.logger.info((0, lang_1.i18n)('lib.sandbox.create.failure.scopes.instructions', {
|
|
65
75
|
accountName: accountConfig.name || derivedAccountId,
|
|
66
76
|
url,
|
|
67
77
|
}));
|
|
68
78
|
}
|
|
69
79
|
else {
|
|
70
|
-
logError(err);
|
|
80
|
+
(0, index_2.logError)(err);
|
|
71
81
|
}
|
|
72
|
-
process.exit(EXIT_CODES.ERROR);
|
|
82
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
73
83
|
}
|
|
74
84
|
if (!name) {
|
|
75
85
|
if (!force) {
|
|
76
|
-
namePrompt = await hubspotAccountNamePrompt({ accountType: sandboxType });
|
|
86
|
+
namePrompt = await (0, accountNamePrompt_1.hubspotAccountNamePrompt)({ accountType: sandboxType });
|
|
77
87
|
}
|
|
78
88
|
else {
|
|
79
|
-
logger.error(i18n(`${i18nKey}.failure.optionMissing.name`));
|
|
80
|
-
process.exit(EXIT_CODES.ERROR);
|
|
89
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.optionMissing.name`));
|
|
90
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
const sandboxName = name || namePrompt.name;
|
|
84
94
|
let contactRecordsSyncPromptResult = false;
|
|
85
95
|
if (!force) {
|
|
86
|
-
const isStandardSandbox = sandboxType === HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
|
|
96
|
+
const isStandardSandbox = sandboxType === config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX;
|
|
87
97
|
// Prompt to sync contact records for standard sandboxes only
|
|
88
98
|
if (isStandardSandbox) {
|
|
89
|
-
const { contactRecordsSyncPrompt } = await promptUser([
|
|
99
|
+
const { contactRecordsSyncPrompt } = await (0, promptUtils_1.promptUser)([
|
|
90
100
|
{
|
|
91
101
|
name: 'contactRecordsSyncPrompt',
|
|
92
102
|
type: 'confirm',
|
|
93
|
-
message: i18n('lib.sandbox.sync.confirm.syncContactRecords.standard'),
|
|
103
|
+
message: (0, lang_1.i18n)('lib.sandbox.sync.confirm.syncContactRecords.standard'),
|
|
94
104
|
},
|
|
95
105
|
]);
|
|
96
106
|
contactRecordsSyncPromptResult = contactRecordsSyncPrompt;
|
|
97
107
|
}
|
|
98
108
|
}
|
|
99
109
|
try {
|
|
100
|
-
const result = await buildSandbox(sandboxName, accountConfig, sandboxType, env, force);
|
|
101
|
-
const sandboxAccountConfig = getAccountConfig(result.sandbox.sandboxHubId);
|
|
110
|
+
const result = await (0, buildAccount_1.buildSandbox)(sandboxName, accountConfig, sandboxType, env, force);
|
|
111
|
+
const sandboxAccountConfig = (0, config_1.getAccountConfig)(result.sandbox.sandboxHubId);
|
|
112
|
+
// Check if sandbox account config exists
|
|
113
|
+
if (!sandboxAccountConfig) {
|
|
114
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noSandboxAccountConfig`, {
|
|
115
|
+
accountId: result.sandbox.sandboxHubId,
|
|
116
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
117
|
+
}));
|
|
118
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
119
|
+
}
|
|
102
120
|
// For v1 sandboxes, keep sync here. Once we migrate to v2, this will be handled by BE automatically
|
|
103
|
-
|
|
104
|
-
await syncSandbox(sandboxAccountConfig, accountConfig, env, syncTasks);
|
|
105
|
-
}
|
|
121
|
+
async function handleSyncSandbox(syncTasks) {
|
|
122
|
+
await (0, sandboxSync_1.syncSandbox)(sandboxAccountConfig, accountConfig, env, syncTasks);
|
|
123
|
+
}
|
|
106
124
|
try {
|
|
107
|
-
let availableSyncTasks = await getAvailableSyncTypes(accountConfig, sandboxAccountConfig);
|
|
125
|
+
let availableSyncTasks = await (0, sandboxes_1.getAvailableSyncTypes)(accountConfig, sandboxAccountConfig);
|
|
108
126
|
if (!contactRecordsSyncPromptResult) {
|
|
109
|
-
availableSyncTasks = availableSyncTasks.filter(t => t.type !== SYNC_TYPES.OBJECT_RECORDS);
|
|
127
|
+
availableSyncTasks = availableSyncTasks.filter(t => t.type !== sandboxes_1.SYNC_TYPES.OBJECT_RECORDS);
|
|
110
128
|
}
|
|
111
129
|
await handleSyncSandbox(availableSyncTasks);
|
|
112
130
|
}
|
|
113
131
|
catch (err) {
|
|
114
|
-
logError(err);
|
|
132
|
+
(0, index_2.logError)(err);
|
|
115
133
|
throw err;
|
|
116
134
|
}
|
|
117
135
|
const highlightItems = ['accountsUseCommand', 'projectCreateCommand'];
|
|
118
|
-
if (sandboxType === HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
|
|
136
|
+
if (sandboxType === config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX) {
|
|
119
137
|
highlightItems.push('projectDevCommand');
|
|
120
138
|
}
|
|
121
139
|
else {
|
|
122
140
|
highlightItems.push('projectUploadCommand');
|
|
123
141
|
}
|
|
124
|
-
uiFeatureHighlight(highlightItems);
|
|
125
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
142
|
+
(0, ui_1.uiFeatureHighlight)(highlightItems);
|
|
143
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
126
144
|
}
|
|
127
145
|
catch (error) {
|
|
128
146
|
// Errors are logged in util functions
|
|
129
|
-
process.exit(EXIT_CODES.ERROR);
|
|
147
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
130
148
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
149
|
+
}
|
|
150
|
+
function builder(yargs) {
|
|
133
151
|
yargs.option('force', {
|
|
134
152
|
type: 'boolean',
|
|
135
153
|
alias: 'f',
|
|
136
|
-
describe: i18n(`${i18nKey}.options.force.describe`),
|
|
154
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.force.describe`),
|
|
137
155
|
});
|
|
138
156
|
yargs.option('name', {
|
|
139
|
-
describe: i18n(`${i18nKey}.options.name.describe`),
|
|
157
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.name.describe`),
|
|
140
158
|
type: 'string',
|
|
141
159
|
});
|
|
142
160
|
yargs.option('type', {
|
|
143
|
-
describe: i18n(`${i18nKey}.options.type.describe`),
|
|
144
|
-
|
|
161
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.type.describe`),
|
|
162
|
+
choices: Object.keys(sandboxes_1.SANDBOX_TYPE_MAP),
|
|
145
163
|
});
|
|
146
164
|
yargs.example([
|
|
147
165
|
[
|
|
148
166
|
'$0 sandbox create --name=MySandboxAccount --type=STANDARD',
|
|
149
|
-
i18n(`${i18nKey}.examples.default`),
|
|
167
|
+
(0, lang_1.i18n)(`${i18nKey}.examples.default`),
|
|
150
168
|
],
|
|
151
169
|
]);
|
|
152
|
-
addConfigOptions(yargs);
|
|
153
|
-
addAccountOptions(yargs);
|
|
154
|
-
addUseEnvironmentOptions(yargs);
|
|
155
|
-
addTestingOptions(yargs);
|
|
170
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
171
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
172
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
173
|
+
(0, commonOpts_1.addTestingOptions)(yargs);
|
|
156
174
|
return yargs;
|
|
157
|
-
}
|
|
175
|
+
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
+
import { Argv, ArgumentsCamelCase } from 'yargs';
|
|
2
|
+
import { CommonArgs, ConfigArgs, AccountArgs, EnvironmentArgs, TestingArgs } from '../../types/Yargs';
|
|
3
|
+
export declare const command = "delete";
|
|
4
|
+
export declare const describe: string | undefined;
|
|
5
|
+
type CombinedArgs = ConfigArgs & AccountArgs & EnvironmentArgs & TestingArgs;
|
|
6
|
+
type SandboxDeleteArgs = CommonArgs & CombinedArgs & {
|
|
7
|
+
account?: string;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function handler(args: ArgumentsCamelCase<SandboxDeleteArgs>): Promise<void>;
|
|
11
|
+
export declare function builder(yargs: Argv): Argv<SandboxDeleteArgs>;
|
|
1
12
|
export {};
|
|
@@ -1,190 +1,207 @@
|
|
|
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
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
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 index_1 = require("@hubspot/local-dev-lib/errors/index");
|
|
8
|
+
const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
|
|
9
|
+
const config_1 = require("@hubspot/local-dev-lib/config");
|
|
10
|
+
const getAccountIdentifier_1 = require("@hubspot/local-dev-lib/config/getAccountIdentifier");
|
|
11
|
+
const urls_1 = require("@hubspot/local-dev-lib/urls");
|
|
12
|
+
const environment_1 = require("@hubspot/local-dev-lib/environment");
|
|
13
|
+
const commonOpts_1 = require("../../lib/commonOpts");
|
|
14
|
+
const usageTracking_1 = require("../../lib/usageTracking");
|
|
15
|
+
const index_2 = require("../../lib/errorHandlers/index");
|
|
16
|
+
const lang_1 = require("../../lib/lang");
|
|
17
|
+
const sandboxesPrompt_1 = require("../../lib/prompts/sandboxesPrompt");
|
|
18
|
+
const accountsPrompt_1 = require("../../lib/prompts/accountsPrompt");
|
|
19
|
+
const exitCodes_1 = require("../../lib/enums/exitCodes");
|
|
20
|
+
const promptUtils_1 = require("../../lib/prompts/promptUtils");
|
|
21
|
+
const ui_1 = require("../../lib/ui");
|
|
20
22
|
const i18nKey = 'commands.sandbox.subcommands.delete';
|
|
21
23
|
exports.command = 'delete';
|
|
22
|
-
exports.describe =
|
|
23
|
-
|
|
24
|
-
const { providedAccountId, force } =
|
|
25
|
-
trackCommandUsage('sandbox-delete',
|
|
24
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
25
|
+
async function handler(args) {
|
|
26
|
+
const { providedAccountId, force } = args;
|
|
27
|
+
(0, usageTracking_1.trackCommandUsage)('sandbox-delete', {}, providedAccountId);
|
|
26
28
|
let accountPrompt;
|
|
27
29
|
if (!providedAccountId) {
|
|
28
30
|
if (!force) {
|
|
29
|
-
accountPrompt = await deleteSandboxPrompt();
|
|
31
|
+
accountPrompt = await (0, sandboxesPrompt_1.deleteSandboxPrompt)();
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
34
|
// Account is required, throw error if force flag is present and no account is specified
|
|
33
|
-
logger.log('');
|
|
34
|
-
logger.error(i18n(`${i18nKey}.failure.noAccount`));
|
|
35
|
-
process.exit(EXIT_CODES.ERROR);
|
|
35
|
+
logger_1.logger.log('');
|
|
36
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noAccount`));
|
|
37
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
36
38
|
}
|
|
37
39
|
if (!accountPrompt) {
|
|
38
|
-
logger.log('');
|
|
39
|
-
logger.error(i18n(`${i18nKey}.failure.noSandboxAccounts
|
|
40
|
-
|
|
40
|
+
logger_1.logger.log('');
|
|
41
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noSandboxAccounts`, {
|
|
42
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
43
|
+
}));
|
|
44
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
|
-
const sandboxAccountId = getAccountId(providedAccountId || accountPrompt.account);
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
const sandboxAccountId = (0, config_1.getAccountId)(providedAccountId || accountPrompt.account);
|
|
48
|
+
if (!sandboxAccountId) {
|
|
49
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noSandboxAccountId`));
|
|
50
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
51
|
+
}
|
|
52
|
+
const isDefaultAccount = sandboxAccountId === (0, config_1.getAccountId)();
|
|
53
|
+
const baseUrl = (0, urls_1.getHubSpotWebsiteOrigin)((0, environment_1.getValidEnv)((0, config_1.getEnv)(sandboxAccountId)));
|
|
46
54
|
let parentAccountId;
|
|
47
|
-
const accountsList = getConfigAccounts();
|
|
55
|
+
const accountsList = (0, config_1.getConfigAccounts)() || [];
|
|
48
56
|
for (const portal of accountsList) {
|
|
49
|
-
if (getAccountIdentifier(portal) === sandboxAccountId) {
|
|
57
|
+
if ((0, getAccountIdentifier_1.getAccountIdentifier)(portal) === sandboxAccountId) {
|
|
50
58
|
if (portal.parentAccountId) {
|
|
51
59
|
parentAccountId = portal.parentAccountId;
|
|
52
60
|
}
|
|
53
61
|
else if (!force) {
|
|
54
|
-
const parentAccountPrompt = await deleteSandboxPrompt(true);
|
|
55
|
-
|
|
62
|
+
const parentAccountPrompt = await (0, sandboxesPrompt_1.deleteSandboxPrompt)(true);
|
|
63
|
+
if (!parentAccountPrompt) {
|
|
64
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noParentAccount`, {
|
|
65
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
66
|
+
}));
|
|
67
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
68
|
+
}
|
|
69
|
+
parentAccountId = (0, config_1.getAccountId)(parentAccountPrompt.account);
|
|
56
70
|
}
|
|
57
71
|
else {
|
|
58
|
-
logger.error(i18n(`${i18nKey}.failure.noParentAccount
|
|
59
|
-
|
|
72
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noParentAccount`, {
|
|
73
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
74
|
+
}));
|
|
75
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
60
76
|
}
|
|
61
77
|
}
|
|
62
78
|
}
|
|
63
79
|
const url = `${baseUrl}/sandboxes/${parentAccountId}`;
|
|
64
|
-
const command = `hs auth ${getEnv(sandboxAccountId) === 'qa' ? '--qa' : ''} --account=${parentAccountId}`;
|
|
65
|
-
if (parentAccountId && !getAccountId(parentAccountId)) {
|
|
66
|
-
logger.log('');
|
|
67
|
-
logger.error(i18n(`${i18nKey}.failure.noParentPortalAvailable`, {
|
|
80
|
+
const command = `hs auth ${(0, config_1.getEnv)(sandboxAccountId) === 'qa' ? '--qa' : ''} --account=${parentAccountId}`;
|
|
81
|
+
if (parentAccountId && !(0, config_1.getAccountId)(parentAccountId)) {
|
|
82
|
+
logger_1.logger.log('');
|
|
83
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.noParentPortalAvailable`, {
|
|
68
84
|
parentAccountId,
|
|
69
85
|
url,
|
|
70
86
|
command,
|
|
71
87
|
}));
|
|
72
|
-
logger.log('');
|
|
73
|
-
process.exit(EXIT_CODES.ERROR);
|
|
88
|
+
logger_1.logger.log('');
|
|
89
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
74
90
|
}
|
|
75
|
-
logger.debug(i18n(`${i18nKey}.debug.deleting`, {
|
|
76
|
-
account: uiAccountDescription(sandboxAccountId),
|
|
91
|
+
logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.debug.deleting`, {
|
|
92
|
+
account: (0, ui_1.uiAccountDescription)(sandboxAccountId),
|
|
77
93
|
}));
|
|
78
94
|
if (isDefaultAccount) {
|
|
79
|
-
logger.info(i18n(`${i18nKey}.defaultAccountWarning`, {
|
|
80
|
-
account: uiAccountDescription(sandboxAccountId),
|
|
95
|
+
logger_1.logger.info((0, lang_1.i18n)(`${i18nKey}.defaultAccountWarning`, {
|
|
96
|
+
account: (0, ui_1.uiAccountDescription)(sandboxAccountId),
|
|
81
97
|
}));
|
|
82
|
-
logger.log('');
|
|
98
|
+
logger_1.logger.log('');
|
|
83
99
|
}
|
|
84
100
|
try {
|
|
85
101
|
if (!force) {
|
|
86
|
-
const { confirmSandboxDeletePrompt: confirmed } = await promptUser([
|
|
102
|
+
const { confirmSandboxDeletePrompt: confirmed } = await (0, promptUtils_1.promptUser)([
|
|
87
103
|
{
|
|
88
104
|
name: 'confirmSandboxDeletePrompt',
|
|
89
105
|
type: 'confirm',
|
|
90
|
-
message: i18n(`${i18nKey}.confirm`, {
|
|
91
|
-
account: uiAccountDescription(sandboxAccountId),
|
|
106
|
+
message: (0, lang_1.i18n)(`${i18nKey}.confirm`, {
|
|
107
|
+
account: (0, ui_1.uiAccountDescription)(sandboxAccountId),
|
|
92
108
|
}),
|
|
93
109
|
},
|
|
94
110
|
]);
|
|
95
111
|
if (!confirmed) {
|
|
96
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
112
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
|
-
await deleteSandbox(parentAccountId, sandboxAccountId);
|
|
115
|
+
await (0, sandboxHubs_1.deleteSandbox)(parentAccountId, sandboxAccountId);
|
|
100
116
|
const deleteKey = isDefaultAccount
|
|
101
117
|
? `${i18nKey}.success.deleteDefault`
|
|
102
118
|
: `${i18nKey}.success.delete`;
|
|
103
|
-
logger.log('');
|
|
104
|
-
logger.success(i18n(deleteKey, {
|
|
119
|
+
logger_1.logger.log('');
|
|
120
|
+
logger_1.logger.success((0, lang_1.i18n)(deleteKey, {
|
|
105
121
|
account: providedAccountId || accountPrompt.account,
|
|
106
|
-
sandboxHubId: sandboxAccountId,
|
|
122
|
+
sandboxHubId: sandboxAccountId || '',
|
|
107
123
|
}));
|
|
108
|
-
logger.log('');
|
|
109
|
-
const promptDefaultAccount = removeSandboxAccountFromConfig(sandboxAccountId);
|
|
124
|
+
logger_1.logger.log('');
|
|
125
|
+
const promptDefaultAccount = (0, config_1.removeSandboxAccountFromConfig)(sandboxAccountId);
|
|
110
126
|
if (promptDefaultAccount && !force) {
|
|
111
|
-
const newDefaultAccount = await selectAccountFromConfig();
|
|
112
|
-
updateDefaultAccount(newDefaultAccount);
|
|
127
|
+
const newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
128
|
+
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
113
129
|
}
|
|
114
130
|
else {
|
|
115
131
|
// If force is specified, skip prompt and set the parent account id as the default account
|
|
116
|
-
updateDefaultAccount(parentAccountId);
|
|
132
|
+
(0, config_1.updateDefaultAccount)(parentAccountId);
|
|
117
133
|
}
|
|
118
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
134
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
119
135
|
}
|
|
120
136
|
catch (err) {
|
|
121
|
-
debugError(err);
|
|
122
|
-
if (isSpecifiedError(err, { statusCode: 401 })) {
|
|
137
|
+
(0, index_2.debugError)(err);
|
|
138
|
+
if ((0, index_1.isSpecifiedError)(err, { statusCode: 401 })) {
|
|
123
139
|
// Intercept invalid key error
|
|
124
140
|
// This command uses the parent portal PAK to delete a sandbox, so we must specify which account needs a new key
|
|
125
|
-
logger.log('');
|
|
126
|
-
logger.error(i18n(`${i18nKey}.failure.invalidKey`, {
|
|
127
|
-
account: uiAccountDescription(parentAccountId),
|
|
141
|
+
logger_1.logger.log('');
|
|
142
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.invalidKey`, {
|
|
143
|
+
account: (0, ui_1.uiAccountDescription)(parentAccountId),
|
|
144
|
+
authCommand: (0, ui_1.uiCommandReference)('hs auth'),
|
|
128
145
|
}));
|
|
129
146
|
}
|
|
130
|
-
else if (isSpecifiedError(err, {
|
|
147
|
+
else if ((0, index_1.isSpecifiedError)(err, {
|
|
131
148
|
statusCode: 403,
|
|
132
149
|
category: 'BANNED',
|
|
133
150
|
subCategory: 'SandboxErrors.USER_ACCESS_NOT_ALLOWED',
|
|
134
151
|
})) {
|
|
135
|
-
logger.log('');
|
|
136
|
-
logger.error(i18n(`${i18nKey}.failure.invalidUser`, {
|
|
137
|
-
accountName: uiAccountDescription(sandboxAccountId),
|
|
138
|
-
parentAccountName: uiAccountDescription(parentAccountId),
|
|
152
|
+
logger_1.logger.log('');
|
|
153
|
+
logger_1.logger.error((0, lang_1.i18n)(`${i18nKey}.failure.invalidUser`, {
|
|
154
|
+
accountName: (0, ui_1.uiAccountDescription)(sandboxAccountId),
|
|
155
|
+
parentAccountName: (0, ui_1.uiAccountDescription)(parentAccountId),
|
|
139
156
|
}));
|
|
140
|
-
logger.log('');
|
|
157
|
+
logger_1.logger.log('');
|
|
141
158
|
}
|
|
142
|
-
else if (isSpecifiedError(err, {
|
|
159
|
+
else if ((0, index_1.isSpecifiedError)(err, {
|
|
143
160
|
statusCode: 404,
|
|
144
161
|
category: 'OBJECT_NOT_FOUND',
|
|
145
162
|
subCategory: 'SandboxErrors.SANDBOX_NOT_FOUND',
|
|
146
163
|
})) {
|
|
147
|
-
logger.log('');
|
|
148
|
-
logger.warn(i18n(`${i18nKey}.failure.objectNotFound`, {
|
|
149
|
-
account: uiAccountDescription(sandboxAccountId),
|
|
164
|
+
logger_1.logger.log('');
|
|
165
|
+
logger_1.logger.warn((0, lang_1.i18n)(`${i18nKey}.failure.objectNotFound`, {
|
|
166
|
+
account: (0, ui_1.uiAccountDescription)(sandboxAccountId),
|
|
150
167
|
}));
|
|
151
|
-
logger.log('');
|
|
152
|
-
const promptDefaultAccount = removeSandboxAccountFromConfig(sandboxAccountId);
|
|
168
|
+
logger_1.logger.log('');
|
|
169
|
+
const promptDefaultAccount = (0, config_1.removeSandboxAccountFromConfig)(sandboxAccountId);
|
|
153
170
|
if (promptDefaultAccount && !force) {
|
|
154
|
-
const newDefaultAccount = await selectAccountFromConfig();
|
|
155
|
-
updateDefaultAccount(newDefaultAccount);
|
|
171
|
+
const newDefaultAccount = await (0, accountsPrompt_1.selectAccountFromConfig)();
|
|
172
|
+
(0, config_1.updateDefaultAccount)(newDefaultAccount);
|
|
156
173
|
}
|
|
157
174
|
else {
|
|
158
175
|
// If force is specified, skip prompt and set the parent account id as the default account
|
|
159
|
-
updateDefaultAccount(parentAccountId);
|
|
176
|
+
(0, config_1.updateDefaultAccount)(parentAccountId);
|
|
160
177
|
}
|
|
161
|
-
process.exit(EXIT_CODES.SUCCESS);
|
|
178
|
+
process.exit(exitCodes_1.EXIT_CODES.SUCCESS);
|
|
162
179
|
}
|
|
163
180
|
else {
|
|
164
|
-
logError(err);
|
|
181
|
+
(0, index_2.logError)(err);
|
|
165
182
|
}
|
|
166
|
-
process.exit(EXIT_CODES.ERROR);
|
|
183
|
+
process.exit(exitCodes_1.EXIT_CODES.ERROR);
|
|
167
184
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
185
|
+
}
|
|
186
|
+
function builder(yargs) {
|
|
170
187
|
yargs.option('account', {
|
|
171
|
-
describe: i18n(`${i18nKey}.options.account.describe`),
|
|
188
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.account.describe`),
|
|
172
189
|
type: 'string',
|
|
173
190
|
});
|
|
174
191
|
yargs.option('force', {
|
|
175
192
|
type: 'boolean',
|
|
176
193
|
alias: 'f',
|
|
177
|
-
describe: i18n(`${i18nKey}.options.force.describe`),
|
|
194
|
+
describe: (0, lang_1.i18n)(`${i18nKey}.options.force.describe`),
|
|
178
195
|
});
|
|
179
196
|
yargs.example([
|
|
180
197
|
[
|
|
181
198
|
'$0 sandbox delete --account=MySandboxAccount',
|
|
182
|
-
i18n(`${i18nKey}.examples.default`),
|
|
199
|
+
(0, lang_1.i18n)(`${i18nKey}.examples.default`),
|
|
183
200
|
],
|
|
184
201
|
]);
|
|
185
|
-
addConfigOptions(yargs);
|
|
186
|
-
addAccountOptions(yargs);
|
|
187
|
-
addUseEnvironmentOptions(yargs);
|
|
188
|
-
addTestingOptions(yargs);
|
|
202
|
+
(0, commonOpts_1.addConfigOptions)(yargs);
|
|
203
|
+
(0, commonOpts_1.addAccountOptions)(yargs);
|
|
204
|
+
(0, commonOpts_1.addUseEnvironmentOptions)(yargs);
|
|
205
|
+
(0, commonOpts_1.addTestingOptions)(yargs);
|
|
189
206
|
return yargs;
|
|
190
|
-
}
|
|
207
|
+
}
|
package/commands/sandbox.d.ts
CHANGED
package/commands/sandbox.js
CHANGED
|
@@ -1,16 +1,50 @@
|
|
|
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
|
|
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 ui_1 = require("../lib/ui");
|
|
41
|
+
const create = __importStar(require("./sandbox/create"));
|
|
42
|
+
const del = __importStar(require("./sandbox/delete"));
|
|
9
43
|
const i18nKey = 'commands.sandbox';
|
|
10
44
|
exports.command = ['sandbox', 'sandboxes'];
|
|
11
|
-
exports.describe = uiBetaTag(i18n(`${i18nKey}.describe`), false);
|
|
12
|
-
|
|
13
|
-
addGlobalOptions(yargs);
|
|
45
|
+
exports.describe = (0, ui_1.uiBetaTag)((0, lang_1.i18n)(`${i18nKey}.describe`), false);
|
|
46
|
+
function builder(yargs) {
|
|
47
|
+
(0, commonOpts_1.addGlobalOptions)(yargs);
|
|
14
48
|
yargs.command(create).command(del).demandCommand(1, '');
|
|
15
49
|
return yargs;
|
|
16
|
-
}
|
|
50
|
+
}
|