@hubspot/cli 7.7.35-experimental.0 → 7.8.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
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
+ });
@@ -0,0 +1 @@
1
+ export declare function getAccountIdFromCliConfig(absolutePathToWorkingDirectory: string, accountNameOrId?: string | number): number | null;
@@ -0,0 +1,12 @@
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
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "7.7.35-experimental.0",
3
+ "version": "7.8.1-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
9
  "@hubspot/local-dev-lib": "3.18.0",
10
- "@hubspot/project-parsing-lib": "0.8.3",
10
+ "@hubspot/project-parsing-lib": "0.8.5-beta.0",
11
11
  "@hubspot/serverless-dev-runtime": "7.0.6",
12
12
  "@hubspot/theme-preview-dev-server": "0.0.10",
13
13
  "@hubspot/ui-extensions-dev-server": "0.9.8",