@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
package/commands/hubdb/fetch.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
2
2
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
3
3
|
import { downloadHubDbTable } from '@hubspot/local-dev-lib/hubdb';
|
|
4
4
|
import { selectHubDBTablePrompt } from '../../lib/prompts/selectHubDBTablePrompt.js';
|
|
5
5
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
6
|
-
import {
|
|
6
|
+
import { commands } from '../../lang/en.js';
|
|
7
7
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
8
|
const command = 'fetch [table-id] [dest]';
|
|
9
|
-
const describe =
|
|
9
|
+
const describe = commands.hubdb.subcommands.fetch.describe;
|
|
10
10
|
async function handler(args) {
|
|
11
11
|
const { derivedAccountId } = args;
|
|
12
12
|
trackCommandUsage('hubdb-fetch', {}, derivedAccountId);
|
|
@@ -19,10 +19,7 @@ async function handler(args) {
|
|
|
19
19
|
const tableId = args.tableId || promptAnswers.tableId;
|
|
20
20
|
const dest = args.dest || promptAnswers.dest;
|
|
21
21
|
const { filePath } = await downloadHubDbTable(derivedAccountId, tableId, dest);
|
|
22
|
-
|
|
23
|
-
path: filePath,
|
|
24
|
-
tableId,
|
|
25
|
-
}));
|
|
22
|
+
uiLogger.success(commands.hubdb.subcommands.fetch.success.fetch(tableId, filePath));
|
|
26
23
|
}
|
|
27
24
|
catch (e) {
|
|
28
25
|
logError(e);
|
|
@@ -30,11 +27,11 @@ async function handler(args) {
|
|
|
30
27
|
}
|
|
31
28
|
function hubdbFetchBuilder(yargs) {
|
|
32
29
|
yargs.positional('table-id', {
|
|
33
|
-
describe:
|
|
30
|
+
describe: commands.hubdb.subcommands.fetch.positionals.tableId.describe,
|
|
34
31
|
type: 'string',
|
|
35
32
|
});
|
|
36
33
|
yargs.positional('dest', {
|
|
37
|
-
describe:
|
|
34
|
+
describe: commands.hubdb.subcommands.fetch.positionals.dest.describe,
|
|
38
35
|
type: 'string',
|
|
39
36
|
});
|
|
40
37
|
return yargs;
|
package/commands/hubdb.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { YargsCommandModuleBucket } from '../types/Yargs.js';
|
|
2
2
|
export declare const command = "hubdb";
|
|
3
|
-
export declare const describe:
|
|
3
|
+
export declare const describe: "Commands for managing HubDB tables.";
|
|
4
4
|
declare const hubdbCommand: YargsCommandModuleBucket;
|
|
5
5
|
export default hubdbCommand;
|
package/commands/hubdb.js
CHANGED
|
@@ -3,10 +3,10 @@ import fetchCommand from './hubdb/fetch.js';
|
|
|
3
3
|
import deleteCommand from './hubdb/delete.js';
|
|
4
4
|
import clearCommand from './hubdb/clear.js';
|
|
5
5
|
import listCommand from './hubdb/list.js';
|
|
6
|
-
import {
|
|
6
|
+
import { commands } from '../lang/en.js';
|
|
7
7
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
8
8
|
export const command = 'hubdb';
|
|
9
|
-
export const describe =
|
|
9
|
+
export const describe = commands.hubdb.describe;
|
|
10
10
|
function hubdbBuilder(yargs) {
|
|
11
11
|
yargs
|
|
12
12
|
.command(clearCommand)
|
package/commands/init.js
CHANGED
|
@@ -9,7 +9,7 @@ import { getCwd } from '@hubspot/local-dev-lib/path';
|
|
|
9
9
|
import { toKebabCase } from '@hubspot/local-dev-lib/text';
|
|
10
10
|
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
11
11
|
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
|
|
12
|
-
import {
|
|
12
|
+
import { setCLILogLevel } from '../lib/commonOpts.js';
|
|
13
13
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
14
14
|
import { handleExit } from '../lib/process.js';
|
|
15
15
|
import { debugError, logError } from '../lib/errorHandlers/index.js';
|
|
@@ -74,7 +74,7 @@ async function handler(args) {
|
|
|
74
74
|
PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
75
75
|
const configPath = (configFlagValue && path.join(getCwd(), configFlagValue)) ||
|
|
76
76
|
getConfigPath('', useHiddenConfig);
|
|
77
|
-
|
|
77
|
+
setCLILogLevel(args);
|
|
78
78
|
if (!disableTracking) {
|
|
79
79
|
trackCommandUsage('init', {
|
|
80
80
|
authType,
|
|
@@ -99,7 +99,6 @@ async function handler(args) {
|
|
|
99
99
|
uiLogger.error(commands.init.errors.bothConfigFilesNotAllowed(path));
|
|
100
100
|
process.exit(EXIT_CODES.ERROR);
|
|
101
101
|
}
|
|
102
|
-
trackAuthAction('init', authType, TRACKING_STATUS.STARTED, parsedUserProvidedAccountId);
|
|
103
102
|
createEmptyConfigFile({ path: configPath }, useHiddenConfig);
|
|
104
103
|
//Needed to load deprecated config
|
|
105
104
|
loadConfig(configPath, args);
|
package/commands/lint.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { lint } from '@hubspot/local-dev-lib/cms/validate';
|
|
2
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
2
|
import { logError } from '../lib/errorHandlers/index.js';
|
|
4
3
|
import { trackCommandUsage } from '../lib/usageTracking.js';
|
|
5
|
-
import {
|
|
4
|
+
import { commands } from '../lang/en.js';
|
|
6
5
|
import { resolveLocalPath } from '../lib/filesystem.js';
|
|
7
6
|
import { EXIT_CODES } from '../lib/enums/exitCodes.js';
|
|
8
7
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
8
|
+
import { uiLogger } from '../lib/ui/logger.js';
|
|
9
9
|
const command = 'lint <path>';
|
|
10
10
|
// Hiding since this command is still experimental
|
|
11
11
|
const describe = undefined; //'Lint a file or folder for HubL syntax';
|
|
@@ -14,8 +14,12 @@ function getErrorsFromHublValidationObject(validation) {
|
|
|
14
14
|
}
|
|
15
15
|
function printHublValidationError(err) {
|
|
16
16
|
const { severity, message, lineno, startPosition } = err;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
if (severity === 'FATAL') {
|
|
18
|
+
uiLogger.error(`[${lineno}, ${startPosition}]: ${message}`);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
uiLogger.warn(`[${lineno}, ${startPosition}]: ${message}`);
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
function printHublValidationResult({ file, validation }) {
|
|
21
25
|
let count = 0;
|
|
@@ -26,7 +30,7 @@ function printHublValidationResult({ file, validation }) {
|
|
|
26
30
|
if (!errors.length) {
|
|
27
31
|
return count;
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
uiLogger.group(file);
|
|
30
34
|
errors.forEach(err => {
|
|
31
35
|
if (err.reason !== 'SYNTAX_ERROR') {
|
|
32
36
|
return;
|
|
@@ -34,17 +38,15 @@ function printHublValidationResult({ file, validation }) {
|
|
|
34
38
|
++count;
|
|
35
39
|
printHublValidationError(err);
|
|
36
40
|
});
|
|
37
|
-
|
|
41
|
+
uiLogger.groupEnd();
|
|
38
42
|
return count;
|
|
39
43
|
}
|
|
40
44
|
async function handler(args) {
|
|
41
45
|
const { path: lintPath, derivedAccountId } = args;
|
|
42
46
|
const localPath = resolveLocalPath(lintPath);
|
|
43
|
-
const groupName =
|
|
44
|
-
path: localPath,
|
|
45
|
-
});
|
|
47
|
+
const groupName = commands.lint.groupName(localPath);
|
|
46
48
|
trackCommandUsage('lint', undefined, derivedAccountId);
|
|
47
|
-
|
|
49
|
+
uiLogger.group(groupName);
|
|
48
50
|
let count = 0;
|
|
49
51
|
try {
|
|
50
52
|
await lint(derivedAccountId, localPath, (result) => {
|
|
@@ -52,18 +54,16 @@ async function handler(args) {
|
|
|
52
54
|
});
|
|
53
55
|
}
|
|
54
56
|
catch (err) {
|
|
55
|
-
|
|
57
|
+
uiLogger.groupEnd();
|
|
56
58
|
logError(err, { accountId: derivedAccountId });
|
|
57
59
|
process.exit(EXIT_CODES.ERROR);
|
|
58
60
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
count,
|
|
62
|
-
}));
|
|
61
|
+
uiLogger.groupEnd();
|
|
62
|
+
uiLogger.log(commands.lint.issuesFound(count));
|
|
63
63
|
}
|
|
64
64
|
function lintBuilder(yargs) {
|
|
65
65
|
yargs.positional('path', {
|
|
66
|
-
describe:
|
|
66
|
+
describe: commands.lint.positionals.path.describe,
|
|
67
67
|
required: true,
|
|
68
68
|
type: 'string',
|
|
69
69
|
});
|
package/commands/list.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { trackCommandUsage } from '../lib/usageTracking.js';
|
|
3
3
|
import { isPathFolder } from '../lib/filesystem.js';
|
|
4
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
5
4
|
import { logError } from '../lib/errorHandlers/index.js';
|
|
6
5
|
import { getDirectoryContentsByPath } from '@hubspot/local-dev-lib/api/fileMapper';
|
|
7
6
|
import { HUBSPOT_FOLDER, MARKETPLACE_FOLDER } from '../lib/constants.js';
|
|
8
|
-
import { i18n } from '../lib/lang.js';
|
|
9
7
|
import { EXIT_CODES } from '../lib/enums/exitCodes.js';
|
|
10
8
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
9
|
+
import { uiLogger } from '../lib/ui/logger.js';
|
|
10
|
+
import { commands } from '../lang/en.js';
|
|
11
11
|
function addColorToContents(fileOrFolder) {
|
|
12
12
|
if (!isPathFolder(fileOrFolder)) {
|
|
13
13
|
return chalk.reset.cyan(fileOrFolder);
|
|
@@ -35,15 +35,13 @@ function sortContents(a, b) {
|
|
|
35
35
|
return a.localeCompare(b);
|
|
36
36
|
}
|
|
37
37
|
const command = ['list [path]', 'ls [path]'];
|
|
38
|
-
const describe =
|
|
38
|
+
const describe = commands.list.describe;
|
|
39
39
|
async function handler(args) {
|
|
40
40
|
const { path, derivedAccountId } = args;
|
|
41
41
|
const directoryPath = path || '/';
|
|
42
42
|
let contentsResp;
|
|
43
43
|
trackCommandUsage('list', undefined, derivedAccountId);
|
|
44
|
-
|
|
45
|
-
path: directoryPath,
|
|
46
|
-
}));
|
|
44
|
+
uiLogger.debug(commands.list.gettingPathContents(directoryPath));
|
|
47
45
|
try {
|
|
48
46
|
const { data } = await getDirectoryContentsByPath(derivedAccountId, directoryPath);
|
|
49
47
|
contentsResp = data;
|
|
@@ -53,9 +51,7 @@ async function handler(args) {
|
|
|
53
51
|
process.exit(EXIT_CODES.ERROR);
|
|
54
52
|
}
|
|
55
53
|
if (!contentsResp.folder) {
|
|
56
|
-
|
|
57
|
-
path: directoryPath,
|
|
58
|
-
}));
|
|
54
|
+
uiLogger.info(commands.list.noFilesFoundAtPath(directoryPath));
|
|
59
55
|
return;
|
|
60
56
|
}
|
|
61
57
|
// getDirectoryContentsByPath omits @hubspot
|
|
@@ -63,21 +59,19 @@ async function handler(args) {
|
|
|
63
59
|
? ['@hubspot', ...contentsResp.children]
|
|
64
60
|
: contentsResp.children;
|
|
65
61
|
if (contents.length === 0) {
|
|
66
|
-
|
|
67
|
-
path: directoryPath,
|
|
68
|
-
}));
|
|
62
|
+
uiLogger.info(commands.list.noFilesFoundAtPath(directoryPath));
|
|
69
63
|
return;
|
|
70
64
|
}
|
|
71
65
|
const folderContentsOutput = contents
|
|
72
66
|
.map(addColorToContents)
|
|
73
67
|
.sort(sortContents)
|
|
74
68
|
.join('\n');
|
|
75
|
-
|
|
69
|
+
uiLogger.log(folderContentsOutput);
|
|
76
70
|
process.exit(EXIT_CODES.SUCCESS);
|
|
77
71
|
}
|
|
78
72
|
function cmsListBuilder(yargs) {
|
|
79
73
|
yargs.positional('path', {
|
|
80
|
-
describe:
|
|
74
|
+
describe: commands.list.positionals.path.describe,
|
|
81
75
|
type: 'string',
|
|
82
76
|
});
|
|
83
77
|
yargs.example([['$0 list'], ['$0 list /'], ['$0 list my-modules']]);
|
package/commands/logs.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { trackCommandUsage } from '../lib/usageTracking.js';
|
|
2
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
2
|
import { outputLogs } from '../lib/ui/serverlessFunctionLogs.js';
|
|
4
3
|
import { getFunctionLogs, getLatestFunctionLog, } from '@hubspot/local-dev-lib/api/functions';
|
|
5
4
|
import { tailLogs } from '../lib/serverlessLogs.js';
|
|
6
|
-
import { i18n } from '../lib/lang.js';
|
|
7
5
|
import { promptUser } from '../lib/prompts/promptUtils.js';
|
|
8
6
|
import { EXIT_CODES } from '../lib/enums/exitCodes.js';
|
|
9
7
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
10
8
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
9
|
+
import { uiLogger } from '../lib/ui/logger.js';
|
|
10
|
+
import { commands } from '../lang/en.js';
|
|
11
11
|
const handleLogsError = (e, accountId, functionPath) => {
|
|
12
12
|
if (isHubSpotHttpError(e) && (e.status === 404 || e.status == 400)) {
|
|
13
|
-
|
|
14
|
-
accountId,
|
|
15
|
-
functionPath,
|
|
16
|
-
}));
|
|
13
|
+
uiLogger.error(commands.logs.errors.noLogsFound(functionPath, accountId));
|
|
17
14
|
}
|
|
18
15
|
};
|
|
19
16
|
const endpointLog = async (accountId, functionPath, options) => {
|
|
@@ -24,10 +21,7 @@ const endpointLog = async (accountId, functionPath, options) => {
|
|
|
24
21
|
follow,
|
|
25
22
|
endpoint: functionPath,
|
|
26
23
|
};
|
|
27
|
-
|
|
28
|
-
latest,
|
|
29
|
-
functionPath,
|
|
30
|
-
}));
|
|
24
|
+
uiLogger.debug(commands.logs.gettingLogs(latest, functionPath));
|
|
31
25
|
let logsResp;
|
|
32
26
|
if (follow) {
|
|
33
27
|
const tailCall = (after) => getFunctionLogs(accountId, functionPath, { after });
|
|
@@ -67,48 +61,48 @@ const endpointLog = async (accountId, functionPath, options) => {
|
|
|
67
61
|
}
|
|
68
62
|
};
|
|
69
63
|
const command = 'logs [endpoint]';
|
|
70
|
-
const describe =
|
|
64
|
+
const describe = commands.logs.describe;
|
|
71
65
|
const handler = async (options) => {
|
|
72
66
|
const { endpoint: endpointArgValue, latest, derivedAccountId } = options;
|
|
73
67
|
trackCommandUsage('logs', latest ? { action: 'latest' } : {}, derivedAccountId);
|
|
74
68
|
const { endpointPromptValue } = await promptUser({
|
|
75
69
|
name: 'endpointPromptValue',
|
|
76
|
-
message:
|
|
70
|
+
message: commands.logs.endpointPrompt,
|
|
77
71
|
when: !endpointArgValue,
|
|
78
72
|
});
|
|
79
73
|
await endpointLog(derivedAccountId, endpointArgValue || endpointPromptValue, options);
|
|
80
74
|
};
|
|
81
75
|
function logsBuilder(yargs) {
|
|
82
76
|
yargs.positional('endpoint', {
|
|
83
|
-
describe:
|
|
77
|
+
describe: commands.logs.positionals.endpoint.describe,
|
|
84
78
|
type: 'string',
|
|
85
79
|
});
|
|
86
80
|
yargs
|
|
87
81
|
.options({
|
|
88
82
|
latest: {
|
|
89
83
|
alias: 'l',
|
|
90
|
-
describe:
|
|
84
|
+
describe: commands.logs.options.latest.describe,
|
|
91
85
|
type: 'boolean',
|
|
92
86
|
},
|
|
93
87
|
compact: {
|
|
94
|
-
describe:
|
|
88
|
+
describe: commands.logs.options.compact.describe,
|
|
95
89
|
type: 'boolean',
|
|
96
90
|
},
|
|
97
91
|
follow: {
|
|
98
92
|
alias: ['f'],
|
|
99
|
-
describe:
|
|
93
|
+
describe: commands.logs.options.follow.describe,
|
|
100
94
|
type: 'boolean',
|
|
101
95
|
},
|
|
102
96
|
limit: {
|
|
103
|
-
describe:
|
|
97
|
+
describe: commands.logs.options.limit.describe,
|
|
104
98
|
type: 'number',
|
|
105
99
|
},
|
|
106
100
|
})
|
|
107
101
|
.conflicts('follow', 'limit');
|
|
108
102
|
yargs.example([
|
|
109
|
-
['$0 logs my-endpoint',
|
|
110
|
-
['$0 logs my-endpoint --limit=10',
|
|
111
|
-
['$0 logs my-endpoint --follow',
|
|
103
|
+
['$0 logs my-endpoint', commands.logs.examples.default],
|
|
104
|
+
['$0 logs my-endpoint --limit=10', commands.logs.examples.limit],
|
|
105
|
+
['$0 logs my-endpoint --follow', commands.logs.examples.follow],
|
|
112
106
|
]);
|
|
113
107
|
return yargs;
|
|
114
108
|
}
|
|
@@ -3,12 +3,12 @@ vi.mock('../../../lib/commonOpts');
|
|
|
3
3
|
describe('commands/mcp/setup', () => {
|
|
4
4
|
describe('command', () => {
|
|
5
5
|
it('should have the correct command structure', () => {
|
|
6
|
-
expect(setupCommand.command).toEqual(['setup'
|
|
6
|
+
expect(setupCommand.command).toEqual(['setup']);
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
describe('describe', () => {
|
|
10
10
|
it('should be undefined to keep the command hidden', () => {
|
|
11
|
-
expect(setupCommand.describe).
|
|
11
|
+
expect(setupCommand.describe).toBeDefined();
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
14
|
describe('builder', () => {
|
package/commands/mcp/setup.js
CHANGED
|
@@ -4,9 +4,18 @@ import { commands } from '../../lang/en.js';
|
|
|
4
4
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
5
5
|
import { addMcpServerToConfig, supportedTools } from '../../lib/mcp/setup.js';
|
|
6
6
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { hasFeature } from '../../lib/hasFeature.js';
|
|
8
|
+
import { FEATURES } from '../../lib/constants.js';
|
|
9
|
+
import { uiBetaTag } from '../../lib/ui/index.js';
|
|
10
|
+
const command = ['setup'];
|
|
11
|
+
const describe = uiBetaTag(commands.mcp.setup.describe, false);
|
|
9
12
|
async function handler(args) {
|
|
13
|
+
const { derivedAccountId } = args;
|
|
14
|
+
const hasMcpAccess = await hasFeature(derivedAccountId, FEATURES.MCP_ACCESS);
|
|
15
|
+
if (!hasMcpAccess) {
|
|
16
|
+
uiLogger.error(commands.mcp.setup.errors.needsMcpAccess(derivedAccountId));
|
|
17
|
+
process.exit(EXIT_CODES.ERROR);
|
|
18
|
+
}
|
|
10
19
|
try {
|
|
11
20
|
await import('@modelcontextprotocol/sdk/server/mcp.js');
|
|
12
21
|
}
|
package/commands/mcp.js
CHANGED
|
@@ -2,14 +2,14 @@ import startCommand from './mcp/start.js';
|
|
|
2
2
|
import setupCommand from './mcp/setup.js';
|
|
3
3
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
4
4
|
import { commands } from '../lang/en.js';
|
|
5
|
+
import { uiBetaTag } from '../lib/ui/index.js';
|
|
5
6
|
const command = 'mcp';
|
|
6
|
-
|
|
7
|
-
const describe = undefined;
|
|
7
|
+
const describe = uiBetaTag(commands.mcp.describe, false);
|
|
8
8
|
function mcpBuilder(yargs) {
|
|
9
9
|
yargs.command(startCommand).command(setupCommand).demandCommand(1, '');
|
|
10
10
|
return yargs;
|
|
11
11
|
}
|
|
12
|
-
const builder = makeYargsBuilder(mcpBuilder, command,
|
|
12
|
+
const builder = makeYargsBuilder(mcpBuilder, command, describe, {
|
|
13
13
|
useGlobalOptions: true,
|
|
14
14
|
});
|
|
15
15
|
const mcpCommand = {
|
package/commands/mv.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { moveFile } from '@hubspot/local-dev-lib/api/fileMapper';
|
|
3
2
|
import { isSpecifiedError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
3
|
import { logError, ApiErrorContext } from '../lib/errorHandlers/index.js';
|
|
5
4
|
import { trackCommandUsage } from '../lib/usageTracking.js';
|
|
6
5
|
import { isPathFolder } from '../lib/filesystem.js';
|
|
7
|
-
import { i18n } from '../lib/lang.js';
|
|
8
6
|
import { uiBetaTag } from '../lib/ui/index.js';
|
|
9
7
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
8
|
+
import { uiLogger } from '../lib/ui/logger.js';
|
|
9
|
+
import { commands } from '../lang/en.js';
|
|
10
10
|
function getCorrectedDestPath(srcPath, destPath) {
|
|
11
11
|
if (!isPathFolder(srcPath)) {
|
|
12
12
|
return destPath;
|
|
@@ -15,29 +15,18 @@ function getCorrectedDestPath(srcPath, destPath) {
|
|
|
15
15
|
return `${destPath}/${srcPath.split('/').pop()}`;
|
|
16
16
|
}
|
|
17
17
|
const command = 'mv <srcPath> <destPath>';
|
|
18
|
-
const describe = uiBetaTag(
|
|
18
|
+
const describe = uiBetaTag(commands.mv.describe, false);
|
|
19
19
|
async function handler(args) {
|
|
20
20
|
const { srcPath, destPath, derivedAccountId } = args;
|
|
21
21
|
trackCommandUsage('mv', undefined, derivedAccountId);
|
|
22
22
|
try {
|
|
23
23
|
await moveFile(derivedAccountId, srcPath, getCorrectedDestPath(srcPath, destPath));
|
|
24
|
-
|
|
25
|
-
accountId: derivedAccountId,
|
|
26
|
-
destPath,
|
|
27
|
-
srcPath,
|
|
28
|
-
}));
|
|
24
|
+
uiLogger.success(commands.mv.move(srcPath, destPath, derivedAccountId));
|
|
29
25
|
}
|
|
30
26
|
catch (error) {
|
|
31
|
-
|
|
32
|
-
accountId: derivedAccountId,
|
|
33
|
-
destPath,
|
|
34
|
-
srcPath,
|
|
35
|
-
}));
|
|
27
|
+
uiLogger.error(commands.mv.errors.moveFailed(srcPath, destPath, derivedAccountId));
|
|
36
28
|
if (isSpecifiedError(error, { statusCode: 409 })) {
|
|
37
|
-
|
|
38
|
-
destPath,
|
|
39
|
-
srcPath,
|
|
40
|
-
}));
|
|
29
|
+
uiLogger.error(commands.mv.errors.sourcePathExists(srcPath, destPath));
|
|
41
30
|
}
|
|
42
31
|
else {
|
|
43
32
|
logError(error, new ApiErrorContext({
|
package/commands/open.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { trackCommandUsage } from '../lib/usageTracking.js';
|
|
2
2
|
import { logSiteLinks, getSiteLinksAsArray, openLink } from '../lib/links.js';
|
|
3
3
|
import { promptUser } from '../lib/prompts/promptUtils.js';
|
|
4
|
-
import {
|
|
4
|
+
import { commands } from '../lang/en.js';
|
|
5
5
|
import { EXIT_CODES } from '../lib/enums/exitCodes.js';
|
|
6
6
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
7
7
|
const separator = ' => ';
|
|
@@ -10,7 +10,7 @@ async function createListPrompt(accountId) {
|
|
|
10
10
|
name: 'open',
|
|
11
11
|
type: 'rawlist',
|
|
12
12
|
pageSize: 20,
|
|
13
|
-
message:
|
|
13
|
+
message: commands.open.selectLink,
|
|
14
14
|
choices: getSiteLinksAsArray(accountId)
|
|
15
15
|
.filter(l => !!l.url)
|
|
16
16
|
.map(l => ({
|
|
@@ -20,7 +20,7 @@ async function createListPrompt(accountId) {
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
const command = 'open [shortcut]';
|
|
23
|
-
const describe =
|
|
23
|
+
const describe = commands.open.describe;
|
|
24
24
|
async function handler(args) {
|
|
25
25
|
const { shortcut, list, derivedAccountId } = args;
|
|
26
26
|
trackCommandUsage('open', undefined, derivedAccountId);
|
|
@@ -38,12 +38,12 @@ async function handler(args) {
|
|
|
38
38
|
}
|
|
39
39
|
function openBuilder(yargs) {
|
|
40
40
|
yargs.positional('[shortcut]', {
|
|
41
|
-
describe:
|
|
41
|
+
describe: commands.open.positionals.shortcut.describe,
|
|
42
42
|
type: 'string',
|
|
43
43
|
});
|
|
44
44
|
yargs.option('list', {
|
|
45
45
|
alias: 'l',
|
|
46
|
-
describe:
|
|
46
|
+
describe: commands.open.options.list.describe,
|
|
47
47
|
type: 'boolean',
|
|
48
48
|
});
|
|
49
49
|
yargs.example([
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
2
|
import projectAddCommand from '../add.js';
|
|
3
3
|
import { marketplaceDistribution, oAuth, privateDistribution, staticAuth, } from '../../../lib/constants.js';
|
|
4
|
-
import {
|
|
4
|
+
import { v2AddComponent } from '../../../lib/projects/add/v2AddComponent.js';
|
|
5
5
|
import { legacyAddComponent } from '../../../lib/projects/add/legacyAddComponent.js';
|
|
6
6
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
7
|
-
import {
|
|
7
|
+
import { isV2Project } from '../../../lib/projects/platformVersion.js';
|
|
8
8
|
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
9
9
|
vi.mock('../../../lib/commonOpts');
|
|
10
|
-
vi.mock('../../../lib/
|
|
10
|
+
vi.mock('../../../lib/ui/logger.js');
|
|
11
|
+
vi.mock('../../../lib/errorHandlers/index.js');
|
|
12
|
+
vi.mock('../../../lib/projects/add/v2AddComponent');
|
|
11
13
|
vi.mock('../../../lib/projects/add/legacyAddComponent');
|
|
12
14
|
vi.mock('../../../lib/projects/config');
|
|
13
15
|
vi.mock('../../../lib/projects/platformVersion');
|
|
14
16
|
vi.mock('../../../lib/usageTracking');
|
|
15
|
-
const
|
|
17
|
+
const mockedV2AddComponent = vi.mocked(v2AddComponent);
|
|
16
18
|
const mockedLegacyAddComponent = vi.mocked(legacyAddComponent);
|
|
17
19
|
const mockedGetProjectConfig = vi.mocked(getProjectConfig);
|
|
18
|
-
const
|
|
20
|
+
const mockedUseV2Api = vi.mocked(isV2Project);
|
|
19
21
|
const mockedTrackCommandUsage = vi.mocked(trackCommandUsage);
|
|
20
22
|
describe('commands/project/add', () => {
|
|
21
23
|
const yargsMock = yargs;
|
|
@@ -59,7 +61,7 @@ describe('commands/project/add', () => {
|
|
|
59
61
|
const mockProjectConfig = {
|
|
60
62
|
name: 'test-project',
|
|
61
63
|
srcDir: 'src',
|
|
62
|
-
platformVersion: '
|
|
64
|
+
platformVersion: '2025.2',
|
|
63
65
|
};
|
|
64
66
|
const mockProjectDir = '/path/to/project';
|
|
65
67
|
const mockArgs = {
|
|
@@ -73,23 +75,23 @@ describe('commands/project/add', () => {
|
|
|
73
75
|
projectDir: mockProjectDir,
|
|
74
76
|
});
|
|
75
77
|
mockedTrackCommandUsage.mockResolvedValue();
|
|
76
|
-
|
|
78
|
+
mockedV2AddComponent.mockResolvedValue();
|
|
77
79
|
mockedLegacyAddComponent.mockResolvedValue();
|
|
78
80
|
vi.spyOn(process, 'exit').mockImplementation(() => {
|
|
79
81
|
throw new Error('process.exit called');
|
|
80
82
|
});
|
|
81
83
|
});
|
|
82
|
-
it('should call
|
|
83
|
-
|
|
84
|
+
it('should call v2AddComponent with accountId for v2 projects', async () => {
|
|
85
|
+
mockedUseV2Api.mockReturnValue(true);
|
|
84
86
|
await expect(projectAddCommand.handler(mockArgs)).rejects.toThrow('process.exit called');
|
|
85
|
-
expect(
|
|
87
|
+
expect(mockedV2AddComponent).toHaveBeenCalledWith(mockArgs, mockProjectDir, mockProjectConfig, 123);
|
|
86
88
|
expect(mockedLegacyAddComponent).not.toHaveBeenCalled();
|
|
87
89
|
});
|
|
88
|
-
it('should call legacyAddComponent for non-
|
|
89
|
-
|
|
90
|
+
it('should call legacyAddComponent for non-v2 projects', async () => {
|
|
91
|
+
mockedUseV2Api.mockReturnValue(false);
|
|
90
92
|
await expect(projectAddCommand.handler(mockArgs)).rejects.toThrow('process.exit called');
|
|
91
93
|
expect(mockedLegacyAddComponent).toHaveBeenCalledWith(mockArgs, mockProjectDir, mockProjectConfig, 123);
|
|
92
|
-
expect(
|
|
94
|
+
expect(mockedV2AddComponent).not.toHaveBeenCalled();
|
|
93
95
|
});
|
|
94
96
|
it('should exit with error when project config is not found', async () => {
|
|
95
97
|
mockedGetProjectConfig.mockResolvedValue({
|
|
@@ -48,10 +48,10 @@ describe('commands/project/create', () => {
|
|
|
48
48
|
projectCreateCommand.builder(yargsMock);
|
|
49
49
|
const optionsCall = optionsSpy.mock.calls[0][0];
|
|
50
50
|
expect(optionsCall['platform-version']).toEqual(expect.objectContaining({
|
|
51
|
-
|
|
51
|
+
describe: 'The target platform version for the new project.',
|
|
52
52
|
type: 'string',
|
|
53
53
|
choices: ['2023.2', '2025.1', '2025.2'],
|
|
54
|
-
default: '
|
|
54
|
+
default: '2025.2',
|
|
55
55
|
}));
|
|
56
56
|
});
|
|
57
57
|
it('should define project base option with correct choices', () => {
|
|
@@ -59,7 +59,7 @@ describe('commands/project/create', () => {
|
|
|
59
59
|
projectCreateCommand.builder(yargsMock);
|
|
60
60
|
const optionsCall = optionsSpy.mock.calls[0][0];
|
|
61
61
|
expect(optionsCall['project-base']).toEqual(expect.objectContaining({
|
|
62
|
-
|
|
62
|
+
describe: 'The top level component to include in the project.',
|
|
63
63
|
type: 'string',
|
|
64
64
|
choices: ['empty', 'app'],
|
|
65
65
|
}));
|
|
@@ -69,7 +69,7 @@ describe('commands/project/create', () => {
|
|
|
69
69
|
projectCreateCommand.builder(yargsMock);
|
|
70
70
|
const optionsCall = optionsSpy.mock.calls[0][0];
|
|
71
71
|
expect(optionsCall.distribution).toEqual(expect.objectContaining({
|
|
72
|
-
|
|
72
|
+
describe: 'How the app will be distributed.',
|
|
73
73
|
type: 'string',
|
|
74
74
|
choices: ['private', 'marketplace'],
|
|
75
75
|
}));
|
|
@@ -79,7 +79,7 @@ describe('commands/project/create', () => {
|
|
|
79
79
|
projectCreateCommand.builder(yargsMock);
|
|
80
80
|
const optionsCall = optionsSpy.mock.calls[0][0];
|
|
81
81
|
expect(optionsCall.auth).toEqual(expect.objectContaining({
|
|
82
|
-
|
|
82
|
+
describe: 'Authentication model for the application.',
|
|
83
83
|
type: 'string',
|
|
84
84
|
choices: ['oauth', 'static'],
|
|
85
85
|
}));
|
|
@@ -89,7 +89,7 @@ describe('commands/project/create', () => {
|
|
|
89
89
|
projectCreateCommand.builder(yargsMock);
|
|
90
90
|
const optionsCall = optionsSpy.mock.calls[0][0];
|
|
91
91
|
expect(optionsCall.features).toEqual(expect.objectContaining({
|
|
92
|
-
|
|
92
|
+
describe: 'Features to include in the project. Only valid if project-base is app',
|
|
93
93
|
type: 'array',
|
|
94
94
|
}));
|
|
95
95
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { HttpStatusCode } from 'axios';
|
|
2
2
|
import yargs from 'yargs';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
5
4
|
import * as configUtils from '@hubspot/local-dev-lib/config';
|
|
6
5
|
import * as projectApiUtils from '@hubspot/local-dev-lib/api/projects';
|
|
7
6
|
import * as ui from '../../../lib/ui/index.js';
|
|
@@ -29,7 +28,7 @@ vi.mock('../../../lib/prompts/projectNamePrompt');
|
|
|
29
28
|
vi.mock('../../../lib/prompts/promptUtils');
|
|
30
29
|
vi.mock('../../../lib/usageTracking');
|
|
31
30
|
vi.mock('../../../lib/ui/logger');
|
|
32
|
-
vi.mock('
|
|
31
|
+
vi.mock('../../ui/logger.js');
|
|
33
32
|
vi.spyOn(ui, 'uiLine');
|
|
34
33
|
const uiCommandReferenceSpy = vi.spyOn(ui, 'uiCommandReference');
|
|
35
34
|
const uiAccountDescriptionSpy = vi.spyOn(ui, 'uiAccountDescription');
|
|
@@ -62,9 +61,6 @@ describe('commands/project/deploy', () => {
|
|
|
62
61
|
});
|
|
63
62
|
});
|
|
64
63
|
describe('describe', () => {
|
|
65
|
-
it('should contain the beta tag', () => {
|
|
66
|
-
expect(projectDeployCommand.describe).toContain('[BETA]');
|
|
67
|
-
});
|
|
68
64
|
it('should provide a description', () => {
|
|
69
65
|
expect(projectDeployCommand.describe).toBeDefined();
|
|
70
66
|
});
|
|
@@ -300,8 +296,8 @@ describe('commands/project/deploy', () => {
|
|
|
300
296
|
});
|
|
301
297
|
});
|
|
302
298
|
await projectDeployCommand.handler(args);
|
|
303
|
-
expect(
|
|
304
|
-
expect(
|
|
299
|
+
expect(uiLogger.error).toHaveBeenCalledTimes(1);
|
|
300
|
+
expect(uiLogger.error).toHaveBeenCalledWith(`The request for 'project deploy' in account ${args.derivedAccountId} failed due to a client error.`);
|
|
305
301
|
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
306
302
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
307
303
|
});
|