@hubspot/cli 7.10.0-beta.2 → 7.10.0-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 +2 -2
- package/commands/project/cloneApp.js +2 -2
- package/commands/project/deploy.js +2 -2
- package/commands/project/dev/deprecatedFlow.js +4 -5
- package/commands/project/dev/index.js +6 -3
- 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/profile/add.js +6 -7
- package/commands/project/profile/delete.js +2 -2
- package/commands/project/upload.js +2 -2
- package/commands/project/validate.js +2 -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/create.js +2 -2
- package/commands/testAccount/delete.js +9 -8
- package/lang/en.d.ts +40 -6
- package/lang/en.js +49 -9
- 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__/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 +12 -4
- 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/gitMiddleware.js +8 -4
- 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__/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/DevSessionManager.d.ts +17 -0
- package/lib/projects/localDev/DevSessionManager.js +56 -0
- package/lib/projects/localDev/LocalDevLogger.d.ts +3 -0
- package/lib/projects/localDev/LocalDevLogger.js +13 -4
- package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
- package/lib/projects/localDev/LocalDevProcess.d.ts +1 -0
- package/lib/projects/localDev/LocalDevProcess.js +12 -1
- package/lib/projects/localDev/LocalDevState.d.ts +3 -0
- package/lib/projects/localDev/LocalDevState.js +9 -0
- package/lib/projects/localDev/helpers/account.d.ts +10 -10
- package/lib/projects/localDev/helpers/account.js +6 -11
- package/lib/projects/localDev/helpers/devSessionsApi.d.ts +9 -0
- package/lib/projects/localDev/helpers/devSessionsApi.js +19 -0
- 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 +8 -7
- package/types/LocalDev.d.ts +1 -0
- 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/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,9 +1,10 @@
|
|
|
1
1
|
import { trackUsage } from '@hubspot/local-dev-lib/trackUsage';
|
|
2
2
|
import { EventClass, getNodeVersionData, getPlatform, } from '../../lib/usageTracking.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfig, getConfigDefaultAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
4
4
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
5
5
|
export async function trackToolUsage(toolName, meta) {
|
|
6
|
-
|
|
6
|
+
const config = getConfig();
|
|
7
|
+
if (config?.allowUsageTracking === false) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
9
10
|
const usageTrackingEvent = {
|
|
@@ -14,7 +15,7 @@ export async function trackToolUsage(toolName, meta) {
|
|
|
14
15
|
type: process.env.HUBSPOT_MCP_AI_AGENT,
|
|
15
16
|
...meta,
|
|
16
17
|
};
|
|
17
|
-
const accountId =
|
|
18
|
+
const accountId = getConfigDefaultAccountIfExists()?.accountId || undefined;
|
|
18
19
|
try {
|
|
19
20
|
uiLogger.info('Tracking tool usage');
|
|
20
21
|
await trackUsage('cli-interaction', EventClass.INTERACTION, usageTrackingEvent, accountId);
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.10.0-
|
|
3
|
+
"version": "7.10.0-experimental.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@hubspot/local-dev-lib": "
|
|
10
|
-
"@hubspot/project-parsing-lib": "0.10.
|
|
11
|
-
"@hubspot/serverless-dev-runtime": "7.0.
|
|
12
|
-
"@hubspot/theme-preview-dev-server": "0.0.
|
|
13
|
-
"@hubspot/ui-extensions-dev-server": "0.
|
|
9
|
+
"@hubspot/local-dev-lib": "4.0.1",
|
|
10
|
+
"@hubspot/project-parsing-lib": "0.10.2",
|
|
11
|
+
"@hubspot/serverless-dev-runtime": "7.0.7",
|
|
12
|
+
"@hubspot/theme-preview-dev-server": "0.0.12",
|
|
13
|
+
"@hubspot/ui-extensions-dev-server": "1.0.0",
|
|
14
14
|
"archiver": "7.0.1",
|
|
15
15
|
"boxen": "8.0.1",
|
|
16
16
|
"chalk": "5.4.1",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"vitest": "^2.1.9"
|
|
69
69
|
},
|
|
70
70
|
"optionalDependencies": {
|
|
71
|
-
"@hubspot/cms-dev-server": "^1.
|
|
71
|
+
"@hubspot/cms-dev-server": "^1.2.1",
|
|
72
72
|
"@modelcontextprotocol/sdk": "1.13.3"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"test-cli-debug": "yarn build && yarn --cwd 'acceptance-tests' test-debug",
|
|
93
93
|
"test-cli-latest": "yarn build && yarn build-docker && docker container run -it --rm --name=hs-cli-container hs-cli-image yarn --cwd 'acceptance-tests' test-latest",
|
|
94
94
|
"test-cli-qa": "yarn build && yarn --cwd 'acceptance-tests' test-qa",
|
|
95
|
+
"test-cli-qa-debug": "yarn build && yarn --cwd 'acceptance-tests' test-qa-debug",
|
|
95
96
|
"update-ldl": "yarn add --exact @hubspot/local-dev-lib@latest",
|
|
96
97
|
"view-unreleased-changes": "node ./scripts/unreleasedChanges.js"
|
|
97
98
|
},
|
package/types/LocalDev.d.ts
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { notifyAboutUpdates } from '../notificationsMiddleware.js';
|
|
2
|
-
describe('lib/middleware/notificationsMiddleware', () => {
|
|
3
|
-
describe('notifyAboutUpdates()', () => {
|
|
4
|
-
it('should safely execute without throwing an error', () => {
|
|
5
|
-
expect(() => notifyAboutUpdates()).not.toThrow();
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function notifyAboutUpdates(): void;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import updateNotifier from 'update-notifier';
|
|
2
|
-
import { pkg } from '../jsonLoader.js';
|
|
3
|
-
import { UI_COLORS } from '../ui/index.js';
|
|
4
|
-
import { lib } from '../../lang/en.js';
|
|
5
|
-
const notifier = updateNotifier({
|
|
6
|
-
pkg: { ...pkg, name: '@hubspot/cli' },
|
|
7
|
-
distTag: 'latest',
|
|
8
|
-
shouldNotifyInNpmScript: true,
|
|
9
|
-
});
|
|
10
|
-
const CMS_CLI_PACKAGE_NAME = '@hubspot/cms-cli';
|
|
11
|
-
export function notifyAboutUpdates() {
|
|
12
|
-
notifier.notify({
|
|
13
|
-
message: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
14
|
-
? lib.middleware.updateNotification.cmsUpdateNotification(CMS_CLI_PACKAGE_NAME)
|
|
15
|
-
: lib.middleware.updateNotification.cliUpdateNotification,
|
|
16
|
-
defer: false,
|
|
17
|
-
boxenOptions: {
|
|
18
|
-
borderColor: UI_COLORS.MARIGOLD_DARK,
|
|
19
|
-
margin: 1,
|
|
20
|
-
padding: 1,
|
|
21
|
-
textAlignment: 'center',
|
|
22
|
-
borderStyle: 'round',
|
|
23
|
-
title: pkg.name === CMS_CLI_PACKAGE_NAME
|
|
24
|
-
? undefined
|
|
25
|
-
: lib.middleware.updateNotification.notifyTitle,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { getAccountIdFromCliConfig } from '../cliConfig.js';
|
|
2
|
-
import { configFileExists, findConfig, getAccountId, loadConfig, } from '@hubspot/local-dev-lib/config';
|
|
3
|
-
vi.mock('@hubspot/local-dev-lib/config');
|
|
4
|
-
const mockConfigFileExists = configFileExists;
|
|
5
|
-
const mockFindConfig = findConfig;
|
|
6
|
-
const mockGetAccountId = getAccountId;
|
|
7
|
-
const mockLoadConfig = loadConfig;
|
|
8
|
-
describe('mcp-server/utils/cliConfig', () => {
|
|
9
|
-
const mockWorkingDirectory = '/test/working/directory';
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
vi.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
describe('getAccountIdFromCliConfig', () => {
|
|
14
|
-
it('should load global config when it exists and return account ID', () => {
|
|
15
|
-
const expectedAccountId = 12345;
|
|
16
|
-
mockConfigFileExists.mockReturnValue(true);
|
|
17
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
18
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory);
|
|
19
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
20
|
-
expect(mockLoadConfig).toHaveBeenCalledWith('');
|
|
21
|
-
expect(mockFindConfig).not.toHaveBeenCalled();
|
|
22
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(undefined);
|
|
23
|
-
expect(result).toBe(expectedAccountId);
|
|
24
|
-
});
|
|
25
|
-
it('should load local config when global config does not exist and return account ID', () => {
|
|
26
|
-
const expectedAccountId = 67890;
|
|
27
|
-
const localConfigPath = '/path/to/local/config';
|
|
28
|
-
mockConfigFileExists.mockReturnValue(false);
|
|
29
|
-
mockFindConfig.mockReturnValue(localConfigPath);
|
|
30
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
31
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory);
|
|
32
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
33
|
-
expect(mockFindConfig).toHaveBeenCalledWith(mockWorkingDirectory);
|
|
34
|
-
expect(mockLoadConfig).toHaveBeenCalledWith(localConfigPath);
|
|
35
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(undefined);
|
|
36
|
-
expect(result).toBe(expectedAccountId);
|
|
37
|
-
});
|
|
38
|
-
it('should pass accountNameOrId parameter to getAccountId when provided as string', () => {
|
|
39
|
-
const expectedAccountId = 11111;
|
|
40
|
-
const accountName = 'test-account';
|
|
41
|
-
mockConfigFileExists.mockReturnValue(true);
|
|
42
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
43
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory, accountName);
|
|
44
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
45
|
-
expect(mockLoadConfig).toHaveBeenCalledWith('');
|
|
46
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(accountName);
|
|
47
|
-
expect(result).toBe(expectedAccountId);
|
|
48
|
-
});
|
|
49
|
-
it('should pass accountNameOrId parameter to getAccountId when provided as number', () => {
|
|
50
|
-
const expectedAccountId = 22222;
|
|
51
|
-
const accountId = 22222;
|
|
52
|
-
mockConfigFileExists.mockReturnValue(true);
|
|
53
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
54
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory, accountId);
|
|
55
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
56
|
-
expect(mockLoadConfig).toHaveBeenCalledWith('');
|
|
57
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(accountId);
|
|
58
|
-
expect(result).toBe(expectedAccountId);
|
|
59
|
-
});
|
|
60
|
-
it('should return null when getAccountId returns null', () => {
|
|
61
|
-
mockConfigFileExists.mockReturnValue(true);
|
|
62
|
-
mockGetAccountId.mockReturnValue(null);
|
|
63
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory);
|
|
64
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
65
|
-
expect(mockLoadConfig).toHaveBeenCalledWith('');
|
|
66
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(undefined);
|
|
67
|
-
expect(result).toBeNull();
|
|
68
|
-
});
|
|
69
|
-
it('should handle findConfig returning null by passing null to loadConfig', () => {
|
|
70
|
-
const expectedAccountId = 33333;
|
|
71
|
-
mockConfigFileExists.mockReturnValue(false);
|
|
72
|
-
mockFindConfig.mockReturnValue(null);
|
|
73
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
74
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory);
|
|
75
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
76
|
-
expect(mockFindConfig).toHaveBeenCalledWith(mockWorkingDirectory);
|
|
77
|
-
expect(mockLoadConfig).toHaveBeenCalledWith(null);
|
|
78
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(undefined);
|
|
79
|
-
expect(result).toBe(expectedAccountId);
|
|
80
|
-
});
|
|
81
|
-
it('should work with local config when provided with account name parameter', () => {
|
|
82
|
-
const expectedAccountId = 44444;
|
|
83
|
-
const accountName = 'local-test-account';
|
|
84
|
-
const localConfigPath = '/path/to/local/config';
|
|
85
|
-
mockConfigFileExists.mockReturnValue(false);
|
|
86
|
-
mockFindConfig.mockReturnValue(localConfigPath);
|
|
87
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
88
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory, accountName);
|
|
89
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
90
|
-
expect(mockFindConfig).toHaveBeenCalledWith(mockWorkingDirectory);
|
|
91
|
-
expect(mockLoadConfig).toHaveBeenCalledWith(localConfigPath);
|
|
92
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(accountName);
|
|
93
|
-
expect(result).toBe(expectedAccountId);
|
|
94
|
-
});
|
|
95
|
-
it('should work with local config when provided with account ID parameter', () => {
|
|
96
|
-
const expectedAccountId = 55555;
|
|
97
|
-
const accountId = 55555;
|
|
98
|
-
const localConfigPath = '/path/to/local/config';
|
|
99
|
-
mockConfigFileExists.mockReturnValue(false);
|
|
100
|
-
mockFindConfig.mockReturnValue(localConfigPath);
|
|
101
|
-
mockGetAccountId.mockReturnValue(expectedAccountId);
|
|
102
|
-
const result = getAccountIdFromCliConfig(mockWorkingDirectory, accountId);
|
|
103
|
-
expect(mockConfigFileExists).toHaveBeenCalledWith(true);
|
|
104
|
-
expect(mockFindConfig).toHaveBeenCalledWith(mockWorkingDirectory);
|
|
105
|
-
expect(mockLoadConfig).toHaveBeenCalledWith(localConfigPath);
|
|
106
|
-
expect(mockGetAccountId).toHaveBeenCalledWith(accountId);
|
|
107
|
-
expect(result).toBe(expectedAccountId);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getAccountIdFromCliConfig(absolutePathToWorkingDirectory: string, accountNameOrId?: string | number): number | null;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { configFileExists, findConfig, getAccountId, loadConfig, } from '@hubspot/local-dev-lib/config';
|
|
2
|
-
export function getAccountIdFromCliConfig(absolutePathToWorkingDirectory, accountNameOrId) {
|
|
3
|
-
const globalConfigExists = configFileExists(true);
|
|
4
|
-
if (globalConfigExists) {
|
|
5
|
-
loadConfig('');
|
|
6
|
-
}
|
|
7
|
-
else {
|
|
8
|
-
const configPath = findConfig(absolutePathToWorkingDirectory);
|
|
9
|
-
loadConfig(configPath);
|
|
10
|
-
}
|
|
11
|
-
return getAccountId(accountNameOrId);
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
/package/lib/middleware/{__test__/gitMiddleware.test.d.ts → __tests__/configMiddleware.test.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|