@hubspot/cli 7.9.0 → 7.9.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 +2 -0
- package/commands/account/__tests__/rename.test.js +42 -0
- package/commands/account/auth.js +10 -14
- package/commands/account/clean.js +11 -19
- package/commands/account/createOverride.js +17 -23
- package/commands/account/info.js +8 -5
- package/commands/account/list.js +13 -18
- package/commands/account/remove.js +23 -22
- package/commands/account/removeOverride.js +8 -16
- package/commands/account/rename.d.ts +1 -1
- package/commands/account/rename.js +6 -3
- 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/cms/theme/preview.js +1 -4
- package/commands/config/migrate.js +5 -5
- package/commands/config/set.js +1 -2
- package/commands/customObject/createSchema.js +2 -3
- package/commands/customObject/updateSchema.js +2 -3
- package/commands/getStarted.js +15 -22
- package/commands/hubdb/__tests__/list.test.js +1 -0
- package/commands/hubdb/list.js +2 -2
- package/commands/hubdb.d.ts +1 -1
- 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__/logs.test.js +4 -0
- package/commands/project/__tests__/updateDeps.test.js +142 -0
- package/commands/project/__tests__/validate.test.js +2 -2
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/create.js +0 -1
- package/commands/project/deploy.js +2 -2
- package/commands/project/dev/deprecatedFlow.js +4 -5
- package/commands/project/dev/index.js +14 -4
- package/commands/project/dev/unifiedFlow.js +4 -5
- package/commands/project/listBuilds.js +7 -1
- package/commands/project/logs.js +2 -3
- package/commands/project/profile/add.js +6 -7
- package/commands/project/profile/delete.js +2 -2
- package/commands/project/updateDeps.d.ts +6 -0
- package/commands/project/updateDeps.js +80 -0
- package/commands/project/upload.js +9 -3
- package/commands/project/validate.js +9 -3
- package/commands/project/watch.js +7 -2
- 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/__tests__/create.test.js +68 -0
- package/commands/testAccount/create.d.ts +8 -0
- package/commands/testAccount/create.js +135 -45
- package/commands/testAccount/delete.js +9 -8
- package/commands/testAccount/importData.d.ts +1 -1
- package/lang/en.d.ts +3199 -3185
- package/lang/en.js +52 -14
- package/lib/__tests__/buildAccount.test.js +22 -30
- package/lib/__tests__/commonOpts.test.js +9 -13
- package/lib/__tests__/dependencyManagement.test.js +273 -1
- 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__/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 +5 -8
- package/lib/configMigrate.d.ts +2 -2
- package/lib/configMigrate.js +42 -18
- package/lib/configOptions.js +3 -2
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +6 -0
- package/lib/dependencyManagement.d.ts +8 -2
- package/lib/dependencyManagement.js +75 -12
- 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/mcp/__tests__/setup.test.d.ts +1 -0
- package/lib/mcp/__tests__/setup.test.js +127 -0
- package/lib/mcp/setup.d.ts +4 -12
- package/lib/mcp/setup.js +34 -1
- package/lib/middleware/__test__/commandTargetingUtils.test.js +3 -3
- package/lib/middleware/__test__/configMiddleware.test.js +23 -22
- package/lib/middleware/__test__/gitMiddleware.test.js +9 -7
- package/lib/middleware/autoUpdateMiddleware.d.ts +3 -1
- package/lib/middleware/autoUpdateMiddleware.js +10 -2
- package/lib/middleware/commandTargetingUtils.js +2 -2
- package/lib/middleware/configMiddleware.d.ts +6 -1
- package/lib/middleware/configMiddleware.js +36 -15
- package/lib/middleware/gitMiddleware.js +8 -4
- package/lib/npm.d.ts +3 -0
- package/lib/npm.js +6 -0
- package/lib/oauth.d.ts +2 -2
- package/lib/oauth.js +8 -10
- 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__/components.test.js +148 -24
- package/lib/projects/__tests__/deploy.test.js +1 -0
- package/lib/projects/__tests__/platformVersion.test.js +5 -1
- package/lib/projects/__tests__/projects.test.js +13 -42
- package/lib/projects/components.js +76 -20
- package/lib/projects/config.js +5 -9
- 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/platformVersion.js +1 -1
- package/lib/projects/urls.js +5 -6
- package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/createDeveloperTestAccountConfigPrompt.test.js +153 -0
- 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/createDeveloperTestAccountConfigPrompt.d.ts +5 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +76 -66
- 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 +8 -2
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +4 -4
- package/mcp-server/tools/cms/HsCreateModuleTool.js +8 -2
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +8 -2
- package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +4 -4
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +6 -2
- package/mcp-server/tools/cms/HsListFunctionsTool.js +5 -1
- package/mcp-server/tools/cms/HsListTool.js +5 -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.d.ts +1 -1
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +9 -3
- package/mcp-server/tools/project/CreateProjectTool.js +8 -2
- package/mcp-server/tools/project/CreateTestAccountTool.d.ts +41 -0
- package/mcp-server/tools/project/CreateTestAccountTool.js +150 -0
- package/mcp-server/tools/project/DeployProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/DeployProjectTool.js +8 -2
- package/mcp-server/tools/project/DocFetchTool.d.ts +1 -1
- package/mcp-server/tools/project/DocFetchTool.js +9 -5
- package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
- package/mcp-server/tools/project/DocsSearchTool.js +12 -8
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +11 -7
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +1 -1
- package/mcp-server/tools/project/GetApplicationInfoTool.js +11 -7
- package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
- package/mcp-server/tools/project/GetBuildStatusTool.js +164 -0
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +11 -7
- package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +7 -3
- package/mcp-server/tools/project/UploadProjectTools.d.ts +9 -3
- package/mcp-server/tools/project/UploadProjectTools.js +51 -5
- package/mcp-server/tools/project/ValidateProjectTool.d.ts +1 -1
- package/mcp-server/tools/project/ValidateProjectTool.js +7 -3
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.d.ts +1 -0
- package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +454 -0
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +25 -13
- 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__/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/tools/project/__tests__/UploadProjectTools.test.js +56 -4
- package/mcp-server/utils/__tests__/content.test.js +21 -20
- package/mcp-server/utils/__tests__/feedbackTracking.test.js +33 -28
- 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 +8 -7
- package/lang/en.lyaml +0 -1508
- package/lib/lang.d.ts +0 -8
- package/lib/lang.js +0 -72
- 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/{mcp-server/utils/__tests__/cliConfig.test.d.ts → commands/project/__tests__/updateDeps.test.d.ts} +0 -0
|
@@ -2,6 +2,7 @@ import util from 'util';
|
|
|
2
2
|
import { vi } from 'vitest';
|
|
3
3
|
vi.mock('@hubspot/local-dev-lib/fs');
|
|
4
4
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
5
|
+
vi.mock('@hubspot/local-dev-lib/config/defaultAccountOverride');
|
|
5
6
|
vi.mock('@hubspot/local-dev-lib/personalAccessKey');
|
|
6
7
|
vi.mock('../../projects/config');
|
|
7
8
|
vi.mock('@hubspot/local-dev-lib/api/projects');
|
|
@@ -16,17 +17,19 @@ vi.mock('../../jsonLoader.js', () => {
|
|
|
16
17
|
};
|
|
17
18
|
});
|
|
18
19
|
import { DiagnosticInfoBuilder, } from '../DiagnosticInfoBuilder.js';
|
|
19
|
-
import {
|
|
20
|
+
import { getConfigAccountIfExists as _getConfigAccountIfExists, getConfigAccountById as _getConfigAccountById, getConfigFilePath as _getConfigFilePath, isConfigFlagEnabled as _isConfigFlagEnabled, getConfigDefaultAccountIfExists as _getConfigDefaultAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
21
|
+
import { getDefaultAccountOverrideFilePath as _getDefaultAccountOverrideFilePath } from '@hubspot/local-dev-lib/config/defaultAccountOverride';
|
|
20
22
|
import { getAccessToken as _getAccessToken } from '@hubspot/local-dev-lib/personalAccessKey';
|
|
21
23
|
import { walk as _walk } from '@hubspot/local-dev-lib/fs';
|
|
22
24
|
import { getProjectConfig as _getProjectConfig } from '../../projects/config.js';
|
|
23
25
|
import { fetchProject as _fetchProject } from '@hubspot/local-dev-lib/api/projects';
|
|
24
26
|
const walk = _walk;
|
|
25
27
|
const getAccessToken = _getAccessToken;
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
+
const getConfigAccountById = _getConfigAccountById;
|
|
29
|
+
const getConfigAccountIfExists = _getConfigAccountIfExists;
|
|
30
|
+
const getConfigDefaultAccountIfExists = _getConfigDefaultAccountIfExists;
|
|
31
|
+
const getConfigFilePath = _getConfigFilePath;
|
|
28
32
|
const getDefaultAccountOverrideFilePath = _getDefaultAccountOverrideFilePath;
|
|
29
|
-
const getAccountId = _getAccountId;
|
|
30
33
|
const getProjectConfig = _getProjectConfig;
|
|
31
34
|
const isConfigFlagEnabled = _isConfigFlagEnabled;
|
|
32
35
|
const fetchProject = _fetchProject;
|
|
@@ -36,6 +39,8 @@ util.promisify = utilPromisify;
|
|
|
36
39
|
describe('lib/doctor/DiagnosticInfo', () => {
|
|
37
40
|
const accountId = 898989;
|
|
38
41
|
const accountConfig = {
|
|
42
|
+
name: 'test-account',
|
|
43
|
+
accountId: accountId,
|
|
39
44
|
env: 'prod',
|
|
40
45
|
authType: 'personalaccesskey',
|
|
41
46
|
accountType: 'STANDARD',
|
|
@@ -73,16 +78,19 @@ describe('lib/doctor/DiagnosticInfo', () => {
|
|
|
73
78
|
const configPath = '/path/to/config';
|
|
74
79
|
const defaultAccountOverrideFile = 'path/to/default/account/override/.hsaccount';
|
|
75
80
|
beforeEach(() => {
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
getConfigAccountIfExists.mockReturnValue({
|
|
82
|
+
accountId,
|
|
83
|
+
name: 'test',
|
|
84
|
+
});
|
|
85
|
+
getConfigAccountById.mockReturnValue(accountConfig);
|
|
86
|
+
getConfigDefaultAccountIfExists.mockReturnValue(accountConfig);
|
|
78
87
|
walk.mockResolvedValue(projectFiles);
|
|
79
88
|
isConfigFlagEnabled.mockReturnValue(false);
|
|
80
89
|
mockPromisifyImpl.mockResolvedValue(npmVersion);
|
|
81
90
|
});
|
|
82
91
|
it('should initialize the required state on creation', () => {
|
|
83
92
|
const builder = new DiagnosticInfoBuilder(processInfo);
|
|
84
|
-
expect(
|
|
85
|
-
expect(getAccountConfig).toHaveBeenCalledTimes(1);
|
|
93
|
+
expect(getConfigDefaultAccountIfExists).toHaveBeenCalledTimes(1);
|
|
86
94
|
expect(builder.accountId).toEqual(accountId);
|
|
87
95
|
expect(builder.env).toEqual(accountConfig.env);
|
|
88
96
|
expect(builder.authType).toEqual(accountConfig.authType);
|
|
@@ -131,7 +139,7 @@ describe('lib/doctor/DiagnosticInfo', () => {
|
|
|
131
139
|
data: projectDetails,
|
|
132
140
|
});
|
|
133
141
|
getAccessToken.mockResolvedValue(accessToken);
|
|
134
|
-
|
|
142
|
+
getConfigFilePath.mockReturnValue(configPath);
|
|
135
143
|
getDefaultAccountOverrideFilePath.mockReturnValue(defaultAccountOverrideFile);
|
|
136
144
|
});
|
|
137
145
|
it('should gather the required data and generate the diagnostic', async () => {
|
|
@@ -6,6 +6,7 @@ import { HubSpotHttpError } from '@hubspot/local-dev-lib/models/HubSpotHttpError
|
|
|
6
6
|
import { AxiosError } from 'axios';
|
|
7
7
|
import { isSpecifiedError as _isSpecifiedError } from '@hubspot/local-dev-lib/errors/index';
|
|
8
8
|
import { promisify as _promisify } from 'util';
|
|
9
|
+
import { getConfigDefaultAccount as _getConfigDefaultAccount, getConfigDefaultAccountIfExists as _getConfigDefaultAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
9
10
|
vi.mock('../../ui/logger.js');
|
|
10
11
|
vi.mock('../Diagnosis');
|
|
11
12
|
vi.mock('../../ui/SpinniesManager');
|
|
@@ -15,6 +16,7 @@ vi.mock('../../npm');
|
|
|
15
16
|
vi.mock('@hubspot/local-dev-lib/portManager');
|
|
16
17
|
vi.mock('@hubspot/local-dev-lib/personalAccessKey');
|
|
17
18
|
vi.mock('@hubspot/local-dev-lib/errors/index');
|
|
19
|
+
vi.mock('@hubspot/local-dev-lib/config');
|
|
18
20
|
vi.mock('util');
|
|
19
21
|
const hasMissingPackages = vi.mocked(_hasMissingPackages);
|
|
20
22
|
const isPortManagerPortAvailable = vi.mocked(_isPortManagerPortAvailable);
|
|
@@ -23,6 +25,8 @@ const accessTokenForPersonalAccessKey = vi.mocked(_accessTokenForPersonalAccessK
|
|
|
23
25
|
const authorizedScopesForPortalAndUser = vi.mocked(_authorizedScopesForPortalAndUser);
|
|
24
26
|
const scopesOnAccessToken = vi.mocked(_scopesOnAccessToken);
|
|
25
27
|
const isSpecifiedError = vi.mocked(_isSpecifiedError);
|
|
28
|
+
const getConfigDefaultAccount = vi.mocked(_getConfigDefaultAccount);
|
|
29
|
+
const getConfigDefaultAccountIfExists = vi.mocked(_getConfigDefaultAccountIfExists);
|
|
26
30
|
describe('lib/doctor/Doctor', () => {
|
|
27
31
|
let doctor;
|
|
28
32
|
// @ts-ignore
|
|
@@ -57,6 +61,16 @@ describe('lib/doctor/Doctor', () => {
|
|
|
57
61
|
},
|
|
58
62
|
};
|
|
59
63
|
beforeEach(() => {
|
|
64
|
+
// Mock config functions
|
|
65
|
+
const mockAccount = {
|
|
66
|
+
accountId: 123456,
|
|
67
|
+
accountType: 'STANDARD',
|
|
68
|
+
name: 'Test Account',
|
|
69
|
+
authType: 'personalaccesskey',
|
|
70
|
+
personalAccessKey: 'test-key',
|
|
71
|
+
};
|
|
72
|
+
getConfigDefaultAccount.mockReturnValue(mockAccount);
|
|
73
|
+
getConfigDefaultAccountIfExists.mockReturnValue(mockAccount);
|
|
60
74
|
doctor = new Doctor({
|
|
61
75
|
generateDiagnosticInfo: vi.fn().mockResolvedValue({
|
|
62
76
|
...diagnosticInfo,
|
package/lib/importData.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfigAccountById, getConfigAccountEnvironment, getConfigAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
2
2
|
import { createImport } from '@hubspot/local-dev-lib/api/crm';
|
|
3
3
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
4
4
|
import { importDataTestAccountSelectPrompt } from './prompts/importDataTestAccountSelectPrompt.js';
|
|
@@ -7,7 +7,7 @@ import { isAppDeveloperAccount, isDeveloperTestAccount, isStandardAccount, } fro
|
|
|
7
7
|
import { uiLogger } from './ui/logger.js';
|
|
8
8
|
export async function handleImportData(targetAccountId, dataFileNames, importRequest) {
|
|
9
9
|
try {
|
|
10
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
10
|
+
const baseUrl = getHubSpotWebsiteOrigin(getConfigAccountEnvironment(targetAccountId));
|
|
11
11
|
const response = await createImport(targetAccountId, importRequest, dataFileNames);
|
|
12
12
|
const importId = response.data.id;
|
|
13
13
|
uiLogger.info(lib.importData.viewImportLink(baseUrl, targetAccountId, importId));
|
|
@@ -18,19 +18,20 @@ export async function handleImportData(targetAccountId, dataFileNames, importReq
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
export async function handleTargetTestAccountSelectionFlow(derivedAccountId, userProvidedAccount) {
|
|
21
|
-
let targetAccountId
|
|
21
|
+
let targetAccountId;
|
|
22
|
+
let testAccount;
|
|
22
23
|
if (userProvidedAccount) {
|
|
23
|
-
|
|
24
|
+
testAccount = getConfigAccountIfExists(userProvidedAccount);
|
|
25
|
+
targetAccountId = testAccount?.accountId;
|
|
24
26
|
}
|
|
25
27
|
// Only allow users to pass in test accounts
|
|
26
28
|
if (targetAccountId) {
|
|
27
|
-
|
|
28
|
-
if (!testAccount || !isDeveloperTestAccount(testAccount)) {
|
|
29
|
+
if (testAccount && !isDeveloperTestAccount(testAccount)) {
|
|
29
30
|
throw new Error(lib.importData.errors.notDeveloperTestAccount);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
const targetProjectAccountConfig =
|
|
34
|
+
const targetProjectAccountConfig = getConfigAccountById(derivedAccountId);
|
|
34
35
|
if (!targetProjectAccountConfig) {
|
|
35
36
|
throw new Error(lib.importData.errors.noAccountConfig(derivedAccountId));
|
|
36
37
|
}
|
package/lib/links.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import open from 'open';
|
|
2
|
-
import {
|
|
3
|
-
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
2
|
+
import { getConfigAccountEnvironment } from '@hubspot/local-dev-lib/config';
|
|
4
3
|
import { getHubSpotWebsiteOrigin } from '@hubspot/local-dev-lib/urls';
|
|
4
|
+
import { ENVIRONMENTS } from '@hubspot/local-dev-lib/constants/environments';
|
|
5
5
|
import { uiLogger } from './ui/logger.js';
|
|
6
6
|
import { getTableContents, getTableHeader } from './ui/table.js';
|
|
7
7
|
const COMMON_SITE_LINKS = {
|
|
@@ -75,7 +75,7 @@ const COMMON_SITE_LINKS = {
|
|
|
75
75
|
},
|
|
76
76
|
};
|
|
77
77
|
export function getSiteLinksAsArray(accountId) {
|
|
78
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
78
|
+
const baseUrl = getHubSpotWebsiteOrigin(getConfigAccountEnvironment(accountId));
|
|
79
79
|
return Object.values(COMMON_SITE_LINKS)
|
|
80
80
|
.sort((a, b) => (a.shortcut < b.shortcut ? -1 : 1))
|
|
81
81
|
.map(l => ({ ...l, url: l.getUrl(accountId, baseUrl) }));
|
|
@@ -95,12 +95,12 @@ export function openLink(accountId, shortcut) {
|
|
|
95
95
|
uiLogger.error(`We couldn't find a shortcut matching ${shortcut}. Type 'hs open list' to see a list of available shortcuts`);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
98
|
+
const baseUrl = getHubSpotWebsiteOrigin(getConfigAccountEnvironment(accountId));
|
|
99
99
|
open(match.getUrl(accountId, baseUrl), { url: true });
|
|
100
100
|
uiLogger.success(`We opened ${match.getUrl(accountId, baseUrl)} in your browser`);
|
|
101
101
|
}
|
|
102
102
|
export function getProductUpdatesUrl(rolloutId, accountId) {
|
|
103
|
-
const baseUrl = getHubSpotWebsiteOrigin(
|
|
103
|
+
const baseUrl = getHubSpotWebsiteOrigin(accountId ? getConfigAccountEnvironment(accountId) : ENVIRONMENTS.PROD);
|
|
104
104
|
if (accountId) {
|
|
105
105
|
return `${baseUrl}/product-updates/${accountId}/in-beta?rollout=${rolloutId}`;
|
|
106
106
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { execAsync } from '../../../mcp-server/utils/command.js';
|
|
2
|
+
import { setupCodex, supportedTools } from '../setup.js';
|
|
3
|
+
import SpinniesManager from '../../ui/SpinniesManager.js';
|
|
4
|
+
import { logError } from '../../errorHandlers/index.js';
|
|
5
|
+
import { commands } from '../../../lang/en.js';
|
|
6
|
+
// Mock dependencies
|
|
7
|
+
vi.mock('../../../mcp-server/utils/command.js');
|
|
8
|
+
vi.mock('../../ui/SpinniesManager.js');
|
|
9
|
+
vi.mock('../../ui/logger.js');
|
|
10
|
+
vi.mock('../../errorHandlers/index.js');
|
|
11
|
+
vi.mock('../../../lang/en.js', () => ({
|
|
12
|
+
commands: {
|
|
13
|
+
mcp: {
|
|
14
|
+
setup: {
|
|
15
|
+
codex: 'Codex CLI',
|
|
16
|
+
claudeCode: 'Claude Code',
|
|
17
|
+
cursor: 'Cursor',
|
|
18
|
+
vsCode: 'VS Code',
|
|
19
|
+
windsurf: 'Windsurf',
|
|
20
|
+
success: vi.fn(targets => `Success message for ${targets.join(', ')}`),
|
|
21
|
+
spinners: {
|
|
22
|
+
configuringCodex: 'Configuring Codex...',
|
|
23
|
+
configuredCodex: 'Configured Codex',
|
|
24
|
+
codexNotFound: 'Codex command not found - skipping configuration',
|
|
25
|
+
codexInstallFailed: 'Failed to configure Codex',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
const mockedExecAsync = vi.mocked(execAsync);
|
|
32
|
+
const mockedSpinniesManager = vi.mocked(SpinniesManager);
|
|
33
|
+
const mockedLogError = vi.mocked(logError);
|
|
34
|
+
describe('lib/mcp/setup', () => {
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
vi.resetAllMocks();
|
|
37
|
+
});
|
|
38
|
+
describe('supportedTools', () => {
|
|
39
|
+
it('should include Codex in the supported tools list', () => {
|
|
40
|
+
const codexTool = supportedTools.find(tool => tool.value === 'codex');
|
|
41
|
+
expect(codexTool).toBeDefined();
|
|
42
|
+
expect(codexTool?.name).toBe(commands.mcp.setup.codex);
|
|
43
|
+
expect(codexTool?.value).toBe('codex');
|
|
44
|
+
});
|
|
45
|
+
it('should have Codex as the first tool in the list', () => {
|
|
46
|
+
expect(supportedTools[0].value).toBe('codex');
|
|
47
|
+
});
|
|
48
|
+
it('should contain all expected tools', () => {
|
|
49
|
+
const toolValues = supportedTools.map(tool => tool.value);
|
|
50
|
+
expect(toolValues).toContain('codex');
|
|
51
|
+
expect(toolValues).toContain('claude');
|
|
52
|
+
expect(toolValues).toContain('cursor');
|
|
53
|
+
expect(toolValues).toContain('vscode');
|
|
54
|
+
expect(toolValues).toContain('windsurf');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('setupCodex', () => {
|
|
58
|
+
const mockMcpCommand = {
|
|
59
|
+
command: 'test-command',
|
|
60
|
+
args: ['--arg1', '--arg2'],
|
|
61
|
+
};
|
|
62
|
+
it('should successfully configure Codex when command is available', async () => {
|
|
63
|
+
mockedExecAsync.mockResolvedValueOnce({
|
|
64
|
+
stdout: 'codex version 1.0.0',
|
|
65
|
+
stderr: '',
|
|
66
|
+
}); // version check
|
|
67
|
+
mockedExecAsync.mockResolvedValueOnce({ stdout: '', stderr: '' }); // mcp add command
|
|
68
|
+
const result = await setupCodex(mockMcpCommand);
|
|
69
|
+
expect(result).toBe(true);
|
|
70
|
+
expect(mockedSpinniesManager.add).toHaveBeenCalledWith('codexSpinner', {
|
|
71
|
+
text: commands.mcp.setup.spinners.configuringCodex,
|
|
72
|
+
});
|
|
73
|
+
expect(mockedExecAsync).toHaveBeenCalledWith('codex --version');
|
|
74
|
+
expect(mockedExecAsync).toHaveBeenCalledWith('codex mcp add "HubSpotDev" -- test-command --arg1 --arg2 --ai-agent codex');
|
|
75
|
+
expect(mockedSpinniesManager.succeed).toHaveBeenCalledWith('codexSpinner', {
|
|
76
|
+
text: commands.mcp.setup.spinners.configuredCodex,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
it('should use default mcp command when none provided', async () => {
|
|
80
|
+
mockedExecAsync.mockResolvedValueOnce({
|
|
81
|
+
stdout: 'codex version 1.0.0',
|
|
82
|
+
stderr: '',
|
|
83
|
+
}); // version check
|
|
84
|
+
mockedExecAsync.mockResolvedValueOnce({ stdout: '', stderr: '' }); // mcp add command
|
|
85
|
+
const result = await setupCodex();
|
|
86
|
+
expect(result).toBe(true);
|
|
87
|
+
expect(mockedExecAsync).toHaveBeenCalledWith('codex mcp add "HubSpotDev" -- hs mcp start --ai-agent codex');
|
|
88
|
+
});
|
|
89
|
+
it('should handle codex command not found', async () => {
|
|
90
|
+
const error = new Error('Command not found: codex');
|
|
91
|
+
mockedExecAsync.mockRejectedValueOnce(error);
|
|
92
|
+
const result = await setupCodex(mockMcpCommand);
|
|
93
|
+
expect(result).toBe(false);
|
|
94
|
+
expect(mockedSpinniesManager.fail).toHaveBeenCalledWith('codexSpinner', {
|
|
95
|
+
text: commands.mcp.setup.spinners.codexNotFound,
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it('should handle codex installation failure', async () => {
|
|
99
|
+
const error = new Error('Some other error');
|
|
100
|
+
mockedExecAsync.mockResolvedValueOnce({
|
|
101
|
+
stdout: 'codex version 1.0.0',
|
|
102
|
+
stderr: '',
|
|
103
|
+
}); // version check passes
|
|
104
|
+
mockedExecAsync.mockRejectedValueOnce(error); // mcp add fails
|
|
105
|
+
const result = await setupCodex(mockMcpCommand);
|
|
106
|
+
expect(result).toBe(false);
|
|
107
|
+
expect(mockedSpinniesManager.fail).toHaveBeenCalledWith('codexSpinner', {
|
|
108
|
+
text: commands.mcp.setup.spinners.codexInstallFailed,
|
|
109
|
+
});
|
|
110
|
+
expect(mockedLogError).toHaveBeenCalledWith(error);
|
|
111
|
+
});
|
|
112
|
+
it('should handle unexpected errors during spinner setup', async () => {
|
|
113
|
+
const error = new Error('Unexpected error');
|
|
114
|
+
mockedSpinniesManager.add.mockImplementationOnce(() => {
|
|
115
|
+
throw error;
|
|
116
|
+
});
|
|
117
|
+
const result = await setupCodex(mockMcpCommand);
|
|
118
|
+
expect(result).toBe(false);
|
|
119
|
+
expect(mockedSpinniesManager.fail).toHaveBeenCalledWith('codexSpinner', {
|
|
120
|
+
text: commands.mcp.setup.spinners.codexInstallFailed,
|
|
121
|
+
});
|
|
122
|
+
expect(mockedLogError).toHaveBeenCalledWith(error);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
// Note: addMcpServerToConfig integration tests would require mocking many dependencies
|
|
126
|
+
// and complex setup. The setupCodex function tests above cover the new functionality.
|
|
127
|
+
});
|
package/lib/mcp/setup.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
export declare const supportedTools:
|
|
2
|
-
name:
|
|
1
|
+
export declare const supportedTools: {
|
|
2
|
+
name: string;
|
|
3
3
|
value: string;
|
|
4
|
-
}
|
|
5
|
-
name: "Cursor";
|
|
6
|
-
value: string;
|
|
7
|
-
} | {
|
|
8
|
-
name: "Windsurf";
|
|
9
|
-
value: string;
|
|
10
|
-
} | {
|
|
11
|
-
name: "VSCode";
|
|
12
|
-
value: string;
|
|
13
|
-
})[];
|
|
4
|
+
}[];
|
|
14
5
|
interface McpCommand {
|
|
15
6
|
command: string;
|
|
16
7
|
args: string[];
|
|
@@ -20,4 +11,5 @@ export declare function setupVsCode(mcpCommand?: McpCommand): Promise<boolean>;
|
|
|
20
11
|
export declare function setupClaudeCode(mcpCommand?: McpCommand): Promise<boolean>;
|
|
21
12
|
export declare function setupCursor(mcpCommand?: McpCommand): boolean;
|
|
22
13
|
export declare function setupWindsurf(mcpCommand?: McpCommand): boolean;
|
|
14
|
+
export declare function setupCodex(mcpCommand?: McpCommand): Promise<boolean>;
|
|
23
15
|
export {};
|
package/lib/mcp/setup.js
CHANGED
|
@@ -13,11 +13,13 @@ const claudeCode = 'claude';
|
|
|
13
13
|
const windsurf = 'windsurf';
|
|
14
14
|
const cursor = 'cursor';
|
|
15
15
|
const vscode = 'vscode';
|
|
16
|
+
const codex = 'codex';
|
|
16
17
|
export const supportedTools = [
|
|
18
|
+
{ name: commands.mcp.setup.codex, value: codex },
|
|
17
19
|
{ name: commands.mcp.setup.claudeCode, value: claudeCode },
|
|
18
20
|
{ name: commands.mcp.setup.cursor, value: cursor },
|
|
19
|
-
{ name: commands.mcp.setup.windsurf, value: windsurf },
|
|
20
21
|
{ name: commands.mcp.setup.vsCode, value: vscode },
|
|
22
|
+
{ name: commands.mcp.setup.windsurf, value: windsurf },
|
|
21
23
|
];
|
|
22
24
|
const defaultMcpCommand = {
|
|
23
25
|
command: 'hs',
|
|
@@ -56,6 +58,9 @@ export async function addMcpServerToConfig(targets) {
|
|
|
56
58
|
if (derivedTargets.includes(vscode)) {
|
|
57
59
|
await runSetupFunction(setupVsCode);
|
|
58
60
|
}
|
|
61
|
+
if (derivedTargets.includes(codex)) {
|
|
62
|
+
await runSetupFunction(setupCodex);
|
|
63
|
+
}
|
|
59
64
|
uiLogger.info(commands.mcp.setup.success(derivedTargets));
|
|
60
65
|
return derivedTargets;
|
|
61
66
|
}
|
|
@@ -231,6 +236,34 @@ export function setupWindsurf(mcpCommand = defaultMcpCommand) {
|
|
|
231
236
|
mcpCommand: buildCommandWithAgentString(mcpCommand, windsurf),
|
|
232
237
|
});
|
|
233
238
|
}
|
|
239
|
+
export async function setupCodex(mcpCommand = defaultMcpCommand) {
|
|
240
|
+
try {
|
|
241
|
+
SpinniesManager.add('codexSpinner', {
|
|
242
|
+
text: commands.mcp.setup.spinners.configuringCodex,
|
|
243
|
+
});
|
|
244
|
+
// Check if codex command is available
|
|
245
|
+
await execAsync('codex --version');
|
|
246
|
+
await execAsync(`codex mcp add "${mcpServerName}" -- ${mcpCommand.command} ${mcpCommand.args.join(' ')} --ai-agent codex`);
|
|
247
|
+
SpinniesManager.succeed('codexSpinner', {
|
|
248
|
+
text: commands.mcp.setup.spinners.configuredCodex,
|
|
249
|
+
});
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
if (error instanceof Error && error.message.includes('codex')) {
|
|
254
|
+
SpinniesManager.fail('codexSpinner', {
|
|
255
|
+
text: commands.mcp.setup.spinners.codexNotFound,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
SpinniesManager.fail('codexSpinner', {
|
|
260
|
+
text: commands.mcp.setup.spinners.codexInstallFailed,
|
|
261
|
+
});
|
|
262
|
+
logError(error);
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
234
267
|
function buildCommandWithAgentString(mcpCommand, agent) {
|
|
235
268
|
const mcpCommandCopy = structuredClone(mcpCommand);
|
|
236
269
|
mcpCommandCopy.args.push('--ai-agent', agent);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as cliConfig from '@hubspot/local-dev-lib/config';
|
|
2
2
|
import { isTargetedCommand, shouldLoadConfigForCommand, shouldRunAccountValidationForCommand, shouldRunConfigValidationForCommand, } from '../commandTargetingUtils.js';
|
|
3
3
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
4
|
-
const
|
|
4
|
+
const globalConfigFileExistsSpy = vi.spyOn(cliConfig, 'globalConfigFileExists');
|
|
5
5
|
const targetCommandMap = {
|
|
6
6
|
init: true,
|
|
7
7
|
account: {
|
|
@@ -56,12 +56,12 @@ describe('lib/middleware/commandTargetingUtils', () => {
|
|
|
56
56
|
expect(result).toBe(false);
|
|
57
57
|
});
|
|
58
58
|
it('should return false when the user is trying to migrate the global config', () => {
|
|
59
|
-
|
|
59
|
+
globalConfigFileExistsSpy.mockReturnValue(false);
|
|
60
60
|
const result = shouldLoadConfigForCommand(['config', 'migrate']);
|
|
61
61
|
expect(result).toBe(false);
|
|
62
62
|
});
|
|
63
63
|
it('should return true when the global config file does exist', () => {
|
|
64
|
-
|
|
64
|
+
globalConfigFileExistsSpy.mockReturnValue(true);
|
|
65
65
|
const result = shouldLoadConfigForCommand(['account', 'use']);
|
|
66
66
|
expect(result).toBe(true);
|
|
67
67
|
});
|
|
@@ -2,7 +2,7 @@ import { uiLogger } from '../../ui/logger.js';
|
|
|
2
2
|
import * as cliConfig from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import * as validation from '../../validation.js';
|
|
4
4
|
import { EXIT_CODES } from '../../enums/exitCodes.js';
|
|
5
|
-
import { handleDeprecatedEnvVariables, injectAccountIdMiddleware,
|
|
5
|
+
import { handleDeprecatedEnvVariables, injectAccountIdMiddleware, validateConfigMiddleware, validateAccountOptions, } from '../configMiddleware.js';
|
|
6
6
|
vi.mock('../../ui/logger.js', () => ({
|
|
7
7
|
uiLogger: {
|
|
8
8
|
error: vi.fn(),
|
|
@@ -12,10 +12,10 @@ vi.mock('../../ui/logger.js', () => ({
|
|
|
12
12
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
13
13
|
vi.mock('../../validation');
|
|
14
14
|
const validateAccountSpy = vi.spyOn(validation, 'validateAccount');
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const getConfigAccountIfExistsSpy = vi.spyOn(cliConfig, 'getConfigAccountIfExists');
|
|
16
|
+
const globalConfigFileExistsSpy = vi.spyOn(cliConfig, 'globalConfigFileExists');
|
|
17
17
|
const configFileExistsSpy = vi.spyOn(cliConfig, 'configFileExists');
|
|
18
|
-
const
|
|
18
|
+
const getConfigFilePathSpy = vi.spyOn(cliConfig, 'getConfigFilePath');
|
|
19
19
|
const validateConfigSpy = vi.spyOn(cliConfig, 'validateConfig');
|
|
20
20
|
const processExitSpy = vi.spyOn(process, 'exit');
|
|
21
21
|
describe('lib/middleware/configMiddleware', () => {
|
|
@@ -23,7 +23,7 @@ describe('lib/middleware/configMiddleware', () => {
|
|
|
23
23
|
processExitSpy.mockImplementation(code => {
|
|
24
24
|
throw new Error(`Process.exit called with code ${code}`);
|
|
25
25
|
});
|
|
26
|
-
|
|
26
|
+
getConfigFilePathSpy.mockReturnValue('/path/to/config');
|
|
27
27
|
});
|
|
28
28
|
describe('handleDeprecatedEnvVariables()', () => {
|
|
29
29
|
it('should handle deprecated HUBSPOT_PORTAL_ID environment variable', () => {
|
|
@@ -76,11 +76,13 @@ describe('lib/middleware/configMiddleware', () => {
|
|
|
76
76
|
await injectAccountIdMiddleware(argv);
|
|
77
77
|
expect(argv.userProvidedAccount).toBeUndefined();
|
|
78
78
|
expect(argv.derivedAccountId).toBe(123);
|
|
79
|
-
expect(
|
|
79
|
+
expect(getConfigAccountIfExistsSpy).not.toHaveBeenCalled();
|
|
80
80
|
process.env = originalEnv;
|
|
81
81
|
});
|
|
82
82
|
it('should use getAccountId when useEnv is false', async () => {
|
|
83
|
-
|
|
83
|
+
getConfigAccountIfExistsSpy.mockReturnValue({
|
|
84
|
+
accountId: 456,
|
|
85
|
+
});
|
|
84
86
|
const argv = {
|
|
85
87
|
_: ['some-command'],
|
|
86
88
|
account: 'test-account',
|
|
@@ -90,41 +92,40 @@ describe('lib/middleware/configMiddleware', () => {
|
|
|
90
92
|
await injectAccountIdMiddleware(argv);
|
|
91
93
|
expect(argv.userProvidedAccount).toBe('test-account');
|
|
92
94
|
expect(argv.derivedAccountId).toBe(456);
|
|
93
|
-
expect(
|
|
95
|
+
expect(getConfigAccountIfExistsSpy).toHaveBeenCalledWith('test-account');
|
|
94
96
|
});
|
|
95
97
|
});
|
|
96
|
-
describe('
|
|
97
|
-
it('should
|
|
98
|
+
describe('validateConfigMiddleware()', () => {
|
|
99
|
+
it('should allow using --config flag', async () => {
|
|
98
100
|
configFileExistsSpy.mockReturnValue(true);
|
|
101
|
+
validateConfigSpy.mockReturnValue({ isValid: true, errors: [] });
|
|
99
102
|
const argv = {
|
|
100
103
|
_: ['some-command'],
|
|
101
104
|
config: 'custom-config.json',
|
|
102
105
|
$0: 'hs',
|
|
103
106
|
};
|
|
104
|
-
await
|
|
105
|
-
|
|
106
|
-
expect(
|
|
107
|
+
await validateConfigMiddleware(argv);
|
|
108
|
+
// Should not throw or exit - this is now allowed
|
|
109
|
+
expect(processExitSpy).not.toHaveBeenCalled();
|
|
110
|
+
expect(uiLogger.error).not.toHaveBeenCalled();
|
|
107
111
|
});
|
|
108
|
-
it('should
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
validateConfigSpy.mockReturnValue(true);
|
|
112
|
+
it('should validate config for non-init commands', async () => {
|
|
113
|
+
globalConfigFileExistsSpy.mockReturnValue(true);
|
|
114
|
+
validateConfigSpy.mockReturnValue({ isValid: true, errors: [] });
|
|
112
115
|
const argv = {
|
|
113
116
|
_: ['some-command'],
|
|
114
117
|
$0: 'hs',
|
|
115
118
|
};
|
|
116
|
-
await
|
|
117
|
-
expect(loadConfigSpy).toHaveBeenCalled();
|
|
119
|
+
await validateConfigMiddleware(argv);
|
|
118
120
|
expect(validateConfigSpy).toHaveBeenCalled();
|
|
119
121
|
});
|
|
120
122
|
it('should skip validation for init command', async () => {
|
|
121
|
-
|
|
123
|
+
globalConfigFileExistsSpy.mockReturnValue(false);
|
|
122
124
|
const argv = {
|
|
123
125
|
_: ['init'],
|
|
124
126
|
$0: 'hs',
|
|
125
127
|
};
|
|
126
|
-
await
|
|
127
|
-
expect(loadConfigSpy).not.toHaveBeenCalled();
|
|
128
|
+
await validateConfigMiddleware(argv);
|
|
128
129
|
expect(validateConfigSpy).not.toHaveBeenCalled();
|
|
129
130
|
});
|
|
130
131
|
});
|
|
@@ -3,19 +3,19 @@ import * as gitUI from '../../ui/git.js';
|
|
|
3
3
|
import { checkAndWarnGitInclusionMiddleware } from '../gitMiddleware.js';
|
|
4
4
|
vi.mock('@hubspot/local-dev-lib/config');
|
|
5
5
|
vi.mock('../../ui/git');
|
|
6
|
-
const
|
|
6
|
+
const getConfigFilePathSpy = vi.spyOn(config, 'getConfigFilePath');
|
|
7
7
|
const checkAndWarnGitInclusionSpy = vi.spyOn(gitUI, 'checkAndWarnGitInclusion');
|
|
8
8
|
describe('lib/middleware/gitMiddleware', () => {
|
|
9
9
|
describe('checkAndWarnGitInclusionMiddleware()', () => {
|
|
10
10
|
it('should call checkAndWarnGitInclusion when command is provided and config path exists', () => {
|
|
11
11
|
const mockConfigPath = '/path/to/config.js';
|
|
12
|
-
|
|
12
|
+
getConfigFilePathSpy.mockReturnValue(mockConfigPath);
|
|
13
13
|
const argv = {
|
|
14
14
|
_: ['some-command'],
|
|
15
15
|
$0: 'hs',
|
|
16
16
|
};
|
|
17
17
|
checkAndWarnGitInclusionMiddleware(argv);
|
|
18
|
-
expect(
|
|
18
|
+
expect(getConfigFilePathSpy).toHaveBeenCalledTimes(1);
|
|
19
19
|
expect(checkAndWarnGitInclusionSpy).toHaveBeenCalledWith(mockConfigPath);
|
|
20
20
|
});
|
|
21
21
|
it('should not call checkAndWarnGitInclusion when no command is provided', () => {
|
|
@@ -24,17 +24,19 @@ describe('lib/middleware/gitMiddleware', () => {
|
|
|
24
24
|
$0: 'hs',
|
|
25
25
|
};
|
|
26
26
|
checkAndWarnGitInclusionMiddleware(argv);
|
|
27
|
-
expect(
|
|
27
|
+
expect(getConfigFilePathSpy).not.toHaveBeenCalled();
|
|
28
28
|
expect(checkAndWarnGitInclusionSpy).not.toHaveBeenCalled();
|
|
29
29
|
});
|
|
30
|
-
it('should not call checkAndWarnGitInclusion when config path
|
|
31
|
-
|
|
30
|
+
it('should not call checkAndWarnGitInclusion when config path does not exist', () => {
|
|
31
|
+
getConfigFilePathSpy.mockImplementation(() => {
|
|
32
|
+
throw new Error('Config path does not exist');
|
|
33
|
+
});
|
|
32
34
|
const argv = {
|
|
33
35
|
_: ['some-command'],
|
|
34
36
|
$0: 'hs',
|
|
35
37
|
};
|
|
36
38
|
checkAndWarnGitInclusionMiddleware(argv);
|
|
37
|
-
expect(
|
|
39
|
+
expect(getConfigFilePathSpy).toHaveBeenCalledTimes(1);
|
|
38
40
|
expect(checkAndWarnGitInclusionSpy).not.toHaveBeenCalled();
|
|
39
41
|
});
|
|
40
42
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import updateNotifier from 'update-notifier';
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig } from '@hubspot/local-dev-lib/config';
|
|
3
3
|
import { pkg } from '../jsonLoader.js';
|
|
4
4
|
import { UI_COLORS } from '../ui/index.js';
|
|
5
5
|
import SpinniesManager from '../ui/SpinniesManager.js';
|
|
@@ -45,10 +45,18 @@ const preventAutoUpdateForCommand = (commandParts) => {
|
|
|
45
45
|
export async function autoUpdateCLI(argv) {
|
|
46
46
|
// This lets us back to default update-notifier behavior
|
|
47
47
|
let showManualInstallHelp = true;
|
|
48
|
+
let config;
|
|
49
|
+
try {
|
|
50
|
+
config = getConfig();
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
debugError(e);
|
|
54
|
+
}
|
|
48
55
|
if (notifier &&
|
|
49
56
|
notifier.update &&
|
|
57
|
+
!argv.useEnv &&
|
|
50
58
|
!process.env.SKIP_HUBSPOT_CLI_AUTO_UPDATES &&
|
|
51
|
-
|
|
59
|
+
config?.allowAutoUpdates !== false &&
|
|
52
60
|
!preventAutoUpdateForCommand(argv._)) {
|
|
53
61
|
// Ignore all update notifications if the current version is a pre-release
|
|
54
62
|
if (!notifier.update.current.includes('-')) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { globalConfigFileExists } from '@hubspot/local-dev-lib/config';
|
|
2
2
|
export function isTargetedCommand(commandParts, targetCommandMap) {
|
|
3
3
|
const currentCommandPart = commandParts[0];
|
|
4
4
|
if (!targetCommandMap[currentCommandPart]) {
|
|
@@ -23,7 +23,7 @@ const SKIP_CONFIG_LOADING_COMMANDS = {
|
|
|
23
23
|
};
|
|
24
24
|
// Returns true if the command requires a config file to be present
|
|
25
25
|
export function shouldLoadConfigForCommand(commandParts) {
|
|
26
|
-
const globalConfigExists =
|
|
26
|
+
const globalConfigExists = globalConfigFileExists();
|
|
27
27
|
// the user is trying to migrate the global config
|
|
28
28
|
const isGlobalConfigMigration = !globalConfigExists &&
|
|
29
29
|
isTargetedCommand(commandParts, {
|