@hubspot/cli 7.7.35-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 +2 -2
- 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 +2 -9
- 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.js +16 -25
- 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/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 -98
- package/lang/en.js +312 -96
- 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.d.ts +1 -0
- 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/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.js +6 -6
- package/lib/projects/upload.d.ts +1 -1
- package/lib/projects/upload.js +17 -8
- 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/ui/index.js +1 -1
- 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/middleware/__test__/utils.test.d.ts → commands/project/__tests__/validate.test.d.ts} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { logger } from '@hubspot/local-dev-lib/logger';
|
|
2
1
|
import { loadConfig, getAccountId, configFileExists, getConfigPath, validateConfig, } from '@hubspot/local-dev-lib/config';
|
|
3
2
|
import { validateAccount } from '../validation.js';
|
|
4
3
|
import { EXIT_CODES } from '../enums/exitCodes.js';
|
|
5
|
-
import {
|
|
4
|
+
import { commands } from '../../lang/en.js';
|
|
6
5
|
import { uiDeprecatedTag } from '../ui/index.js';
|
|
7
|
-
import { isTargetedCommand } from './
|
|
6
|
+
import { isTargetedCommand, shouldLoadConfigForCommand, shouldRunAccountValidationForCommand, shouldRunConfigValidationForCommand, } from './commandTargetingUtils.js';
|
|
8
7
|
import { parseStringToNumber } from '../parsing.js';
|
|
9
8
|
import { uiLogger } from '../ui/logger.js';
|
|
10
9
|
import { lib } from '../../lang/en.js';
|
|
@@ -14,9 +13,7 @@ export function handleDeprecatedEnvVariables(argv) {
|
|
|
14
13
|
if (argv.useEnv &&
|
|
15
14
|
process.env.HUBSPOT_PORTAL_ID &&
|
|
16
15
|
!process.env.HUBSPOT_ACCOUNT_ID) {
|
|
17
|
-
uiDeprecatedTag(
|
|
18
|
-
configPath: getConfigPath(),
|
|
19
|
-
}));
|
|
16
|
+
uiDeprecatedTag(commands.generalErrors.handleDeprecatedEnvVariables.portalEnvVarDeprecated);
|
|
20
17
|
process.env.HUBSPOT_ACCOUNT_ID = process.env.HUBSPOT_PORTAL_ID;
|
|
21
18
|
}
|
|
22
19
|
}
|
|
@@ -39,99 +36,42 @@ export async function injectAccountIdMiddleware(argv) {
|
|
|
39
36
|
argv.derivedAccountId = getAccountId(account);
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
init: { target: true },
|
|
44
|
-
auth: { target: true },
|
|
45
|
-
mcp: {
|
|
46
|
-
target: false,
|
|
47
|
-
subCommands: {
|
|
48
|
-
setup: { target: true },
|
|
49
|
-
start: { target: true },
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
export async function loadConfigMiddleware(argv) {
|
|
39
|
+
export async function loadAndValidateConfigMiddleware(argv) {
|
|
54
40
|
// Skip this when no command is provided
|
|
55
41
|
if (!argv._.length || argv.help) {
|
|
56
42
|
return;
|
|
57
43
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
!validateConfig()) {
|
|
61
|
-
process.exit(EXIT_CODES.ERROR);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
if (!configFileExists(true) &&
|
|
65
|
-
isTargetedCommand(argv._, {
|
|
66
|
-
account: { target: false, subCommands: { auth: { target: true } } },
|
|
67
|
-
config: { target: false, subCommands: { migrate: { target: true } } },
|
|
68
|
-
})) {
|
|
44
|
+
// Do not load or validate the config for the commands that do not require it
|
|
45
|
+
if (!shouldLoadConfigForCommand(argv._)) {
|
|
69
46
|
return;
|
|
70
47
|
}
|
|
48
|
+
// If the config file exists and the --config flag is used, exit with an error
|
|
71
49
|
if (configFileExists(true) &&
|
|
72
50
|
argv.config &&
|
|
73
|
-
!isTargetedCommand(argv._, {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
!isTargetedCommand(argv._, { config: { migrate: true } })) {
|
|
52
|
+
uiLogger.error(commands.generalErrors.loadConfigMiddleware.configFileExists(getConfigPath()));
|
|
53
|
+
process.exit(EXIT_CODES.ERROR);
|
|
54
|
+
}
|
|
55
|
+
const config = loadConfig(argv.config, argv);
|
|
56
|
+
// We don't run validation for auth because users should be able to run it when
|
|
57
|
+
// no accounts are configured, but we still want to exit if the config file is not found
|
|
58
|
+
if (isTargetedCommand(argv._, { auth: true }) && !config) {
|
|
79
59
|
process.exit(EXIT_CODES.ERROR);
|
|
80
60
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (isTargetedCommand(argv._, { auth: { target: true } }) && !config) {
|
|
61
|
+
// Only validate the config if the command requires it
|
|
62
|
+
if (shouldRunConfigValidationForCommand(argv._)) {
|
|
63
|
+
const configIsValid = validateConfig();
|
|
64
|
+
if (!configIsValid) {
|
|
86
65
|
process.exit(EXIT_CODES.ERROR);
|
|
87
66
|
}
|
|
88
67
|
}
|
|
89
|
-
maybeValidateConfig();
|
|
90
68
|
}
|
|
91
|
-
const accountsSubCommands = {
|
|
92
|
-
target: false,
|
|
93
|
-
subCommands: {
|
|
94
|
-
auth: { target: true },
|
|
95
|
-
clean: { target: true },
|
|
96
|
-
list: { target: true },
|
|
97
|
-
ls: { target: true },
|
|
98
|
-
remove: { target: true },
|
|
99
|
-
use: { target: true },
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
const sandboxesSubCommands = {
|
|
103
|
-
target: false,
|
|
104
|
-
subCommands: {
|
|
105
|
-
delete: { target: true },
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
const configSubCommands = {
|
|
109
|
-
target: false,
|
|
110
|
-
subCommands: {
|
|
111
|
-
migrate: { target: true },
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
const SKIP_ACCOUNT_VALIDATION = {
|
|
115
|
-
init: { target: true },
|
|
116
|
-
auth: { target: true },
|
|
117
|
-
mcp: {
|
|
118
|
-
target: false,
|
|
119
|
-
subCommands: {
|
|
120
|
-
setup: { target: true },
|
|
121
|
-
start: { target: true },
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
account: accountsSubCommands,
|
|
125
|
-
accounts: accountsSubCommands,
|
|
126
|
-
sandbox: sandboxesSubCommands,
|
|
127
|
-
sandboxes: sandboxesSubCommands,
|
|
128
|
-
config: configSubCommands,
|
|
129
|
-
};
|
|
130
69
|
export async function validateAccountOptions(argv) {
|
|
131
70
|
// Skip this when no command is provided
|
|
132
71
|
if (argv._.length && !argv.help) {
|
|
133
72
|
let validAccount = true;
|
|
134
|
-
if
|
|
73
|
+
// Only validate the account if the command requires it
|
|
74
|
+
if (shouldRunAccountValidationForCommand(argv._)) {
|
|
135
75
|
validAccount = await validateAccount(argv);
|
|
136
76
|
}
|
|
137
77
|
if (!validAccount) {
|
|
@@ -3,6 +3,8 @@ import { fetchFireAlarms } from '@hubspot/local-dev-lib/api/fireAlarm';
|
|
|
3
3
|
import { debugError } from '../errorHandlers/index.js';
|
|
4
4
|
import pkg from '../../package.json' with { type: 'json' };
|
|
5
5
|
import { logInBox } from '../ui/boxen.js';
|
|
6
|
+
import { renderInline } from '../../ui/index.js';
|
|
7
|
+
import { getWarningBox } from '../../ui/components/StatusMessageBoxes.js';
|
|
6
8
|
/*
|
|
7
9
|
* Versions can be formatted like this:
|
|
8
10
|
* =7.2.2 -> targets the exact version 7.2.2
|
|
@@ -98,12 +100,20 @@ async function logFireAlarms(accountId, command, version) {
|
|
|
98
100
|
}
|
|
99
101
|
return acc;
|
|
100
102
|
}, '');
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
if (!process.env.HUBSPOT_ENABLE_INK) {
|
|
104
|
+
await logInBox({
|
|
105
|
+
contents: notifications,
|
|
106
|
+
options: {
|
|
107
|
+
title: 'Notifications',
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
await renderInline(getWarningBox({
|
|
104
113
|
title: 'Notifications',
|
|
105
|
-
|
|
106
|
-
|
|
114
|
+
message: notifications,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
export async function checkFireAlarms(argv) {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { getConfigPath } from '@hubspot/local-dev-lib/config';
|
|
1
|
+
import { getConfigPath, configFileExists } from '@hubspot/local-dev-lib/config';
|
|
2
2
|
import { checkAndWarnGitInclusion } from '../ui/git.js';
|
|
3
3
|
export function checkAndWarnGitInclusionMiddleware(argv) {
|
|
4
4
|
// Skip this when no command is provided
|
|
5
5
|
if (argv._.length) {
|
|
6
|
+
// Skip if using global config
|
|
7
|
+
if (configFileExists(true)) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
6
10
|
const configPath = getConfigPath();
|
|
7
11
|
if (configPath) {
|
|
8
12
|
checkAndWarnGitInclusion(configPath);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import updateNotifier from 'update-notifier';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
2
|
import pkg from '../../package.json' with { type: 'json' };
|
|
4
|
-
import { UI_COLORS
|
|
5
|
-
import {
|
|
3
|
+
import { UI_COLORS } from '../ui/index.js';
|
|
4
|
+
import { lib } from '../../lang/en.js';
|
|
6
5
|
const notifier = updateNotifier({
|
|
7
6
|
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
8
7
|
distTag: 'latest',
|
|
@@ -12,13 +11,8 @@ const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
|
12
11
|
export function notifyAboutUpdates() {
|
|
13
12
|
notifier.notify({
|
|
14
13
|
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
15
|
-
?
|
|
16
|
-
|
|
17
|
-
updateCommand: uiCommandReference('{updateCommand}'),
|
|
18
|
-
})
|
|
19
|
-
: i18n(`commands.generalErrors.updateNotify.cliUpdateNotification`, {
|
|
20
|
-
updateCommand: uiCommandReference('{updateCommand}'),
|
|
21
|
-
}),
|
|
14
|
+
? lib.middleware.updateNotification.cmsUpdateNotification(CMS_CLI_PACKAGE_NAME)
|
|
15
|
+
: lib.middleware.updateNotification.cliUpdateNotification,
|
|
22
16
|
defer: false,
|
|
23
17
|
boxenOptions: {
|
|
24
18
|
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
@@ -28,7 +22,7 @@ export function notifyAboutUpdates() {
|
|
|
28
22
|
borderStyle: 'round',
|
|
29
23
|
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
30
24
|
? undefined
|
|
31
|
-
:
|
|
25
|
+
: lib.middleware.updateNotification.notifyTitle,
|
|
32
26
|
},
|
|
33
27
|
});
|
|
34
28
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { uiLogger } from '../ui/logger.js';
|
|
2
2
|
import { EXIT_CODES } from '../enums/exitCodes.js';
|
|
3
|
-
import {
|
|
3
|
+
import { commands } from '../../lang/en.js';
|
|
4
4
|
import { getIsInProject } from '../projects/config.js';
|
|
5
|
-
import { isTargetedCommand } from './
|
|
5
|
+
import { isTargetedCommand } from './commandTargetingUtils.js';
|
|
6
6
|
const UPLOAD_AND_WATCH_COMMANDS = {
|
|
7
|
-
upload:
|
|
8
|
-
watch:
|
|
7
|
+
upload: true,
|
|
8
|
+
watch: true,
|
|
9
9
|
};
|
|
10
10
|
export function performChecks(argv) {
|
|
11
11
|
// Require "project" command when running upload/watch inside of a project
|
|
12
12
|
if (isTargetedCommand(argv._, UPLOAD_AND_WATCH_COMMANDS) &&
|
|
13
13
|
getIsInProject(argv.src)) {
|
|
14
|
-
|
|
15
|
-
src: argv.src || './',
|
|
16
|
-
command: argv._.join(' '),
|
|
17
|
-
}));
|
|
14
|
+
uiLogger.error(commands.generalErrors.srcIsProject(argv.src || './', argv._.join(' ')));
|
|
18
15
|
process.exit(EXIT_CODES.ERROR);
|
|
19
16
|
}
|
|
20
17
|
return true;
|
package/lib/npm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { exec as execAsync } from 'node:child_process';
|
|
2
2
|
import util from 'util';
|
|
3
|
-
import {
|
|
3
|
+
import { uiLogger } from './ui/logger.js';
|
|
4
4
|
import pkg from '../package.json' with { type: 'json' };
|
|
5
5
|
export const DEFAULT_PACKAGE_MANAGER = 'npm';
|
|
6
6
|
export async function isGloballyInstalled(packageName) {
|
|
@@ -21,7 +21,7 @@ export async function getLatestCliVersion() {
|
|
|
21
21
|
}
|
|
22
22
|
export async function executeInstall(packages = [], flags, options) {
|
|
23
23
|
const installCommand = `${DEFAULT_PACKAGE_MANAGER} install${flags ? ` ${flags}` : ''} ${packages.join(' ')}`;
|
|
24
|
-
|
|
24
|
+
uiLogger.debug('Running', installCommand);
|
|
25
25
|
const exec = util.promisify(execAsync);
|
|
26
26
|
await exec(installCommand, options);
|
|
27
27
|
}
|
package/lib/oauth.js
CHANGED
|
@@ -5,11 +5,11 @@ import { getAccountConfig } from '@hubspot/local-dev-lib/config';
|
|
|
5
5
|
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
|
|
6
6
|
import { addOauthToAccountConfig } from '@hubspot/local-dev-lib/oauth';
|
|
7
7
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
8
|
-
import {
|
|
8
|
+
import { uiLogger } from './ui/logger.js';
|
|
9
9
|
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
10
10
|
import { DEFAULT_OAUTH_SCOPES } from '@hubspot/local-dev-lib/constants/auth';
|
|
11
11
|
import { handleExit } from './process.js';
|
|
12
|
-
import {
|
|
12
|
+
import { lib } from '../lang/en.js';
|
|
13
13
|
import { EXIT_CODES } from './enums/exitCodes.js';
|
|
14
14
|
const PORT = 3000;
|
|
15
15
|
const redirectUri = `http://localhost:${PORT}/oauth-callback`;
|
|
@@ -18,7 +18,7 @@ function buildAuthUrl(oauthManager) {
|
|
|
18
18
|
const env = accountEnv || ENVIRONMENTS.PROD;
|
|
19
19
|
const scopes = accountScopes || DEFAULT_OAUTH_SCOPES;
|
|
20
20
|
if (!clientId) {
|
|
21
|
-
|
|
21
|
+
uiLogger.error(lib.oauth.missingClientId);
|
|
22
22
|
process.exit(EXIT_CODES.ERROR);
|
|
23
23
|
}
|
|
24
24
|
return (`${getHubSpotWebsiteOrigin(env)}/oauth/${oauthManager.account.accountId}/authorize` +
|
|
@@ -77,7 +77,7 @@ async function authorize(oauthManager) {
|
|
|
77
77
|
reject();
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
|
-
server = app.listen(PORT, () =>
|
|
80
|
+
server = app.listen(PORT, () => uiLogger.log(`Waiting for authorization...`));
|
|
81
81
|
handleServerOnProcessEnd(server);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -91,7 +91,7 @@ function setupOauth(accountConfig) {
|
|
|
91
91
|
}
|
|
92
92
|
export async function authenticateWithOauth(accountConfig) {
|
|
93
93
|
const oauthManager = setupOauth(accountConfig);
|
|
94
|
-
|
|
94
|
+
uiLogger.log('Authorizing');
|
|
95
95
|
await authorize(oauthManager);
|
|
96
96
|
addOauthToAccountConfig(oauthManager);
|
|
97
97
|
}
|
package/lib/process.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import readline from 'readline';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { setLogLevel, LOG_LEVEL } from '@hubspot/local-dev-lib/logger';
|
|
3
|
+
import { uiLogger } from './ui/logger.js';
|
|
4
|
+
import { lib } from '../lang/en.js';
|
|
4
5
|
import { logError } from './errorHandlers/index.js';
|
|
5
6
|
const SIGHUP = 'SIGHUP';
|
|
6
7
|
const uncaughtException = 'uncaughtException';
|
|
@@ -26,13 +27,13 @@ export function handleExit(callback) {
|
|
|
26
27
|
if (isSIGHUP) {
|
|
27
28
|
setLogLevel(LOG_LEVEL.NONE);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
uiLogger.debug(lib.process.exitDebug(signal));
|
|
30
31
|
if (signal === uncaughtException && args && args.length > 0) {
|
|
31
32
|
try {
|
|
32
33
|
logError(args[0]);
|
|
33
34
|
}
|
|
34
35
|
catch (e) {
|
|
35
|
-
|
|
36
|
+
uiLogger.error(String(args[0]));
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
await callback({ isSIGHUP });
|
|
@@ -67,6 +67,8 @@ describe('AppDevModeInterface', () => {
|
|
|
67
67
|
componentRoot: '/test/path',
|
|
68
68
|
componentConfigPath: '/test/path/config.json',
|
|
69
69
|
configUpdatedSinceLastUpload: false,
|
|
70
|
+
removed: false,
|
|
71
|
+
parsingErrors: [],
|
|
70
72
|
},
|
|
71
73
|
componentDeps: {},
|
|
72
74
|
metaFilePath: '/test/path',
|