@hubspot/cli 7.8.12-experimental.0 → 7.8.12-experimental.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +31 -25
- package/commands/__tests__/auth.test.js +5 -0
- package/commands/__tests__/doctor.test.js +16 -16
- package/commands/account/clean.js +18 -27
- package/commands/account/createOverride.js +13 -31
- package/commands/account/info.js +20 -31
- package/commands/account/list.js +16 -22
- package/commands/account/remove.js +12 -20
- package/commands/account/removeOverride.js +11 -21
- package/commands/account/rename.js +6 -9
- package/commands/account/use.js +12 -26
- package/commands/account.js +2 -2
- package/commands/app/__tests__/migrate.test.js +5 -5
- package/commands/app/migrate.js +13 -18
- package/commands/app.js +1 -6
- package/commands/auth.d.ts +1 -0
- package/commands/auth.js +16 -7
- package/commands/cms/convertFields.js +7 -9
- package/commands/cms/getReactModule.js +9 -14
- package/commands/cms/lighthouseScore.js +33 -36
- package/commands/cms.js +2 -2
- package/commands/completion.js +3 -3
- package/commands/config/set.d.ts +1 -1
- package/commands/config/set.js +64 -36
- package/commands/config.js +2 -2
- package/commands/create.js +2 -2
- package/commands/customObject/create.js +10 -12
- package/commands/customObject/schema/create.js +9 -11
- package/commands/customObject/schema/delete.js +16 -16
- package/commands/customObject/schema/fetch-all.js +12 -11
- package/commands/customObject/schema/fetch.js +15 -15
- package/commands/customObject/schema/list.js +4 -4
- package/commands/customObject/schema/update.js +13 -13
- package/commands/customObject/schema.js +2 -2
- package/commands/customObject.js +6 -7
- package/commands/doctor.js +8 -11
- package/commands/feedback.js +6 -11
- package/commands/fetch.js +8 -8
- package/commands/filemanager/fetch.js +7 -7
- package/commands/filemanager/upload.js +15 -34
- package/commands/filemanager.js +2 -2
- package/commands/function/deploy.js +11 -29
- package/commands/function/list.js +8 -8
- package/commands/function/server.js +9 -11
- package/commands/function.d.ts +1 -1
- package/commands/function.js +2 -2
- package/commands/getStarted.js +2 -2
- package/commands/hubdb/clear.js +7 -15
- package/commands/hubdb/create.js +9 -15
- package/commands/hubdb/delete.js +8 -15
- package/commands/hubdb/fetch.js +6 -9
- package/commands/hubdb.d.ts +1 -1
- package/commands/hubdb.js +2 -2
- package/commands/init.js +2 -3
- package/commands/lint.js +16 -16
- package/commands/list.js +8 -14
- package/commands/logs.js +14 -20
- package/commands/mv.js +6 -17
- package/commands/open.js +5 -5
- package/commands/project/__tests__/add.test.js +4 -2
- package/commands/project/__tests__/deploy.test.js +3 -4
- package/commands/project/__tests__/installDeps.test.js +8 -8
- package/commands/project/__tests__/logs.test.js +1 -1
- package/commands/project/__tests__/migrate.test.js +5 -5
- package/commands/project/__tests__/migrateApp.test.js +2 -5
- package/commands/project/__tests__/validate.test.js +98 -0
- package/commands/project/add.js +3 -3
- package/commands/project/cloneApp.js +14 -19
- package/commands/project/create.js +0 -1
- package/commands/project/deploy.js +3 -3
- package/commands/project/dev/deprecatedFlow.js +7 -16
- package/commands/project/dev/index.js +14 -12
- package/commands/project/dev/unifiedFlow.js +3 -1
- package/commands/project/download.js +10 -13
- package/commands/project/installDeps.js +8 -8
- package/commands/project/listBuilds.js +11 -20
- package/commands/project/logs.js +21 -24
- package/commands/project/migrateApp.js +9 -15
- package/commands/project/open.js +6 -13
- package/commands/project/upload.d.ts +2 -2
- package/commands/project/upload.js +17 -26
- package/commands/project/validate.js +6 -6
- package/commands/project/watch.js +13 -22
- package/commands/project.js +2 -2
- package/commands/sandbox/__tests__/create.test.js +5 -5
- package/commands/sandbox/create.js +22 -32
- package/commands/sandbox/delete.js +38 -63
- package/commands/sandbox.js +2 -2
- package/commands/secret/addSecret.js +7 -17
- package/commands/secret/deleteSecret.js +10 -20
- package/commands/secret/listSecret.js +8 -10
- package/commands/secret/updateSecret.js +9 -17
- package/commands/secret.js +2 -2
- package/commands/testAccount/__tests__/delete.test.js +2 -4
- package/commands/testAccount/create.js +0 -3
- package/commands/testAccount/delete.d.ts +4 -3
- package/commands/testAccount/delete.js +155 -14
- package/commands/theme/preview.js +1 -4
- package/lang/en.d.ts +310 -124
- package/lang/en.js +351 -169
- package/lang/en.lyaml +2 -2
- package/lib/__tests__/buildAccount.test.js +2 -1
- package/lib/__tests__/commonOpts.test.js +1 -1
- package/lib/__tests__/dependencyManagement.test.js +1 -1
- package/lib/__tests__/developerTestAccounts.test.js +3 -3
- package/lib/__tests__/npm.test.js +1 -1
- package/lib/__tests__/oauth.test.js +4 -4
- package/lib/__tests__/process.test.js +10 -5
- package/lib/__tests__/sandboxSync.test.js +8 -8
- package/lib/__tests__/sandboxes.test.js +8 -8
- package/lib/__tests__/serverlessLogs.test.js +1 -1
- package/lib/__tests__/usageTracking.test.js +5 -5
- package/lib/__tests__/validation.test.js +2 -1
- package/lib/__tests__/yargsUtils.test.js +83 -9
- package/lib/app/__tests__/migrate.test.js +5 -5
- package/lib/app/__tests__/migrate_legacy.test.js +1 -1
- package/lib/app/migrate.js +1 -1
- package/lib/app/migrate_legacy.js +20 -24
- package/lib/buildAccount.js +25 -57
- package/lib/commonOpts.d.ts +1 -1
- package/lib/commonOpts.js +25 -22
- package/lib/configOptions.js +7 -0
- package/lib/constants.d.ts +6 -1
- package/lib/constants.js +10 -1
- package/lib/dependencyManagement.js +9 -27
- package/lib/developerTestAccounts.js +9 -23
- package/lib/doctor/Diagnosis.js +11 -23
- package/lib/doctor/DiagnosticInfoBuilder.js +12 -11
- package/lib/doctor/Doctor.js +42 -90
- package/lib/doctor/__tests__/Doctor.test.js +4 -4
- package/lib/errorHandlers/index.js +12 -20
- package/lib/errorHandlers/suppressError.js +11 -18
- package/lib/lang.js +6 -5
- package/lib/links.js +4 -4
- package/lib/middleware/__test__/commandTargetingUtils.test.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/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 +14 -34
- package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +70 -39
- package/lib/projects/__tests__/localDevProjectHelpers.test.js +2 -0
- package/lib/projects/__tests__/platformVersion.test.js +8 -8
- package/lib/projects/__tests__/projects.test.js +12 -12
- package/lib/projects/__tests__/structure.test.js +3 -3
- package/lib/projects/__tests__/upload.test.d.ts +1 -0
- package/lib/projects/__tests__/upload.test.js +82 -0
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +6 -6
- package/lib/projects/add/__tests__/v3AddComponent.test.js +4 -4
- package/lib/projects/create/__tests__/legacy.test.js +5 -5
- package/lib/projects/create/__tests__/v3.test.js +1 -1
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/legacy.js +2 -2
- package/lib/projects/create/v3.js +2 -2
- package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -0
- package/lib/projects/localDev/AppDevModeInterface.js +22 -20
- package/lib/projects/localDev/LocalDevLogger.js +10 -11
- package/lib/projects/localDev/LocalDevManager.js +4 -5
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +0 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.js +7 -10
- package/lib/projects/localDev/helpers/project.d.ts +1 -0
- package/lib/projects/localDev/helpers/project.js +37 -0
- package/lib/projects/platformVersion.d.ts +1 -1
- package/lib/projects/platformVersion.js +1 -1
- package/lib/projects/structure.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/__tests__/downloadProjectPrompt.test.js +1 -0
- package/lib/prompts/accountNamePrompt.js +14 -19
- package/lib/prompts/accountsPrompt.js +2 -2
- package/lib/prompts/cmsFieldPrompt.js +2 -2
- package/lib/prompts/createApiSamplePrompt.js +5 -5
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +10 -1
- package/lib/prompts/createFunctionPrompt.js +14 -14
- package/lib/prompts/createModulePrompt.js +9 -9
- package/lib/prompts/createTemplatePrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.js +5 -8
- package/lib/prompts/personalAccessKeyPrompt.js +3 -3
- package/lib/prompts/previewPrompt.js +6 -6
- package/lib/prompts/projectAddPrompt.js +6 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +20 -32
- package/lib/prompts/projectNamePrompt.js +4 -8
- package/lib/prompts/projectsLogsPrompt.js +2 -4
- package/lib/prompts/promptUtils.js +27 -9
- package/lib/prompts/sandboxesPrompt.js +7 -7
- package/lib/prompts/secretPrompt.js +3 -3
- package/lib/prompts/selectAppPrompt.js +3 -3
- package/lib/prompts/selectHubDBTablePrompt.js +9 -13
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +15 -19
- package/lib/prompts/setAsDefaultAccountPrompt.js +4 -8
- package/lib/prompts/uploadPrompt.js +5 -5
- package/lib/sandboxSync.js +24 -41
- package/lib/sandboxes.js +19 -47
- package/lib/schema.js +3 -3
- package/lib/serverlessLogs.js +11 -13
- package/lib/theme/__tests__/migrate.test.js +3 -3
- package/lib/theme/migrate.js +2 -2
- package/lib/ui/SpinniesManager.d.ts +2 -0
- package/lib/ui/SpinniesManager.js +7 -0
- package/lib/ui/boxen.js +1 -2
- package/lib/ui/git.js +13 -10
- package/lib/ui/index.d.ts +4 -0
- package/lib/ui/index.js +47 -38
- package/lib/ui/serverlessFunctionLogs.js +9 -7
- package/lib/ui/uiMessages.d.ts +68 -0
- package/lib/ui/uiMessages.js +71 -0
- package/lib/usageTracking.js +7 -7
- package/lib/validation.js +20 -23
- package/lib/yargsUtils.d.ts +1 -1
- package/lib/yargsUtils.js +12 -5
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +2 -2
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +23 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +68 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +11 -0
- package/mcp-server/tools/project/GetApplicationInfoTool.js +49 -0
- package/mcp-server/tools/project/GetConfigValuesTool.js +2 -2
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +2 -2
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +169 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +115 -0
- package/mcp-server/utils/toolUsageTracking.js +2 -2
- package/package.json +6 -6
- package/types/Yargs.d.ts +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
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
2
|
import { loadConfig, getConfigPath, deleteAccount, getConfigDefaultAccount, getAccountId, updateDefaultAccount, getCWDAccountOverride, getDefaultAccountOverrideFilePath, } from '@hubspot/local-dev-lib/config';
|
|
4
3
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
5
|
-
import { i18n } from '../../lib/lang.js';
|
|
6
4
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
7
5
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
8
6
|
import { selectAccountFromConfig } from '../../lib/prompts/accountsPrompt.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
|
const command = 'remove [account]';
|
|
11
|
-
const describe =
|
|
11
|
+
const describe = commands.account.subcommands.remove.describe;
|
|
12
12
|
async function handler(args) {
|
|
13
13
|
const { account } = args;
|
|
14
14
|
let accountToRemove = account;
|
|
15
15
|
if (accountToRemove && !getAccountId(accountToRemove)) {
|
|
16
|
-
|
|
17
|
-
specifiedAccount: accountToRemove,
|
|
18
|
-
configPath: getConfigPath(),
|
|
19
|
-
}));
|
|
16
|
+
uiLogger.error(commands.account.subcommands.remove.errors.accountNotFound(accountToRemove, getConfigPath()));
|
|
20
17
|
}
|
|
21
18
|
if (!accountToRemove || !getAccountId(accountToRemove)) {
|
|
22
|
-
accountToRemove = await selectAccountFromConfig(
|
|
19
|
+
accountToRemove = await selectAccountFromConfig(commands.account.subcommands.remove.prompts.selectAccountToRemove);
|
|
23
20
|
}
|
|
24
21
|
trackCommandUsage('accounts-remove', undefined, getAccountId(accountToRemove));
|
|
25
22
|
const currentDefaultAccount = getConfigDefaultAccount();
|
|
@@ -31,10 +28,7 @@ async function handler(args) {
|
|
|
31
28
|
const { deleteOverrideFile } = await promptUser({
|
|
32
29
|
type: 'confirm',
|
|
33
30
|
name: 'deleteOverrideFile',
|
|
34
|
-
message:
|
|
35
|
-
overrideFilePath,
|
|
36
|
-
accountName: accountToRemove,
|
|
37
|
-
}),
|
|
31
|
+
message: commands.account.subcommands.remove.prompts.deleteOverrideFile(overrideFilePath, accountToRemove),
|
|
38
32
|
});
|
|
39
33
|
try {
|
|
40
34
|
if (deleteOverrideFile) {
|
|
@@ -46,9 +40,7 @@ async function handler(args) {
|
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
42
|
await deleteAccount(accountToRemove);
|
|
49
|
-
|
|
50
|
-
accountName: accountToRemove,
|
|
51
|
-
}));
|
|
43
|
+
uiLogger.success(commands.account.subcommands.remove.success.accountRemoved(accountToRemove));
|
|
52
44
|
// Get updated version of the config
|
|
53
45
|
loadConfig(getConfigPath());
|
|
54
46
|
const accountToRemoveId = getAccountId(accountToRemove);
|
|
@@ -57,25 +49,25 @@ async function handler(args) {
|
|
|
57
49
|
defaultAccountId = getAccountId(currentDefaultAccount);
|
|
58
50
|
}
|
|
59
51
|
if (accountToRemoveId === defaultAccountId) {
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
uiLogger.log('');
|
|
53
|
+
uiLogger.log(commands.account.subcommands.remove.logs.replaceDefaultAccount);
|
|
62
54
|
const newDefaultAccount = await selectAccountFromConfig();
|
|
63
55
|
updateDefaultAccount(newDefaultAccount);
|
|
64
56
|
}
|
|
65
57
|
}
|
|
66
58
|
function accountRemoveBuilder(yargs) {
|
|
67
59
|
yargs.positional('account', {
|
|
68
|
-
describe:
|
|
60
|
+
describe: commands.account.subcommands.remove.options.account.describe,
|
|
69
61
|
type: 'string',
|
|
70
62
|
});
|
|
71
63
|
yargs.example([
|
|
72
64
|
[
|
|
73
65
|
'$0 accounts remove',
|
|
74
|
-
|
|
66
|
+
commands.account.subcommands.remove.examples.default,
|
|
75
67
|
],
|
|
76
68
|
[
|
|
77
69
|
'$0 accounts remove MyAccount',
|
|
78
|
-
|
|
70
|
+
commands.account.subcommands.remove.examples.byName,
|
|
79
71
|
],
|
|
80
72
|
]);
|
|
81
73
|
return yargs;
|
|
@@ -1,26 +1,21 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
3
2
|
import { getCWDAccountOverride, getDefaultAccountOverrideFilePath, getAccountId, } from '@hubspot/local-dev-lib/config';
|
|
4
3
|
import { DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME } from '@hubspot/local-dev-lib/constants/config';
|
|
5
4
|
import { getGlobalConfig } from '@hubspot/local-dev-lib/config/migrate';
|
|
6
|
-
import { i18n } from '../../lib/lang.js';
|
|
7
5
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
8
6
|
import { trackCommandMetadataUsage } from '../../lib/usageTracking.js';
|
|
9
7
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
10
8
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
11
|
-
import { uiCommandReference } from '../../lib/ui/index.js';
|
|
12
9
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
10
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
11
|
+
import { commands } from '../../lang/en.js';
|
|
13
12
|
const command = 'remove-override';
|
|
14
|
-
const describe =
|
|
15
|
-
overrideFile: DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME,
|
|
16
|
-
});
|
|
13
|
+
const describe = commands.account.subcommands.removeOverride.describe(DEFAULT_ACCOUNT_OVERRIDE_FILE_NAME);
|
|
17
14
|
async function handler(args) {
|
|
18
15
|
const { force } = args;
|
|
19
16
|
const globalConfig = getGlobalConfig();
|
|
20
17
|
if (!globalConfig) {
|
|
21
|
-
|
|
22
|
-
authCommand: uiCommandReference('hs account auth'),
|
|
23
|
-
}));
|
|
18
|
+
uiLogger.error(commands.account.subcommands.removeOverride.errors.globalConfigNotFound);
|
|
24
19
|
process.exit(EXIT_CODES.ERROR);
|
|
25
20
|
}
|
|
26
21
|
const accountOverride = getCWDAccountOverride();
|
|
@@ -28,19 +23,14 @@ async function handler(args) {
|
|
|
28
23
|
if (accountOverride && overrideFilePath) {
|
|
29
24
|
const accountId = getAccountId(accountOverride) || undefined;
|
|
30
25
|
if (!force) {
|
|
31
|
-
|
|
32
|
-
accountOverride,
|
|
33
|
-
overrideFilePath,
|
|
34
|
-
}));
|
|
26
|
+
uiLogger.log(commands.account.subcommands.removeOverride.accountOverride(overrideFilePath, accountOverride.toString()));
|
|
35
27
|
const { deleteOverrideFile } = await promptUser({
|
|
36
28
|
type: 'confirm',
|
|
37
29
|
name: 'deleteOverrideFile',
|
|
38
|
-
message:
|
|
39
|
-
|
|
40
|
-
overrideFilePath,
|
|
41
|
-
}),
|
|
30
|
+
message: commands.account.subcommands.removeOverride.prompts
|
|
31
|
+
.deleteOverrideFile,
|
|
42
32
|
});
|
|
43
|
-
|
|
33
|
+
uiLogger.log('');
|
|
44
34
|
if (!deleteOverrideFile) {
|
|
45
35
|
trackCommandMetadataUsage('account-removeOverride', {
|
|
46
36
|
command: 'hs account remove-override',
|
|
@@ -51,7 +41,7 @@ async function handler(args) {
|
|
|
51
41
|
}
|
|
52
42
|
try {
|
|
53
43
|
fs.unlinkSync(overrideFilePath);
|
|
54
|
-
|
|
44
|
+
uiLogger.success(commands.account.subcommands.removeOverride.success);
|
|
55
45
|
trackCommandMetadataUsage('account-removeOverride', {
|
|
56
46
|
command: 'hs account remove-override',
|
|
57
47
|
step: 'Confirm removing override file (via prompt/force)',
|
|
@@ -65,13 +55,13 @@ async function handler(args) {
|
|
|
65
55
|
}
|
|
66
56
|
}
|
|
67
57
|
else {
|
|
68
|
-
|
|
58
|
+
uiLogger.log(commands.account.subcommands.removeOverride.noOverrideFile);
|
|
69
59
|
process.exit(EXIT_CODES.SUCCESS);
|
|
70
60
|
}
|
|
71
61
|
}
|
|
72
62
|
function accountRemoveOverrideBuilder(yargs) {
|
|
73
63
|
yargs.options('force', {
|
|
74
|
-
describe:
|
|
64
|
+
describe: commands.account.subcommands.removeOverride.options.force.describe,
|
|
75
65
|
type: 'boolean',
|
|
76
66
|
});
|
|
77
67
|
return yargs;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { renameAccount } from '@hubspot/local-dev-lib/config';
|
|
3
2
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
4
|
-
import {
|
|
3
|
+
import { commands } from '../../lang/en.js';
|
|
4
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
5
5
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
6
6
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
7
7
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
8
|
const command = 'rename <account-name> <new-name>';
|
|
9
|
-
const describe =
|
|
9
|
+
const describe = commands.account.subcommands.rename.describe;
|
|
10
10
|
async function handler(args) {
|
|
11
11
|
const { accountName, newName, derivedAccountId } = args;
|
|
12
12
|
trackCommandUsage('accounts-rename', undefined, derivedAccountId);
|
|
@@ -17,19 +17,16 @@ async function handler(args) {
|
|
|
17
17
|
logError(error);
|
|
18
18
|
process.exit(EXIT_CODES.ERROR);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
name: accountName,
|
|
22
|
-
newName,
|
|
23
|
-
}));
|
|
20
|
+
uiLogger.log(commands.account.subcommands.rename.success.renamed(accountName, newName));
|
|
24
21
|
process.exit(EXIT_CODES.SUCCESS);
|
|
25
22
|
}
|
|
26
23
|
function accountRenameBuilder(yargs) {
|
|
27
24
|
yargs.positional('account-name', {
|
|
28
|
-
describe:
|
|
25
|
+
describe: commands.account.subcommands.rename.positionals.accountName.describe,
|
|
29
26
|
type: 'string',
|
|
30
27
|
});
|
|
31
28
|
yargs.positional('new-name', {
|
|
32
|
-
describe:
|
|
29
|
+
describe: commands.account.subcommands.rename.positionals.newName.describe,
|
|
33
30
|
type: 'string',
|
|
34
31
|
});
|
|
35
32
|
yargs.example([
|
package/commands/account/use.js
CHANGED
|
@@ -1,59 +1,45 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { getConfigPath, updateDefaultAccount, getAccountId, getCWDAccountOverride, getDefaultAccountOverrideFilePath, } from '@hubspot/local-dev-lib/config';
|
|
3
2
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
4
|
-
import {
|
|
3
|
+
import { commands } from '../../lang/en.js';
|
|
4
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
5
5
|
import { selectAccountFromConfig } from '../../lib/prompts/accountsPrompt.js';
|
|
6
|
-
import { uiCommandReference } from '../../lib/ui/index.js';
|
|
7
6
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
8
7
|
const command = 'use [account]';
|
|
9
|
-
const describe =
|
|
8
|
+
const describe = commands.account.subcommands.use.describe;
|
|
10
9
|
async function handler(args) {
|
|
11
10
|
let newDefaultAccount = args.account;
|
|
12
11
|
if (!newDefaultAccount) {
|
|
13
12
|
newDefaultAccount = await selectAccountFromConfig();
|
|
14
13
|
}
|
|
15
14
|
else if (!getAccountId(newDefaultAccount)) {
|
|
16
|
-
|
|
17
|
-
specifiedAccount: newDefaultAccount,
|
|
18
|
-
configPath: getConfigPath(),
|
|
19
|
-
}));
|
|
15
|
+
uiLogger.error(commands.account.subcommands.use.errors.accountNotFound(newDefaultAccount, getConfigPath()));
|
|
20
16
|
newDefaultAccount = await selectAccountFromConfig();
|
|
21
17
|
}
|
|
22
18
|
trackCommandUsage('accounts-use', undefined, getAccountId(newDefaultAccount));
|
|
23
19
|
const accountOverride = getCWDAccountOverride();
|
|
24
20
|
const overrideFilePath = getDefaultAccountOverrideFilePath();
|
|
25
21
|
if (accountOverride && overrideFilePath) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
logger.log(i18n(`commands.account.subcommands.use.accountOverrideCommands`, {
|
|
30
|
-
createOverrideCommand: uiCommandReference('hs account create-override'),
|
|
31
|
-
removeOverrideCommand: uiCommandReference('hs account remove-override'),
|
|
32
|
-
}));
|
|
33
|
-
logger.log('');
|
|
22
|
+
uiLogger.warn(commands.account.subcommands.use.accountOverride(accountOverride.toString()));
|
|
23
|
+
uiLogger.log(commands.account.subcommands.use.accountOverrideCommands);
|
|
24
|
+
uiLogger.log('');
|
|
34
25
|
}
|
|
35
26
|
updateDefaultAccount(newDefaultAccount);
|
|
36
|
-
return
|
|
37
|
-
accountName: newDefaultAccount,
|
|
38
|
-
}));
|
|
27
|
+
return uiLogger.success(commands.account.subcommands.use.success.defaultAccountUpdated(newDefaultAccount));
|
|
39
28
|
}
|
|
40
29
|
function accountUseBuilder(yargs) {
|
|
41
30
|
yargs.positional('account', {
|
|
42
|
-
describe:
|
|
31
|
+
describe: commands.account.subcommands.use.options.account.describe,
|
|
43
32
|
type: 'string',
|
|
44
33
|
});
|
|
45
34
|
yargs.example([
|
|
46
|
-
[
|
|
47
|
-
'$0 accounts use',
|
|
48
|
-
i18n('commands.account.subcommands.use.examples.default'),
|
|
49
|
-
],
|
|
35
|
+
['$0 accounts use', commands.account.subcommands.use.examples.default],
|
|
50
36
|
[
|
|
51
37
|
'$0 accounts use MyAccount',
|
|
52
|
-
|
|
38
|
+
commands.account.subcommands.use.examples.nameBased,
|
|
53
39
|
],
|
|
54
40
|
[
|
|
55
41
|
'$0 accounts use 1234567',
|
|
56
|
-
|
|
42
|
+
commands.account.subcommands.use.examples.idBased,
|
|
57
43
|
],
|
|
58
44
|
]);
|
|
59
45
|
return yargs;
|
package/commands/account.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { commands } from '../lang/en.js';
|
|
2
2
|
import auth from './account/auth.js';
|
|
3
3
|
import list from './account/list.js';
|
|
4
4
|
import rename from './account/rename.js';
|
|
@@ -10,7 +10,7 @@ import createOverride from './account/createOverride.js';
|
|
|
10
10
|
import removeOverride from './account/removeOverride.js';
|
|
11
11
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
12
12
|
const command = ['account', 'accounts'];
|
|
13
|
-
const describe =
|
|
13
|
+
const describe = commands.account.describe;
|
|
14
14
|
function accountBuilder(yargs) {
|
|
15
15
|
yargs
|
|
16
16
|
.command(auth)
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import yargs from 'yargs';
|
|
2
2
|
import { PLATFORM_VERSIONS } from '@hubspot/local-dev-lib/constants/projects';
|
|
3
|
-
import {
|
|
3
|
+
import { uiLogger } from '../../../lib/ui/logger.js';
|
|
4
4
|
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
5
5
|
import { migrateApp2025_2 } from '../../../lib/app/migrate.js';
|
|
6
6
|
import { migrateApp2023_2 } from '../../../lib/app/migrate_legacy.js';
|
|
7
7
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
8
8
|
import migrateCommand from '../migrate.js';
|
|
9
9
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
10
|
-
vi.mock('
|
|
10
|
+
vi.mock('../../../lib/ui/logger.js');
|
|
11
11
|
vi.mock('../../../lib/app/migrate');
|
|
12
12
|
vi.mock('../../../lib/app/migrate_legacy');
|
|
13
13
|
vi.mock('../../../lib/projects/config.js');
|
|
@@ -15,7 +15,7 @@ const mockYargs = yargs;
|
|
|
15
15
|
const mockedGetAccountConfig = getAccountConfig;
|
|
16
16
|
const mockedMigrateApp2023_2 = migrateApp2023_2;
|
|
17
17
|
const mockedMigrateApp2025_2 = migrateApp2025_2;
|
|
18
|
-
const
|
|
18
|
+
const mockedUiLogger = uiLogger;
|
|
19
19
|
const optionsSpy = vi.spyOn(mockYargs, 'options');
|
|
20
20
|
const exampleSpy = vi.spyOn(mockYargs, 'example');
|
|
21
21
|
const exitSpy = vi
|
|
@@ -40,7 +40,7 @@ describe('commands/app/migrate', () => {
|
|
|
40
40
|
await migrateCommand.handler({
|
|
41
41
|
derivedAccountId: mockAccountId,
|
|
42
42
|
});
|
|
43
|
-
expect(
|
|
43
|
+
expect(mockedUiLogger.error).toHaveBeenCalled();
|
|
44
44
|
expect(exitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
45
45
|
});
|
|
46
46
|
it('should call migrateApp2025_2 for platform version 2025.2', async () => {
|
|
@@ -80,7 +80,7 @@ describe('commands/app/migrate', () => {
|
|
|
80
80
|
derivedAccountId: mockAccountId,
|
|
81
81
|
platformVersion: PLATFORM_VERSIONS.v2023_2,
|
|
82
82
|
});
|
|
83
|
-
expect(
|
|
83
|
+
expect(mockedUiLogger.error).toHaveBeenCalled();
|
|
84
84
|
expect(exitSpy).toHaveBeenCalledWith(EXIT_CODES.ERROR);
|
|
85
85
|
});
|
|
86
86
|
});
|
package/commands/app/migrate.js
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
3
2
|
import { PLATFORM_VERSIONS } from '@hubspot/local-dev-lib/constants/projects';
|
|
4
3
|
import { trackCommandMetadataUsage, trackCommandUsage, } from '../../lib/usageTracking.js';
|
|
5
|
-
import {
|
|
4
|
+
import { commands } from '../../lang/en.js';
|
|
5
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
6
6
|
import { ApiErrorContext, logError } from '../../lib/errorHandlers/index.js';
|
|
7
7
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
8
8
|
import { migrateApp2025_2 } from '../../lib/app/migrate.js';
|
|
9
|
-
import { uiCommandReference, uiLink } from '../../lib/ui/index.js';
|
|
10
9
|
import { migrateApp2023_2 } from '../../lib/app/migrate_legacy.js';
|
|
11
10
|
import { getIsInProject } from '../../lib/projects/config.js';
|
|
12
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
13
12
|
const { v2023_2, v2025_2 } = PLATFORM_VERSIONS;
|
|
14
13
|
const command = 'migrate';
|
|
15
|
-
const describe =
|
|
14
|
+
const describe = commands.project.migrateApp.describe;
|
|
16
15
|
export function handlerGenerator(commandTrackingName) {
|
|
17
16
|
return async function handler(args) {
|
|
18
17
|
const { derivedAccountId, platformVersion, unstable } = args;
|
|
19
18
|
await trackCommandUsage(commandTrackingName, {}, derivedAccountId);
|
|
20
19
|
const accountConfig = getAccountConfig(derivedAccountId);
|
|
21
20
|
if (!accountConfig) {
|
|
22
|
-
|
|
21
|
+
uiLogger.error(commands.project.migrateApp.errors.noAccountConfig);
|
|
23
22
|
return process.exit(EXIT_CODES.ERROR);
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
logger.log('');
|
|
24
|
+
uiLogger.log('');
|
|
25
|
+
uiLogger.log(commands.project.migrateApp.header);
|
|
26
|
+
uiLogger.log('');
|
|
29
27
|
try {
|
|
30
28
|
if (platformVersion === v2025_2 || unstable) {
|
|
31
29
|
if (getIsInProject()) {
|
|
32
|
-
|
|
30
|
+
uiLogger.error(commands.project.migrateApp.errors.notAllowedWithinProject);
|
|
33
31
|
return process.exit(EXIT_CODES.ERROR);
|
|
34
32
|
}
|
|
35
33
|
args.platformVersion = unstable
|
|
@@ -62,15 +60,15 @@ const handler = handlerGenerator('app-migrate');
|
|
|
62
60
|
function appMigrateBuilder(yargs) {
|
|
63
61
|
yargs.options({
|
|
64
62
|
name: {
|
|
65
|
-
describe:
|
|
63
|
+
describe: commands.project.migrateApp.options.name.describe,
|
|
66
64
|
type: 'string',
|
|
67
65
|
},
|
|
68
66
|
dest: {
|
|
69
|
-
describe:
|
|
67
|
+
describe: commands.project.migrateApp.options.dest.describe,
|
|
70
68
|
type: 'string',
|
|
71
69
|
},
|
|
72
70
|
'app-id': {
|
|
73
|
-
describe:
|
|
71
|
+
describe: commands.project.migrateApp.options.appId.describe,
|
|
74
72
|
type: 'number',
|
|
75
73
|
},
|
|
76
74
|
'platform-version': {
|
|
@@ -85,14 +83,11 @@ function appMigrateBuilder(yargs) {
|
|
|
85
83
|
},
|
|
86
84
|
});
|
|
87
85
|
yargs.example([
|
|
88
|
-
[
|
|
89
|
-
`$0 app migrate`,
|
|
90
|
-
i18n(`commands.project.subcommands.migrateApp.examples.default`),
|
|
91
|
-
],
|
|
86
|
+
[`$0 app migrate`, commands.project.migrateApp.examples.default],
|
|
92
87
|
]);
|
|
93
88
|
return yargs;
|
|
94
89
|
}
|
|
95
|
-
const builder = makeYargsBuilder(appMigrateBuilder, command,
|
|
90
|
+
const builder = makeYargsBuilder(appMigrateBuilder, command, commands.project.migrateApp.describe, {
|
|
96
91
|
useGlobalOptions: true,
|
|
97
92
|
useConfigOptions: true,
|
|
98
93
|
useAccountOptions: true,
|
package/commands/app.js
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import migrateCommand from './app/migrate.js';
|
|
2
2
|
import appSecretCommand from './app/secret.js';
|
|
3
|
-
import installAppCommand from './app/install.js';
|
|
4
3
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
5
4
|
import { commands } from '../lang/en.js';
|
|
6
5
|
const command = ['app', 'apps'];
|
|
7
6
|
const describe = commands.app.describe;
|
|
8
7
|
function appBuilder(yargs) {
|
|
9
|
-
yargs
|
|
10
|
-
.command(migrateCommand)
|
|
11
|
-
.command(appSecretCommand)
|
|
12
|
-
.command(installAppCommand)
|
|
13
|
-
.demandCommand(1, '');
|
|
8
|
+
yargs.command(migrateCommand).command(appSecretCommand).demandCommand(1, '');
|
|
14
9
|
return yargs;
|
|
15
10
|
}
|
|
16
11
|
const builder = makeYargsBuilder(appBuilder, command, describe);
|
package/commands/auth.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AccountArgs, CommonArgs, ConfigArgs, TestingArgs, YargsCommandModule } from '../types/Yargs.js';
|
|
2
2
|
type AuthArgs = CommonArgs & ConfigArgs & TestingArgs & AccountArgs & {
|
|
3
3
|
authType?: string;
|
|
4
|
+
disableTracking: boolean;
|
|
4
5
|
} & {
|
|
5
6
|
personalAccessKey?: string;
|
|
6
7
|
};
|
package/commands/auth.js
CHANGED
|
@@ -9,7 +9,7 @@ import { promptUser } from '../lib/prompts/promptUtils.js';
|
|
|
9
9
|
import { personalAccessKeyPrompt, OAUTH_FLOW, } from '../lib/prompts/personalAccessKeyPrompt.js';
|
|
10
10
|
import { cliAccountNamePrompt } from '../lib/prompts/accountNamePrompt.js';
|
|
11
11
|
import { setAsDefaultAccountPrompt } from '../lib/prompts/setAsDefaultAccountPrompt.js';
|
|
12
|
-
import {
|
|
12
|
+
import { setCLILogLevel } from '../lib/commonOpts.js';
|
|
13
13
|
import { makeYargsBuilder } from '../lib/yargsUtils.js';
|
|
14
14
|
import { trackAuthAction, trackCommandUsage } from '../lib/usageTracking.js';
|
|
15
15
|
import { authenticateWithOauth } from '../lib/oauth.js';
|
|
@@ -32,7 +32,7 @@ const SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT = commaSeparatedValues(ALLOWED_AUT
|
|
|
32
32
|
const command = 'auth';
|
|
33
33
|
const describe = commands.auth.describe;
|
|
34
34
|
async function handler(args) {
|
|
35
|
-
const { authType: authTypeFlagValue, config: configFlagValue, qa, personalAccessKey: providedPersonalAccessKey, userProvidedAccount, } = args;
|
|
35
|
+
const { authType: authTypeFlagValue, config: configFlagValue, qa, personalAccessKey: providedPersonalAccessKey, userProvidedAccount, disableTracking, } = args;
|
|
36
36
|
let parsedUserProvidedAccountId;
|
|
37
37
|
try {
|
|
38
38
|
if (userProvidedAccount) {
|
|
@@ -45,7 +45,7 @@ async function handler(args) {
|
|
|
45
45
|
}
|
|
46
46
|
const authType = (authTypeFlagValue && authTypeFlagValue.toLowerCase()) ||
|
|
47
47
|
PERSONAL_ACCESS_KEY_AUTH_METHOD.value;
|
|
48
|
-
|
|
48
|
+
setCLILogLevel(args);
|
|
49
49
|
const env = qa ? ENVIRONMENTS.QA : ENVIRONMENTS.PROD;
|
|
50
50
|
// Needed to load deprecated config
|
|
51
51
|
loadConfig(configFlagValue);
|
|
@@ -57,8 +57,10 @@ async function handler(args) {
|
|
|
57
57
|
uiLogger.error(commands.auth.errors.globalConfigFileExists('hs account auth'));
|
|
58
58
|
process.exit(EXIT_CODES.ERROR);
|
|
59
59
|
}
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (!disableTracking) {
|
|
61
|
+
trackCommandUsage('auth');
|
|
62
|
+
trackAuthAction('auth', authType, TRACKING_STATUS.STARTED, parsedUserProvidedAccountId);
|
|
63
|
+
}
|
|
62
64
|
let configData;
|
|
63
65
|
let updatedConfig;
|
|
64
66
|
let validName;
|
|
@@ -110,7 +112,7 @@ async function handler(args) {
|
|
|
110
112
|
uiLogger.error(commands.auth.errors.unsupportedAuthType(authType, SUPPORTED_AUTHENTICATION_PROTOCOLS_TEXT));
|
|
111
113
|
break;
|
|
112
114
|
}
|
|
113
|
-
if (!successAuthMethod) {
|
|
115
|
+
if (!successAuthMethod && !disableTracking) {
|
|
114
116
|
await trackAuthAction('auth', authType, TRACKING_STATUS.ERROR, parsedUserProvidedAccountId);
|
|
115
117
|
process.exit(EXIT_CODES.ERROR);
|
|
116
118
|
}
|
|
@@ -124,7 +126,9 @@ async function handler(args) {
|
|
|
124
126
|
'accountsListCommand',
|
|
125
127
|
]);
|
|
126
128
|
const accountId = getAccountId(accountName) || undefined;
|
|
127
|
-
|
|
129
|
+
if (!disableTracking) {
|
|
130
|
+
await trackAuthAction('auth', authType, TRACKING_STATUS.COMPLETE, accountId);
|
|
131
|
+
}
|
|
128
132
|
process.exit(EXIT_CODES.SUCCESS);
|
|
129
133
|
}
|
|
130
134
|
function authBuilder(yargs) {
|
|
@@ -149,6 +153,11 @@ function authBuilder(yargs) {
|
|
|
149
153
|
hidden: false,
|
|
150
154
|
alias: 'pak',
|
|
151
155
|
},
|
|
156
|
+
'disable-tracking': {
|
|
157
|
+
type: 'boolean',
|
|
158
|
+
hidden: true,
|
|
159
|
+
default: false,
|
|
160
|
+
},
|
|
152
161
|
});
|
|
153
162
|
return yargs;
|
|
154
163
|
}
|
|
@@ -2,21 +2,19 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { createIgnoreFilter } from '@hubspot/local-dev-lib/ignoreRules';
|
|
4
4
|
import { isAllowedExtension, getCwd } from '@hubspot/local-dev-lib/path';
|
|
5
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
6
5
|
import { walk } from '@hubspot/local-dev-lib/fs';
|
|
7
6
|
import { getThemeJSONPath } from '@hubspot/local-dev-lib/cms/themes';
|
|
8
|
-
import {
|
|
7
|
+
import { commands } from '../../lang/en.js';
|
|
8
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
9
9
|
import { FieldsJs, isConvertableFieldJs, } from '@hubspot/local-dev-lib/cms/handleFieldsJS';
|
|
10
10
|
import { trackConvertFieldsUsage } from '../../lib/usageTracking.js';
|
|
11
11
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
12
12
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
13
13
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
14
14
|
const command = 'convert-fields';
|
|
15
|
-
const describe =
|
|
15
|
+
const describe = commands.convertFields.describe;
|
|
16
16
|
function invalidPath(src) {
|
|
17
|
-
|
|
18
|
-
path: src,
|
|
19
|
-
}));
|
|
17
|
+
uiLogger.error(commands.convertFields.errors.invalidPath(src));
|
|
20
18
|
process.exit(EXIT_CODES.ERROR);
|
|
21
19
|
}
|
|
22
20
|
async function handler(args) {
|
|
@@ -77,13 +75,13 @@ async function handler(args) {
|
|
|
77
75
|
}
|
|
78
76
|
function convertFieldsBuilder(yargs) {
|
|
79
77
|
yargs.option('src', {
|
|
80
|
-
describe:
|
|
78
|
+
describe: commands.convertFields.positionals.src.describe,
|
|
81
79
|
type: 'string',
|
|
82
80
|
required: true,
|
|
83
|
-
demandOption:
|
|
81
|
+
demandOption: commands.convertFields.errors.missingSrc,
|
|
84
82
|
});
|
|
85
83
|
yargs.option('fieldOptions', {
|
|
86
|
-
describe:
|
|
84
|
+
describe: commands.convertFields.options.options.describe,
|
|
87
85
|
type: 'array',
|
|
88
86
|
default: [''],
|
|
89
87
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getCwd } from '@hubspot/local-dev-lib/path';
|
|
4
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
5
4
|
import { retrieveDefaultModule } from '@hubspot/local-dev-lib/cms/modules';
|
|
6
|
-
import {
|
|
5
|
+
import { commands } from '../../lang/en.js';
|
|
6
|
+
import { uiLogger } from '../../lib/ui/logger.js';
|
|
7
7
|
import { logError } from '../../lib/errorHandlers/index.js';
|
|
8
8
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
9
9
|
import { listPrompt } from '../../lib/prompts/promptUtils.js';
|
|
10
10
|
import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
11
11
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
12
12
|
const command = 'get-react-module [name] [dest]';
|
|
13
|
-
const describe =
|
|
13
|
+
const describe = commands.cms.subcommands.getReactModule.describe;
|
|
14
14
|
async function handler(args) {
|
|
15
15
|
const { name, dest } = args;
|
|
16
16
|
trackCommandUsage('get-react-modules');
|
|
@@ -26,7 +26,7 @@ async function handler(args) {
|
|
|
26
26
|
if (!availableModules) {
|
|
27
27
|
process.exit(EXIT_CODES.ERROR);
|
|
28
28
|
}
|
|
29
|
-
const moduleChoice = await listPrompt(
|
|
29
|
+
const moduleChoice = await listPrompt(commands.cms.subcommands.getReactModule.selectModulePrompt, {
|
|
30
30
|
choices: availableModules.map(module => module.name),
|
|
31
31
|
});
|
|
32
32
|
moduleToRetrieve = moduleChoice;
|
|
@@ -35,22 +35,17 @@ async function handler(args) {
|
|
|
35
35
|
? path.join(path.resolve(getCwd(), dest), `${moduleToRetrieve}`)
|
|
36
36
|
: path.join(getCwd(), `${moduleToRetrieve}`);
|
|
37
37
|
if (fs.existsSync(destPath)) {
|
|
38
|
-
|
|
39
|
-
path: destPath,
|
|
40
|
-
}));
|
|
38
|
+
uiLogger.error(commands.cms.subcommands.getReactModule.errors.pathExists(destPath));
|
|
41
39
|
process.exit(EXIT_CODES.ERROR);
|
|
42
40
|
}
|
|
43
41
|
try {
|
|
44
42
|
await retrieveDefaultModule(moduleToRetrieve, destPath);
|
|
45
|
-
|
|
46
|
-
moduleName: moduleToRetrieve,
|
|
47
|
-
path: destPath,
|
|
48
|
-
}));
|
|
43
|
+
uiLogger.success(commands.cms.subcommands.getReactModule.success.moduleDownloaded(moduleToRetrieve, destPath));
|
|
49
44
|
}
|
|
50
45
|
catch (e) {
|
|
51
46
|
const isBadRequestError = e?.cause?.code === 'ERR_BAD_REQUEST';
|
|
52
47
|
if (isBadRequestError) {
|
|
53
|
-
|
|
48
|
+
uiLogger.error(commands.cms.subcommands.getReactModule.errors.invalidName);
|
|
54
49
|
}
|
|
55
50
|
else {
|
|
56
51
|
logError(e);
|
|
@@ -61,11 +56,11 @@ async function handler(args) {
|
|
|
61
56
|
}
|
|
62
57
|
function cmsGetReactModuleBuilder(yargs) {
|
|
63
58
|
yargs.positional('name', {
|
|
64
|
-
describe:
|
|
59
|
+
describe: commands.cms.subcommands.getReactModule.positionals.name.describe,
|
|
65
60
|
type: 'string',
|
|
66
61
|
});
|
|
67
62
|
yargs.positional('dest', {
|
|
68
|
-
describe:
|
|
63
|
+
describe: commands.cms.subcommands.getReactModule.positionals.dest.describe,
|
|
69
64
|
type: 'string',
|
|
70
65
|
});
|
|
71
66
|
return yargs;
|