@hubspot/cli 7.8.0-experimental.0 → 7.8.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/bin/cli.js +31 -27
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/__tests__/getStarted.test.js +2 -2
- package/commands/__tests__/mcp.test.js +1 -1
- package/commands/__tests__/project.test.js +2 -3
- package/commands/account/auth.js +1 -0
- 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 -6
- package/commands/app/migrate.js +13 -19
- package/commands/app/secret/add.js +2 -1
- package/commands/app/secret/delete.js +2 -1
- package/commands/app/secret/list.js +2 -1
- package/commands/app/secret/update.js +2 -1
- package/commands/app/secret.js +2 -1
- package/commands/app.js +2 -2
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +17 -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 -37
- 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 +8 -13
- 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.d.ts +1 -3
- package/commands/getStarted.js +68 -20
- 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/mcp/__tests__/setup.test.js +2 -2
- package/commands/mcp/setup.js +11 -2
- package/commands/mcp.js +3 -3
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +15 -13
- package/commands/project/__tests__/create.test.js +6 -6
- package/commands/project/__tests__/deploy.test.js +3 -7
- package/commands/project/__tests__/devUnifiedFlow.test.js +2 -4
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/list.test.js +31 -0
- package/commands/project/__tests__/logs.test.js +1 -4
- package/commands/project/__tests__/migrate.test.js +7 -7
- package/commands/project/__tests__/migrateApp.test.js +3 -7
- package/commands/project/__tests__/profile.test.js +1 -1
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.d.ts +2 -2
- package/commands/project/add.js +7 -10
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +4 -11
- package/commands/project/deploy.js +5 -5
- package/commands/project/dev/deprecatedFlow.js +9 -18
- package/commands/project/dev/index.js +21 -18
- package/commands/project/dev/unifiedFlow.js +15 -8
- package/commands/project/download.js +15 -16
- package/commands/project/installDeps.d.ts +2 -2
- package/commands/project/installDeps.js +9 -9
- package/commands/project/list.d.ts +4 -0
- package/commands/project/list.js +62 -0
- package/commands/project/listBuilds.js +12 -21
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +33 -12
- package/commands/project/migrateApp.js +10 -17
- package/commands/project/open.js +6 -14
- package/commands/project/profile/add.js +3 -3
- package/commands/project/profile/delete.js +1 -2
- package/commands/project/profile.js +2 -3
- package/commands/project/upload.js +16 -25
- package/commands/project/validate.js +7 -7
- package/commands/project/watch.js +13 -22
- package/commands/project.js +4 -3
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +39 -64
- 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/create.js +2 -2
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/testAccount/importData.d.ts +1 -1
- package/commands/testAccount/importData.js +1 -1
- package/commands/testAccount.js +1 -1
- package/commands/theme/preview.js +1 -4
- package/lang/en.d.ts +365 -111
- package/lang/en.js +409 -158
- package/lang/en.lyaml +4 -4
- package/lib/__tests__/buildAccount.test.js +4 -3
- 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__/hasFeature.test.js +145 -7
- 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 +19 -56
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.d.ts +2 -8
- package/lib/app/migrate.js +6 -81
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.d.ts +2 -2
- package/lib/buildAccount.js +32 -64
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configMigrate.js +88 -9
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +22 -1
- package/lib/constants.js +26 -1
- package/lib/dependencyManagement.d.ts +0 -5
- package/lib/dependencyManagement.js +9 -36
- 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/hasFeature.js +6 -0
- package/lib/lang.js +6 -5
- package/lib/links.d.ts +1 -0
- package/lib/links.js +14 -7
- package/lib/mcp/setup.js +1 -1
- 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 +74 -0
- package/lib/middleware/configMiddleware.d.ts +1 -1
- package/lib/middleware/configMiddleware.js +21 -81
- package/lib/middleware/fireAlarmMiddleware.js +15 -5
- 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 +87 -90
- package/lib/projects/__tests__/LocalDevProcess.test.js +231 -19
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +89 -63
- package/lib/projects/__tests__/deploy.test.js +73 -8
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +6 -2
- 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__/v2AddComponent.test.d.ts +1 -0
- package/lib/projects/add/__tests__/{v3AddComponent.test.js → v2AddComponent.test.js} +39 -39
- package/lib/projects/add/{v3AddComponent.d.ts → v2AddComponent.d.ts} +1 -1
- package/lib/projects/add/{v3AddComponent.js → v2AddComponent.js} +5 -5
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v2.test.d.ts +1 -0
- package/lib/projects/create/__tests__/{v3.test.js → v2.test.js} +82 -7
- package/lib/projects/create/index.js +4 -4
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/{v3.d.ts → v2.d.ts} +3 -3
- package/lib/projects/create/{v3.js → v2.js} +16 -13
- package/lib/projects/deploy.d.ts +1 -1
- package/lib/projects/deploy.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +10 -1
- package/lib/projects/localDev/AppDevModeInterface.js +118 -89
- package/lib/projects/localDev/DevServerManager.d.ts +11 -29
- package/lib/projects/localDev/DevServerManager.js +19 -61
- package/lib/projects/localDev/DevServerManager_DEPRECATED.d.ts +40 -0
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +120 -0
- package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
- package/lib/projects/localDev/LocalDevLogger.js +27 -6
- package/lib/projects/localDev/{LocalDevManager.js → LocalDevManager_DEPRECATED.js} +10 -11
- package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
- package/lib/projects/localDev/LocalDevProcess.js +93 -21
- package/lib/projects/localDev/LocalDevState.d.ts +12 -8
- package/lib/projects/localDev/LocalDevState.js +27 -17
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +6 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +94 -33
- package/lib/projects/localDev/helpers/account.d.ts +1 -1
- package/lib/projects/localDev/helpers/account.js +2 -2
- package/lib/projects/localDev/helpers/project.d.ts +3 -2
- package/lib/projects/localDev/helpers/project.js +49 -10
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +7 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +19 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +17 -8
- package/lib/projects/urls.d.ts +0 -1
- package/lib/projects/urls.js +0 -3
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/__tests__/projectAddPrompt.test.js +10 -10
- 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/installAppPrompt.d.ts +1 -6
- package/lib/prompts/installAppPrompt.js +1 -6
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.d.ts +2 -2
- package/lib/prompts/projectAddPrompt.js +9 -2
- 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 +30 -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/selectProjectTemplatePrompt.js +2 -0
- 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.d.ts +1 -0
- package/lib/theme/__tests__/migrate.test.js +233 -0
- package/lib/theme/migrate.d.ts +13 -0
- package/lib/theme/migrate.js +90 -0
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +112 -8
- 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 +72 -0
- package/lib/ui/uiMessages.js +75 -0
- package/lib/usageTracking.js +8 -8
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.js +1 -1
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +2 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
- package/mcp-server/tools/cms/HsListTool.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +2 -2
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsListTool.test.js +1 -1
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +3 -3
- package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/CreateProjectTool.js +5 -5
- package/mcp-server/tools/project/DeployProjectTool.js +1 -1
- package/mcp-server/tools/project/DocFetchTool.js +2 -2
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +7 -7
- 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.d.ts +4 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +13 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
- package/mcp-server/tools/project/UploadProjectTools.js +2 -2
- package/mcp-server/tools/project/ValidateProjectTool.js +1 -1
- package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +14 -12
- 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/tools/project/__tests__/GetConfigValuesTool.test.js +9 -8
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -1
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/constants.d.ts +1 -1
- package/mcp-server/tools/project/constants.js +9 -3
- package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
- package/mcp-server/utils/cliConfig.d.ts +1 -0
- package/mcp-server/utils/cliConfig.js +12 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +8 -12
- package/types/LocalDev.d.ts +19 -3
- package/ui/components/HorizontalSelectPrompt.js +1 -1
- package/ui/index.js +1 -1
- package/commands/getStartedV2.d.ts +0 -9
- package/commands/getStartedV2.js +0 -39
- 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/projects/localDev/DevServerManagerV2.d.ts +0 -22
- package/lib/projects/localDev/DevServerManagerV2.js +0 -81
- package/ui/components/Ascii.d.ts +0 -10
- package/ui/components/Ascii.js +0 -11
- package/ui/views/GetStarted.d.ts +0 -7
- package/ui/views/GetStarted.js +0 -157
- /package/{lib/middleware/__test__/utils.test.d.ts → commands/project/__tests__/list.test.d.ts} +0 -0
- /package/{lib/projects/add/__tests__/v3AddComponent.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
- /package/lib/{projects/create/__tests__/v3.test.d.ts → middleware/__test__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/projects/localDev/{LocalDevManager.d.ts → LocalDevManager_DEPRECATED.d.ts} +0 -0
|
@@ -10,11 +10,11 @@ import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
|
10
10
|
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
11
11
|
import * as buildAccount from '../../../lib/buildAccount.js';
|
|
12
12
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
13
|
-
import {
|
|
13
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
14
14
|
import * as sandboxesLib from '../../../lib/sandboxes.js';
|
|
15
15
|
import * as sandboxSync from '../../../lib/sandboxSync.js';
|
|
16
16
|
import { vi } from 'vitest';
|
|
17
|
-
vi.mock('
|
|
17
|
+
vi.mock('../../../lib/ui/logger.js');
|
|
18
18
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
19
19
|
vi.mock('../../../lib/commonOpts');
|
|
20
20
|
vi.mock('../../../lib/hasFeature');
|
|
@@ -207,7 +207,7 @@ describe('commands/sandbox/create', () => {
|
|
|
207
207
|
type: 'invalid',
|
|
208
208
|
force: true,
|
|
209
209
|
});
|
|
210
|
-
expect(
|
|
210
|
+
expect(uiLogger.error).toHaveBeenCalledTimes(1);
|
|
211
211
|
expect(processExitSpy).toHaveBeenCalled();
|
|
212
212
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
213
213
|
});
|
|
@@ -217,7 +217,7 @@ describe('commands/sandbox/create', () => {
|
|
|
217
217
|
type: 'standard',
|
|
218
218
|
force: true,
|
|
219
219
|
});
|
|
220
|
-
expect(
|
|
220
|
+
expect(uiLogger.error).toHaveBeenCalled();
|
|
221
221
|
expect(processExitSpy).toHaveBeenCalled();
|
|
222
222
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
223
223
|
});
|
|
@@ -230,7 +230,7 @@ describe('commands/sandbox/create', () => {
|
|
|
230
230
|
...args,
|
|
231
231
|
type: 'developer',
|
|
232
232
|
});
|
|
233
|
-
expect(
|
|
233
|
+
expect(uiLogger.error).toHaveBeenCalled();
|
|
234
234
|
expect(processExitSpy).toHaveBeenCalled();
|
|
235
235
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
236
236
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getAccountConfig, getEnv } from '@hubspot/local-dev-lib/config';
|
|
2
|
-
import {
|
|
2
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
3
3
|
import { isMissingScopeError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
4
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
5
5
|
import { HUBSPOT_ACCOUNT_TYPES, HUBSPOT_ACCOUNT_TYPE_STRINGS, } from '@hubspot/local-dev-lib/constants/config';
|
|
6
6
|
import { getValidEnv } from '@hubspot/local-dev-lib/environment';
|
|
7
|
-
import {
|
|
7
|
+
import { commands, lib } from '../../lang/en.js';
|
|
8
8
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
9
|
-
import { uiFeatureHighlight, uiBetaTag
|
|
9
|
+
import { uiFeatureHighlight, uiBetaTag } from '../../lib/ui/index.js';
|
|
10
10
|
import { SANDBOX_TYPE_MAP, getAvailableSyncTypes, SYNC_TYPES, validateSandboxUsageLimits, } from '../../lib/sandboxes.js';
|
|
11
11
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
12
12
|
import { sandboxTypePrompt } from '../../lib/prompts/sandboxesPrompt.js';
|
|
@@ -19,7 +19,7 @@ import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
|
19
19
|
import { hasFeature } from '../../lib/hasFeature.js';
|
|
20
20
|
import { FEATURES } from '../../lib/constants.js';
|
|
21
21
|
const command = 'create';
|
|
22
|
-
const describe = uiBetaTag(
|
|
22
|
+
const describe = uiBetaTag(commands.sandbox.subcommands.create.describe, false);
|
|
23
23
|
async function handler(args) {
|
|
24
24
|
const { name, type, force, derivedAccountId } = args;
|
|
25
25
|
const accountConfig = getAccountConfig(derivedAccountId);
|
|
@@ -27,19 +27,13 @@ async function handler(args) {
|
|
|
27
27
|
trackCommandUsage('sandbox-create', {}, derivedAccountId);
|
|
28
28
|
// Check if account config exists
|
|
29
29
|
if (!accountConfig) {
|
|
30
|
-
|
|
31
|
-
accountId: derivedAccountId,
|
|
32
|
-
authCommand: uiCommandReference('hs auth'),
|
|
33
|
-
}));
|
|
30
|
+
uiLogger.error(commands.sandbox.subcommands.create.failure.noAccountConfig(derivedAccountId));
|
|
34
31
|
process.exit(EXIT_CODES.ERROR);
|
|
35
32
|
}
|
|
36
33
|
// Default account is not a production portal
|
|
37
34
|
if (accountConfig.accountType &&
|
|
38
35
|
accountConfig.accountType !== HUBSPOT_ACCOUNT_TYPES.STANDARD) {
|
|
39
|
-
|
|
40
|
-
accountType: HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]],
|
|
41
|
-
accountName: accountConfig.name || '',
|
|
42
|
-
}));
|
|
36
|
+
uiLogger.error(commands.sandbox.subcommands.create.failure.invalidAccountType(HUBSPOT_ACCOUNT_TYPE_STRINGS[HUBSPOT_ACCOUNT_TYPES[accountConfig.accountType]], accountConfig.name || ''));
|
|
43
37
|
process.exit(EXIT_CODES.ERROR);
|
|
44
38
|
}
|
|
45
39
|
let typePrompt;
|
|
@@ -49,7 +43,7 @@ async function handler(args) {
|
|
|
49
43
|
typePrompt = await sandboxTypePrompt();
|
|
50
44
|
}
|
|
51
45
|
else {
|
|
52
|
-
|
|
46
|
+
uiLogger.error(commands.sandbox.subcommands.create.failure.optionMissing.type);
|
|
53
47
|
process.exit(EXIT_CODES.ERROR);
|
|
54
48
|
}
|
|
55
49
|
}
|
|
@@ -62,15 +56,14 @@ async function handler(args) {
|
|
|
62
56
|
}
|
|
63
57
|
catch (err) {
|
|
64
58
|
if (isMissingScopeError(err)) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
uiLogger.error(sandboxType === 'DEVELOPMENT_SANDBOX'
|
|
60
|
+
? lib.sandbox.create.developer.failure.scopes.message
|
|
61
|
+
: lib.sandbox.create.standard.failure.scopes.message);
|
|
68
62
|
const websiteOrigin = getHubSpotWebsiteOrigin(env);
|
|
69
63
|
const url = `${websiteOrigin}/personal-access-key/${derivedAccountId}`;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
url
|
|
73
|
-
}));
|
|
64
|
+
uiLogger.info(sandboxType === 'DEVELOPMENT_SANDBOX'
|
|
65
|
+
? lib.sandbox.create.developer.failure.scopes.instructions(accountConfig.name || derivedAccountId, url)
|
|
66
|
+
: lib.sandbox.create.standard.failure.scopes.instructions(accountConfig.name || derivedAccountId, url));
|
|
74
67
|
}
|
|
75
68
|
else {
|
|
76
69
|
logError(err);
|
|
@@ -82,13 +75,13 @@ async function handler(args) {
|
|
|
82
75
|
namePrompt = await hubspotAccountNamePrompt({ accountType: sandboxType });
|
|
83
76
|
}
|
|
84
77
|
else {
|
|
85
|
-
|
|
78
|
+
uiLogger.error(commands.sandbox.subcommands.create.failure.optionMissing.name);
|
|
86
79
|
process.exit(EXIT_CODES.ERROR);
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
82
|
const sandboxName = name || (namePrompt && namePrompt.name);
|
|
90
83
|
if (!sandboxName) {
|
|
91
|
-
|
|
84
|
+
uiLogger.error(commands.sandbox.subcommands.create.failure.optionMissing.name);
|
|
92
85
|
process.exit(EXIT_CODES.ERROR);
|
|
93
86
|
}
|
|
94
87
|
let contactRecordsSyncPromptResult = false;
|
|
@@ -100,7 +93,7 @@ async function handler(args) {
|
|
|
100
93
|
{
|
|
101
94
|
name: 'contactRecordsSyncPrompt',
|
|
102
95
|
type: 'confirm',
|
|
103
|
-
message:
|
|
96
|
+
message: commands.sandbox.sync.confirm.syncContactRecords.standard,
|
|
104
97
|
},
|
|
105
98
|
]);
|
|
106
99
|
contactRecordsSyncPromptResult = contactRecordsSyncPrompt;
|
|
@@ -121,10 +114,7 @@ async function handler(args) {
|
|
|
121
114
|
const sandboxAccountConfig = getAccountConfig(result.sandbox.sandboxHubId);
|
|
122
115
|
// Check if sandbox account config exists
|
|
123
116
|
if (!sandboxAccountConfig) {
|
|
124
|
-
|
|
125
|
-
accountId: result.sandbox.sandboxHubId,
|
|
126
|
-
authCommand: uiCommandReference('hs auth'),
|
|
127
|
-
}));
|
|
117
|
+
uiLogger.error(commands.sandbox.subcommands.create.failure.noSandboxAccountConfig(result.sandbox.sandboxHubId));
|
|
128
118
|
process.exit(EXIT_CODES.ERROR);
|
|
129
119
|
}
|
|
130
120
|
if (result && !canCreateV2Sandbox) {
|
|
@@ -160,20 +150,20 @@ function sandboxCreateBuilder(yargs) {
|
|
|
160
150
|
yargs.option('force', {
|
|
161
151
|
type: 'boolean',
|
|
162
152
|
alias: 'f',
|
|
163
|
-
describe:
|
|
153
|
+
describe: commands.sandbox.subcommands.create.options.force.describe,
|
|
164
154
|
});
|
|
165
155
|
yargs.option('name', {
|
|
166
|
-
describe:
|
|
156
|
+
describe: commands.sandbox.subcommands.create.options.name.describe,
|
|
167
157
|
type: 'string',
|
|
168
158
|
});
|
|
169
159
|
yargs.option('type', {
|
|
170
|
-
describe:
|
|
160
|
+
describe: commands.sandbox.subcommands.create.options.type.describe,
|
|
171
161
|
choices: Object.keys(SANDBOX_TYPE_MAP),
|
|
172
162
|
});
|
|
173
163
|
yargs.example([
|
|
174
164
|
[
|
|
175
|
-
'$0 sandbox create --name=MySandboxAccount --type=
|
|
176
|
-
|
|
165
|
+
'$0 sandbox create --name=MySandboxAccount --type=standard',
|
|
166
|
+
commands.sandbox.subcommands.create.examples.default,
|
|
177
167
|
],
|
|
178
168
|
]);
|
|
179
169
|
return yargs;
|
|
@@ -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,21 +94,17 @@ 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();
|
|
122
105
|
updateDefaultAccount(newDefaultAccount);
|
|
123
106
|
}
|
|
124
|
-
else {
|
|
107
|
+
else if (isDefaultAccount && force) {
|
|
125
108
|
// If force is specified, skip prompt and set the parent account id as the default account
|
|
126
109
|
updateDefaultAccount(parentAccountId);
|
|
127
110
|
}
|
|
@@ -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)
|