@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/filemanager.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import upload from './filemanager/upload.js';
|
|
2
2
|
import fetch from './filemanager/fetch.js';
|
|
3
|
-
import {
|
|
3
|
+
import { commands } from '../lang/en.js';
|
|
4
4
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
5
5
|
const command = 'filemanager';
|
|
6
|
-
const describe =
|
|
6
|
+
const describe = commands.filemanager.describe;
|
|
7
7
|
function fileManagerBuilder(yargs) {
|
|
8
8
|
yargs.command(upload).command(fetch).demandCommand(1, '');
|
|
9
9
|
return yargs;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
2
2
|
import { buildPackage, getBuildStatus, } from '@hubspot/local-dev-lib/api/functions';
|
|
3
3
|
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
4
4
|
import SpinniesManager from '../../lib/ui/SpinniesManager.js';
|
|
@@ -7,7 +7,7 @@ import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
|
|
|
7
7
|
import { uiAccountDescription } from '../../lib/ui/index.js';
|
|
8
8
|
import { poll } from '../../lib/polling.js';
|
|
9
9
|
import { outputBuildLog } from '../../lib/serverlessLogs.js';
|
|
10
|
-
import {
|
|
10
|
+
import { commands } from '../../lang/en.js';
|
|
11
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
12
12
|
function isFunctionBuildError(e) {
|
|
13
13
|
return (typeof e === 'object' && e !== null && 'status' in e && e.status === 'ERROR');
|
|
@@ -20,20 +20,13 @@ async function handler(args) {
|
|
|
20
20
|
trackCommandUsage('function-deploy', undefined, derivedAccountId);
|
|
21
21
|
if (!splitFunctionPath.length ||
|
|
22
22
|
splitFunctionPath[splitFunctionPath.length - 1] !== 'functions') {
|
|
23
|
-
|
|
24
|
-
functionPath,
|
|
25
|
-
}));
|
|
23
|
+
uiLogger.error(commands.function.subcommands.deploy.errors.notFunctionsFolder(functionPath));
|
|
26
24
|
return;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
functionPath,
|
|
30
|
-
}));
|
|
26
|
+
uiLogger.debug(commands.function.subcommands.deploy.debug.startingBuildAndDeploy(functionPath));
|
|
31
27
|
SpinniesManager.init();
|
|
32
28
|
SpinniesManager.add('loading', {
|
|
33
|
-
text:
|
|
34
|
-
account: uiAccountDescription(derivedAccountId),
|
|
35
|
-
functionPath,
|
|
36
|
-
}),
|
|
29
|
+
text: commands.function.subcommands.deploy.loading(functionPath, uiAccountDescription(derivedAccountId)),
|
|
37
30
|
});
|
|
38
31
|
try {
|
|
39
32
|
const { data: buildId } = await buildPackage(derivedAccountId, functionPath);
|
|
@@ -46,30 +39,19 @@ async function handler(args) {
|
|
|
46
39
|
if (successResp.cdnUrl) {
|
|
47
40
|
await outputBuildLog(successResp.cdnUrl);
|
|
48
41
|
}
|
|
49
|
-
|
|
50
|
-
accountId: derivedAccountId,
|
|
51
|
-
buildTimeSeconds,
|
|
52
|
-
functionPath,
|
|
53
|
-
}));
|
|
42
|
+
uiLogger.success(commands.function.subcommands.deploy.success.deployed(functionPath, derivedAccountId, buildTimeSeconds));
|
|
54
43
|
}
|
|
55
44
|
}
|
|
56
45
|
catch (e) {
|
|
57
46
|
SpinniesManager.fail('loading', {
|
|
58
|
-
text:
|
|
59
|
-
account: uiAccountDescription(derivedAccountId),
|
|
60
|
-
functionPath,
|
|
61
|
-
}),
|
|
47
|
+
text: commands.function.subcommands.deploy.loadingFailed(functionPath, uiAccountDescription(derivedAccountId)),
|
|
62
48
|
});
|
|
63
49
|
if (isHubSpotHttpError(e) && e.status === 404) {
|
|
64
|
-
|
|
65
|
-
functionPath,
|
|
66
|
-
}));
|
|
50
|
+
uiLogger.error(commands.function.subcommands.deploy.errors.noPackageJson(functionPath));
|
|
67
51
|
}
|
|
68
52
|
else if (isFunctionBuildError(e)) {
|
|
69
53
|
await outputBuildLog(e.cdnUrl);
|
|
70
|
-
|
|
71
|
-
details: String(e.errorReason),
|
|
72
|
-
}));
|
|
54
|
+
uiLogger.error(commands.function.subcommands.deploy.errors.buildError(String(e.errorReason)));
|
|
73
55
|
}
|
|
74
56
|
else {
|
|
75
57
|
logError(e, new ApiErrorContext({
|
|
@@ -81,13 +63,13 @@ async function handler(args) {
|
|
|
81
63
|
}
|
|
82
64
|
function functionDeployBuilder(yargs) {
|
|
83
65
|
yargs.positional('path', {
|
|
84
|
-
describe:
|
|
66
|
+
describe: commands.function.subcommands.deploy.positionals.path.describe,
|
|
85
67
|
type: 'string',
|
|
86
68
|
});
|
|
87
69
|
yargs.example([
|
|
88
70
|
[
|
|
89
71
|
'$0 functions deploy myFunctionFolder.functions',
|
|
90
|
-
|
|
72
|
+
commands.function.subcommands.deploy.examples.default,
|
|
91
73
|
],
|
|
92
74
|
]);
|
|
93
75
|
return yargs;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import moment from 'moment';
|
|
2
2
|
import { getRoutes } from '@hubspot/local-dev-lib/api/functions';
|
|
3
|
-
import {
|
|
3
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
4
4
|
import { logError, ApiErrorContext } from '../../lib/errorHandlers/index.js';
|
|
5
5
|
import { getTableContents, getTableHeader } from '../../lib/ui/table.js';
|
|
6
6
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
7
|
-
import {
|
|
7
|
+
import { commands } from '../../lang/en.js';
|
|
8
8
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
9
9
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
10
10
|
const command = ['list', 'ls'];
|
|
11
|
-
const describe =
|
|
11
|
+
const describe = commands.function.subcommands.list.describe;
|
|
12
12
|
async function handler(args) {
|
|
13
13
|
const { derivedAccountId } = args;
|
|
14
14
|
trackCommandUsage('function-list', undefined, derivedAccountId);
|
|
15
|
-
|
|
15
|
+
uiLogger.debug(commands.function.subcommands.list.debug.gettingFunctions);
|
|
16
16
|
const { data: routesResp } = await getRoutes(derivedAccountId).catch(async (e) => {
|
|
17
17
|
logError(e, new ApiErrorContext({ accountId: derivedAccountId }));
|
|
18
18
|
process.exit(EXIT_CODES.SUCCESS);
|
|
19
19
|
});
|
|
20
20
|
if (!routesResp.objects.length) {
|
|
21
|
-
return
|
|
21
|
+
return uiLogger.info(commands.function.subcommands.list.info.noFunctions);
|
|
22
22
|
}
|
|
23
23
|
if (args.json) {
|
|
24
|
-
return
|
|
24
|
+
return uiLogger.json(routesResp.objects);
|
|
25
25
|
}
|
|
26
26
|
const functionsAsArrays = routesResp.objects.map(func => {
|
|
27
27
|
const { route, method, created, updated, secretNames } = func;
|
|
@@ -34,12 +34,12 @@ async function handler(args) {
|
|
|
34
34
|
];
|
|
35
35
|
});
|
|
36
36
|
functionsAsArrays.unshift(getTableHeader(['Route', 'Method', 'Secrets', 'Created', 'Updated']));
|
|
37
|
-
return
|
|
37
|
+
return uiLogger.log(getTableContents(functionsAsArrays));
|
|
38
38
|
}
|
|
39
39
|
function functionListBuilder(yargs) {
|
|
40
40
|
yargs.options({
|
|
41
41
|
json: {
|
|
42
|
-
describe:
|
|
42
|
+
describe: commands.function.subcommands.list.options.json.describe,
|
|
43
43
|
type: 'boolean',
|
|
44
44
|
},
|
|
45
45
|
});
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
2
|
-
import {
|
|
2
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
3
3
|
// This package is not typed, so we need to use require
|
|
4
4
|
import { start as startTestServer } from '@hubspot/serverless-dev-runtime';
|
|
5
|
-
import {
|
|
5
|
+
import { commands } from '../../lang/en.js';
|
|
6
6
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
7
7
|
const command = 'server <path>';
|
|
8
8
|
const describe = undefined;
|
|
9
9
|
async function handler(args) {
|
|
10
10
|
const { path: functionPath, derivedAccountId } = args;
|
|
11
11
|
trackCommandUsage('functions-server', undefined, derivedAccountId);
|
|
12
|
-
|
|
13
|
-
functionPath,
|
|
14
|
-
}));
|
|
12
|
+
uiLogger.debug(commands.function.subcommands.server.debug.startingServer(functionPath));
|
|
15
13
|
startTestServer({
|
|
16
14
|
accountId: derivedAccountId,
|
|
17
15
|
...args,
|
|
@@ -19,27 +17,27 @@ async function handler(args) {
|
|
|
19
17
|
}
|
|
20
18
|
function functionServerBuilder(yargs) {
|
|
21
19
|
yargs.positional('path', {
|
|
22
|
-
describe:
|
|
20
|
+
describe: commands.function.subcommands.server.positionals.path.describe,
|
|
23
21
|
type: 'string',
|
|
24
22
|
});
|
|
25
23
|
yargs.options({
|
|
26
24
|
port: {
|
|
27
|
-
describe:
|
|
25
|
+
describe: commands.function.subcommands.server.options.port.describe,
|
|
28
26
|
type: 'string',
|
|
29
27
|
default: 5432,
|
|
30
28
|
},
|
|
31
29
|
contact: {
|
|
32
|
-
describe:
|
|
30
|
+
describe: commands.function.subcommands.server.options.contact.describe,
|
|
33
31
|
type: 'boolean',
|
|
34
32
|
default: true,
|
|
35
33
|
},
|
|
36
34
|
watch: {
|
|
37
|
-
describe:
|
|
35
|
+
describe: commands.function.subcommands.server.options.watch.describe,
|
|
38
36
|
type: 'boolean',
|
|
39
37
|
default: true,
|
|
40
38
|
},
|
|
41
39
|
'log-output': {
|
|
42
|
-
describe:
|
|
40
|
+
describe: commands.function.subcommands.server.options.logOutput.describe,
|
|
43
41
|
type: 'boolean',
|
|
44
42
|
default: false,
|
|
45
43
|
},
|
|
@@ -47,7 +45,7 @@ function functionServerBuilder(yargs) {
|
|
|
47
45
|
yargs.example([
|
|
48
46
|
[
|
|
49
47
|
'$0 functions server ./tmp/myFunctionFolder.functions',
|
|
50
|
-
|
|
48
|
+
commands.function.subcommands.server.examples.default,
|
|
51
49
|
],
|
|
52
50
|
]);
|
|
53
51
|
return yargs;
|
package/commands/function.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { YargsCommandModuleBucket } from '../types/Yargs.js';
|
|
2
2
|
export declare const command: string[];
|
|
3
|
-
export declare const describe:
|
|
3
|
+
export declare const describe: "Commands for managing CMS serverless functions.";
|
|
4
4
|
declare const functionCommand: YargsCommandModuleBucket;
|
|
5
5
|
export default functionCommand;
|
package/commands/function.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import list from './function/list.js';
|
|
2
2
|
import deploy from './function/deploy.js';
|
|
3
3
|
import server from './function/server.js';
|
|
4
|
-
import {
|
|
4
|
+
import { commands } from '../lang/en.js';
|
|
5
5
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
6
6
|
export const command = ['function', 'functions'];
|
|
7
|
-
export const describe =
|
|
7
|
+
export const describe = commands.function.describe;
|
|
8
8
|
function functionBuilder(yargs) {
|
|
9
9
|
yargs.command(list).command(deploy).command(server).demandCommand(1, '');
|
|
10
10
|
return yargs;
|
package/commands/getStarted.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AccountArgs, YargsCommandModule, CommonArgs, ConfigArgs, EnvironmentArgs } from '../types/Yargs.js';
|
|
2
|
-
|
|
3
|
-
export declare const describe: undefined;
|
|
4
|
-
export type GetStartedArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
2
|
+
type GetStartedArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
5
3
|
name?: string;
|
|
6
4
|
dest?: string;
|
|
7
5
|
};
|
package/commands/getStarted.js
CHANGED
|
@@ -4,6 +4,7 @@ import open from 'open';
|
|
|
4
4
|
import { getCwd } from '@hubspot/local-dev-lib/path';
|
|
5
5
|
import { cloneGithubRepo } from '@hubspot/local-dev-lib/github';
|
|
6
6
|
import { commands } from '../lang/en.js';
|
|
7
|
+
import { trackCommandMetadataUsage, trackCommandUsage, } from '../lib/usageTracking.js';
|
|
7
8
|
import { EXIT_CODES } from '../lib/enums/exitCodes.js';
|
|
8
9
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
9
10
|
import { promptUser } from '../lib/prompts/promptUtils.js';
|
|
@@ -16,20 +17,19 @@ import { PROJECT_CONFIG_FILE, GET_STARTED_OPTIONS, HUBSPOT_PROJECT_COMPONENTS_GI
|
|
|
16
17
|
import { writeProjectConfig, getProjectConfig, validateProjectConfig, } from '../lib/projects/config.js';
|
|
17
18
|
import { getProjectPackageJsonLocations, installPackages, } from '../lib/dependencyManagement.js';
|
|
18
19
|
import { pollProjectBuildAndDeploy } from '../lib/projects/pollProjectBuildAndDeploy.js';
|
|
19
|
-
import {
|
|
20
|
+
import { isV2Project } from '../lib/projects/platformVersion.js';
|
|
20
21
|
import { openLink } from '../lib/links.js';
|
|
21
22
|
import { getStaticAuthAppInstallUrl } from '../lib/app/urls.js';
|
|
22
23
|
import { getEnv } from '@hubspot/local-dev-lib/config';
|
|
23
24
|
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
24
25
|
import { fetchPublicAppsForPortal } from '@hubspot/local-dev-lib/api/appsDev';
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const command = 'get-started';
|
|
27
|
+
const describe = commands.getStarted.describe;
|
|
27
28
|
async function handler(args) {
|
|
28
29
|
const { derivedAccountId } = args;
|
|
29
30
|
const env = getEnv(derivedAccountId) === 'qa' ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
31
|
+
await trackCommandUsage('get-started', {}, derivedAccountId);
|
|
30
32
|
const accountName = uiAccountDescription(derivedAccountId);
|
|
31
|
-
// TODO: Put this in constants.ts once we have a defined place for the template before INBOUND
|
|
32
|
-
const templateSource = 'robrown-hubspot/hubspot-project-components-ua-app-objects-beta';
|
|
33
33
|
uiInfoSection(commands.getStarted.startTitle, () => {
|
|
34
34
|
uiLogger.log(commands.getStarted.startDescription);
|
|
35
35
|
uiLogger.log(commands.getStarted.guideOverview(accountName));
|
|
@@ -52,6 +52,8 @@ async function handler(args) {
|
|
|
52
52
|
default: GET_STARTED_OPTIONS.APP,
|
|
53
53
|
},
|
|
54
54
|
]);
|
|
55
|
+
// Track user's initial choice
|
|
56
|
+
await trackCommandMetadataUsage('get-started', { step: 'select-option', type: selectedOption }, derivedAccountId);
|
|
55
57
|
if (selectedOption === GET_STARTED_OPTIONS.CMS) {
|
|
56
58
|
uiLogger.log(' ');
|
|
57
59
|
uiLogger.log(commands.getStarted.designManager);
|
|
@@ -64,6 +66,11 @@ async function handler(args) {
|
|
|
64
66
|
message: commands.getStarted.openDesignManagerPrompt,
|
|
65
67
|
},
|
|
66
68
|
]);
|
|
69
|
+
// Track Design Manager browser action
|
|
70
|
+
await trackCommandMetadataUsage('get-started', {
|
|
71
|
+
step: 'open-design-manager',
|
|
72
|
+
type: shouldOpen ? 'opened' : 'declined',
|
|
73
|
+
}, derivedAccountId);
|
|
67
74
|
if (shouldOpen) {
|
|
68
75
|
uiLogger.log('');
|
|
69
76
|
openLink(derivedAccountId, 'design-manager');
|
|
@@ -74,36 +81,37 @@ async function handler(args) {
|
|
|
74
81
|
else {
|
|
75
82
|
uiLogger.log(' ');
|
|
76
83
|
uiLogger.log(commands.getStarted.logs.appSelected);
|
|
77
|
-
// 1. Fetch project templates
|
|
78
|
-
let latestRepoReleaseTag;
|
|
79
84
|
const { dest, name } = await projectNameAndDestPrompt(args);
|
|
80
|
-
// Specific template for get-started command
|
|
81
|
-
const projectTemplate = {
|
|
82
|
-
name: 'private-app-get-started-template',
|
|
83
|
-
label: 'CRM getting started project with private apps',
|
|
84
|
-
path: 'projects/private-app-get-started-template',
|
|
85
|
-
};
|
|
86
|
-
// 3. Create the project files
|
|
87
85
|
const projectDest = path.resolve(getCwd(), dest);
|
|
88
86
|
const { projectConfig: existingProjectConfig, projectDir: existingProjectDir, } = await getProjectConfig(projectDest);
|
|
89
87
|
if (existingProjectConfig &&
|
|
90
88
|
existingProjectDir &&
|
|
91
89
|
projectDest.startsWith(existingProjectDir)) {
|
|
90
|
+
// Track nested project error
|
|
91
|
+
await trackCommandMetadataUsage('get-started', {
|
|
92
|
+
successful: false,
|
|
93
|
+
step: 'project-creation',
|
|
94
|
+
}, derivedAccountId);
|
|
92
95
|
uiLogger.log(' ');
|
|
93
96
|
uiLogger.error(commands.project.create.errors.cannotNestProjects(existingProjectDir));
|
|
94
97
|
process.exit(EXIT_CODES.ERROR);
|
|
95
98
|
}
|
|
96
|
-
const repo = templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH;
|
|
97
99
|
// 4. Clone the project template from GitHub
|
|
98
|
-
// This is temporary until we have the UA template in the main repo
|
|
99
100
|
try {
|
|
100
|
-
await cloneGithubRepo(
|
|
101
|
-
sourceDir:
|
|
102
|
-
tag: latestRepoReleaseTag,
|
|
101
|
+
await cloneGithubRepo(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, projectDest, {
|
|
102
|
+
sourceDir: '2025.2/private-app-get-started-template',
|
|
103
103
|
hideLogs: true,
|
|
104
104
|
});
|
|
105
|
+
await trackCommandMetadataUsage('get-started', {
|
|
106
|
+
successful: true,
|
|
107
|
+
step: 'github-clone',
|
|
108
|
+
}, derivedAccountId);
|
|
105
109
|
}
|
|
106
110
|
catch (err) {
|
|
111
|
+
await trackCommandMetadataUsage('get-started', {
|
|
112
|
+
successful: false,
|
|
113
|
+
step: 'github-clone',
|
|
114
|
+
}, derivedAccountId);
|
|
107
115
|
debugError(err);
|
|
108
116
|
uiLogger.log(' ');
|
|
109
117
|
uiLogger.error(commands.project.create.errors.failedToDownloadProject);
|
|
@@ -122,6 +130,11 @@ async function handler(args) {
|
|
|
122
130
|
uiLogger.log(' ');
|
|
123
131
|
uiLogger.log(commands.getStarted.prompts.projectCreated.description);
|
|
124
132
|
uiLogger.log(' ');
|
|
133
|
+
// Track successful project creation
|
|
134
|
+
await trackCommandMetadataUsage('get-started', {
|
|
135
|
+
successful: true,
|
|
136
|
+
step: 'project-creation',
|
|
137
|
+
}, derivedAccountId);
|
|
125
138
|
// 5. Install dependencies
|
|
126
139
|
const installLocations = await getProjectPackageJsonLocations(projectDest);
|
|
127
140
|
try {
|
|
@@ -147,11 +160,21 @@ async function handler(args) {
|
|
|
147
160
|
default: true,
|
|
148
161
|
},
|
|
149
162
|
]);
|
|
163
|
+
// Track upload decision
|
|
164
|
+
await trackCommandMetadataUsage('get-started', {
|
|
165
|
+
step: 'upload-decision',
|
|
166
|
+
type: shouldUpload ? 'upload' : 'skip',
|
|
167
|
+
}, derivedAccountId);
|
|
150
168
|
if (shouldUpload) {
|
|
151
169
|
try {
|
|
152
170
|
// Get the project config for the newly created project
|
|
153
171
|
const { projectConfig: newProjectConfig, projectDir: newProjectDir } = await getProjectConfig(projectDest);
|
|
154
172
|
if (!newProjectConfig || !newProjectDir) {
|
|
173
|
+
// Track config file not found error
|
|
174
|
+
await trackCommandMetadataUsage('get-started', {
|
|
175
|
+
successful: false,
|
|
176
|
+
step: 'config-file-not-found',
|
|
177
|
+
}, derivedAccountId);
|
|
155
178
|
uiLogger.log(' ');
|
|
156
179
|
uiLogger.error(commands.getStarted.errors.configFileNotFound);
|
|
157
180
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -168,15 +191,25 @@ async function handler(args) {
|
|
|
168
191
|
uploadMessage: 'Initial upload from get-started command',
|
|
169
192
|
forceCreate: true, // Auto-create project on HubSpot
|
|
170
193
|
isUploadCommand: false,
|
|
171
|
-
sendIR:
|
|
194
|
+
sendIR: isV2Project(newProjectConfig.platformVersion),
|
|
172
195
|
skipValidation: false,
|
|
173
196
|
});
|
|
174
197
|
if (uploadError) {
|
|
198
|
+
// Track upload failure
|
|
199
|
+
await trackCommandMetadataUsage('get-started', {
|
|
200
|
+
successful: false,
|
|
201
|
+
step: 'upload',
|
|
202
|
+
}, derivedAccountId);
|
|
175
203
|
uiLogger.log(' ');
|
|
176
204
|
uiLogger.error(commands.getStarted.errors.uploadFailed);
|
|
177
205
|
debugError(uploadError);
|
|
178
206
|
}
|
|
179
207
|
else if (result) {
|
|
208
|
+
// Track successful upload completion
|
|
209
|
+
await trackCommandMetadataUsage('get-started', {
|
|
210
|
+
successful: true,
|
|
211
|
+
step: 'upload',
|
|
212
|
+
}, derivedAccountId);
|
|
180
213
|
uiLogger.log(' ');
|
|
181
214
|
uiLogger.success(commands.getStarted.logs.uploadSuccess);
|
|
182
215
|
const { data: { results }, } = await fetchPublicAppsForPortal(derivedAccountId);
|
|
@@ -192,6 +225,11 @@ async function handler(args) {
|
|
|
192
225
|
message: commands.getStarted.openInstallUrl,
|
|
193
226
|
},
|
|
194
227
|
]);
|
|
228
|
+
// Track Developer Overview browser action
|
|
229
|
+
await trackCommandMetadataUsage('get-started', {
|
|
230
|
+
step: 'open-distribution-page',
|
|
231
|
+
type: shouldOpenOverview ? 'opened' : 'declined',
|
|
232
|
+
}, derivedAccountId);
|
|
195
233
|
if (shouldOpenOverview) {
|
|
196
234
|
open(getStaticAuthAppInstallUrl({
|
|
197
235
|
targetAccountId: derivedAccountId,
|
|
@@ -207,6 +245,11 @@ async function handler(args) {
|
|
|
207
245
|
}
|
|
208
246
|
}
|
|
209
247
|
catch (err) {
|
|
248
|
+
// Track upload exception
|
|
249
|
+
await trackCommandMetadataUsage('get-started', {
|
|
250
|
+
successful: false,
|
|
251
|
+
step: 'upload',
|
|
252
|
+
}, derivedAccountId);
|
|
210
253
|
uiLogger.log(' ');
|
|
211
254
|
uiLogger.error(commands.getStarted.errors.uploadFailed);
|
|
212
255
|
debugError(err);
|
|
@@ -214,6 +257,11 @@ async function handler(args) {
|
|
|
214
257
|
}
|
|
215
258
|
}
|
|
216
259
|
}
|
|
260
|
+
// Track successful completion of get-started command
|
|
261
|
+
await trackCommandMetadataUsage('get-started', {
|
|
262
|
+
successful: true,
|
|
263
|
+
step: 'command-completed',
|
|
264
|
+
}, derivedAccountId);
|
|
217
265
|
process.exit(EXIT_CODES.SUCCESS);
|
|
218
266
|
}
|
|
219
267
|
function getStartedBuilder(yargs) {
|
package/commands/hubdb/clear.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
2
2
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
3
3
|
import { clearHubDbTableRows } from '@hubspot/local-dev-lib/hubdb';
|
|
4
4
|
import { publishTable } from '@hubspot/local-dev-lib/api/hubdb';
|
|
5
5
|
import { selectHubDBTablePrompt } from '../../lib/prompts/selectHubDBTablePrompt.js';
|
|
6
6
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
7
|
-
import {
|
|
7
|
+
import { commands } from '../../lang/en.js';
|
|
8
8
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
9
9
|
const command = 'clear [table-id]';
|
|
10
|
-
const describe =
|
|
10
|
+
const describe = commands.hubdb.subcommands.clear.describe;
|
|
11
11
|
async function handler(args) {
|
|
12
12
|
const { derivedAccountId } = args;
|
|
13
13
|
trackCommandUsage('hubdb-clear', {}, derivedAccountId);
|
|
@@ -20,20 +20,12 @@ async function handler(args) {
|
|
|
20
20
|
});
|
|
21
21
|
const { deletedRowCount } = await clearHubDbTableRows(derivedAccountId, tableId);
|
|
22
22
|
if (deletedRowCount > 0) {
|
|
23
|
-
|
|
24
|
-
deletedRowCount,
|
|
25
|
-
tableId,
|
|
26
|
-
}));
|
|
23
|
+
uiLogger.log(commands.hubdb.subcommands.clear.logs.removedRows(deletedRowCount, tableId));
|
|
27
24
|
const { data: { rowCount }, } = await publishTable(derivedAccountId, tableId);
|
|
28
|
-
|
|
29
|
-
rowCount,
|
|
30
|
-
tableId,
|
|
31
|
-
}));
|
|
25
|
+
uiLogger.log(commands.hubdb.subcommands.clear.logs.rowCount(tableId, rowCount));
|
|
32
26
|
}
|
|
33
27
|
else {
|
|
34
|
-
|
|
35
|
-
tableId,
|
|
36
|
-
}));
|
|
28
|
+
uiLogger.log(commands.hubdb.subcommands.clear.logs.tableEmpty(tableId));
|
|
37
29
|
}
|
|
38
30
|
}
|
|
39
31
|
catch (e) {
|
|
@@ -42,7 +34,7 @@ async function handler(args) {
|
|
|
42
34
|
}
|
|
43
35
|
function hubdbClearBuilder(yargs) {
|
|
44
36
|
yargs.positional('table-id', {
|
|
45
|
-
describe:
|
|
37
|
+
describe: commands.hubdb.subcommands.clear.positionals.tableId.describe,
|
|
46
38
|
type: 'string',
|
|
47
39
|
});
|
|
48
40
|
return yargs;
|
package/commands/hubdb/create.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import {
|
|
2
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
3
3
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
4
4
|
import { getCwd, untildify, isValidPath } from '@hubspot/local-dev-lib/path';
|
|
5
5
|
import { createHubDbTable } from '@hubspot/local-dev-lib/hubdb';
|
|
6
6
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
7
7
|
import { checkAndConvertToJson } from '../../lib/validation.js';
|
|
8
8
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
9
|
-
import {
|
|
9
|
+
import { commands } from '../../lang/en.js';
|
|
10
10
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
11
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
12
12
|
const command = 'create';
|
|
13
|
-
const describe =
|
|
13
|
+
const describe = commands.hubdb.subcommands.create.describe;
|
|
14
14
|
function selectPathPrompt(options) {
|
|
15
15
|
return promptUser([
|
|
16
16
|
{
|
|
17
17
|
name: 'path',
|
|
18
|
-
message:
|
|
18
|
+
message: commands.hubdb.subcommands.create.enterPath,
|
|
19
19
|
when: !options.path,
|
|
20
20
|
validate: (input) => {
|
|
21
21
|
if (!input) {
|
|
22
|
-
return
|
|
22
|
+
return commands.hubdb.subcommands.create.errors.pathRequired;
|
|
23
23
|
}
|
|
24
24
|
if (!isValidPath(input)) {
|
|
25
|
-
return
|
|
25
|
+
return commands.hubdb.subcommands.create.errors.invalidCharacters;
|
|
26
26
|
}
|
|
27
27
|
return true;
|
|
28
28
|
},
|
|
@@ -45,22 +45,16 @@ async function handler(args) {
|
|
|
45
45
|
process.exit(EXIT_CODES.ERROR);
|
|
46
46
|
}
|
|
47
47
|
const table = await createHubDbTable(derivedAccountId, path.resolve(getCwd(), filePath));
|
|
48
|
-
|
|
49
|
-
accountId: derivedAccountId,
|
|
50
|
-
rowCount: table.rowCount,
|
|
51
|
-
tableId: table.tableId,
|
|
52
|
-
}));
|
|
48
|
+
uiLogger.success(commands.hubdb.subcommands.create.success.create(table.tableId, derivedAccountId, table.rowCount));
|
|
53
49
|
}
|
|
54
50
|
catch (e) {
|
|
55
|
-
|
|
56
|
-
filePath: filePath || '',
|
|
57
|
-
}));
|
|
51
|
+
uiLogger.error(commands.hubdb.subcommands.create.errors.create(filePath || ''));
|
|
58
52
|
logError(e);
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
55
|
function hubdbCreateBuilder(yargs) {
|
|
62
56
|
yargs.options('path', {
|
|
63
|
-
describe:
|
|
57
|
+
describe: commands.hubdb.subcommands.create.options.path.describe,
|
|
64
58
|
type: 'string',
|
|
65
59
|
});
|
|
66
60
|
return yargs;
|
package/commands/hubdb/delete.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
2
2
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
3
3
|
import { deleteTable } from '@hubspot/local-dev-lib/api/hubdb';
|
|
4
4
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
5
5
|
import { selectHubDBTablePrompt } from '../../lib/prompts/selectHubDBTablePrompt.js';
|
|
6
6
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
7
7
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
8
|
-
import {
|
|
8
|
+
import { commands } from '../../lang/en.js';
|
|
9
9
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
10
10
|
const command = 'delete [table-id]';
|
|
11
|
-
const describe =
|
|
11
|
+
const describe = commands.hubdb.subcommands.delete.describe;
|
|
12
12
|
async function handler(args) {
|
|
13
13
|
const { force, derivedAccountId } = args;
|
|
14
14
|
trackCommandUsage('hubdb-delete', {}, derivedAccountId);
|
|
@@ -23,35 +23,28 @@ async function handler(args) {
|
|
|
23
23
|
const { shouldDeleteTable } = await promptUser({
|
|
24
24
|
name: 'shouldDeleteTable',
|
|
25
25
|
type: 'confirm',
|
|
26
|
-
message:
|
|
27
|
-
tableId,
|
|
28
|
-
}),
|
|
26
|
+
message: commands.hubdb.subcommands.delete.shouldDeleteTable(tableId),
|
|
29
27
|
});
|
|
30
28
|
if (!shouldDeleteTable) {
|
|
31
29
|
process.exit(EXIT_CODES.SUCCESS);
|
|
32
30
|
}
|
|
33
31
|
}
|
|
34
32
|
await deleteTable(derivedAccountId, tableId);
|
|
35
|
-
|
|
36
|
-
accountId: derivedAccountId,
|
|
37
|
-
tableId,
|
|
38
|
-
}));
|
|
33
|
+
uiLogger.success(commands.hubdb.subcommands.delete.success.delete(tableId, derivedAccountId));
|
|
39
34
|
process.exit(EXIT_CODES.SUCCESS);
|
|
40
35
|
}
|
|
41
36
|
catch (e) {
|
|
42
|
-
|
|
43
|
-
tableId: args.tableId || '',
|
|
44
|
-
}));
|
|
37
|
+
uiLogger.error(commands.hubdb.subcommands.delete.errors.delete(args.tableId || ''));
|
|
45
38
|
logError(e);
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
41
|
function hubdbDeleteBuilder(yargs) {
|
|
49
42
|
yargs.positional('table-id', {
|
|
50
|
-
describe:
|
|
43
|
+
describe: commands.hubdb.subcommands.delete.positionals.tableId.describe,
|
|
51
44
|
type: 'string',
|
|
52
45
|
});
|
|
53
46
|
yargs.option('force', {
|
|
54
|
-
describe:
|
|
47
|
+
describe: commands.hubdb.subcommands.delete.options.force.describe,
|
|
55
48
|
type: 'boolean',
|
|
56
49
|
});
|
|
57
50
|
return yargs;
|