@hubspot/cli 7.8.11-experimental.0 → 7.8.12-experimental.1
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/bin/cli.js +31 -25
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -5
- package/commands/app/migrate.js +13 -18
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +16 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -36
- package/commands/config.js +2 -2
- package/commands/create.js +2 -2
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/schema/create.js +9 -11
- package/commands/customObject/schema/delete.js +16 -16
- package/commands/customObject/schema/fetch-all.js +12 -11
- package/commands/customObject/schema/fetch.js +15 -15
- package/commands/customObject/schema/list.js +4 -4
- package/commands/customObject/schema/update.js +13 -13
- package/commands/customObject/schema.js +2 -2
- package/commands/customObject.js +6 -7
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +6 -11
- package/commands/fetch.js +8 -8
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.js +11 -29
- package/commands/function/list.js +8 -8
- package/commands/function/server.js +9 -11
- package/commands/function.d.ts +1 -1
- package/commands/function.js +2 -2
- package/commands/getStarted.js +2 -2
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.js +16 -16
- package/commands/list.js +8 -14
- package/commands/logs.js +14 -20
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +4 -2
- package/commands/project/__tests__/deploy.test.js +3 -4
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/logs.test.js +1 -1
- package/commands/project/__tests__/migrate.test.js +5 -5
- package/commands/project/__tests__/migrateApp.test.js +2 -5
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.js +3 -3
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +0 -1
- package/commands/project/deploy.js +3 -3
- package/commands/project/dev/deprecatedFlow.js +7 -16
- package/commands/project/dev/index.js +14 -12
- package/commands/project/dev/unifiedFlow.js +3 -1
- package/commands/project/download.js +10 -13
- package/commands/project/installDeps.js +8 -8
- package/commands/project/listBuilds.js +11 -20
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +14 -16
- package/commands/project/migrateApp.js +9 -15
- package/commands/project/open.js +6 -13
- package/commands/project/upload.js +16 -25
- package/commands/project/validate.js +6 -6
- package/commands/project/watch.js +13 -22
- package/commands/project.js +2 -2
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +38 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/theme/preview.js +1 -4
- package/lang/en.d.ts +310 -102
- package/lang/en.js +351 -147
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -1
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +5 -5
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.js +1 -1
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.js +25 -57
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +6 -1
- package/lib/constants.js +10 -1
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +11 -18
- package/lib/lang.js +6 -5
- package/lib/links.js +4 -4
- package/lib/middleware/__test__/commandTargetingUtils.test.d.ts +1 -0
- package/lib/middleware/__test__/commandTargetingUtils.test.js +99 -0
- package/lib/middleware/__test__/configMiddleware.test.js +11 -11
- package/lib/middleware/__test__/yargsChecksMiddleware.test.js +6 -8
- package/lib/middleware/commandTargetingUtils.d.ts +8 -0
- package/lib/middleware/commandTargetingUtils.js +78 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/fireAlarmMiddleware.js +15 -17
- package/lib/middleware/gitMiddleware.js +5 -1
- package/lib/middleware/notificationsMiddleware.js +5 -11
- package/lib/middleware/yargsChecksMiddleware.js +6 -9
- package/lib/npm.js +2 -2
- package/lib/oauth.js +5 -5
- package/lib/process.js +5 -4
- package/lib/projects/__tests__/AppDevModeInterface.test.js +14 -34
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +70 -39
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v3AddComponent.test.js +4 -4
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v3.test.js +1 -1
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/v3.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -0
- package/lib/projects/localDev/AppDevModeInterface.js +22 -20
- package/lib/projects/localDev/LocalDevLogger.js +10 -11
- package/lib/projects/localDev/LocalDevManager.js +4 -5
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +0 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +7 -10
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +37 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +17 -8
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.js +6 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +27 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.js +3 -3
- package/lib/theme/migrate.js +2 -2
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +4 -0
- package/lib/ui/index.js +47 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +68 -0
- package/lib/ui/uiMessages.js +71 -0
- package/lib/usageTracking.js +7 -7
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +7 -7
- package/ui/components/BoxWithTitle.d.ts +8 -0
- package/ui/components/BoxWithTitle.js +9 -0
- package/ui/components/HorizontalSelectPrompt.d.ts +8 -0
- package/ui/components/HorizontalSelectPrompt.js +30 -0
- package/ui/components/StatusMessageBoxes.d.ts +12 -0
- package/ui/components/StatusMessageBoxes.js +31 -0
- package/ui/index.d.ts +1 -0
- package/ui/index.js +6 -0
- package/ui/lib/ui-testing-utils.d.ts +9 -0
- package/ui/lib/ui-testing-utils.js +47 -0
- package/ui/lib/useTerminalSize.d.ts +13 -0
- package/ui/lib/useTerminalSize.js +31 -0
- package/ui/styles.d.ts +18 -0
- package/ui/styles.js +18 -0
- package/ui/views/UiSandbox.d.ts +5 -0
- package/ui/views/UiSandbox.js +25 -0
- package/lib/middleware/__test__/utils.test.js +0 -51
- package/lib/middleware/utils.d.ts +0 -8
- package/lib/middleware/utils.js +0 -14
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
2
2
|
import { isSpecifiedError } from '@hubspot/local-dev-lib/errors/index';
|
|
3
3
|
import { deleteSandbox } from '@hubspot/local-dev-lib/api/sandboxHubs';
|
|
4
4
|
import { getEnv, removeSandboxAccountFromConfig, updateDefaultAccount, getAccountId, getConfigAccounts, } from '@hubspot/local-dev-lib/config';
|
|
@@ -7,15 +7,15 @@ import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
|
7
7
|
import { getValidEnv } from '@hubspot/local-dev-lib/environment';
|
|
8
8
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
9
9
|
import { logError, debugError } from '../../lib/errorHandlers/index.js';
|
|
10
|
-
import {
|
|
10
|
+
import { commands } from '../../lang/en.js';
|
|
11
11
|
import { deleteSandboxPrompt } from '../../lib/prompts/sandboxesPrompt.js';
|
|
12
12
|
import { selectAccountFromConfig } from '../../lib/prompts/accountsPrompt.js';
|
|
13
13
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
14
14
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
15
|
-
import {
|
|
15
|
+
import { uiAuthCommandReference, uiBetaTag } from '../../lib/ui/index.js';
|
|
16
16
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
17
17
|
const command = 'delete';
|
|
18
|
-
const describe = uiBetaTag(
|
|
18
|
+
const describe = uiBetaTag(commands.sandbox.subcommands.delete.describe, false);
|
|
19
19
|
async function handler(args) {
|
|
20
20
|
const { userProvidedAccount, derivedAccountId, force } = args;
|
|
21
21
|
trackCommandUsage('sandbox-delete', {}, derivedAccountId);
|
|
@@ -26,21 +26,19 @@ async function handler(args) {
|
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
// Account is required, throw error if force flag is present and no account is specified
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
uiLogger.log('');
|
|
30
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.noAccount);
|
|
31
31
|
process.exit(EXIT_CODES.ERROR);
|
|
32
32
|
}
|
|
33
33
|
if (!accountPrompt) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
authCommand: uiCommandReference('hs auth'),
|
|
37
|
-
}));
|
|
34
|
+
uiLogger.log('');
|
|
35
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.noSandboxAccounts);
|
|
38
36
|
process.exit(EXIT_CODES.ERROR);
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
const sandboxAccountId = getAccountId(userProvidedAccount || accountPrompt.account);
|
|
42
40
|
if (!sandboxAccountId) {
|
|
43
|
-
|
|
41
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.noSandboxAccountId);
|
|
44
42
|
process.exit(EXIT_CODES.ERROR);
|
|
45
43
|
}
|
|
46
44
|
const isDefaultAccount = sandboxAccountId === getAccountId();
|
|
@@ -55,41 +53,32 @@ async function handler(args) {
|
|
|
55
53
|
else if (!force) {
|
|
56
54
|
const parentAccountPrompt = await deleteSandboxPrompt(true);
|
|
57
55
|
if (!parentAccountPrompt) {
|
|
58
|
-
|
|
59
|
-
authCommand: uiCommandReference('hs auth'),
|
|
60
|
-
}));
|
|
56
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.noParentAccount);
|
|
61
57
|
process.exit(EXIT_CODES.ERROR);
|
|
62
58
|
}
|
|
63
59
|
parentAccountId = getAccountId(parentAccountPrompt.account);
|
|
64
60
|
}
|
|
65
61
|
else {
|
|
66
|
-
|
|
67
|
-
authCommand: uiCommandReference('hs auth'),
|
|
68
|
-
}));
|
|
62
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.noParentAccount);
|
|
69
63
|
process.exit(EXIT_CODES.ERROR);
|
|
70
64
|
}
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
67
|
const url = `${baseUrl}/sandboxes/${parentAccountId}`;
|
|
74
|
-
const command =
|
|
68
|
+
const command = uiAuthCommandReference({
|
|
69
|
+
accountId: parentAccountId || undefined,
|
|
70
|
+
qa: getEnv(sandboxAccountId) === 'qa',
|
|
71
|
+
});
|
|
75
72
|
if (parentAccountId && !getAccountId(parentAccountId)) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
url,
|
|
80
|
-
command,
|
|
81
|
-
}));
|
|
82
|
-
logger.log('');
|
|
73
|
+
uiLogger.log('');
|
|
74
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.noParentPortalAvailable(command, url));
|
|
75
|
+
uiLogger.log('');
|
|
83
76
|
process.exit(EXIT_CODES.ERROR);
|
|
84
77
|
}
|
|
85
|
-
|
|
86
|
-
account: uiAccountDescription(sandboxAccountId),
|
|
87
|
-
}));
|
|
78
|
+
uiLogger.debug(commands.sandbox.subcommands.delete.debug.deleting(sandboxAccountId));
|
|
88
79
|
if (isDefaultAccount) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}));
|
|
92
|
-
logger.log('');
|
|
80
|
+
uiLogger.info(commands.sandbox.subcommands.delete.defaultAccountWarning(sandboxAccountId));
|
|
81
|
+
uiLogger.log('');
|
|
93
82
|
}
|
|
94
83
|
try {
|
|
95
84
|
if (!force) {
|
|
@@ -97,9 +86,7 @@ async function handler(args) {
|
|
|
97
86
|
{
|
|
98
87
|
name: 'confirmSandboxDeletePrompt',
|
|
99
88
|
type: 'confirm',
|
|
100
|
-
message:
|
|
101
|
-
account: uiAccountDescription(sandboxAccountId),
|
|
102
|
-
}),
|
|
89
|
+
message: commands.sandbox.subcommands.delete.confirm(sandboxAccountId),
|
|
103
90
|
},
|
|
104
91
|
]);
|
|
105
92
|
if (!confirmed) {
|
|
@@ -107,15 +94,11 @@ async function handler(args) {
|
|
|
107
94
|
}
|
|
108
95
|
}
|
|
109
96
|
await deleteSandbox(parentAccountId, sandboxAccountId);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
account: userProvidedAccount || accountPrompt.account,
|
|
116
|
-
sandboxHubId: sandboxAccountId || '',
|
|
117
|
-
}));
|
|
118
|
-
logger.log('');
|
|
97
|
+
uiLogger.log('');
|
|
98
|
+
uiLogger.success(isDefaultAccount
|
|
99
|
+
? commands.sandbox.subcommands.delete.success.deleteDefault(userProvidedAccount || accountPrompt.account, sandboxAccountId)
|
|
100
|
+
: commands.sandbox.subcommands.delete.success.delete(userProvidedAccount || accountPrompt.account, sandboxAccountId));
|
|
101
|
+
uiLogger.log('');
|
|
119
102
|
const promptDefaultAccount = removeSandboxAccountFromConfig(sandboxAccountId);
|
|
120
103
|
if (promptDefaultAccount && !force) {
|
|
121
104
|
const newDefaultAccount = await selectAccountFromConfig();
|
|
@@ -132,34 +115,26 @@ async function handler(args) {
|
|
|
132
115
|
if (isSpecifiedError(err, { statusCode: 401 })) {
|
|
133
116
|
// Intercept invalid key error
|
|
134
117
|
// This command uses the parent portal PAK to delete a sandbox, so we must specify which account needs a new key
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
account: uiAccountDescription(parentAccountId),
|
|
138
|
-
authCommand: uiCommandReference('hs auth'),
|
|
139
|
-
}));
|
|
118
|
+
uiLogger.log('');
|
|
119
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.invalidKey(parentAccountId));
|
|
140
120
|
}
|
|
141
121
|
else if (isSpecifiedError(err, {
|
|
142
122
|
statusCode: 403,
|
|
143
123
|
category: 'BANNED',
|
|
144
124
|
subCategory: 'SandboxErrors.USER_ACCESS_NOT_ALLOWED',
|
|
145
125
|
})) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
parentAccountName: uiAccountDescription(parentAccountId),
|
|
150
|
-
}));
|
|
151
|
-
logger.log('');
|
|
126
|
+
uiLogger.log('');
|
|
127
|
+
uiLogger.error(commands.sandbox.subcommands.delete.failure.invalidUser(sandboxAccountId, parentAccountId));
|
|
128
|
+
uiLogger.log('');
|
|
152
129
|
}
|
|
153
130
|
else if (isSpecifiedError(err, {
|
|
154
131
|
statusCode: 404,
|
|
155
132
|
category: 'OBJECT_NOT_FOUND',
|
|
156
133
|
subCategory: 'SandboxErrors.SANDBOX_NOT_FOUND',
|
|
157
134
|
})) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}));
|
|
162
|
-
logger.log('');
|
|
135
|
+
uiLogger.log('');
|
|
136
|
+
uiLogger.warn(commands.sandbox.subcommands.delete.failure.objectNotFound(sandboxAccountId));
|
|
137
|
+
uiLogger.log('');
|
|
163
138
|
const promptDefaultAccount = removeSandboxAccountFromConfig(sandboxAccountId);
|
|
164
139
|
if (promptDefaultAccount && !force) {
|
|
165
140
|
const newDefaultAccount = await selectAccountFromConfig();
|
|
@@ -179,18 +154,18 @@ async function handler(args) {
|
|
|
179
154
|
}
|
|
180
155
|
function sandboxDeleteBuilder(yargs) {
|
|
181
156
|
yargs.option('account', {
|
|
182
|
-
describe:
|
|
157
|
+
describe: commands.sandbox.subcommands.delete.options.account.describe,
|
|
183
158
|
type: 'string',
|
|
184
159
|
});
|
|
185
160
|
yargs.option('force', {
|
|
186
161
|
type: 'boolean',
|
|
187
162
|
alias: 'f',
|
|
188
|
-
describe:
|
|
163
|
+
describe: commands.sandbox.subcommands.delete.options.force.describe,
|
|
189
164
|
});
|
|
190
165
|
yargs.example([
|
|
191
166
|
[
|
|
192
167
|
'$0 sandbox delete --account=MySandboxAccount',
|
|
193
|
-
|
|
168
|
+
commands.sandbox.subcommands.delete.examples.default,
|
|
194
169
|
],
|
|
195
170
|
]);
|
|
196
171
|
return yargs;
|
package/commands/sandbox.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commands } from '../lang/en.js';
|
|
2
2
|
import { uiBetaTag } from '../lib/ui/index.js';
|
|
3
3
|
import create from './sandbox/create.js';
|
|
4
4
|
import del from './sandbox/delete.js';
|
|
5
5
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
6
6
|
const command = ['sandbox', 'sandboxes'];
|
|
7
|
-
const describe = uiBetaTag(
|
|
7
|
+
const describe = uiBetaTag(commands.sandbox.describe, false);
|
|
8
8
|
function sandboxBuilder(yargs) {
|
|
9
9
|
yargs.command(create).command(del).demandCommand(1, '');
|
|
10
10
|
return yargs;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { addSecret, fetchSecrets } from '@hubspot/local-dev-lib/api/secrets';
|
|
3
2
|
import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
|
|
4
3
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
5
|
-
import { uiAccountDescription } from '../../lib/ui/index.js';
|
|
6
4
|
import { secretValuePrompt, secretNamePrompt, } from '../../lib/prompts/secretPrompt.js';
|
|
7
|
-
import {
|
|
5
|
+
import { commands } from '../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
8
7
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
9
|
-
import { uiCommandReference } from '../../lib/ui/index.js';
|
|
10
8
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
11
9
|
const command = 'add [name]';
|
|
12
|
-
const describe =
|
|
10
|
+
const describe = commands.secret.subcommands.add.describe;
|
|
13
11
|
async function handler(args) {
|
|
14
12
|
const { name, derivedAccountId } = args;
|
|
15
13
|
let secretName = name;
|
|
@@ -21,23 +19,15 @@ async function handler(args) {
|
|
|
21
19
|
}
|
|
22
20
|
const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
|
|
23
21
|
if (secrets.includes(secretName)) {
|
|
24
|
-
|
|
25
|
-
secretName,
|
|
26
|
-
command: uiCommandReference('hs secret update'),
|
|
27
|
-
}));
|
|
22
|
+
uiLogger.error(commands.secret.subcommands.add.errors.alreadyExists(secretName));
|
|
28
23
|
process.exit(EXIT_CODES.ERROR);
|
|
29
24
|
}
|
|
30
25
|
const { secretValue } = await secretValuePrompt();
|
|
31
26
|
await addSecret(derivedAccountId, secretName, secretValue);
|
|
32
|
-
|
|
33
|
-
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
34
|
-
secretName,
|
|
35
|
-
}));
|
|
27
|
+
uiLogger.success(commands.secret.subcommands.add.success.add(secretName, derivedAccountId));
|
|
36
28
|
}
|
|
37
29
|
catch (err) {
|
|
38
|
-
|
|
39
|
-
secretName: secretName || '',
|
|
40
|
-
}));
|
|
30
|
+
uiLogger.error(commands.secret.subcommands.add.errors.add(secretName || ''));
|
|
41
31
|
logError(err, new ApiErrorContext({
|
|
42
32
|
request: 'add secret',
|
|
43
33
|
accountId: derivedAccountId,
|
|
@@ -46,7 +36,7 @@ async function handler(args) {
|
|
|
46
36
|
}
|
|
47
37
|
function addSecretBuilder(yargs) {
|
|
48
38
|
yargs.positional('name', {
|
|
49
|
-
describe:
|
|
39
|
+
describe: commands.secret.subcommands.add.positionals.name.describe,
|
|
50
40
|
type: 'string',
|
|
51
41
|
});
|
|
52
42
|
return yargs;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { deleteSecret, fetchSecrets } from '@hubspot/local-dev-lib/api/secrets';
|
|
3
2
|
import { secretListPrompt } from '../../lib/prompts/secretPrompt.js';
|
|
4
3
|
import { confirmPrompt } from '../../lib/prompts/promptUtils.js';
|
|
5
4
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
6
5
|
import { ApiErrorContext, logError } from '../../lib/errorHandlers/index.js';
|
|
7
6
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { commands } from './../../lang/en.js';
|
|
8
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
10
9
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
11
10
|
const command = 'delete [name]';
|
|
12
|
-
const describe =
|
|
11
|
+
const describe = commands.secret.subcommands.delete.describe;
|
|
13
12
|
async function handler(args) {
|
|
14
13
|
const { name, derivedAccountId, force } = args;
|
|
15
14
|
let secretName = name;
|
|
@@ -17,36 +16,27 @@ async function handler(args) {
|
|
|
17
16
|
try {
|
|
18
17
|
const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
|
|
19
18
|
if (secretName && !secrets.includes(secretName)) {
|
|
20
|
-
|
|
21
|
-
secretName,
|
|
22
|
-
}));
|
|
19
|
+
uiLogger.error(commands.secret.subcommands.delete.errors.noSecret(secretName));
|
|
23
20
|
process.exit(EXIT_CODES.ERROR);
|
|
24
21
|
}
|
|
25
22
|
if (!secretName) {
|
|
26
|
-
const { secretToModify } = await secretListPrompt(secrets,
|
|
23
|
+
const { secretToModify } = await secretListPrompt(secrets, commands.secret.subcommands.delete.selectSecret);
|
|
27
24
|
secretName = secretToModify;
|
|
28
25
|
}
|
|
29
26
|
const confirmDelete = force ||
|
|
30
|
-
(await confirmPrompt(
|
|
31
|
-
secretName,
|
|
32
|
-
}), {
|
|
27
|
+
(await confirmPrompt(commands.secret.subcommands.delete.confirmDelete(secretName), {
|
|
33
28
|
defaultAnswer: false,
|
|
34
29
|
}));
|
|
35
30
|
if (!confirmDelete) {
|
|
36
|
-
|
|
31
|
+
uiLogger.success(commands.secret.subcommands.delete.deleteCanceled);
|
|
37
32
|
process.exit(EXIT_CODES.SUCCESS);
|
|
38
33
|
}
|
|
39
34
|
await deleteSecret(derivedAccountId, secretName);
|
|
40
|
-
|
|
41
|
-
accountIdentifier: uiAccountDescription(derivedAccountId),
|
|
42
|
-
secretName,
|
|
43
|
-
}));
|
|
35
|
+
uiLogger.success(commands.secret.subcommands.delete.success.delete(secretName, derivedAccountId));
|
|
44
36
|
}
|
|
45
37
|
catch (err) {
|
|
46
38
|
if (secretName) {
|
|
47
|
-
|
|
48
|
-
secretName,
|
|
49
|
-
}));
|
|
39
|
+
uiLogger.error(commands.secret.subcommands.delete.errors.delete(secretName));
|
|
50
40
|
}
|
|
51
41
|
logError(err, new ApiErrorContext({
|
|
52
42
|
request: 'delete a secret',
|
|
@@ -57,7 +47,7 @@ async function handler(args) {
|
|
|
57
47
|
function deleteSecretBuilder(yargs) {
|
|
58
48
|
yargs
|
|
59
49
|
.positional('name', {
|
|
60
|
-
describe:
|
|
50
|
+
describe: commands.secret.subcommands.delete.positionals.name.describe,
|
|
61
51
|
type: 'string',
|
|
62
52
|
})
|
|
63
53
|
.options('force', {
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { fetchSecrets } from '@hubspot/local-dev-lib/api/secrets';
|
|
3
2
|
import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
|
|
4
3
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
5
4
|
import { uiAccountDescription } from '../../lib/ui/index.js';
|
|
6
|
-
import {
|
|
5
|
+
import { commands } from '../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
7
7
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
8
|
const command = 'list';
|
|
9
|
-
const describe =
|
|
9
|
+
const describe = commands.secret.subcommands.list.describe;
|
|
10
10
|
async function handler(args) {
|
|
11
11
|
const { derivedAccountId } = args;
|
|
12
12
|
trackCommandUsage('secrets-list', {}, derivedAccountId);
|
|
13
13
|
try {
|
|
14
14
|
const { data: { results }, } = await fetchSecrets(derivedAccountId);
|
|
15
|
-
const groupLabel =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
results.forEach(secret => logger.log(secret));
|
|
20
|
-
logger.groupEnd();
|
|
15
|
+
const groupLabel = commands.secret.subcommands.list.groupLabel(uiAccountDescription(derivedAccountId));
|
|
16
|
+
uiLogger.group(groupLabel);
|
|
17
|
+
results.forEach(secret => uiLogger.log(secret));
|
|
18
|
+
uiLogger.groupEnd();
|
|
21
19
|
}
|
|
22
20
|
catch (err) {
|
|
23
|
-
|
|
21
|
+
uiLogger.error(commands.secret.subcommands.list.errors.list);
|
|
24
22
|
logError(err, new ApiErrorContext({
|
|
25
23
|
request: 'add secret',
|
|
26
24
|
accountId: derivedAccountId,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { updateSecret, fetchSecrets } from '@hubspot/local-dev-lib/api/secrets';
|
|
2
2
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
3
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
4
3
|
import { ApiErrorContext, logError } from '../../lib/errorHandlers/index.js';
|
|
5
4
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
6
|
-
import { uiAccountDescription } from '../../lib/ui/index.js';
|
|
7
5
|
import { secretValuePrompt, secretListPrompt, } from '../../lib/prompts/secretPrompt.js';
|
|
8
|
-
import {
|
|
6
|
+
import { commands } from '../../lang/en.js';
|
|
7
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
9
8
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
10
9
|
const command = 'update [name]';
|
|
11
|
-
const describe =
|
|
10
|
+
const describe = commands.secret.subcommands.update.describe;
|
|
12
11
|
async function handler(args) {
|
|
13
12
|
const { name, derivedAccountId } = args;
|
|
14
13
|
let secretName = name;
|
|
@@ -16,27 +15,20 @@ async function handler(args) {
|
|
|
16
15
|
try {
|
|
17
16
|
const { data: { results: secrets }, } = await fetchSecrets(derivedAccountId);
|
|
18
17
|
if (secretName && !secrets.includes(secretName)) {
|
|
19
|
-
|
|
20
|
-
secretName,
|
|
21
|
-
}));
|
|
18
|
+
uiLogger.error(commands.secret.subcommands.update.errors.noSecret(secretName));
|
|
22
19
|
process.exit(EXIT_CODES.ERROR);
|
|
23
20
|
}
|
|
24
21
|
if (!secretName) {
|
|
25
|
-
const { secretToModify } = await secretListPrompt(secrets,
|
|
22
|
+
const { secretToModify } = await secretListPrompt(secrets, commands.secret.subcommands.update.selectSecret);
|
|
26
23
|
secretName = secretToModify;
|
|
27
24
|
}
|
|
28
25
|
const { secretValue } = await secretValuePrompt();
|
|
29
26
|
await updateSecret(derivedAccountId, secretName, secretValue);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
secretName,
|
|
33
|
-
}));
|
|
34
|
-
logger.log(i18n(`commands.secret.subcommands.update.success.updateExplanation`));
|
|
27
|
+
uiLogger.success(commands.secret.subcommands.update.success.update(secretName, derivedAccountId));
|
|
28
|
+
uiLogger.log(commands.secret.subcommands.update.success.updateExplanation);
|
|
35
29
|
}
|
|
36
30
|
catch (err) {
|
|
37
|
-
|
|
38
|
-
secretName: secretName || '',
|
|
39
|
-
}));
|
|
31
|
+
uiLogger.error(commands.secret.subcommands.update.errors.update(secretName || ''));
|
|
40
32
|
logError(err, new ApiErrorContext({
|
|
41
33
|
request: 'update secret',
|
|
42
34
|
accountId: derivedAccountId,
|
|
@@ -45,7 +37,7 @@ async function handler(args) {
|
|
|
45
37
|
}
|
|
46
38
|
function updateSecretBuilder(yargs) {
|
|
47
39
|
yargs.positional('name', {
|
|
48
|
-
describe:
|
|
40
|
+
describe: commands.secret.subcommands.update.positionals.name.describe,
|
|
49
41
|
type: 'string',
|
|
50
42
|
});
|
|
51
43
|
return yargs;
|
package/commands/secret.js
CHANGED
|
@@ -2,10 +2,10 @@ import addSecretCommand from './secret/addSecret.js';
|
|
|
2
2
|
import listSecretCommand from './secret/listSecret.js';
|
|
3
3
|
import deleteSecretCommand from './secret/deleteSecret.js';
|
|
4
4
|
import updateSecretCommand from './secret/updateSecret.js';
|
|
5
|
-
import {
|
|
5
|
+
import { commands } from '../lang/en.js';
|
|
6
6
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
7
7
|
const command = ['secret', 'secrets'];
|
|
8
|
-
const describe =
|
|
8
|
+
const describe = commands.secret.describe;
|
|
9
9
|
function secretBuilder(yargs) {
|
|
10
10
|
yargs
|
|
11
11
|
.command(listSecretCommand)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import {
|
|
2
|
+
import { addConfigOptions, addUseEnvironmentOptions, addTestingOptions, } from '../../../lib/commonOpts.js';
|
|
3
3
|
import testAccountDeleteCommand from '../delete.js';
|
|
4
4
|
vi.mock('../../../lib/commonOpts');
|
|
5
5
|
describe('commands/testAccount/delete', () => {
|
|
6
6
|
const yargsMock = yargs;
|
|
7
7
|
describe('command', () => {
|
|
8
8
|
it('should have the correct command structure', () => {
|
|
9
|
-
expect(testAccountDeleteCommand.command).toEqual('delete
|
|
9
|
+
expect(testAccountDeleteCommand.command).toEqual('delete [test-account]');
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
12
|
describe('describe', () => {
|
|
@@ -20,8 +20,6 @@ describe('commands/testAccount/delete', () => {
|
|
|
20
20
|
expect(yargsMock.example).toHaveBeenCalledTimes(1);
|
|
21
21
|
expect(addTestingOptions).toHaveBeenCalledTimes(1);
|
|
22
22
|
expect(addTestingOptions).toHaveBeenCalledWith(yargsMock);
|
|
23
|
-
expect(addAccountOptions).toHaveBeenCalledTimes(1);
|
|
24
|
-
expect(addAccountOptions).toHaveBeenCalledWith(yargsMock);
|
|
25
23
|
expect(addConfigOptions).toHaveBeenCalledTimes(1);
|
|
26
24
|
expect(addConfigOptions).toHaveBeenCalledWith(yargsMock);
|
|
27
25
|
expect(addUseEnvironmentOptions).toHaveBeenCalledTimes(1);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CommonArgs, ConfigArgs,
|
|
2
|
-
type DeleteTestAccountArgs = CommonArgs &
|
|
3
|
-
|
|
1
|
+
import { CommonArgs, ConfigArgs, EnvironmentArgs, TestingArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
|
+
type DeleteTestAccountArgs = CommonArgs & ConfigArgs & TestingArgs & EnvironmentArgs & {
|
|
3
|
+
testAccount?: string | number;
|
|
4
|
+
force?: boolean;
|
|
4
5
|
};
|
|
5
6
|
declare const deleteTestAccountCommand: YargsCommandModule<unknown, DeleteTestAccountArgs>;
|
|
6
7
|
export default deleteTestAccountCommand;
|