@hubspot/cli 7.7.34-experimental.0 → 7.8.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +31 -25
- 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 +0 -3
- 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 +3 -8
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +16 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -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 +7 -12
- 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 +0 -2
- package/commands/getStarted.js +4 -4
- 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 +4 -2
- 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__/logs.test.js +1 -4
- package/commands/project/__tests__/migrate.test.js +6 -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.js +4 -8
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +3 -10
- package/commands/project/deploy.js +5 -5
- package/commands/project/dev/deprecatedFlow.js +7 -16
- package/commands/project/dev/index.js +16 -13
- package/commands/project/dev/unifiedFlow.js +8 -4
- package/commands/project/download.js +10 -14
- package/commands/project/installDeps.js +8 -9
- package/commands/project/listBuilds.js +12 -21
- package/commands/project/logs.js +21 -24
- package/commands/project/migrate.js +41 -13
- 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.d.ts +2 -2
- package/commands/project/upload.js +17 -26
- package/commands/project/validate.js +7 -7
- package/commands/project/watch.js +13 -22
- package/commands/project.js +2 -3
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +35 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/create.js +0 -3
- 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/lang/en.d.ts +317 -120
- package/lang/en.js +312 -118
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -1
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +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 +5 -80
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.js +25 -57
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +13 -0
- package/lib/constants.js +17 -0
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +10 -17
- 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 +78 -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/projectProfiles.d.ts +1 -1
- package/lib/projectProfiles.js +2 -10
- package/lib/projects/__tests__/AppDevModeInterface.test.js +2 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +227 -16
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +86 -60
- package/lib/projects/__tests__/deploy.test.js +71 -6
- 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__/v3AddComponent.test.js +4 -4
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v3.test.js +80 -5
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/v3.js +10 -8
- package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -0
- package/lib/projects/localDev/AppDevModeInterface.js +21 -12
- package/lib/projects/localDev/LocalDevLogger.d.ts +4 -0
- package/lib/projects/localDev/LocalDevLogger.js +27 -6
- package/lib/projects/localDev/LocalDevManager.js +4 -5
- package/lib/projects/localDev/LocalDevProcess.d.ts +7 -5
- package/lib/projects/localDev/LocalDevProcess.js +90 -19
- package/lib/projects/localDev/LocalDevState.d.ts +9 -8
- package/lib/projects/localDev/LocalDevState.js +18 -17
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +2 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +62 -33
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +42 -1
- package/lib/projects/localDev/localDevWebsocketServerUtils.d.ts +4 -0
- package/lib/projects/localDev/localDevWebsocketServerUtils.js +10 -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.d.ts +2 -2
- package/lib/projects/structure.js +6 -6
- package/lib/projects/upload.d.ts +2 -3
- package/lib/projects/upload.js +17 -9
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.js +8 -1
- 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 +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.js +38 -37
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +68 -0
- package/lib/ui/uiMessages.js +71 -0
- package/lib/usageTracking.js +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/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +5 -5
- 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 +12 -6
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +12 -10
- 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 +8 -7
- 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 +4 -4
- package/types/LocalDev.d.ts +19 -3
- package/types/Yargs.d.ts +1 -1
- package/ui/index.js +1 -1
- package/commands/app/__tests__/install.test.js +0 -47
- package/commands/app/install.d.ts +0 -8
- package/commands/app/install.js +0 -122
- 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/commands/{app/__tests__/install.test.d.ts → project/__tests__/validate.test.d.ts} +0 -0
- /package/lib/middleware/__test__/{utils.test.d.ts → commandTargetingUtils.test.d.ts} +0 -0
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([
|
|
@@ -4,9 +4,11 @@ import { marketplaceDistribution, oAuth, privateDistribution, staticAuth, } from
|
|
|
4
4
|
import { v3AddComponent } from '../../../lib/projects/add/v3AddComponent.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/ui/logger.js');
|
|
11
|
+
vi.mock('../../../lib/errorHandlers/index.js');
|
|
10
12
|
vi.mock('../../../lib/projects/add/v3AddComponent');
|
|
11
13
|
vi.mock('../../../lib/projects/add/legacyAddComponent');
|
|
12
14
|
vi.mock('../../../lib/projects/config');
|
|
@@ -15,7 +17,7 @@ vi.mock('../../../lib/usageTracking');
|
|
|
15
17
|
const mockedV3AddComponent = vi.mocked(v3AddComponent);
|
|
16
18
|
const mockedLegacyAddComponent = vi.mocked(legacyAddComponent);
|
|
17
19
|
const mockedGetProjectConfig = vi.mocked(getProjectConfig);
|
|
18
|
-
const mockedUseV3Api = vi.mocked(
|
|
20
|
+
const mockedUseV3Api = vi.mocked(isV2Project);
|
|
19
21
|
const mockedTrackCommandUsage = vi.mocked(trackCommandUsage);
|
|
20
22
|
describe('commands/project/add', () => {
|
|
21
23
|
const yargsMock = yargs;
|
|
@@ -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
|
});
|
|
@@ -324,8 +324,7 @@ describe('unifiedProjectDevFlow', () => {
|
|
|
324
324
|
});
|
|
325
325
|
expect(createNewProjectForLocalDev).not.toHaveBeenCalled();
|
|
326
326
|
expect(LocalDevProcess).toHaveBeenCalledWith(expect.objectContaining({
|
|
327
|
-
|
|
328
|
-
projectName: mockProject.name,
|
|
327
|
+
projectData: mockProject,
|
|
329
328
|
}));
|
|
330
329
|
});
|
|
331
330
|
});
|
|
@@ -346,8 +345,7 @@ describe('unifiedProjectDevFlow', () => {
|
|
|
346
345
|
targetTestingAccountId: mockProvidedTargetTestingAccountId,
|
|
347
346
|
projectConfig: mockProjectConfig,
|
|
348
347
|
projectDir: mockProjectDir,
|
|
349
|
-
|
|
350
|
-
projectId: mockProject.id,
|
|
348
|
+
projectData: mockProject,
|
|
351
349
|
env: ENVIRONMENTS.PROD,
|
|
352
350
|
});
|
|
353
351
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
4
4
|
import * as projectUtils from '../../../lib/projects/config.js';
|
|
5
5
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
6
6
|
import { trackCommandUsage } from '../../../lib/usageTracking.js';
|
|
7
7
|
import * as dependencyManagement from '../../../lib/dependencyManagement.js';
|
|
8
8
|
import * as promptUtils from '../../../lib/prompts/promptUtils.js';
|
|
9
9
|
import projectInstallDepsCommand from '../installDeps.js';
|
|
10
|
-
vi.mock('
|
|
10
|
+
vi.mock('../../../lib/ui/logger.js');
|
|
11
11
|
vi.mock('../../../lib/projects/config');
|
|
12
12
|
vi.mock('../../../lib/dependencyManagement');
|
|
13
13
|
vi.mock('../../../lib/prompts/promptUtils');
|
|
@@ -56,8 +56,8 @@ describe('commands/project/installDeps', () => {
|
|
|
56
56
|
throw error;
|
|
57
57
|
});
|
|
58
58
|
await projectInstallDepsCommand.handler(args);
|
|
59
|
-
expect(
|
|
60
|
-
expect(
|
|
59
|
+
expect(uiLogger.error).toHaveBeenCalledTimes(1);
|
|
60
|
+
expect(uiLogger.error).toHaveBeenCalledWith(error.message);
|
|
61
61
|
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
62
62
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
63
63
|
});
|
|
@@ -67,8 +67,8 @@ describe('commands/project/installDeps', () => {
|
|
|
67
67
|
projectConfig: null,
|
|
68
68
|
});
|
|
69
69
|
await projectInstallDepsCommand.handler(args);
|
|
70
|
-
expect(
|
|
71
|
-
expect(
|
|
70
|
+
expect(uiLogger.error).toHaveBeenCalledTimes(1);
|
|
71
|
+
expect(uiLogger.error).toHaveBeenCalledWith('No project detected. Run this command from a project directory.');
|
|
72
72
|
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
73
73
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
74
74
|
});
|
|
@@ -78,8 +78,8 @@ describe('commands/project/installDeps', () => {
|
|
|
78
78
|
projectConfig: null,
|
|
79
79
|
});
|
|
80
80
|
await projectInstallDepsCommand.handler(args);
|
|
81
|
-
expect(
|
|
82
|
-
expect(
|
|
81
|
+
expect(uiLogger.error).toHaveBeenCalledTimes(1);
|
|
82
|
+
expect(uiLogger.error).toHaveBeenCalledWith('No project detected. Run this command from a project directory.');
|
|
83
83
|
expect(processExitSpy).toHaveBeenCalledTimes(1);
|
|
84
84
|
expect(processExitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
85
85
|
});
|
|
@@ -8,7 +8,7 @@ import * as ui from '../../../lib/ui/index.js';
|
|
|
8
8
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
9
9
|
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
10
10
|
import projectLogsCommand from '../logs.js';
|
|
11
|
-
vi.mock('
|
|
11
|
+
vi.mock('../../ui/logger.js');
|
|
12
12
|
vi.mock('../../../lib/commonOpts');
|
|
13
13
|
vi.mock('../../../lib/usageTracking');
|
|
14
14
|
vi.mock('../../../lib/validation');
|
|
@@ -45,9 +45,6 @@ describe('commands/project/logs', () => {
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
describe('describe', () => {
|
|
48
|
-
it('should contain the beta tag', () => {
|
|
49
|
-
expect(projectLogsCommand.describe).toContain('[BETA]');
|
|
50
|
-
});
|
|
51
48
|
it('should provide a description', () => {
|
|
52
49
|
expect(projectLogsCommand.describe).toBeDefined();
|
|
53
50
|
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import {
|
|
2
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
3
3
|
import { PLATFORM_VERSIONS } from '@hubspot/local-dev-lib/constants/projects';
|
|
4
4
|
import migrateCommand from '../migrate.js';
|
|
5
5
|
import { migrateApp2025_2 } from '../../../lib/app/migrate.js';
|
|
6
6
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
7
7
|
import { commands } from '../../../lang/en.js';
|
|
8
8
|
import { uiBetaTag, uiCommandReference } from '../../../lib/ui/index.js';
|
|
9
|
-
vi.mock('
|
|
9
|
+
vi.mock('../../../lib/ui/logger.js');
|
|
10
10
|
vi.mock('../../../lib/app/migrate');
|
|
11
11
|
vi.mock('../../../lib/projects/config');
|
|
12
12
|
vi.mock('../../../lib/ui');
|
|
@@ -24,8 +24,8 @@ describe('commands/project/migrate', () => {
|
|
|
24
24
|
.mockImplementation(() => undefined);
|
|
25
25
|
beforeEach(() => {
|
|
26
26
|
// Mock logger methods
|
|
27
|
-
vi.spyOn(
|
|
28
|
-
vi.spyOn(
|
|
27
|
+
vi.spyOn(uiLogger, 'log').mockImplementation(() => { });
|
|
28
|
+
vi.spyOn(uiLogger, 'error').mockImplementation(() => { });
|
|
29
29
|
migrateApp2025_2Mock.mockResolvedValue(undefined);
|
|
30
30
|
getProjectConfigMock.mockResolvedValue({
|
|
31
31
|
projectConfig: { name: 'test-project' },
|
|
@@ -44,7 +44,7 @@ describe('commands/project/migrate', () => {
|
|
|
44
44
|
});
|
|
45
45
|
describe('describe', () => {
|
|
46
46
|
it('should provide a description', () => {
|
|
47
|
-
expect(migrateCommand.describe).
|
|
47
|
+
expect(migrateCommand.describe).toBeDefined();
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
describe('builder', () => {
|
|
@@ -54,7 +54,6 @@ describe('commands/project/migrate', () => {
|
|
|
54
54
|
type: 'string',
|
|
55
55
|
choices: [v2025_2],
|
|
56
56
|
default: v2025_2,
|
|
57
|
-
hidden: true,
|
|
58
57
|
});
|
|
59
58
|
expect(optionsSpy).toHaveBeenCalledWith('unstable', {
|
|
60
59
|
type: 'boolean',
|
|
@@ -75,7 +74,7 @@ describe('commands/project/migrate', () => {
|
|
|
75
74
|
it('should exit with error if no project config exists', async () => {
|
|
76
75
|
getProjectConfigMock.mockResolvedValue({ projectConfig: null });
|
|
77
76
|
await migrateCommand.handler(options);
|
|
78
|
-
expect(
|
|
77
|
+
expect(uiLogger.error).toHaveBeenCalledWith(commands.project.migrate.errors.noProjectConfig('command reference'));
|
|
79
78
|
expect(mockExit).toHaveBeenCalledWith(1);
|
|
80
79
|
expect(mockExit).toHaveBeenCalledTimes(1);
|
|
81
80
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
|
-
import { i18n } from '../../../lib/lang.js';
|
|
3
2
|
import { uiCommandReference, uiDeprecatedTag } from '../../../lib/ui/index.js';
|
|
4
3
|
import { handlerGenerator } from '../../app/migrate.js';
|
|
5
4
|
import { PLATFORM_VERSIONS } from '@hubspot/local-dev-lib/constants/projects';
|
|
6
5
|
import migrateAppCommand from '../migrateApp.js';
|
|
7
|
-
vi.mock('
|
|
8
|
-
vi.mock('../../../
|
|
6
|
+
vi.mock('../../ui/logger.js');
|
|
7
|
+
vi.mock('../../../lang/en.js');
|
|
9
8
|
vi.mock('../../../lib/ui');
|
|
10
9
|
vi.mock('../../app/migrate');
|
|
11
10
|
const { v2023_2, v2025_2 } = PLATFORM_VERSIONS;
|
|
@@ -14,13 +13,11 @@ describe('commands/project/migrateApp', () => {
|
|
|
14
13
|
const optionsSpy = vi.spyOn(yargsMock, 'options').mockReturnValue(yargsMock);
|
|
15
14
|
const exampleSpy = vi.spyOn(yargsMock, 'example').mockReturnValue(yargsMock);
|
|
16
15
|
// Mock the imported functions
|
|
17
|
-
const i18nMock = i18n;
|
|
18
16
|
const uiDeprecatedTagMock = uiDeprecatedTag;
|
|
19
17
|
const uiCommandReferenceMock = uiCommandReference;
|
|
20
18
|
const handlerGeneratorMock = handlerGenerator;
|
|
21
19
|
beforeEach(() => {
|
|
22
20
|
vi.clearAllMocks();
|
|
23
|
-
i18nMock.mockReturnValue('test description');
|
|
24
21
|
uiDeprecatedTagMock.mockReturnValue('deprecated test description');
|
|
25
22
|
uiCommandReferenceMock.mockReturnValue('command reference');
|
|
26
23
|
handlerGeneratorMock.mockReturnValue(vi.fn().mockResolvedValue(undefined));
|
|
@@ -57,8 +54,7 @@ describe('commands/project/migrateApp', () => {
|
|
|
57
54
|
'platform-version': expect.objectContaining({
|
|
58
55
|
type: 'string',
|
|
59
56
|
choices: [v2023_2, v2025_2],
|
|
60
|
-
|
|
61
|
-
default: v2023_2,
|
|
57
|
+
default: v2025_2,
|
|
62
58
|
}),
|
|
63
59
|
});
|
|
64
60
|
expect(exampleSpy).toHaveBeenCalled();
|
|
@@ -19,7 +19,7 @@ describe('commands/project', () => {
|
|
|
19
19
|
});
|
|
20
20
|
describe('describe', () => {
|
|
21
21
|
it('should not provide a description', () => {
|
|
22
|
-
expect(profileCommand.describe).
|
|
22
|
+
expect(profileCommand.describe).toBeDefined();
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
describe('builder', () => {
|