@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
package/lib/lang.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { InterpolationData } from './interpolation.js';
|
|
2
|
-
export declare const MISSING_LANGUAGE_DATA_PREFIX = "[Missing language data]";
|
|
3
|
-
type LanguageObject = {
|
|
4
|
-
[key: string]: string | LanguageObject;
|
|
5
|
-
};
|
|
6
|
-
export declare function i18n(lookupDotNotation: string, options?: InterpolationData): string;
|
|
7
|
-
export declare function setLangData(newLocale: string, newLangObj: LanguageObject): void;
|
|
8
|
-
export {};
|
package/lib/lang.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import util from 'util';
|
|
2
|
-
import path, { dirname } from 'path';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
5
|
-
import { uiLogger } from './ui/logger.js';
|
|
6
|
-
import { interpolate } from './interpolation.js';
|
|
7
|
-
import { fileURLToPath } from 'url';
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
export const MISSING_LANGUAGE_DATA_PREFIX = '[Missing language data]';
|
|
11
|
-
let locale;
|
|
12
|
-
let languageObj;
|
|
13
|
-
function loadLanguageFromYaml() {
|
|
14
|
-
if (languageObj)
|
|
15
|
-
return;
|
|
16
|
-
try {
|
|
17
|
-
const nodeLocale = Intl.DateTimeFormat()
|
|
18
|
-
.resolvedOptions()
|
|
19
|
-
.locale.split('-')[0];
|
|
20
|
-
const languageFilePath = path.join(__dirname, `../lang/${nodeLocale}.lyaml`);
|
|
21
|
-
const languageFileExists = fs.existsSync(languageFilePath);
|
|
22
|
-
// Fall back to using the default language file
|
|
23
|
-
locale = languageFileExists ? nodeLocale : 'en';
|
|
24
|
-
languageObj = yaml.load(fs.readFileSync(path.join(__dirname, `../lang/${locale}.lyaml`), 'utf8'));
|
|
25
|
-
uiLogger.debug('Loaded language data: ' + util.inspect(languageObj, true, 999, true));
|
|
26
|
-
}
|
|
27
|
-
catch (e) {
|
|
28
|
-
uiLogger.error('Error loading language data: ' +
|
|
29
|
-
(e instanceof Error ? e.message : String(e)));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
function getTextValue(lookupDotNotation) {
|
|
33
|
-
const lookupProps = [locale, ...lookupDotNotation.split('.')];
|
|
34
|
-
const missingTextData = `${MISSING_LANGUAGE_DATA_PREFIX}: ${lookupProps.join('.')}`;
|
|
35
|
-
let textValue = languageObj;
|
|
36
|
-
let previouslyCheckedProp = lookupProps[0];
|
|
37
|
-
try {
|
|
38
|
-
lookupProps.forEach(prop => {
|
|
39
|
-
if (textValue && typeof textValue === 'object') {
|
|
40
|
-
textValue = textValue[prop];
|
|
41
|
-
}
|
|
42
|
-
previouslyCheckedProp = prop;
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
uiLogger.debug(`Unable to access language property: ${lookupProps.join('.')}. Failed to access prop "${previouslyCheckedProp}".`);
|
|
47
|
-
uiLogger.error('Unable to access language property.');
|
|
48
|
-
return missingTextData;
|
|
49
|
-
}
|
|
50
|
-
if (!textValue) {
|
|
51
|
-
return missingTextData;
|
|
52
|
-
}
|
|
53
|
-
if (typeof textValue !== 'string') {
|
|
54
|
-
return missingTextData;
|
|
55
|
-
}
|
|
56
|
-
return textValue;
|
|
57
|
-
}
|
|
58
|
-
export function i18n(lookupDotNotation, options = {}) {
|
|
59
|
-
if (!languageObj) {
|
|
60
|
-
loadLanguageFromYaml();
|
|
61
|
-
}
|
|
62
|
-
if (typeof lookupDotNotation !== 'string') {
|
|
63
|
-
throw new Error(`i18n must be passed a string value for lookupDotNotation, received ${typeof lookupDotNotation}`);
|
|
64
|
-
}
|
|
65
|
-
const textValue = getTextValue(lookupDotNotation);
|
|
66
|
-
const shouldInterpolate = !textValue.startsWith(MISSING_LANGUAGE_DATA_PREFIX);
|
|
67
|
-
return shouldInterpolate ? interpolate(textValue, options) : textValue;
|
|
68
|
-
}
|
|
69
|
-
export function setLangData(newLocale, newLangObj) {
|
|
70
|
-
locale = newLocale;
|
|
71
|
-
languageObj = newLangObj;
|
|
72
|
-
}
|
|
@@ -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
|