@hubspot/cli 8.6.0-beta.0 → 8.6.0-beta.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 +4 -3
- package/commands/project/dev/unifiedFlow.js +19 -10
- package/lang/en.d.ts +1 -0
- package/lang/en.js +1 -0
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +1 -0
- package/lib/prompts/projectDevTargetAccountPrompt.js +10 -0
- package/lib/yargs/parseYargsOrExit.d.ts +4 -0
- package/lib/yargs/parseYargsOrExit.js +25 -0
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -36,6 +36,7 @@ import { uiLogger } from '../lib/ui/logger.js';
|
|
|
36
36
|
import { initializeSpinniesManager } from '../lib/middleware/spinniesMiddleware.js';
|
|
37
37
|
import { addCommandSuggestions } from '../lib/commandSuggestion.js';
|
|
38
38
|
import { pkg } from '../lib/jsonLoader.js';
|
|
39
|
+
import { parseYargsOrExit } from '../lib/yargs/parseYargsOrExit.js';
|
|
39
40
|
function getTerminalWidth() {
|
|
40
41
|
const width = yargs().terminalWidth();
|
|
41
42
|
if (width >= 100)
|
|
@@ -74,7 +75,6 @@ const argv = yargs(process.argv.slice(2))
|
|
|
74
75
|
initializeSpinniesManager,
|
|
75
76
|
])
|
|
76
77
|
.exitProcess(false)
|
|
77
|
-
.fail(handleFailure)
|
|
78
78
|
.option('noHyperlinks', {
|
|
79
79
|
default: false,
|
|
80
80
|
describe: 'prevent hyperlinks from displaying in the ui',
|
|
@@ -119,7 +119,7 @@ const argv = yargs(process.argv.slice(2))
|
|
|
119
119
|
.command(doctorCommand)
|
|
120
120
|
.command(mcpCommand)
|
|
121
121
|
.command(upgradeCommand);
|
|
122
|
-
const
|
|
122
|
+
const parser = addCommandSuggestions(argv)
|
|
123
123
|
.help()
|
|
124
124
|
.alias('h', 'help')
|
|
125
125
|
.version(pkg.version)
|
|
@@ -127,7 +127,8 @@ const argvWithSuggestions = addCommandSuggestions(argv)
|
|
|
127
127
|
.recommendCommands()
|
|
128
128
|
.demandCommand(1, '')
|
|
129
129
|
.wrap(getTerminalWidth())
|
|
130
|
-
.strict()
|
|
130
|
+
.strict();
|
|
131
|
+
const argvWithSuggestions = await parseYargsOrExit(parser, handleFailure);
|
|
131
132
|
if ('help' in argvWithSuggestions && argvWithSuggestions.help !== undefined) {
|
|
132
133
|
(async () => {
|
|
133
134
|
await trackHelpUsage(getCommandName(argvWithSuggestions));
|
|
@@ -3,13 +3,13 @@ import util from 'util';
|
|
|
3
3
|
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
4
4
|
import { startPortManagerServer, stopPortManagerServer, } from '@hubspot/local-dev-lib/portManager';
|
|
5
5
|
import { isTranslationError, translateForLocalDev, } from '@hubspot/project-parsing-lib/translate';
|
|
6
|
-
import { getConfigAccountEnvironment, getLinkedOrAllConfigAccounts, getConfigAccountById, } from '@hubspot/local-dev-lib/config';
|
|
6
|
+
import { getConfigAccountEnvironment, getLinkedOrAllConfigAccounts, getConfigAccountById, getConfigAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
7
7
|
import { logError } from '../../../lib/errorHandlers/index.js';
|
|
8
8
|
import { EXIT_CODES } from '../../../lib/enums/exitCodes.js';
|
|
9
9
|
import { ensureProjectExists } from '../../../lib/projects/ensureProjectExists.js';
|
|
10
10
|
import { createInitialBuildForNewProject, createNewProjectForLocalDev, compareLocalProjectToDeployed, checkAndInstallDependencies, } from '../../../lib/projects/localDev/helpers/project.js';
|
|
11
11
|
import { useExistingDevTestAccount, createDeveloperTestAccountForLocalDev, selectAccountTypePrompt, createSandboxForLocalDev, } from '../../../lib/projects/localDev/helpers/account.js';
|
|
12
|
-
import { selectDeveloperTestTargetAccountPrompt, selectSandboxTargetAccountPrompt, } from '../../../lib/prompts/projectDevTargetAccountPrompt.js';
|
|
12
|
+
import { selectDeveloperTestTargetAccountPrompt, selectSandboxTargetAccountPrompt, confirmLinkExistingDeveloperTestAccountPrompt, } from '../../../lib/prompts/projectDevTargetAccountPrompt.js';
|
|
13
13
|
import LocalDevProcess from '../../../lib/projects/localDev/LocalDevProcess.js';
|
|
14
14
|
import LocalDevWatcher from '../../../lib/projects/localDev/LocalDevWatcher.js';
|
|
15
15
|
import { handleExit, handleKeypress } from '../../../lib/process.js';
|
|
@@ -89,17 +89,26 @@ export async function unifiedProjectDevFlow({ args, targetProjectAccountId, prov
|
|
|
89
89
|
const accountType = await selectAccountTypePrompt(targetProjectAccountConfig);
|
|
90
90
|
if (accountType === HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST) {
|
|
91
91
|
const devAccountPromptResponse = await selectDeveloperTestTargetAccountPrompt(accounts, targetProjectAccountConfig);
|
|
92
|
+
const { notInConfigAccount } = devAccountPromptResponse;
|
|
92
93
|
targetTestingAccountId =
|
|
93
94
|
devAccountPromptResponse.targetAccountId || undefined;
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
if (notInConfigAccount) {
|
|
96
|
+
const existingGlobalConfig = getConfigAccountIfExists(notInConfigAccount.id);
|
|
97
|
+
if (directoryIsLinked && existingGlobalConfig) {
|
|
98
|
+
const shouldLink = await confirmLinkExistingDeveloperTestAccountPrompt(notInConfigAccount.accountName);
|
|
99
|
+
if (!shouldLink) {
|
|
100
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
101
|
+
}
|
|
102
|
+
addAccountToLinkedSettings(notInConfigAccount.id);
|
|
100
103
|
}
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
else {
|
|
105
|
+
const accountAdded = await useExistingDevTestAccount(env, notInConfigAccount);
|
|
106
|
+
if (!accountAdded) {
|
|
107
|
+
return exit(EXIT_CODES.SUCCESS);
|
|
108
|
+
}
|
|
109
|
+
if (directoryIsLinked) {
|
|
110
|
+
addAccountToLinkedSettings(notInConfigAccount.id);
|
|
111
|
+
}
|
|
103
112
|
}
|
|
104
113
|
}
|
|
105
114
|
else if (devAccountPromptResponse.createNestedAccount) {
|
package/lang/en.d.ts
CHANGED
|
@@ -3623,6 +3623,7 @@ export declare const lib: {
|
|
|
3623
3623
|
developerTestAccountLimit: (limit: number) => string;
|
|
3624
3624
|
confirmDefaultAccount: (accountName: string, accountType: string) => string;
|
|
3625
3625
|
confirmUseExistingDeveloperTestAccount: (accountName: string) => string;
|
|
3626
|
+
confirmLinkExistingDeveloperTestAccount: (accountName: string) => string;
|
|
3626
3627
|
noAccountId: string;
|
|
3627
3628
|
};
|
|
3628
3629
|
projectLogsPrompt: {
|
package/lang/en.js
CHANGED
|
@@ -3649,6 +3649,7 @@ export const lib = {
|
|
|
3649
3649
|
developerTestAccountLimit: (limit) => `Your account reached the limit of ${limit} developer test accounts.`,
|
|
3650
3650
|
confirmDefaultAccount: (accountName, accountType) => `Continue testing on ${chalk.bold(`${accountName} (${accountType})`)}? (Y/n)`,
|
|
3651
3651
|
confirmUseExistingDeveloperTestAccount: (accountName) => `Continue with ${accountName}? This account isn't currently connected to the HubSpot CLI. By continuing, you'll be prompted to generate a personal access key and connect it.`,
|
|
3652
|
+
confirmLinkExistingDeveloperTestAccount: (accountName) => `${accountName} is not linked to this directory. Would you like to link it?`,
|
|
3652
3653
|
noAccountId: 'No account ID found for the selected account. Please try again.',
|
|
3653
3654
|
},
|
|
3654
3655
|
projectLogsPrompt: {
|
|
@@ -10,3 +10,4 @@ export declare function selectSandboxTargetAccountPrompt(accounts: HubSpotConfig
|
|
|
10
10
|
export declare function selectDeveloperTestTargetAccountPrompt(accounts: HubSpotConfigAccount[], defaultAccountConfig: HubSpotConfigAccount): Promise<ProjectDevTargetAccountPromptResponse>;
|
|
11
11
|
export declare function confirmDefaultAccountPrompt(accountName: string, accountType: string): Promise<boolean>;
|
|
12
12
|
export declare function confirmUseExistingDeveloperTestAccountPrompt(account: DeveloperTestAccount): Promise<boolean>;
|
|
13
|
+
export declare function confirmLinkExistingDeveloperTestAccountPrompt(accountName: string): Promise<boolean>;
|
|
@@ -164,3 +164,13 @@ export async function confirmUseExistingDeveloperTestAccountPrompt(account) {
|
|
|
164
164
|
]);
|
|
165
165
|
return confirmUseExistingDeveloperTestAccount;
|
|
166
166
|
}
|
|
167
|
+
export async function confirmLinkExistingDeveloperTestAccountPrompt(accountName) {
|
|
168
|
+
const { confirmLinkExistingDeveloperTestAccount } = await promptUser([
|
|
169
|
+
{
|
|
170
|
+
name: 'confirmLinkExistingDeveloperTestAccount',
|
|
171
|
+
type: 'confirm',
|
|
172
|
+
message: lib.prompts.projectDevTargetAccountPrompt.confirmLinkExistingDeveloperTestAccount(accountName),
|
|
173
|
+
},
|
|
174
|
+
]);
|
|
175
|
+
return confirmLinkExistingDeveloperTestAccount;
|
|
176
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ArgumentsCamelCase, Argv } from 'yargs';
|
|
2
|
+
type YargsFailureHandler<T> = (message: string | null, error: unknown, parser: Argv<T>) => never;
|
|
3
|
+
export declare function parseYargsOrExit<T>(parser: Argv<T>, handleFailure: YargsFailureHandler<T>): Promise<ArgumentsCamelCase<T>>;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function getYargsErrorMessage(error) {
|
|
2
|
+
return error instanceof Error && error.name === 'YError' ? error.message : '';
|
|
3
|
+
}
|
|
4
|
+
function getYargsFailureMessage(message, error) {
|
|
5
|
+
if (message) {
|
|
6
|
+
return message;
|
|
7
|
+
}
|
|
8
|
+
return getYargsErrorMessage(error) || message;
|
|
9
|
+
}
|
|
10
|
+
export async function parseYargsOrExit(parser, handleFailure) {
|
|
11
|
+
let failureHandled = false;
|
|
12
|
+
const parserWithFailureHandler = parser.fail((message, error, yargs) => {
|
|
13
|
+
failureHandled = true;
|
|
14
|
+
return handleFailure(getYargsFailureMessage(message, error), error, yargs);
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
return await parserWithFailureHandler.parseAsync();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (failureHandled) {
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
return handleFailure(getYargsErrorMessage(error), error, parserWithFailureHandler);
|
|
24
|
+
}
|
|
25
|
+
}
|