@hubspot/cli 7.9.0-experimental.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/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 +15 -11
- 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 +6 -6
- 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/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 +10 -5
- 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__/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 +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/upload.js +9 -3
- package/commands/project/validate.js +9 -3
- package/commands/project/watch.js +7 -2
- 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 +134 -44
- package/commands/testAccount/delete.js +9 -8
- package/commands/testAccount/importData.d.ts +1 -1
- package/lang/en.d.ts +3204 -3205
- package/lang/en.js +33 -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/constants.d.ts +1 -0
- package/lib/constants.js +6 -0
- 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.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/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__/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/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/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 → lib/mcp/__tests__/setup.test.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { getValidEnv } from '@hubspot/local-dev-lib/environment';
|
|
4
|
-
import {
|
|
4
|
+
import { getConfigAccountEnvironment } from '@hubspot/local-dev-lib/config';
|
|
5
5
|
import { getCwd } from '@hubspot/local-dev-lib/path';
|
|
6
6
|
import { makeYargsBuilder } from '../../lib/yargsUtils.js';
|
|
7
7
|
import { promptUser, listPrompt } from '../../lib/prompts/promptUtils.js';
|
|
@@ -14,53 +14,83 @@ import { createDeveloperTestAccountConfigPrompt } from '../../lib/prompts/create
|
|
|
14
14
|
import { debugError, logError } from '../../lib/errorHandlers/index.js';
|
|
15
15
|
import SpinniesManager from '../../lib/ui/SpinniesManager.js';
|
|
16
16
|
import { createDeveloperTestAccountV2, saveAccountToConfig, } from '../../lib/buildAccount.js';
|
|
17
|
+
import { ACCOUNT_LEVEL_CHOICES } from '../../lib/constants.js';
|
|
17
18
|
const command = 'create';
|
|
18
19
|
const describe = commands.testAccount.create.describe;
|
|
19
|
-
|
|
20
|
-
const {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
function hasAnyFlags(args) {
|
|
21
|
+
const { name, description, marketingLevel, opsLevel, serviceLevel, salesLevel, contentLevel, } = args;
|
|
22
|
+
return !!(name ||
|
|
23
|
+
description ||
|
|
24
|
+
marketingLevel ||
|
|
25
|
+
opsLevel ||
|
|
26
|
+
serviceLevel ||
|
|
27
|
+
salesLevel ||
|
|
28
|
+
contentLevel);
|
|
29
|
+
}
|
|
30
|
+
async function readConfigFile(configPath) {
|
|
31
|
+
const absoluteConfigPath = path.resolve(getCwd(), configPath);
|
|
32
|
+
if (!fileExists(absoluteConfigPath)) {
|
|
33
|
+
uiLogger.error(commands.testAccount.create.errors.configFileNotFound(absoluteConfigPath));
|
|
34
|
+
process.exit(EXIT_CODES.ERROR);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(fs.readFileSync(absoluteConfigPath, 'utf8'));
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
uiLogger.error(commands.testAccount.create.errors.configFileParseFailed(absoluteConfigPath));
|
|
41
|
+
process.exit(EXIT_CODES.ERROR);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function promptForConfigPath() {
|
|
45
|
+
const createTestAccountFromConfig = await listPrompt(commands.testAccount.create.createTestAccountFromConfigPrompt, {
|
|
46
|
+
choices: [
|
|
47
|
+
{
|
|
48
|
+
name: commands.testAccount.create.createFromConfigOption,
|
|
49
|
+
value: true,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: commands.testAccount.create.createFromScratchOption,
|
|
53
|
+
value: false,
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
if (createTestAccountFromConfig) {
|
|
58
|
+
const configPathPromptResult = await promptUser({
|
|
59
|
+
name: 'configPath',
|
|
60
|
+
message: commands.testAccount.create.configPathPrompt,
|
|
61
|
+
type: 'input',
|
|
37
62
|
});
|
|
38
|
-
|
|
39
|
-
const configPathPromptResult = await promptUser({
|
|
40
|
-
name: 'configPath',
|
|
41
|
-
message: commands.testAccount.create.configPathPrompt,
|
|
42
|
-
type: 'input',
|
|
43
|
-
});
|
|
44
|
-
accountConfigPath = configPathPromptResult.configPath;
|
|
45
|
-
}
|
|
63
|
+
return configPathPromptResult.configPath;
|
|
46
64
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
testAccountConfig = JSON.parse(fs.readFileSync(absoluteConfigPath, 'utf8'));
|
|
55
|
-
}
|
|
56
|
-
catch (err) {
|
|
57
|
-
uiLogger.error(commands.testAccount.create.errors.configFileParseFailed(absoluteConfigPath));
|
|
58
|
-
process.exit(EXIT_CODES.ERROR);
|
|
59
|
-
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
async function buildTestAccountConfig(args) {
|
|
68
|
+
const { configPath, name, description, marketingLevel, opsLevel, serviceLevel, salesLevel, contentLevel, } = args;
|
|
69
|
+
if (configPath) {
|
|
70
|
+
return readConfigFile(configPath);
|
|
60
71
|
}
|
|
61
|
-
|
|
62
|
-
|
|
72
|
+
let accountConfigPath;
|
|
73
|
+
if (!hasAnyFlags(args)) {
|
|
74
|
+
accountConfigPath = await promptForConfigPath();
|
|
75
|
+
}
|
|
76
|
+
if (accountConfigPath) {
|
|
77
|
+
return readConfigFile(accountConfigPath);
|
|
63
78
|
}
|
|
79
|
+
return createDeveloperTestAccountConfigPrompt({
|
|
80
|
+
name,
|
|
81
|
+
description,
|
|
82
|
+
marketingLevel,
|
|
83
|
+
opsLevel,
|
|
84
|
+
serviceLevel,
|
|
85
|
+
salesLevel,
|
|
86
|
+
contentLevel,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async function handler(args) {
|
|
90
|
+
const { derivedAccountId, formatOutputAsJson } = args;
|
|
91
|
+
trackCommandUsage('test-account-create', {}, derivedAccountId);
|
|
92
|
+
const env = getValidEnv(getConfigAccountEnvironment(derivedAccountId));
|
|
93
|
+
const testAccountConfig = await buildTestAccountConfig(args);
|
|
64
94
|
const resultJson = {};
|
|
65
95
|
SpinniesManager.init({
|
|
66
96
|
succeedColor: 'white',
|
|
@@ -90,7 +120,12 @@ async function handler(args) {
|
|
|
90
120
|
else {
|
|
91
121
|
// Only save to config if not using json output
|
|
92
122
|
try {
|
|
93
|
-
await saveAccountToConfig(resultJson.accountId, testAccountConfig.accountName, env, resultJson.personalAccessKey);
|
|
123
|
+
const savedAccountName = await saveAccountToConfig(resultJson.accountId, testAccountConfig.accountName, env, resultJson.personalAccessKey);
|
|
124
|
+
// Inform user if the account name was normalized
|
|
125
|
+
if (savedAccountName !== testAccountConfig.accountName) {
|
|
126
|
+
uiLogger.log('');
|
|
127
|
+
uiLogger.info(commands.testAccount.create.savedAccountNameDiffers(testAccountConfig.accountName, savedAccountName));
|
|
128
|
+
}
|
|
94
129
|
}
|
|
95
130
|
catch (e) {
|
|
96
131
|
debugError(e);
|
|
@@ -105,10 +140,65 @@ function createTestAccountBuilder(yargs) {
|
|
|
105
140
|
type: 'string',
|
|
106
141
|
description: commands.testAccount.create.options.configPath,
|
|
107
142
|
});
|
|
143
|
+
yargs.option('name', {
|
|
144
|
+
type: 'string',
|
|
145
|
+
description: commands.testAccount.create.options.accountName,
|
|
146
|
+
});
|
|
147
|
+
yargs.option('description', {
|
|
148
|
+
type: 'string',
|
|
149
|
+
description: commands.testAccount.create.options.description,
|
|
150
|
+
});
|
|
151
|
+
yargs.option('marketing-level', {
|
|
152
|
+
type: 'string',
|
|
153
|
+
description: commands.testAccount.create.options.marketingLevel,
|
|
154
|
+
choices: ACCOUNT_LEVEL_CHOICES,
|
|
155
|
+
});
|
|
156
|
+
yargs.option('ops-level', {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: commands.testAccount.create.options.opsLevel,
|
|
159
|
+
choices: ACCOUNT_LEVEL_CHOICES,
|
|
160
|
+
});
|
|
161
|
+
yargs.option('service-level', {
|
|
162
|
+
type: 'string',
|
|
163
|
+
description: commands.testAccount.create.options.serviceLevel,
|
|
164
|
+
choices: ACCOUNT_LEVEL_CHOICES,
|
|
165
|
+
});
|
|
166
|
+
yargs.option('sales-level', {
|
|
167
|
+
type: 'string',
|
|
168
|
+
description: commands.testAccount.create.options.salesLevel,
|
|
169
|
+
choices: ACCOUNT_LEVEL_CHOICES,
|
|
170
|
+
});
|
|
171
|
+
yargs.option('content-level', {
|
|
172
|
+
type: 'string',
|
|
173
|
+
description: commands.testAccount.create.options.contentLevel,
|
|
174
|
+
choices: ACCOUNT_LEVEL_CHOICES,
|
|
175
|
+
});
|
|
176
|
+
yargs.conflicts('config-path', [
|
|
177
|
+
'name',
|
|
178
|
+
'description',
|
|
179
|
+
'marketing-level',
|
|
180
|
+
'ops-level',
|
|
181
|
+
'service-level',
|
|
182
|
+
'sales-level',
|
|
183
|
+
'content-level',
|
|
184
|
+
]);
|
|
108
185
|
yargs.example([
|
|
186
|
+
['$0 test-account create', 'Interactive mode - prompts for all options'],
|
|
187
|
+
[
|
|
188
|
+
'$0 test-account create --name "MyTestAccount"',
|
|
189
|
+
'Provide name via flag, prompt for description and tier selection',
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
'$0 test-account create --name "MyTestAccount" --description "Test account"',
|
|
193
|
+
'Provide name and description, prompt for tier selection',
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
'$0 test-account create --name "MyTestAccount" --marketing-level PROFESSIONAL',
|
|
197
|
+
'Specify marketing tier, other tiers default to ENTERPRISE',
|
|
198
|
+
],
|
|
109
199
|
[
|
|
110
200
|
'$0 test-account create --config-path ./test-account-config.json',
|
|
111
|
-
|
|
201
|
+
'Create from config file (mutually exclusive with other flags)',
|
|
112
202
|
],
|
|
113
203
|
]);
|
|
114
204
|
return yargs;
|
|
@@ -4,7 +4,7 @@ import { EXIT_CODES } from '../../lib/enums/exitCodes.js';
|
|
|
4
4
|
import { uiLogger } from '../../lib/ui/logger.js';
|
|
5
5
|
import { trackCommandUsage } from '../../lib/usageTracking.js';
|
|
6
6
|
import { commands } from '../../lang/en.js';
|
|
7
|
-
import {
|
|
7
|
+
import { removeAccountFromConfig, getConfigAccountById, getConfigAccountIfExists, setConfigAccountAsDefault, getConfigDefaultAccountIfExists, } from '@hubspot/local-dev-lib/config';
|
|
8
8
|
import { promptUser } from '../../lib/prompts/promptUtils.js';
|
|
9
9
|
import { debugError } from '../../lib/errorHandlers/index.js';
|
|
10
10
|
const command = 'delete [test-account]';
|
|
@@ -64,12 +64,12 @@ async function deleteTestAccountFromConfig(testAccountId, parentAccountName, acc
|
|
|
64
64
|
// If the account isn't in the local config then it wasn't auth'd on the local machine
|
|
65
65
|
if (account && account.name && account.accountType) {
|
|
66
66
|
// If the deleted test account was the default account, replace the default account with the parent account
|
|
67
|
-
|
|
68
|
-
const defaultAccountId =
|
|
69
|
-
|
|
67
|
+
const defaultAccount = getConfigDefaultAccountIfExists();
|
|
68
|
+
const defaultAccountId = defaultAccount?.accountId;
|
|
69
|
+
removeAccountFromConfig(account.accountId);
|
|
70
70
|
uiLogger.success(commands.testAccount.delete.success.testAccountDeletedFromConfig(testAccountId));
|
|
71
71
|
if (testAccountId === defaultAccountId) {
|
|
72
|
-
|
|
72
|
+
setConfigAccountAsDefault(parentAccountName);
|
|
73
73
|
uiLogger.info(commands.testAccount.delete.info.replaceDefaultAccount(testAccountId, parentAccountName));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -84,12 +84,12 @@ async function validateTestAccountConfigs(testAccountId) {
|
|
|
84
84
|
uiLogger.error(commands.testAccount.delete.errors.testAccountNotFound(testAccountId));
|
|
85
85
|
process.exit(EXIT_CODES.ERROR);
|
|
86
86
|
}
|
|
87
|
-
const testAccountConfig =
|
|
87
|
+
const testAccountConfig = getConfigAccountById(testAccountId);
|
|
88
88
|
if (!testAccountConfig) {
|
|
89
89
|
uiLogger.error(commands.testAccount.delete.errors.testAccountNotFound(testAccountId));
|
|
90
90
|
process.exit(EXIT_CODES.ERROR);
|
|
91
91
|
}
|
|
92
|
-
const parentAccountConfig =
|
|
92
|
+
const parentAccountConfig = getConfigAccountById(testAccountConfig.parentAccountId);
|
|
93
93
|
if (!parentAccountConfig) {
|
|
94
94
|
uiLogger.error(commands.testAccount.delete.errors.parentAccountNotFound(testAccountId));
|
|
95
95
|
process.exit(EXIT_CODES.ERROR);
|
|
@@ -103,7 +103,8 @@ async function handler(args) {
|
|
|
103
103
|
let testAccountIdToDelete = 0;
|
|
104
104
|
// See if the account exists
|
|
105
105
|
if (testAccount) {
|
|
106
|
-
const
|
|
106
|
+
const account = getConfigAccountIfExists(testAccount);
|
|
107
|
+
const accountId = account?.accountId || null;
|
|
107
108
|
await validateTestAccountConfigs(accountId);
|
|
108
109
|
if (accountId) {
|
|
109
110
|
testAccountIdToDelete = accountId;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AccountArgs, CommonArgs, ConfigArgs, EnvironmentArgs, YargsCommandModule } from '../../types/Yargs.js';
|
|
2
2
|
export declare const command = "import-data";
|
|
3
|
-
export declare const describe:
|
|
3
|
+
export declare const describe: string;
|
|
4
4
|
type CrmImportDataArgs = CommonArgs & ConfigArgs & AccountArgs & EnvironmentArgs & {
|
|
5
5
|
filePath: string | undefined;
|
|
6
6
|
skipConfirm: boolean | undefined;
|