@hubspot/cli 7.7.19-experimental.0 → 7.7.19-experimental.2
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/commands/app/install.d.ts +8 -0
- package/commands/app/install.js +127 -0
- package/commands/app.js +6 -1
- package/commands/mcp/setup.js +0 -1
- package/commands/mcp/start.d.ts +1 -4
- package/commands/mcp/start.js +3 -10
- package/commands/open.js +14 -12
- package/commands/project/dev/unifiedFlow.js +1 -1
- package/commands/testAccount/create.js +14 -24
- package/lang/en.d.ts +65 -5
- package/lang/en.js +65 -5
- package/lib/app/migrate.js +2 -6
- package/lib/buildAccount.d.ts +7 -1
- package/lib/buildAccount.js +54 -4
- package/lib/mcp/setup.js +3 -8
- package/lib/projects/create/v3.d.ts +3 -2
- package/lib/projects/create/v3.js +2 -2
- package/lib/projects/localDev/helpers.d.ts +1 -1
- package/lib/projects/localDev/helpers.js +2 -2
- package/lib/projects/structure.d.ts +2 -2
- package/lib/projects/upload.d.ts +2 -1
- package/lib/projects/upload.js +1 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +9 -10
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +86 -47
- package/lib/prompts/createModulePrompt.js +1 -2
- package/lib/prompts/projectAddPrompt.d.ts +2 -1
- package/lib/prompts/projectAddPrompt.js +2 -1
- package/lib/prompts/promptUtils.d.ts +2 -2
- package/lib/prompts/promptUtils.js +161 -35
- package/lib/prompts/selectProjectTemplatePrompt.d.ts +2 -1
- package/lib/prompts/selectProjectTemplatePrompt.js +2 -1
- package/lib/usageTracking.d.ts +5 -5
- package/lib/usageTracking.js +79 -74
- package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/UploadProjectTools.js +1 -1
- package/mcp-server/utils/project.js +0 -3
- package/package.json +3 -3
- package/types/Prompts.d.ts +4 -2
package/lib/buildAccount.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.saveAccountToConfig = saveAccountToConfig;
|
|
7
|
+
exports.createDeveloperTestAccountV3 = createDeveloperTestAccountV3;
|
|
7
8
|
exports.buildDeveloperTestAccount = buildDeveloperTestAccount;
|
|
8
9
|
exports.buildSandbox = buildSandbox;
|
|
9
10
|
const personalAccessKey_1 = require("@hubspot/local-dev-lib/personalAccessKey");
|
|
@@ -14,12 +15,15 @@ const developerTestAccounts_1 = require("@hubspot/local-dev-lib/api/developerTes
|
|
|
14
15
|
const config_2 = require("@hubspot/local-dev-lib/constants/config");
|
|
15
16
|
const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
|
|
16
17
|
const personalAccessKeyPrompt_1 = require("./prompts/personalAccessKeyPrompt");
|
|
18
|
+
const createDeveloperTestAccountConfigPrompt_1 = require("./prompts/createDeveloperTestAccountConfigPrompt");
|
|
17
19
|
const lang_1 = require("./lang");
|
|
18
20
|
const accountNamePrompt_1 = require("./prompts/accountNamePrompt");
|
|
19
21
|
const SpinniesManager_1 = __importDefault(require("./ui/SpinniesManager"));
|
|
20
22
|
const index_1 = require("./errorHandlers/index");
|
|
21
23
|
const sandboxes_1 = require("./sandboxes");
|
|
22
24
|
const developerTestAccounts_2 = require("./developerTestAccounts");
|
|
25
|
+
const en_1 = require("../lang/en");
|
|
26
|
+
const polling_1 = require("./polling");
|
|
23
27
|
async function saveAccountToConfig(accountId, accountName, env, personalAccessKey, force = false) {
|
|
24
28
|
if (!personalAccessKey) {
|
|
25
29
|
const configData = await (0, personalAccessKeyPrompt_1.personalAccessKeyPrompt)({
|
|
@@ -60,12 +64,51 @@ async function saveAccountToConfig(accountId, accountName, env, personalAccessKe
|
|
|
60
64
|
logger_1.logger.log('');
|
|
61
65
|
return validName;
|
|
62
66
|
}
|
|
63
|
-
async function
|
|
67
|
+
async function createDeveloperTestAccountV3(parentAccountId, testAccountConfig) {
|
|
68
|
+
const result = {
|
|
69
|
+
accountName: testAccountConfig.accountName,
|
|
70
|
+
};
|
|
71
|
+
const { data } = await (0, developerTestAccounts_1.createDeveloperTestAccount)(parentAccountId, testAccountConfig);
|
|
72
|
+
result.accountId = data.id;
|
|
73
|
+
try {
|
|
74
|
+
await (0, polling_1.poll)(() => (0, developerTestAccounts_1.fetchDeveloperTestAccountGateSyncStatus)(parentAccountId, result.accountId), {
|
|
75
|
+
successStates: ['SUCCESS'],
|
|
76
|
+
errorStates: [],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
(0, index_1.debugError)(err);
|
|
81
|
+
throw new Error(en_1.lib.buildAccount.createDeveloperTestAccountV3.syncFailure);
|
|
82
|
+
}
|
|
83
|
+
// HACK: The status endpoint sometimes returns an early success status.
|
|
84
|
+
// Sleep for an extra 6 minutes to make sure the sync is actually complete.
|
|
85
|
+
await new Promise(resolve => setTimeout(resolve, 360000));
|
|
86
|
+
try {
|
|
87
|
+
// Attempt to generate a new personal access key for the test account now that gate sync is complete.
|
|
88
|
+
const { data } = await (0, developerTestAccounts_1.generateDeveloperTestAccountPersonalAccessKey)(parentAccountId, result.accountId);
|
|
89
|
+
result.personalAccessKey = data.personalAccessKey;
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
(0, index_1.debugError)(err);
|
|
93
|
+
throw new Error(en_1.lib.buildAccount.createDeveloperTestAccountV3.pakFailure);
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
async function buildDeveloperTestAccount(testAccountName, parentAccountConfig, env, portalLimit, useV3 = false) {
|
|
64
98
|
const id = (0, getAccountIdentifier_1.getAccountIdentifier)(parentAccountConfig);
|
|
65
99
|
const parentAccountId = (0, config_1.getAccountId)(id);
|
|
100
|
+
let testAccountConfig = {
|
|
101
|
+
accountName: testAccountName,
|
|
102
|
+
};
|
|
66
103
|
if (!parentAccountId) {
|
|
67
104
|
throw new Error((0, lang_1.i18n)(`lib.developerTestAccount.create.loading.fail`));
|
|
68
105
|
}
|
|
106
|
+
if (useV3) {
|
|
107
|
+
testAccountConfig = await (0, createDeveloperTestAccountConfigPrompt_1.createDeveloperTestAccountConfigPrompt)({
|
|
108
|
+
name: testAccountConfig.accountName,
|
|
109
|
+
description: 'Test Account created by the HubSpot CLI',
|
|
110
|
+
}, false);
|
|
111
|
+
}
|
|
69
112
|
SpinniesManager_1.default.init({
|
|
70
113
|
succeedColor: 'white',
|
|
71
114
|
});
|
|
@@ -78,9 +121,16 @@ async function buildDeveloperTestAccount(testAccountName, parentAccountConfig, e
|
|
|
78
121
|
let developerTestAccountId;
|
|
79
122
|
let developerTestAccountPersonalAccessKey;
|
|
80
123
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
124
|
+
if (useV3) {
|
|
125
|
+
const result = await createDeveloperTestAccountV3(parentAccountId, testAccountConfig);
|
|
126
|
+
developerTestAccountId = result.accountId;
|
|
127
|
+
developerTestAccountPersonalAccessKey = result.personalAccessKey;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const { data } = await (0, developerTestAccounts_1.createDeveloperTestAccount)(parentAccountId, testAccountName);
|
|
131
|
+
developerTestAccountId = data.id;
|
|
132
|
+
developerTestAccountPersonalAccessKey = data.personalAccessKey;
|
|
133
|
+
}
|
|
84
134
|
SpinniesManager_1.default.succeed('buildDeveloperTestAccount', {
|
|
85
135
|
text: (0, lang_1.i18n)(`lib.developerTestAccount.create.loading.succeed`, {
|
|
86
136
|
accountName: testAccountName,
|
package/lib/mcp/setup.js
CHANGED
|
@@ -157,7 +157,7 @@ async function setupClaudeCode(mcpCommand = defaultMcpCommand) {
|
|
|
157
157
|
// Run claude mcp add command
|
|
158
158
|
const mcpConfig = JSON.stringify({
|
|
159
159
|
type: 'stdio',
|
|
160
|
-
...
|
|
160
|
+
...mcpCommand,
|
|
161
161
|
});
|
|
162
162
|
const { stdout } = await (0, command_1.execAsync)('claude mcp list');
|
|
163
163
|
if (stdout.includes(mcpServerName)) {
|
|
@@ -203,7 +203,7 @@ function setupCursor(mcpCommand = defaultMcpCommand) {
|
|
|
203
203
|
configuringMessage: en_1.commands.mcp.setup.spinners.configuringCursor,
|
|
204
204
|
configuredMessage: en_1.commands.mcp.setup.spinners.configuredCursor,
|
|
205
205
|
failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureCursor,
|
|
206
|
-
mcpCommand
|
|
206
|
+
mcpCommand,
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
209
|
function setupWindsurf(mcpCommand = defaultMcpCommand) {
|
|
@@ -213,11 +213,6 @@ function setupWindsurf(mcpCommand = defaultMcpCommand) {
|
|
|
213
213
|
configuringMessage: en_1.commands.mcp.setup.spinners.configuringWindsurf,
|
|
214
214
|
configuredMessage: en_1.commands.mcp.setup.spinners.configuredWindsurf,
|
|
215
215
|
failedMessage: en_1.commands.mcp.setup.spinners.failedToConfigureWindsurf,
|
|
216
|
-
mcpCommand
|
|
216
|
+
mcpCommand,
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
-
function buildCommandWithAgentString(mcpCommand, agent) {
|
|
220
|
-
const mcpCommandCopy = structuredClone(mcpCommand);
|
|
221
|
-
mcpCommandCopy.args.push('--ai-agent', agent);
|
|
222
|
-
return mcpCommandCopy;
|
|
223
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Separator } from '@inquirer/prompts';
|
|
1
2
|
import { ComponentTemplate, ComponentTemplateChoice, ProjectTemplateRepoConfig } from '../../../types/Projects';
|
|
2
3
|
import { ProjectMetadata } from '@hubspot/project-parsing-lib/src/lib/project';
|
|
3
4
|
import { SelectProjectTemplatePromptResponse } from '../../prompts/selectProjectTemplatePrompt';
|
|
@@ -7,13 +8,13 @@ export declare function createV3App(providedAuth: string | undefined, providedDi
|
|
|
7
8
|
authType: string;
|
|
8
9
|
distribution: string;
|
|
9
10
|
}>;
|
|
10
|
-
export declare function calculateComponentTemplateChoices(components: ComponentTemplate[], authType: string | undefined, distribution: string | undefined, projectMetadata?: ProjectMetadata): ComponentTemplateChoice[];
|
|
11
|
+
export declare function calculateComponentTemplateChoices(components: ComponentTemplate[], authType: string | undefined, distribution: string | undefined, projectMetadata?: ProjectMetadata): (ComponentTemplateChoice | Separator)[];
|
|
11
12
|
type V3ComponentInfo = {
|
|
12
13
|
authType?: string;
|
|
13
14
|
distribution?: string;
|
|
14
15
|
repoConfig?: ProjectTemplateRepoConfig;
|
|
15
16
|
projectContents?: string;
|
|
16
|
-
componentTemplateChoices?: ComponentTemplateChoice[];
|
|
17
|
+
componentTemplateChoices?: (ComponentTemplateChoice | Separator)[];
|
|
17
18
|
};
|
|
18
19
|
export declare function v3ComponentFlow(platformVersion: string, projectBase: string | undefined, providedAuth: string | undefined, providedDistribution: string | undefined): Promise<V3ComponentInfo>;
|
|
19
20
|
export declare function generateComponentPaths({ selectProjectTemplatePromptResponse, platformVersion, repoConfig, projectContents, authType, distribution, }: {
|
|
@@ -8,6 +8,7 @@ exports.createV3App = createV3App;
|
|
|
8
8
|
exports.calculateComponentTemplateChoices = calculateComponentTemplateChoices;
|
|
9
9
|
exports.v3ComponentFlow = v3ComponentFlow;
|
|
10
10
|
exports.generateComponentPaths = generateComponentPaths;
|
|
11
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
11
12
|
const constants_1 = require("../../constants");
|
|
12
13
|
const en_1 = require("../../../lang/en");
|
|
13
14
|
const promptUtils_1 = require("../../prompts/promptUtils");
|
|
@@ -17,7 +18,6 @@ const path_1 = __importDefault(require("path"));
|
|
|
17
18
|
const legacy_1 = require("./legacy");
|
|
18
19
|
const errorHandlers_1 = require("../../errorHandlers");
|
|
19
20
|
const exitCodes_1 = require("../../enums/exitCodes");
|
|
20
|
-
const inquirer = require('inquirer');
|
|
21
21
|
exports.EMPTY_PROJECT = 'empty';
|
|
22
22
|
exports.PROJECT_WITH_APP = 'app';
|
|
23
23
|
async function createV3App(providedAuth, providedDistribution) {
|
|
@@ -96,7 +96,7 @@ function calculateComponentTemplateChoices(components, authType, distribution, p
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
return disabledComponents.length
|
|
99
|
-
? [...enabledComponents, new
|
|
99
|
+
? [...enabledComponents, new prompts_1.Separator(), ...disabledComponents]
|
|
100
100
|
: [...enabledComponents];
|
|
101
101
|
}
|
|
102
102
|
async function v3ComponentFlow(platformVersion, projectBase, providedAuth, providedDistribution) {
|
|
@@ -11,7 +11,7 @@ export declare function checkIfParentAccountIsAuthed(accountConfig: CLIAccount):
|
|
|
11
11
|
export declare function checkIfAccountFlagIsSupported(accountConfig: CLIAccount, hasPublicApps: boolean): void;
|
|
12
12
|
export declare function suggestRecommendedNestedAccount(accounts: CLIAccount[], accountConfig: CLIAccount, hasPublicApps: boolean): Promise<ProjectDevTargetAccountPromptResponse>;
|
|
13
13
|
export declare function createSandboxForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
|
|
14
|
-
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment): Promise<number>;
|
|
14
|
+
export declare function createDeveloperTestAccountForLocalDev(accountId: number, accountConfig: CLIAccount, env: Environment, useV3?: boolean): Promise<number>;
|
|
15
15
|
export declare function useExistingDevTestAccount(env: Environment, account: DeveloperTestAccount): Promise<void>;
|
|
16
16
|
export declare function createNewProjectForLocalDev(projectConfig: ProjectConfig, targetAccountId: number, shouldCreateWithoutConfirmation: boolean, hasPublicApps: boolean): Promise<Project>;
|
|
17
17
|
export declare function createInitialBuildForNewProject(projectConfig: ProjectConfig, projectDir: string, targetAccountId: number, sendIR?: boolean, profile?: string): Promise<Build>;
|
|
@@ -152,7 +152,7 @@ async function createSandboxForLocalDev(accountId, accountConfig, env) {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
// Create a developer test account and return its accountId
|
|
155
|
-
async function createDeveloperTestAccountForLocalDev(accountId, accountConfig, env) {
|
|
155
|
+
async function createDeveloperTestAccountForLocalDev(accountId, accountConfig, env, useV3 = false) {
|
|
156
156
|
let currentPortalCount = 0;
|
|
157
157
|
let maxTestPortals = 10;
|
|
158
158
|
try {
|
|
@@ -182,7 +182,7 @@ async function createDeveloperTestAccountForLocalDev(accountId, accountConfig, e
|
|
|
182
182
|
accountType: config_1.HUBSPOT_ACCOUNT_TYPES.DEVELOPER_TEST,
|
|
183
183
|
});
|
|
184
184
|
(0, usageTracking_1.trackCommandMetadataUsage)('developer-test-account-create', { step: 'project-dev' }, accountId);
|
|
185
|
-
const result = await (0, buildAccount_1.buildDeveloperTestAccount)(name, accountConfig, env, maxTestPortals);
|
|
185
|
+
const result = await (0, buildAccount_1.buildDeveloperTestAccount)(name, accountConfig, env, maxTestPortals, useV3);
|
|
186
186
|
return result;
|
|
187
187
|
}
|
|
188
188
|
catch (err) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentTypes, Component, GenericComponentConfig, PublicAppComponentConfig, PrivateAppComponentConfig, AppCardComponentConfig } from '../../types/Projects';
|
|
2
|
-
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
|
+
import { IntermediateRepresentationNode, IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
3
3
|
import { AppIRNode } from '../../types/ProjectComponents';
|
|
4
4
|
export declare const CONFIG_FILES: {
|
|
5
5
|
[k in ComponentTypes]: string;
|
|
@@ -15,4 +15,4 @@ export declare function getProjectComponentTypes(components: Array<Component>):
|
|
|
15
15
|
export declare function getComponentUid(component?: Component | null): string | null;
|
|
16
16
|
export declare function componentIsApp(component?: Component | null): component is Component<PublicAppComponentConfig | PrivateAppComponentConfig>;
|
|
17
17
|
export declare function componentIsPublicApp(component?: Component | null): component is Component<PublicAppComponentConfig>;
|
|
18
|
-
export declare function isAppIRNode(component: IntermediateRepresentationNodeLocalDev): component is AppIRNode;
|
|
18
|
+
export declare function isAppIRNode(component: IntermediateRepresentationNodeLocalDev | IntermediateRepresentationNode): component is AppIRNode;
|
package/lib/projects/upload.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FileResult } from 'tmp';
|
|
2
|
+
import { IntermediateRepresentation } from '@hubspot/project-parsing-lib';
|
|
2
3
|
import { ProjectConfig } from '../../types/Projects';
|
|
3
4
|
type ProjectUploadCallbackFunction<T> = (accountId: number, projectConfig: ProjectConfig, tempFile: FileResult, buildId: number) => Promise<T>;
|
|
4
5
|
type ProjectUploadResult<T> = {
|
|
@@ -20,5 +21,5 @@ type HandleProjectUploadArg<T> = {
|
|
|
20
21
|
export declare function handleProjectUpload<T>({ accountId, projectConfig, projectDir, callbackFunc, profile, uploadMessage, forceCreate, isUploadCommand, sendIR, skipValidation, }: HandleProjectUploadArg<T>): Promise<ProjectUploadResult<T>>;
|
|
21
22
|
export declare function validateSourceDirectory(srcDir: string, projectConfig: ProjectConfig): void;
|
|
22
23
|
export declare function validateNoHSMetaMismatch(srcDir: string, projectConfig: ProjectConfig): Promise<void>;
|
|
23
|
-
export declare function handleTranslate(projectDir: string, projectConfig: ProjectConfig, accountId: number, skipValidation: boolean, profile: string | undefined): Promise<
|
|
24
|
+
export declare function handleTranslate(projectDir: string, projectConfig: ProjectConfig, accountId: number, skipValidation: boolean, profile: string | undefined): Promise<IntermediateRepresentation | undefined>;
|
|
24
25
|
export {};
|
package/lib/projects/upload.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { DeveloperTestAccountConfig } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
1
|
+
import { AccountLevel, DeveloperTestAccountConfig } from '@hubspot/local-dev-lib/types/developerTestAccounts';
|
|
2
2
|
declare const hubs: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
MARKETING: string;
|
|
4
|
+
OPS: string;
|
|
5
|
+
SERVICE: string;
|
|
6
|
+
SALES: string;
|
|
7
|
+
CONTENT: string;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
10
|
-
type
|
|
11
|
-
export type HubConfig = `${HubName}:${HubTier}`;
|
|
9
|
+
type HubKey = keyof typeof hubs;
|
|
10
|
+
export type HubConfig = `${HubKey}:${AccountLevel}`;
|
|
12
11
|
export declare function createDeveloperTestAccountConfigPrompt(args?: {
|
|
13
12
|
name?: string;
|
|
14
13
|
description?: string;
|
|
15
14
|
tiers?: HubConfig[];
|
|
16
|
-
}): Promise<DeveloperTestAccountConfig>;
|
|
15
|
+
}, supportFlags?: boolean): Promise<DeveloperTestAccountConfig>;
|
|
17
16
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDeveloperTestAccountConfigPrompt = createDeveloperTestAccountConfigPrompt;
|
|
4
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
4
5
|
const en_1 = require("../../lang/en");
|
|
5
6
|
const promptUtils_1 = require("./promptUtils");
|
|
6
7
|
const hubs = {
|
|
@@ -10,32 +11,43 @@ const hubs = {
|
|
|
10
11
|
SALES: 'salesLevel',
|
|
11
12
|
CONTENT: 'contentLevel',
|
|
12
13
|
};
|
|
14
|
+
const AccountTiers = {
|
|
15
|
+
FREE: 'FREE',
|
|
16
|
+
STARTER: 'STARTER',
|
|
17
|
+
PROFESSIONAL: 'PROFESSIONAL',
|
|
18
|
+
ENTERPRISE: 'ENTERPRISE',
|
|
19
|
+
};
|
|
20
|
+
const makeHubTiers = (hubKey) => {
|
|
21
|
+
const langKey = hubKey.toLowerCase();
|
|
22
|
+
const langObj = en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.tiers[langKey];
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
name: langObj.free,
|
|
26
|
+
value: `${hubKey.toUpperCase()}:${AccountTiers.FREE}`,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: langObj.starter,
|
|
30
|
+
value: `${hubKey.toUpperCase()}:${AccountTiers.STARTER}`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: langObj.professional,
|
|
34
|
+
value: `${hubKey.toUpperCase()}:${AccountTiers.PROFESSIONAL}`,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
};
|
|
13
38
|
const TEST_ACCOUNT_TIERS = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
promptUtils_1.Separator,
|
|
25
|
-
{ name: 'Service STARTER', value: 'SERVICE:STARTER' },
|
|
26
|
-
{ name: 'Service PROFESSIONAL', value: 'SERVICE:PROFESSIONAL' },
|
|
27
|
-
{ name: 'Service ENTERPRISE', value: 'SERVICE:ENTERPRISE' },
|
|
28
|
-
promptUtils_1.Separator,
|
|
29
|
-
{ name: 'Sales STARTER', value: 'SALES:STARTER' },
|
|
30
|
-
{ name: 'Sales PROFESSIONAL', value: 'SALES:PROFESSIONAL' },
|
|
31
|
-
{ name: 'Sales ENTERPRISE', value: 'SALES:ENTERPRISE' },
|
|
32
|
-
promptUtils_1.Separator,
|
|
33
|
-
{ name: 'Content STARTER', value: 'CONTENT:STARTER' },
|
|
34
|
-
{ name: 'Content PROFESSIONAL', value: 'CONTENT:PROFESSIONAL' },
|
|
35
|
-
{ name: 'Content ENTERPRISE', value: 'CONTENT:ENTERPRISE' },
|
|
36
|
-
promptUtils_1.Separator,
|
|
39
|
+
...makeHubTiers('MARKETING'),
|
|
40
|
+
new prompts_1.Separator(),
|
|
41
|
+
...makeHubTiers('OPS'),
|
|
42
|
+
new prompts_1.Separator(),
|
|
43
|
+
...makeHubTiers('SERVICE'),
|
|
44
|
+
new prompts_1.Separator(),
|
|
45
|
+
...makeHubTiers('SALES'),
|
|
46
|
+
new prompts_1.Separator(),
|
|
47
|
+
...makeHubTiers('CONTENT'),
|
|
48
|
+
new prompts_1.Separator(),
|
|
37
49
|
];
|
|
38
|
-
async function createDeveloperTestAccountConfigPrompt(args = {}) {
|
|
50
|
+
async function createDeveloperTestAccountConfigPrompt(args = {}, supportFlags = true) {
|
|
39
51
|
const { name, description, tiers } = args;
|
|
40
52
|
let accountName = name;
|
|
41
53
|
let accountDescription = description;
|
|
@@ -43,7 +55,7 @@ async function createDeveloperTestAccountConfigPrompt(args = {}) {
|
|
|
43
55
|
if (!accountName) {
|
|
44
56
|
const namePromptResult = await (0, promptUtils_1.promptUser)({
|
|
45
57
|
name: 'accountName',
|
|
46
|
-
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.namePrompt,
|
|
58
|
+
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.namePrompt(supportFlags),
|
|
47
59
|
type: 'input',
|
|
48
60
|
});
|
|
49
61
|
accountName = namePromptResult.accountName;
|
|
@@ -51,43 +63,70 @@ async function createDeveloperTestAccountConfigPrompt(args = {}) {
|
|
|
51
63
|
if (!accountDescription) {
|
|
52
64
|
const descriptionPromptResult = await (0, promptUtils_1.promptUser)({
|
|
53
65
|
name: 'description',
|
|
54
|
-
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.descriptionPrompt,
|
|
66
|
+
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.descriptionPrompt(supportFlags),
|
|
55
67
|
type: 'input',
|
|
56
68
|
});
|
|
57
69
|
accountDescription = descriptionPromptResult.description;
|
|
58
70
|
}
|
|
59
71
|
if (!accountLevelsArray) {
|
|
60
|
-
const
|
|
61
|
-
name: '
|
|
62
|
-
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
const useDefaultAccountLevelsPromptResult = await (0, promptUtils_1.promptUser)({
|
|
73
|
+
name: 'useDefaultAccountLevels',
|
|
74
|
+
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt
|
|
75
|
+
.useDefaultAccountLevelsPrompt.message,
|
|
76
|
+
type: 'list',
|
|
77
|
+
choices: [
|
|
78
|
+
{
|
|
79
|
+
name: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt
|
|
80
|
+
.useDefaultAccountLevelsPrompt.default,
|
|
81
|
+
value: 'default',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt
|
|
85
|
+
.useDefaultAccountLevelsPrompt.manual,
|
|
86
|
+
value: 'manual',
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
if (useDefaultAccountLevelsPromptResult.useDefaultAccountLevels === 'manual') {
|
|
91
|
+
const accountLevelsPromptResult = await (0, promptUtils_1.promptUser)({
|
|
92
|
+
name: 'testAccountLevels',
|
|
93
|
+
message: en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.tiersPrompt(supportFlags),
|
|
94
|
+
pageSize: 10,
|
|
95
|
+
type: 'checkbox',
|
|
96
|
+
choices: TEST_ACCOUNT_TIERS,
|
|
97
|
+
validate: choices => {
|
|
98
|
+
if (choices?.length > 1) {
|
|
99
|
+
const hubMap = {};
|
|
100
|
+
for (const choice of choices) {
|
|
101
|
+
const hub = choice.value.split(':')[0];
|
|
102
|
+
if (hubMap[hub]) {
|
|
103
|
+
return en_1.lib.prompts.createDeveloperTestAccountConfigPrompt.errors
|
|
104
|
+
.tiersError;
|
|
105
|
+
}
|
|
106
|
+
hubMap[hub] = true;
|
|
73
107
|
}
|
|
74
|
-
hubMap[hub] = true;
|
|
75
108
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
109
|
+
return true;
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
accountLevelsArray = accountLevelsPromptResult.testAccountLevels;
|
|
113
|
+
}
|
|
81
114
|
}
|
|
82
115
|
if (!accountLevelsArray) {
|
|
83
116
|
accountLevelsArray = [];
|
|
84
117
|
}
|
|
85
118
|
const accountLevels = accountLevelsArray.reduce((acc, level) => {
|
|
86
|
-
const [
|
|
87
|
-
const hubLevel = hubs[
|
|
119
|
+
const [hubKey, hubTier] = level.split(':');
|
|
120
|
+
const hubLevel = hubs[hubKey];
|
|
88
121
|
acc[hubLevel] = hubTier;
|
|
89
122
|
return acc;
|
|
90
123
|
}, {});
|
|
124
|
+
Object.values(hubs).forEach(hubLevel => {
|
|
125
|
+
if (!accountLevels[hubLevel]) {
|
|
126
|
+
accountLevels[hubLevel] = AccountTiers.ENTERPRISE;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
console.log('accountLevels', accountLevels);
|
|
91
130
|
return {
|
|
92
131
|
accountName: accountName,
|
|
93
132
|
description: accountDescription,
|
|
@@ -26,9 +26,8 @@ const CONTENT_TYPES_PROMPT = {
|
|
|
26
26
|
type: 'checkbox',
|
|
27
27
|
name: 'contentTypes',
|
|
28
28
|
message: (0, lang_1.i18n)(`lib.prompts.createModulePrompt.selectContentType`),
|
|
29
|
-
default: ['ANY'],
|
|
30
29
|
choices: [
|
|
31
|
-
{ name: 'Any', value: 'ANY' },
|
|
30
|
+
{ name: 'Any', value: 'ANY', checked: true },
|
|
32
31
|
{ name: 'Landing page', value: 'LANDING_PAGE' },
|
|
33
32
|
{ name: 'Site page', value: 'SITE_PAGE' },
|
|
34
33
|
{ name: 'Blog post', value: 'BLOG_POST' },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Separator } from '@inquirer/prompts';
|
|
1
2
|
import { ComponentTemplate, ComponentTemplateChoice } from '../../types/Projects';
|
|
2
3
|
type ProjectAddPromptResponse = {
|
|
3
4
|
componentTemplate: ComponentTemplate;
|
|
@@ -10,5 +11,5 @@ export declare function projectAddPrompt(components: ComponentTemplate[], prompt
|
|
|
10
11
|
name?: string;
|
|
11
12
|
type?: string;
|
|
12
13
|
}): Promise<ProjectAddPromptResponse>;
|
|
13
|
-
export declare function projectAddPromptV3(components: ComponentTemplateChoice[], selectedFeatures: string[] | undefined): Promise<ProjectAddPromptResponseV3>;
|
|
14
|
+
export declare function projectAddPromptV3(components: (ComponentTemplateChoice | Separator)[], selectedFeatures: string[] | undefined): Promise<ProjectAddPromptResponseV3>;
|
|
14
15
|
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectAddPrompt = projectAddPrompt;
|
|
4
4
|
exports.projectAddPromptV3 = projectAddPromptV3;
|
|
5
|
+
const prompts_1 = require("@inquirer/prompts");
|
|
5
6
|
const promptUtils_1 = require("./promptUtils");
|
|
6
7
|
const en_1 = require("../../lang/en");
|
|
7
8
|
function findComponentByPathOrLabel(components, componentPathOrLabel) {
|
|
@@ -51,7 +52,7 @@ async function projectAddPromptV3(components, selectedFeatures) {
|
|
|
51
52
|
const selectedComponents = [];
|
|
52
53
|
if (selectedFeatures) {
|
|
53
54
|
components.forEach(template => {
|
|
54
|
-
if (!template.value) {
|
|
55
|
+
if (template instanceof prompts_1.Separator || !template.value) {
|
|
55
56
|
return;
|
|
56
57
|
}
|
|
57
58
|
if (selectedFeatures?.includes(template.value.type)) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Separator as _Separator } from '@inquirer/prompts';
|
|
1
2
|
import { PromptConfig, GenericPromptResponse, PromptWhen, PromptChoices } from '../../types/Prompts';
|
|
2
|
-
export declare const Separator:
|
|
3
|
+
export declare const Separator: _Separator;
|
|
3
4
|
export declare function promptUser<T extends GenericPromptResponse>(config: PromptConfig<T> | PromptConfig<T>[]): Promise<T>;
|
|
4
5
|
export declare function confirmPrompt(message: string, options?: {
|
|
5
6
|
defaultAnswer?: boolean;
|
|
6
|
-
when?: PromptWhen;
|
|
7
7
|
}): Promise<boolean>;
|
|
8
8
|
export declare function listPrompt<T = string>(message: string, { choices, when, defaultAnswer, validate, }: {
|
|
9
9
|
choices: PromptChoices<T>;
|