@hubspot/cli 7.10.0 → 7.10.1-experimental.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 +5 -4
- package/commands/__tests__/getStarted.test.js +10 -0
- package/commands/__tests__/project.test.js +3 -0
- package/commands/account/__tests__/rename.test.js +10 -3
- package/commands/account/auth.js +10 -14
- package/commands/account/clean.js +11 -19
- package/commands/account/createOverride.js +15 -11
- package/commands/account/info.js +8 -5
- package/commands/account/list.js +15 -19
- package/commands/account/remove.js +23 -22
- package/commands/account/removeOverride.js +6 -6
- package/commands/account/rename.js +2 -2
- package/commands/account/use.js +19 -8
- package/commands/app/__tests__/migrate.test.js +8 -4
- package/commands/app/migrate.js +2 -2
- package/commands/auth.js +18 -14
- package/commands/config/migrate.js +5 -5
- package/commands/customObject/createSchema.js +2 -3
- package/commands/customObject/updateSchema.js +2 -3
- package/commands/getStarted.js +2 -3
- package/commands/hubdb/__tests__/list.test.js +1 -0
- package/commands/hubdb/list.js +2 -2
- package/commands/init.js +36 -32
- package/commands/project/__tests__/deploy.test.js +10 -5
- package/commands/project/__tests__/devUnifiedFlow.test.js +6 -4
- package/commands/project/__tests__/lint.test.js +709 -0
- package/commands/project/__tests__/logs.test.js +4 -0
- package/commands/project/__tests__/validate.test.js +286 -28
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/deploy.js +16 -8
- package/commands/project/dev/deprecatedFlow.js +4 -5
- package/commands/project/dev/index.js +19 -7
- package/commands/project/dev/unifiedFlow.js +4 -5
- package/commands/project/lint.d.ts +6 -0
- package/commands/project/lint.js +178 -0
- package/commands/project/logs.js +2 -3
- package/commands/project/migrate.js +4 -13
- package/commands/project/profile/add.js +6 -7
- package/commands/project/profile/delete.js +2 -2
- package/commands/project/upload.js +10 -4
- package/commands/project/validate.js +73 -13
- package/commands/project.js +2 -0
- package/commands/sandbox/__tests__/create.test.js +14 -5
- package/commands/sandbox/create.js +4 -5
- package/commands/sandbox/delete.js +23 -20
- package/commands/testAccount/create.js +2 -2
- package/commands/testAccount/delete.js +9 -8
- package/lang/en.d.ts +48 -11
- package/lang/en.js +58 -15
- package/lib/__tests__/buildAccount.test.js +22 -30
- package/lib/__tests__/commonOpts.test.js +9 -13
- package/lib/__tests__/developerTestAccounts.test.js +29 -17
- package/lib/__tests__/importData.test.js +20 -10
- package/lib/__tests__/oauth.test.js +19 -8
- package/lib/__tests__/projectProfiles.test.js +273 -32
- package/lib/__tests__/sandboxSync.test.js +33 -11
- package/lib/__tests__/sandboxes.test.js +30 -19
- package/lib/__tests__/usageTracking.test.js +10 -10
- package/lib/__tests__/validation.test.js +32 -32
- package/lib/accountTypes.d.ts +9 -9
- package/lib/accountTypes.js +2 -4
- package/lib/app/__tests__/migrate.test.js +15 -0
- package/lib/app/__tests__/migrate_legacy.test.js +9 -0
- package/lib/app/migrate_legacy.d.ts +2 -2
- package/lib/buildAccount.d.ts +4 -4
- package/lib/buildAccount.js +7 -14
- package/lib/commonOpts.js +3 -3
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +42 -18
- package/lib/configOptions.js +3 -2
- package/lib/developerTestAccounts.d.ts +3 -3
- package/lib/developerTestAccounts.js +4 -7
- package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
- package/lib/doctor/DiagnosticInfoBuilder.js +9 -6
- package/lib/doctor/Doctor.js +4 -3
- package/lib/doctor/__tests__/Diagnosis.test.js +4 -3
- package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +17 -9
- package/lib/doctor/__tests__/Doctor.test.js +14 -0
- package/lib/importData.js +8 -7
- package/lib/links.js +5 -5
- package/lib/middleware/{__test__ → __tests__}/commandTargetingUtils.test.js +3 -3
- package/lib/middleware/{__test__ → __tests__}/configMiddleware.test.js +23 -22
- package/lib/middleware/{__test__ → __tests__}/gitMiddleware.test.js +9 -7
- package/lib/middleware/autoUpdateMiddleware.js +34 -23
- package/lib/middleware/commandTargetingUtils.js +3 -2
- package/lib/middleware/configMiddleware.d.ts +6 -1
- package/lib/middleware/configMiddleware.js +36 -15
- package/lib/middleware/fireAlarmMiddleware.js +4 -15
- package/lib/middleware/gitMiddleware.js +8 -4
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +8 -10
- package/lib/projectProfiles.d.ts +4 -3
- package/lib/projectProfiles.js +78 -32
- package/lib/projects/__tests__/AppDevModeInterface.test.js +17 -6
- package/lib/projects/__tests__/DevServerManager.test.js +1 -0
- package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
- package/lib/projects/__tests__/deploy.test.js +1 -0
- package/lib/projects/__tests__/uieLinting.test.js +640 -0
- package/lib/projects/create/__tests__/v2.test.js +11 -0
- package/lib/projects/localDev/AppDevModeInterface.js +2 -2
- package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
- package/lib/projects/localDev/LocalDevLogger.js +4 -4
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
- package/lib/projects/localDev/helpers/account.d.ts +10 -10
- package/lib/projects/localDev/helpers/account.js +6 -11
- package/lib/projects/uieLinting.d.ts +33 -0
- package/lib/projects/uieLinting.js +222 -0
- package/lib/projects/urls.js +5 -6
- package/lib/prompts/__tests__/downloadProjectPrompt.test.js +7 -5
- package/lib/prompts/accountNamePrompt.js +3 -3
- package/lib/prompts/accountsPrompt.d.ts +1 -1
- package/lib/prompts/accountsPrompt.js +6 -7
- package/lib/prompts/confirmImportDataPrompt.js +2 -2
- package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
- package/lib/prompts/downloadProjectPrompt.js +5 -2
- package/lib/prompts/importDataTestAccountSelectPrompt.js +4 -5
- package/lib/prompts/personalAccessKeyPrompt.js +2 -2
- package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -3
- package/lib/prompts/projectDevTargetAccountPrompt.js +5 -7
- package/lib/prompts/sandboxesPrompt.js +7 -8
- package/lib/prompts/setAsDefaultAccountPrompt.js +7 -6
- package/lib/sandboxSync.d.ts +2 -2
- package/lib/sandboxSync.js +3 -9
- package/lib/sandboxes.d.ts +4 -4
- package/lib/sandboxes.js +6 -11
- package/lib/serverlessLogs.js +2 -2
- package/lib/theme/__tests__/migrate.test.js +15 -0
- package/lib/ui/index.js +6 -3
- package/lib/usageTracking.js +15 -8
- package/lib/validation.js +13 -11
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +4 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.js +4 -2
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +4 -2
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +4 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +3 -1
- package/mcp-server/tools/cms/HsListTool.js +3 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -0
- package/mcp-server/tools/index.js +4 -0
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +4 -2
- package/mcp-server/tools/project/CreateProjectTool.js +4 -2
- package/mcp-server/tools/project/CreateTestAccountTool.js +17 -7
- package/mcp-server/tools/project/DeployProjectTool.js +3 -1
- package/mcp-server/tools/project/DocFetchTool.js +6 -4
- package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
- package/mcp-server/tools/project/DocsSearchTool.js +10 -8
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +9 -7
- package/mcp-server/tools/project/GetApplicationInfoTool.js +8 -6
- package/mcp-server/tools/project/GetBuildLogsTool.d.ts +26 -0
- package/mcp-server/tools/project/GetBuildLogsTool.js +125 -0
- package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
- package/mcp-server/tools/project/GetBuildStatusTool.js +166 -0
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +9 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +5 -3
- package/mcp-server/tools/project/UploadProjectTools.js +3 -1
- package/mcp-server/tools/project/ValidateProjectTool.js +4 -2
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +12 -2
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +23 -11
- package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +7 -5
- package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +7 -5
- package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +305 -0
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +240 -0
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -6
- package/mcp-server/utils/__tests__/content.test.js +21 -20
- package/mcp-server/utils/__tests__/feedbackTracking.test.js +34 -28
- package/mcp-server/utils/config.d.ts +1 -0
- package/mcp-server/utils/config.js +10 -0
- package/mcp-server/utils/content.d.ts +1 -1
- package/mcp-server/utils/content.js +2 -2
- package/mcp-server/utils/feedbackTracking.d.ts +1 -1
- package/mcp-server/utils/feedbackTracking.js +3 -3
- package/mcp-server/utils/toolUsageTracking.js +4 -3
- package/package.json +9 -9
- package/ui/components/BoxWithTitle.d.ts +2 -1
- package/ui/components/BoxWithTitle.js +2 -2
- package/ui/components/StatusMessageBoxes.d.ts +5 -4
- package/ui/components/StatusMessageBoxes.js +8 -8
- package/lib/middleware/__test__/notificationsMiddleware.test.js +0 -8
- package/lib/middleware/notificationsMiddleware.d.ts +0 -1
- package/lib/middleware/notificationsMiddleware.js +0 -28
- package/lib/ui/boxen.d.ts +0 -5
- package/lib/ui/boxen.js +0 -26
- package/mcp-server/utils/__tests__/cliConfig.test.js +0 -110
- package/mcp-server/utils/cliConfig.d.ts +0 -1
- package/mcp-server/utils/cliConfig.js +0 -12
- /package/{lib/middleware/__test__/commandTargetingUtils.test.d.ts → commands/project/__tests__/lint.test.d.ts} +0 -0
- /package/lib/middleware/{__test__/configMiddleware.test.d.ts → __tests__/commandTargetingUtils.test.d.ts} +0 -0
- /package/lib/middleware/{__test__/gitMiddleware.test.d.ts → __tests__/configMiddleware.test.d.ts} +0 -0
- /package/lib/middleware/{__test__/notificationsMiddleware.test.d.ts → __tests__/gitMiddleware.test.d.ts} +0 -0
- /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.d.ts +0 -0
- /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.js +0 -0
- /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.d.ts +0 -0
- /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.js +0 -0
- /package/{mcp-server/utils/__tests__/cliConfig.test.d.ts → lib/projects/__tests__/uieLinting.test.d.ts} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fetchAppInstallationData } from '@hubspot/local-dev-lib/api/localDevAuth';
|
|
2
2
|
import { fetchAppMetadataByUid, fetchPublicAppProductionInstallCounts, installStaticAuthAppOnTestAccount, } from '@hubspot/local-dev-lib/api/appsDev';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
|
|
4
4
|
import { APP_AUTH_TYPES, APP_DISTRIBUTION_TYPES, APP_INSTALLATION_STATES, LOCAL_DEV_SERVER_MESSAGE_TYPES, } from '../../constants.js';
|
|
5
5
|
import { EXIT_CODES } from '../../enums/exitCodes.js';
|
|
6
6
|
import { isAppIRNode } from '../../projects/structure.js';
|
|
@@ -67,7 +67,7 @@ class AppDevModeInterface {
|
|
|
67
67
|
return (this.appNode?.config.auth.type.toLowerCase() === APP_AUTH_TYPES.OAUTH);
|
|
68
68
|
}
|
|
69
69
|
isAutomaticallyInstallable() {
|
|
70
|
-
const targetTestingAccount =
|
|
70
|
+
const targetTestingAccount = getConfigAccountById(this.localDevState.targetTestingAccountId);
|
|
71
71
|
if (!targetTestingAccount) {
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
@@ -2,7 +2,7 @@ import { logger } from '@hubspot/local-dev-lib/logger';
|
|
|
2
2
|
import { DevModeInterface as UIEDevModeInterface } from '@hubspot/ui-extensions-dev-server';
|
|
3
3
|
import { startPortManagerServer, stopPortManagerServer, requestPorts, } from '@hubspot/local-dev-lib/portManager';
|
|
4
4
|
import { getHubSpotApiOrigin, getHubSpotWebsiteOrigin, } from '@hubspot/local-dev-lib/urls';
|
|
5
|
-
import {
|
|
5
|
+
import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
|
|
6
6
|
import { ComponentTypes, } from '../../../types/Projects.js';
|
|
7
7
|
import { lib } from '../../../lang/en.js';
|
|
8
8
|
import { uiLogger } from '../../ui/logger.js';
|
|
@@ -58,7 +58,7 @@ class DevServerManager_DEPRECATED {
|
|
|
58
58
|
async setup({ components, onUploadRequired, accountId, setActiveApp, }) {
|
|
59
59
|
this.componentsByType = this.arrangeComponentsByType(components);
|
|
60
60
|
let env;
|
|
61
|
-
const accountConfig =
|
|
61
|
+
const accountConfig = getConfigAccountById(accountId);
|
|
62
62
|
if (accountConfig) {
|
|
63
63
|
env = accountConfig.env;
|
|
64
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { hasLocalStateFlag } from '@hubspot/local-dev-lib/config';
|
|
2
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { uiLogger } from '../../ui/logger.js';
|
|
4
4
|
import { uiLine, uiAccountDescription, uiCommandReference, } from '../../ui/index.js';
|
|
5
5
|
import { lib } from '../../../lang/en.js';
|
|
@@ -30,9 +30,9 @@ class LocalDevLogger {
|
|
|
30
30
|
uiLogger.error(langFunction(e instanceof Error ? e.message : ''));
|
|
31
31
|
}
|
|
32
32
|
getUploadCommand() {
|
|
33
|
-
const currentDefaultAccount =
|
|
33
|
+
const currentDefaultAccount = getConfigDefaultAccountIfExists();
|
|
34
34
|
return this.state.targetProjectAccountId !==
|
|
35
|
-
|
|
35
|
+
currentDefaultAccount?.accountId
|
|
36
36
|
? uiCommandReference(`hs project upload --account=${this.state.targetProjectAccountId}`)
|
|
37
37
|
: uiCommandReference('hs project upload');
|
|
38
38
|
}
|
|
@@ -3,7 +3,7 @@ import chokidar from 'chokidar';
|
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import { fetchAppInstallationData } from '@hubspot/local-dev-lib/api/localDevAuth';
|
|
5
5
|
import { fetchPublicAppsForPortal, fetchPublicAppProductionInstallCounts, } from '@hubspot/local-dev-lib/api/appsDev';
|
|
6
|
-
import {
|
|
6
|
+
import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
7
7
|
import { PROJECT_CONFIG_FILE } from '../../constants.js';
|
|
8
8
|
import SpinniesManager from '../../ui/SpinniesManager.js';
|
|
9
9
|
import DevServerManager_DEPRECATED from './DevServerManager_DEPRECATED.js';
|
|
@@ -200,8 +200,8 @@ class LocalDevManager {
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
getUploadCommand() {
|
|
203
|
-
const currentDefaultAccount =
|
|
204
|
-
return this.targetProjectAccountId !==
|
|
203
|
+
const currentDefaultAccount = getConfigDefaultAccountIfExists();
|
|
204
|
+
return this.targetProjectAccountId !== currentDefaultAccount?.accountId
|
|
205
205
|
? uiCommandReference(`hs project upload --account=${this.targetProjectAccountId}`)
|
|
206
206
|
: uiCommandReference('hs project upload');
|
|
207
207
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HubSpotConfigAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
2
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
3
3
|
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts.js';
|
|
4
4
|
import { ProjectDevTargetAccountPromptResponse } from '../../../prompts/projectDevTargetAccountPrompt.js';
|
|
5
|
-
export declare function confirmDefaultAccountIsTarget(accountConfig:
|
|
6
|
-
export declare function checkIfDefaultAccountIsSupported(accountConfig:
|
|
7
|
-
export declare function checkIfParentAccountIsAuthed(accountConfig:
|
|
8
|
-
export declare function checkIfAccountFlagIsSupported(accountConfig:
|
|
9
|
-
export declare function suggestRecommendedNestedAccount(accounts:
|
|
10
|
-
export declare function createSandboxForLocalDev(accountId: number, accountConfig:
|
|
11
|
-
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig:
|
|
5
|
+
export declare function confirmDefaultAccountIsTarget(accountConfig: HubSpotConfigAccount): Promise<void>;
|
|
6
|
+
export declare function checkIfDefaultAccountIsSupported(accountConfig: HubSpotConfigAccount, hasPublicApps: boolean): Promise<void>;
|
|
7
|
+
export declare function checkIfParentAccountIsAuthed(accountConfig: HubSpotConfigAccount): void;
|
|
8
|
+
export declare function checkIfAccountFlagIsSupported(accountConfig: HubSpotConfigAccount, hasPublicApps: boolean): void;
|
|
9
|
+
export declare function suggestRecommendedNestedAccount(accounts: HubSpotConfigAccount[], accountConfig: HubSpotConfigAccount, hasPublicApps: boolean): Promise<ProjectDevTargetAccountPromptResponse>;
|
|
10
|
+
export declare function createSandboxForLocalDev(accountId: number, accountConfig: HubSpotConfigAccount, env: Environment): Promise<number>;
|
|
11
|
+
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: HubSpotConfigAccount, env: Environment, useV2?: boolean): Promise<number>;
|
|
12
12
|
export declare function useExistingDevTestAccount(env: Environment, account: DeveloperTestAccount): Promise<void>;
|
|
13
|
-
export declare function hasSandboxes(account:
|
|
14
|
-
export declare function selectAccountTypePrompt(accountConfig:
|
|
13
|
+
export declare function hasSandboxes(account: HubSpotConfigAccount): Promise<boolean>;
|
|
14
|
+
export declare function selectAccountTypePrompt(accountConfig: HubSpotConfigAccount): Promise<string | null>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HUBSPOT_ACCOUNT_TYPE_STRINGS } from '@hubspot/local-dev-lib/constants/config';
|
|
2
|
-
import {
|
|
3
|
-
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
|
|
2
|
+
import { getConfigAccountById, getConfigAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
4
3
|
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
5
4
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
6
5
|
import { isMissingScopeError } from '@hubspot/local-dev-lib/errors/index';
|
|
@@ -60,8 +59,8 @@ export async function checkIfDefaultAccountIsSupported(accountConfig, hasPublicA
|
|
|
60
59
|
}
|
|
61
60
|
export function checkIfParentAccountIsAuthed(accountConfig) {
|
|
62
61
|
if (!accountConfig.parentAccountId ||
|
|
63
|
-
!
|
|
64
|
-
uiLogger.error(lib.localDevHelpers.account.checkIfParentAccountIsAuthed.notAuthedError(accountConfig.parentAccountId || '', uiAccountDescription(
|
|
62
|
+
!getConfigAccountIfExists(accountConfig.parentAccountId)?.accountId) {
|
|
63
|
+
uiLogger.error(lib.localDevHelpers.account.checkIfParentAccountIsAuthed.notAuthedError(accountConfig.parentAccountId || '', uiAccountDescription(accountConfig.accountId)));
|
|
65
64
|
process.exit(EXIT_CODES.SUCCESS);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
@@ -122,11 +121,7 @@ export async function createSandboxForLocalDev(accountId, accountConfig, env) {
|
|
|
122
121
|
trackCommandMetadataUsage('sandbox-create', { step: 'project-dev' }, accountId);
|
|
123
122
|
const result = await buildSandbox(name, accountConfig, HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, env);
|
|
124
123
|
const targetAccountId = result.sandbox.sandboxHubId;
|
|
125
|
-
const sandboxAccountConfig =
|
|
126
|
-
if (!sandboxAccountConfig) {
|
|
127
|
-
uiLogger.error(lib.sandbox.create.developer.failure.generic);
|
|
128
|
-
process.exit(EXIT_CODES.ERROR);
|
|
129
|
-
}
|
|
124
|
+
const sandboxAccountConfig = getConfigAccountById(result.sandbox.sandboxHubId);
|
|
130
125
|
const syncTasks = await getAvailableSyncTypes(accountConfig, sandboxAccountConfig);
|
|
131
126
|
// For v1 sandboxes, keep sync here. Once we migrate to v2, this will be handled by BE automatically
|
|
132
127
|
await syncSandbox(sandboxAccountConfig, accountConfig, env, syncTasks, true);
|
|
@@ -190,7 +185,7 @@ export async function useExistingDevTestAccount(env, account) {
|
|
|
190
185
|
uiLogger.success(lib.developerTestAccount.create.success.configFileUpdated(devTestAcctConfigName, PERSONAL_ACCESS_KEY_AUTH_METHOD.name));
|
|
191
186
|
}
|
|
192
187
|
export async function hasSandboxes(account) {
|
|
193
|
-
const accountId =
|
|
188
|
+
const accountId = account.accountId;
|
|
194
189
|
if (!accountId) {
|
|
195
190
|
return false;
|
|
196
191
|
}
|
|
@@ -206,7 +201,7 @@ export async function hasSandboxes(account) {
|
|
|
206
201
|
// Top level prompt to choose the type of account to test on
|
|
207
202
|
export async function selectAccountTypePrompt(accountConfig) {
|
|
208
203
|
const hasAccessToSandboxes = await hasSandboxes(accountConfig);
|
|
209
|
-
const accountId =
|
|
204
|
+
const accountId = accountConfig.accountId;
|
|
210
205
|
const result = await listPrompt(lib.localDevHelpers.account.selectAccountTypePrompt.message, {
|
|
211
206
|
choices: [
|
|
212
207
|
{
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const REQUIRED_PACKAGES_AND_MIN_VERSIONS: {
|
|
2
|
+
readonly eslint: "9.0.0";
|
|
3
|
+
readonly '@typescript-eslint/eslint-plugin': "8.46.4";
|
|
4
|
+
readonly '@typescript-eslint/parser': "8.46.4";
|
|
5
|
+
readonly 'typescript-eslint': "8.46.4";
|
|
6
|
+
readonly jiti: "2.6.1";
|
|
7
|
+
};
|
|
8
|
+
export declare function isEslintInstalled(directory: string): boolean;
|
|
9
|
+
export declare function areAllLintPackagesInstalled(directory: string): boolean;
|
|
10
|
+
export declare function getMissingLintPackages(directory: string): {
|
|
11
|
+
missingPackages: string[];
|
|
12
|
+
};
|
|
13
|
+
export declare function hasEslintConfig(directory: string): boolean;
|
|
14
|
+
export declare function hasDeprecatedEslintConfig(directory: string): boolean;
|
|
15
|
+
export declare function getDeprecatedEslintConfigFiles(directory: string): string[];
|
|
16
|
+
export declare function createEslintConfig(directory: string): string;
|
|
17
|
+
export declare function lintPackagesInDirectory(directory: string, projectDir?: string): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
output: string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare function lintPackages(lintLocations?: string[], projectDir?: string): Promise<{
|
|
22
|
+
success: boolean;
|
|
23
|
+
results: Array<{
|
|
24
|
+
location: string;
|
|
25
|
+
success: boolean;
|
|
26
|
+
output: string;
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
29
|
+
export declare function displayLintResults(results: Array<{
|
|
30
|
+
location: string;
|
|
31
|
+
success: boolean;
|
|
32
|
+
output: string;
|
|
33
|
+
}>): void;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
import semver from 'semver';
|
|
5
|
+
import { exec as execAsync } from 'node:child_process';
|
|
6
|
+
import { getProjectPackageJsonLocations, isPackageInstalled, } from '../dependencyManagement.js';
|
|
7
|
+
import { commands } from '../../lang/en.js';
|
|
8
|
+
import { uiLogger } from '../ui/logger.js';
|
|
9
|
+
export const REQUIRED_PACKAGES_AND_MIN_VERSIONS = {
|
|
10
|
+
eslint: '9.0.0',
|
|
11
|
+
'@typescript-eslint/eslint-plugin': '8.46.4',
|
|
12
|
+
'@typescript-eslint/parser': '8.46.4',
|
|
13
|
+
'typescript-eslint': '8.46.4',
|
|
14
|
+
jiti: '2.6.1',
|
|
15
|
+
};
|
|
16
|
+
const ESLINT_CONFIG_FILES = [
|
|
17
|
+
'eslint.config.mts',
|
|
18
|
+
'eslint.config.ts',
|
|
19
|
+
'eslint.config.cts',
|
|
20
|
+
'eslint.config.js',
|
|
21
|
+
'eslint.config.mjs',
|
|
22
|
+
'eslint.config.cjs',
|
|
23
|
+
];
|
|
24
|
+
const DEPRECATED_ESLINT_CONFIG_FILES = [
|
|
25
|
+
'.eslintrc.js',
|
|
26
|
+
'.eslintrc.cjs',
|
|
27
|
+
'.eslintrc.yaml',
|
|
28
|
+
'.eslintrc.yml',
|
|
29
|
+
'.eslintrc.json',
|
|
30
|
+
'.eslintrc',
|
|
31
|
+
];
|
|
32
|
+
const ESLINT_CONFIG_TEMPLATE = `import { defineConfig } from "eslint/config";
|
|
33
|
+
import tsParser from "@typescript-eslint/parser";
|
|
34
|
+
|
|
35
|
+
export default defineConfig([
|
|
36
|
+
{
|
|
37
|
+
files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parser: tsParser,
|
|
40
|
+
parserOptions: {
|
|
41
|
+
ecmaVersion: "latest",
|
|
42
|
+
sourceType: "module",
|
|
43
|
+
ecmaFeatures: {
|
|
44
|
+
jsx: true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
rules: {
|
|
49
|
+
"no-console": ["warn", { allow: ["warn", "error"] }]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
`;
|
|
54
|
+
function getPackageVersionFromPackageJson(directory, packageName) {
|
|
55
|
+
const packageJsonPath = path.join(directory, 'package.json');
|
|
56
|
+
try {
|
|
57
|
+
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
|
|
58
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
59
|
+
const version = packageJson.dependencies?.[packageName] ||
|
|
60
|
+
packageJson.devDependencies?.[packageName];
|
|
61
|
+
return version || null;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function isPackageVersionValid(directory, packageName) {
|
|
68
|
+
const versionRange = getPackageVersionFromPackageJson(directory, packageName);
|
|
69
|
+
if (!versionRange) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const minimumVersion = REQUIRED_PACKAGES_AND_MIN_VERSIONS[packageName];
|
|
73
|
+
if (!minimumVersion) {
|
|
74
|
+
// If no minimum version specified, any version is valid
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
// Check if the version range satisfies the minimum version
|
|
79
|
+
// For ranges like ^9.0.0, ~8.5.0, >=9.0.0, etc.
|
|
80
|
+
const minVersionSatisfied = semver.satisfies(minimumVersion, versionRange, {
|
|
81
|
+
includePrerelease: true,
|
|
82
|
+
});
|
|
83
|
+
const coercedVersion = semver.minVersion(versionRange);
|
|
84
|
+
if (coercedVersion) {
|
|
85
|
+
return semver.gte(coercedVersion, minimumVersion);
|
|
86
|
+
}
|
|
87
|
+
return minVersionSatisfied;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function isEslintInstalled(directory) {
|
|
94
|
+
return isPackageInstalled(directory, 'eslint');
|
|
95
|
+
}
|
|
96
|
+
export function areAllLintPackagesInstalled(directory) {
|
|
97
|
+
return Object.keys(REQUIRED_PACKAGES_AND_MIN_VERSIONS).every(pkg => {
|
|
98
|
+
const installed = isPackageInstalled(directory, pkg);
|
|
99
|
+
const validVersion = isPackageVersionValid(directory, pkg);
|
|
100
|
+
return installed && validVersion;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export function getMissingLintPackages(directory) {
|
|
104
|
+
const missingPackages = [];
|
|
105
|
+
for (const packageName of Object.keys(REQUIRED_PACKAGES_AND_MIN_VERSIONS)) {
|
|
106
|
+
const isInstalled = isPackageInstalled(directory, packageName);
|
|
107
|
+
const isValidVersion = isPackageVersionValid(directory, packageName);
|
|
108
|
+
if (!isInstalled || !isValidVersion) {
|
|
109
|
+
missingPackages.push(packageName);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { missingPackages };
|
|
113
|
+
}
|
|
114
|
+
export function hasEslintConfig(directory) {
|
|
115
|
+
return ESLINT_CONFIG_FILES.some(configFile => {
|
|
116
|
+
const configPath = path.join(directory, configFile);
|
|
117
|
+
return fs.existsSync(configPath);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
export function hasDeprecatedEslintConfig(directory) {
|
|
121
|
+
return DEPRECATED_ESLINT_CONFIG_FILES.some(configFile => {
|
|
122
|
+
const configPath = path.join(directory, configFile);
|
|
123
|
+
return fs.existsSync(configPath);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
export function getDeprecatedEslintConfigFiles(directory) {
|
|
127
|
+
return DEPRECATED_ESLINT_CONFIG_FILES.filter(configFile => {
|
|
128
|
+
const configPath = path.join(directory, configFile);
|
|
129
|
+
return fs.existsSync(configPath);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export function createEslintConfig(directory) {
|
|
133
|
+
const configPath = path.join(directory, 'eslint.config.mts');
|
|
134
|
+
try {
|
|
135
|
+
fs.writeFileSync(configPath, ESLINT_CONFIG_TEMPLATE, 'utf-8');
|
|
136
|
+
return path.relative(process.cwd(), configPath);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
uiLogger.error(commands.project.lint.failedToCreateEslintConfig(configPath));
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export async function lintPackagesInDirectory(directory, projectDir) {
|
|
144
|
+
const displayPath = projectDir
|
|
145
|
+
? path.relative(projectDir, directory)
|
|
146
|
+
: directory;
|
|
147
|
+
const exec = util.promisify(execAsync);
|
|
148
|
+
const lintCommand = 'npx eslint . --color';
|
|
149
|
+
try {
|
|
150
|
+
const { stdout, stderr } = await exec(lintCommand, {
|
|
151
|
+
cwd: directory,
|
|
152
|
+
maxBuffer: 10 * 1024 * 1024, // 10MB buffer for large outputs
|
|
153
|
+
});
|
|
154
|
+
let output = `\n${displayPath}:\n`;
|
|
155
|
+
if (stdout && stdout.trim()) {
|
|
156
|
+
output += stdout;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
output += ' No linting issues found.\n';
|
|
160
|
+
}
|
|
161
|
+
if (stderr && stderr.trim()) {
|
|
162
|
+
output += stderr;
|
|
163
|
+
}
|
|
164
|
+
return { success: true, output };
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
// ESLint returns exit code 1 when there are linting errors
|
|
168
|
+
// but still provides useful output in stdout/stderr
|
|
169
|
+
let output = `\n${displayPath}:\n`;
|
|
170
|
+
if (error && typeof error === 'object' && 'stdout' in error) {
|
|
171
|
+
const execError = error;
|
|
172
|
+
if (execError.stdout) {
|
|
173
|
+
output += execError.stdout;
|
|
174
|
+
}
|
|
175
|
+
if (execError.stderr) {
|
|
176
|
+
output += execError.stderr;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return { success: false, output };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export async function lintPackages(lintLocations, projectDir) {
|
|
183
|
+
const locations = lintLocations || (await getProjectPackageJsonLocations());
|
|
184
|
+
const results = [];
|
|
185
|
+
for (const location of locations) {
|
|
186
|
+
const result = await lintPackagesInDirectory(location, projectDir);
|
|
187
|
+
const displayPath = projectDir
|
|
188
|
+
? path.relative(projectDir, location)
|
|
189
|
+
: location;
|
|
190
|
+
results.push({ location: displayPath, ...result });
|
|
191
|
+
}
|
|
192
|
+
const failedLocations = results.filter(r => !r.success);
|
|
193
|
+
return {
|
|
194
|
+
success: failedLocations.length === 0,
|
|
195
|
+
results,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export function displayLintResults(results) {
|
|
199
|
+
// Display all output
|
|
200
|
+
results.forEach(r => {
|
|
201
|
+
uiLogger.log(r.output);
|
|
202
|
+
});
|
|
203
|
+
// Summary
|
|
204
|
+
const failedLocations = results.filter(r => !r.success);
|
|
205
|
+
const passedLocations = results.filter(r => r.success);
|
|
206
|
+
uiLogger.log('\n' + '='.repeat(50));
|
|
207
|
+
if (passedLocations.length > 0) {
|
|
208
|
+
uiLogger.success(`Linting passed in ${passedLocations.length} ${passedLocations.length === 1 ? 'directory' : 'directories'}:`);
|
|
209
|
+
passedLocations.forEach(r => {
|
|
210
|
+
uiLogger.log(` ✓ ${r.location}`);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (failedLocations.length > 0) {
|
|
214
|
+
if (passedLocations.length > 0) {
|
|
215
|
+
uiLogger.log('');
|
|
216
|
+
}
|
|
217
|
+
uiLogger.error(`Linting failed in ${failedLocations.length} ${failedLocations.length === 1 ? 'directory' : 'directories'}:`);
|
|
218
|
+
failedLocations.forEach(r => {
|
|
219
|
+
uiLogger.log(` ✗ ${r.location}`);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
package/lib/projects/urls.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
2
|
-
import {
|
|
3
|
-
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
2
|
+
import { getConfigAccountEnvironment } from '@hubspot/local-dev-lib/config';
|
|
4
3
|
function getBaseUrl(accountId) {
|
|
5
|
-
return getHubSpotWebsiteOrigin(
|
|
4
|
+
return getHubSpotWebsiteOrigin(getConfigAccountEnvironment(accountId));
|
|
6
5
|
}
|
|
7
6
|
function getProjectHomeUrl(accountId) {
|
|
8
7
|
return `${getBaseUrl(accountId)}/developer-projects/${accountId}`;
|
|
9
8
|
}
|
|
10
9
|
export function getProjectComponentDistributionUrl(projectName, componentName, accountId) {
|
|
11
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
10
|
+
const baseUrl = getHubSpotWebsiteOrigin(getConfigAccountEnvironment(accountId));
|
|
12
11
|
return `${baseUrl}/developer-projects/${accountId}/project/${projectName}/component/${componentName}/distribution`;
|
|
13
12
|
}
|
|
14
13
|
export function getDeveloperOverviewUrl(accountId) {
|
|
15
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
14
|
+
const baseUrl = getHubSpotWebsiteOrigin(getConfigAccountEnvironment(accountId));
|
|
16
15
|
return `${baseUrl}/developer-overview/${accountId}`;
|
|
17
16
|
}
|
|
18
17
|
export function getProjectDetailUrl(projectName, accountId) {
|
|
@@ -38,6 +37,6 @@ export function getLocalDevUiUrl(accountId, showWelcomeScreen) {
|
|
|
38
37
|
return `${getBaseUrl(accountId)}/developer-projects-local-dev/${accountId}${showWelcomeScreen ? '?welcome' : ''}`;
|
|
39
38
|
}
|
|
40
39
|
export function getAccountHomeUrl(accountId) {
|
|
41
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
40
|
+
const baseUrl = getHubSpotWebsiteOrigin(getConfigAccountEnvironment(accountId));
|
|
42
41
|
return `${baseUrl}/home?portalId=${accountId}`;
|
|
43
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfigAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
2
2
|
import { fetchProjects } from '@hubspot/local-dev-lib/api/projects';
|
|
3
3
|
import { downloadProjectPrompt } from '../downloadProjectPrompt.js';
|
|
4
4
|
vi.mock('../promptUtils', () => ({
|
|
@@ -10,15 +10,17 @@ vi.mock('@hubspot/local-dev-lib/api/projects', () => ({
|
|
|
10
10
|
}),
|
|
11
11
|
}));
|
|
12
12
|
vi.mock('@hubspot/local-dev-lib/config', () => ({
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
getConfigAccountIfExists: vi
|
|
14
|
+
.fn()
|
|
15
|
+
.mockImplementation(() => ({ accountId: 123456789 })),
|
|
16
|
+
globalConfigFileExists: vi.fn().mockReturnValue(true),
|
|
15
17
|
}));
|
|
16
18
|
describe('lib/prompts/downloadProjectPrompt', () => {
|
|
17
19
|
it('should honor the account passed as an option', async () => {
|
|
18
20
|
const account = 'Prod';
|
|
19
21
|
await downloadProjectPrompt({ account });
|
|
20
|
-
expect(
|
|
21
|
-
expect(
|
|
22
|
+
expect(getConfigAccountIfExists).toHaveBeenCalledTimes(1);
|
|
23
|
+
expect(getConfigAccountIfExists).toHaveBeenCalledWith(account);
|
|
22
24
|
});
|
|
23
25
|
it('should fetch the projects for the correct accountId', async () => {
|
|
24
26
|
const account = 'Prod';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfigAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
2
2
|
import { promptUser } from './promptUtils.js';
|
|
3
3
|
import { lib } from '../../lang/en.js';
|
|
4
4
|
import { HUBSPOT_ACCOUNT_TYPES } from '@hubspot/local-dev-lib/constants/config';
|
|
@@ -17,7 +17,7 @@ export function getCliAccountNamePromptConfig(defaultName) {
|
|
|
17
17
|
else if (val.indexOf(' ') >= 0) {
|
|
18
18
|
return lib.prompts.accountNamePrompt.errors.spacesInName;
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return getConfigAccountIfExists(val)
|
|
21
21
|
? lib.prompts.accountNamePrompt.errors.accountNameExists(val)
|
|
22
22
|
: true;
|
|
23
23
|
},
|
|
@@ -54,7 +54,7 @@ export function hubspotAccountNamePrompt({ accountType, currentPortalCount = 0,
|
|
|
54
54
|
else if (!val.trim().length) {
|
|
55
55
|
return lib.prompts.accountNamePrompt.errors.nameRequired;
|
|
56
56
|
}
|
|
57
|
-
return
|
|
57
|
+
return getConfigAccountIfExists(val)
|
|
58
58
|
? lib.prompts.accountNamePrompt.errors.accountNameExists(val)
|
|
59
59
|
: true;
|
|
60
60
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function selectAccountFromConfig(prompt?: string): Promise<
|
|
1
|
+
export declare function selectAccountFromConfig(prompt?: string): Promise<number>;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
|
|
1
|
+
import { getConfigDefaultAccountIfExists, getAllConfigAccounts, } from '@hubspot/local-dev-lib/config';
|
|
3
2
|
import { promptUser } from './promptUtils.js';
|
|
4
3
|
import { commands } from '../../lang/en.js';
|
|
5
4
|
import { uiAccountDescription } from '../ui/index.js';
|
|
6
5
|
function mapAccountChoices(portals) {
|
|
7
6
|
return (portals?.map(p => ({
|
|
8
|
-
name: uiAccountDescription(
|
|
9
|
-
value:
|
|
7
|
+
name: uiAccountDescription(p.accountId, false),
|
|
8
|
+
value: p.accountId,
|
|
10
9
|
})) || []);
|
|
11
10
|
}
|
|
12
11
|
export async function selectAccountFromConfig(prompt = '') {
|
|
13
|
-
const accountsList =
|
|
14
|
-
const defaultAccount =
|
|
12
|
+
const accountsList = getAllConfigAccounts();
|
|
13
|
+
const defaultAccount = getConfigDefaultAccountIfExists();
|
|
15
14
|
const { default: selectedDefault } = await promptUser([
|
|
16
15
|
{
|
|
17
16
|
type: 'list',
|
|
@@ -19,7 +18,7 @@ export async function selectAccountFromConfig(prompt = '') {
|
|
|
19
18
|
pageSize: 20,
|
|
20
19
|
message: prompt || commands.account.subcommands.use.promptMessage,
|
|
21
20
|
choices: mapAccountChoices(accountsList),
|
|
22
|
-
default: defaultAccount ?? undefined,
|
|
21
|
+
default: defaultAccount?.accountId ?? undefined,
|
|
23
22
|
},
|
|
24
23
|
]);
|
|
25
24
|
return selectedDefault;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfigAccountById } from '@hubspot/local-dev-lib/config';
|
|
2
2
|
import { promptUser } from './promptUtils.js';
|
|
3
3
|
import { lib } from '../../lang/en.js';
|
|
4
4
|
export async function confirmImportDataPrompt(targetAccountId, dataFileNames) {
|
|
5
|
-
const account =
|
|
5
|
+
const account = getConfigAccountById(targetAccountId);
|
|
6
6
|
const { confirmImportData } = await promptUser({
|
|
7
7
|
type: 'confirm',
|
|
8
8
|
name: 'confirmImportData',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promptUser } from './promptUtils.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getConfigAccountIfExists } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { fetchProjects } from '@hubspot/local-dev-lib/api/projects';
|
|
4
4
|
import { logError, ApiErrorContext } from '../errorHandlers/index.js';
|
|
5
5
|
import { uiLogger } from '../ui/logger.js';
|
|
@@ -20,7 +20,10 @@ async function createProjectsList(accountId) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
export async function downloadProjectPrompt(promptOptions) {
|
|
23
|
-
const
|
|
23
|
+
const account = promptOptions.account
|
|
24
|
+
? getConfigAccountIfExists(promptOptions.account)
|
|
25
|
+
: undefined;
|
|
26
|
+
const accountId = account?.accountId || promptOptions.derivedAccountId || null;
|
|
24
27
|
const projectsList = await createProjectsList(accountId);
|
|
25
28
|
const response = await promptUser([
|
|
26
29
|
{
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { getAccountIdentifier } from '@hubspot/local-dev-lib/config/getAccountIdentifier';
|
|
2
1
|
import { promptUser } from './promptUtils.js';
|
|
3
|
-
import {
|
|
2
|
+
import { getAllConfigAccounts } from '@hubspot/local-dev-lib/config';
|
|
4
3
|
import { uiAccountDescription } from '../ui/index.js';
|
|
5
4
|
import { lib } from '../../lang/en.js';
|
|
6
5
|
export async function importDataTestAccountSelectPrompt(parentAccountId) {
|
|
7
|
-
const accounts =
|
|
6
|
+
const accounts = getAllConfigAccounts();
|
|
8
7
|
if (!accounts) {
|
|
9
8
|
throw new Error(lib.prompts.importDataTestAccountSelectPrompt.errors.noAccountsFound);
|
|
10
9
|
}
|
|
@@ -12,8 +11,8 @@ export async function importDataTestAccountSelectPrompt(parentAccountId) {
|
|
|
12
11
|
.filter(account => account.parentAccountId === parentAccountId)
|
|
13
12
|
.map(account => {
|
|
14
13
|
return {
|
|
15
|
-
name: uiAccountDescription(
|
|
16
|
-
value:
|
|
14
|
+
name: uiAccountDescription(account.accountId),
|
|
15
|
+
value: account.accountId,
|
|
17
16
|
};
|
|
18
17
|
})
|
|
19
18
|
.filter(account => account.value !== undefined && account.name !== undefined);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import open from 'open';
|
|
2
2
|
import { OAUTH_SCOPES, DEFAULT_OAUTH_SCOPES, } from '@hubspot/local-dev-lib/constants/auth';
|
|
3
|
-
import {
|
|
3
|
+
import { deleteConfigFileIfEmpty } from '@hubspot/local-dev-lib/config';
|
|
4
4
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
5
5
|
import { uiLogger } from '../ui/logger.js';
|
|
6
6
|
import { promptUser } from './promptUtils.js';
|
|
@@ -26,7 +26,7 @@ export async function personalAccessKeyPrompt({ env, account, }) {
|
|
|
26
26
|
PERSONAL_ACCESS_KEY_BROWSER_OPEN_PREP,
|
|
27
27
|
]);
|
|
28
28
|
if (!choice) {
|
|
29
|
-
|
|
29
|
+
deleteConfigFileIfEmpty();
|
|
30
30
|
process.exit(EXIT_CODES.SUCCESS);
|
|
31
31
|
}
|
|
32
32
|
if (choice ===
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HubSpotConfigAccount } from '@hubspot/local-dev-lib/types/Accounts';
|
|
2
2
|
import { DeveloperTestAccount } from '@hubspot/local-dev-lib/types/developerTestAccounts.js';
|
|
3
3
|
export type ProjectDevTargetAccountPromptResponse = {
|
|
4
4
|
targetAccountId: number | null;
|
|
@@ -6,7 +6,7 @@ export type ProjectDevTargetAccountPromptResponse = {
|
|
|
6
6
|
parentAccountId?: number | null;
|
|
7
7
|
notInConfigAccount?: DeveloperTestAccount | null;
|
|
8
8
|
};
|
|
9
|
-
export declare function selectSandboxTargetAccountPrompt(accounts:
|
|
10
|
-
export declare function selectDeveloperTestTargetAccountPrompt(accounts:
|
|
9
|
+
export declare function selectSandboxTargetAccountPrompt(accounts: HubSpotConfigAccount[], defaultAccountConfig: HubSpotConfigAccount): Promise<ProjectDevTargetAccountPromptResponse>;
|
|
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>;
|