@hubspot/cli 7.7.16-experimental.2 → 7.7.16-experimental.4
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/account/auth.js +3 -3
- package/commands/app/install.d.ts +8 -0
- package/commands/app/install.js +91 -0
- package/commands/app.js +6 -1
- package/commands/auth.js +23 -25
- package/commands/getStarted.js +2 -2
- package/commands/init.js +29 -31
- package/commands/project/cloneApp.js +4 -4
- package/commands/project/create.js +9 -9
- package/commands/project/dev/deprecatedFlow.js +4 -4
- package/commands/project/dev/index.js +5 -5
- package/commands/project/dev/unifiedFlow.js +1 -0
- package/commands/sandbox/delete.js +5 -5
- package/commands/testAccount/create.js +31 -2
- package/lang/en.d.ts +48 -9
- package/lang/en.js +48 -9
- package/lib/app/migrate_legacy.js +2 -3
- package/lib/middleware/__test__/configMiddleware.test.js +2 -2
- package/lib/middleware/configMiddleware.js +10 -2
- package/lib/parsing.d.ts +1 -0
- package/lib/parsing.js +11 -0
- package/lib/polling.d.ts +1 -1
- package/lib/polling.js +11 -1
- package/lib/projects/add/v3AddComponent.js +4 -0
- package/lib/projects/create/index.d.ts +3 -2
- package/lib/projects/create/index.js +11 -5
- package/lib/projects/create/v3.d.ts +3 -3
- package/lib/projects/create/v3.js +2 -2
- package/lib/projects/localDev/LocalDevProcess.d.ts +3 -2
- package/lib/projects/localDev/LocalDevProcess.js +16 -12
- package/lib/projects/localDev/LocalDevState.d.ts +10 -5
- package/lib/projects/localDev/LocalDevState.js +18 -20
- package/lib/projects/localDev/LocalDevWatcher.js +1 -1
- package/lib/prompts/personalAccessKeyPrompt.js +2 -2
- package/lib/prompts/projectNameAndDestPrompt.d.ts +3 -0
- package/lib/prompts/projectNameAndDestPrompt.js +60 -0
- package/lib/prompts/selectProjectTemplatePrompt.d.ts +26 -0
- package/lib/prompts/{createProjectPrompt.js → selectProjectTemplatePrompt.js} +6 -55
- package/lib/validation.d.ts +1 -1
- package/lib/validation.js +4 -4
- package/mcp-server/tools/project/CreateProjectTool.d.ts +2 -2
- package/package.json +3 -3
- package/types/LocalDev.d.ts +1 -0
- package/types/Yargs.d.ts +1 -1
- package/lib/prompts/createProjectPrompt.d.ts +0 -28
|
@@ -46,9 +46,6 @@ class LocalDevProcess {
|
|
|
46
46
|
get logger() {
|
|
47
47
|
return this._logger;
|
|
48
48
|
}
|
|
49
|
-
get configFilesUpdatedSinceLastUpload() {
|
|
50
|
-
return this.state.configFilesUpdatedSinceLastUpload;
|
|
51
|
-
}
|
|
52
49
|
async setupDevServers() {
|
|
53
50
|
try {
|
|
54
51
|
await this.devServerManager.setup();
|
|
@@ -105,17 +102,28 @@ class LocalDevProcess {
|
|
|
105
102
|
});
|
|
106
103
|
return true;
|
|
107
104
|
}
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
getIntermediateRepresentation(projectNodesAtLastUpload) {
|
|
106
|
+
return (0, project_parsing_lib_1.translateForLocalDev)({
|
|
110
107
|
projectSourceDir: path_1.default.join(this.state.projectDir, this.state.projectConfig.srcDir),
|
|
111
108
|
platformVersion: this.state.projectConfig.platformVersion,
|
|
112
109
|
accountId: this.state.targetProjectAccountId,
|
|
113
110
|
}, {
|
|
114
|
-
|
|
111
|
+
projectNodesAtLastUpload,
|
|
112
|
+
profile: this.state.profile,
|
|
115
113
|
});
|
|
114
|
+
}
|
|
115
|
+
async updateProjectNodes() {
|
|
116
|
+
const intermediateRepresentation = await this.getIntermediateRepresentation(this.state.projectNodesAtLastUpload);
|
|
116
117
|
this.state.projectNodes =
|
|
117
118
|
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
118
119
|
}
|
|
120
|
+
async updateProjectNodesAfterUpload() {
|
|
121
|
+
const intermediateRepresentation = await this.getIntermediateRepresentation();
|
|
122
|
+
this.state.projectNodes =
|
|
123
|
+
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
124
|
+
this.state.projectNodesAtLastUpload =
|
|
125
|
+
intermediateRepresentation.intermediateNodesIndexedByUid;
|
|
126
|
+
}
|
|
119
127
|
async handleFileChange(filePath, event) {
|
|
120
128
|
await this.updateProjectNodes();
|
|
121
129
|
try {
|
|
@@ -125,10 +133,7 @@ class LocalDevProcess {
|
|
|
125
133
|
this.logger.fileChangeError(e);
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
|
-
async handleConfigFileChange(
|
|
129
|
-
if (event === 'add' || event === 'change') {
|
|
130
|
-
this.state.addUpdatedConfigFileUpdatedSinceLastUpload(filePath);
|
|
131
|
-
}
|
|
136
|
+
async handleConfigFileChange() {
|
|
132
137
|
await this.updateProjectNodes();
|
|
133
138
|
this.logger.uploadWarning();
|
|
134
139
|
}
|
|
@@ -185,8 +190,7 @@ class LocalDevProcess {
|
|
|
185
190
|
this.logger.uploadError(uploadError);
|
|
186
191
|
return false;
|
|
187
192
|
}
|
|
188
|
-
this.
|
|
189
|
-
this.updateProjectNodes();
|
|
193
|
+
await this.updateProjectNodesAfterUpload();
|
|
190
194
|
this.logger.uploadSuccess();
|
|
191
195
|
this.logger.clearUploadWarnings();
|
|
192
196
|
return true;
|
|
@@ -6,6 +6,7 @@ import { LocalDevStateConstructorOptions, LocalDevStateListener, AppLocalDevData
|
|
|
6
6
|
declare class LocalDevState {
|
|
7
7
|
private _targetProjectAccountId;
|
|
8
8
|
private _targetTestingAccountId;
|
|
9
|
+
private _profile?;
|
|
9
10
|
private _projectConfig;
|
|
10
11
|
private _projectDir;
|
|
11
12
|
private _projectId;
|
|
@@ -14,15 +15,16 @@ declare class LocalDevState {
|
|
|
14
15
|
private _deployedBuild?;
|
|
15
16
|
private _isGithubLinked;
|
|
16
17
|
private _projectNodes;
|
|
18
|
+
private _projectNodesAtLastUpload;
|
|
17
19
|
private _env;
|
|
18
20
|
private _listeners;
|
|
19
|
-
private _configFilesUpdatedSinceLastUpload;
|
|
20
21
|
private _appData;
|
|
21
22
|
private _devServerMessage;
|
|
22
|
-
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }: LocalDevStateConstructorOptions);
|
|
23
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, profile, env, }: LocalDevStateConstructorOptions);
|
|
23
24
|
private runListeners;
|
|
24
25
|
get targetProjectAccountId(): number;
|
|
25
26
|
get targetTestingAccountId(): number;
|
|
27
|
+
get profile(): string | undefined;
|
|
26
28
|
get projectConfig(): ProjectConfig;
|
|
27
29
|
get projectDir(): string;
|
|
28
30
|
get projectId(): number;
|
|
@@ -36,10 +38,13 @@ declare class LocalDevState {
|
|
|
36
38
|
set projectNodes(nodes: {
|
|
37
39
|
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
38
40
|
});
|
|
41
|
+
get projectNodesAtLastUpload(): {
|
|
42
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
43
|
+
};
|
|
44
|
+
set projectNodesAtLastUpload(nodes: {
|
|
45
|
+
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
46
|
+
});
|
|
39
47
|
get env(): Environment;
|
|
40
|
-
get configFilesUpdatedSinceLastUpload(): Set<string>;
|
|
41
|
-
addUpdatedConfigFileUpdatedSinceLastUpload(filePath: string): void;
|
|
42
|
-
resetConfigFilesUpdatedSinceLastUpload(): void;
|
|
43
48
|
get appData(): Record<string, AppLocalDevData>;
|
|
44
49
|
getAppDataByUid(uid: string): AppLocalDevData | undefined;
|
|
45
50
|
setAppDataForUid(uid: string, appData: AppLocalDevData): void;
|
|
@@ -4,6 +4,7 @@ const constants_1 = require("../../constants");
|
|
|
4
4
|
class LocalDevState {
|
|
5
5
|
_targetProjectAccountId;
|
|
6
6
|
_targetTestingAccountId;
|
|
7
|
+
_profile;
|
|
7
8
|
_projectConfig;
|
|
8
9
|
_projectDir;
|
|
9
10
|
_projectId;
|
|
@@ -12,14 +13,15 @@ class LocalDevState {
|
|
|
12
13
|
_deployedBuild;
|
|
13
14
|
_isGithubLinked;
|
|
14
15
|
_projectNodes;
|
|
16
|
+
_projectNodesAtLastUpload;
|
|
15
17
|
_env;
|
|
16
18
|
_listeners;
|
|
17
|
-
_configFilesUpdatedSinceLastUpload;
|
|
18
19
|
_appData;
|
|
19
20
|
_devServerMessage;
|
|
20
|
-
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }) {
|
|
21
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, profile, env, }) {
|
|
21
22
|
this._targetProjectAccountId = targetProjectAccountId;
|
|
22
23
|
this._targetTestingAccountId = targetTestingAccountId;
|
|
24
|
+
this._profile = profile;
|
|
23
25
|
this._projectConfig = projectConfig;
|
|
24
26
|
this._projectDir = projectDir;
|
|
25
27
|
this._projectId = projectId;
|
|
@@ -28,8 +30,8 @@ class LocalDevState {
|
|
|
28
30
|
this._deployedBuild = deployedBuild;
|
|
29
31
|
this._isGithubLinked = isGithubLinked;
|
|
30
32
|
this._projectNodes = initialProjectNodes;
|
|
33
|
+
this._projectNodesAtLastUpload = initialProjectNodes;
|
|
31
34
|
this._env = env;
|
|
32
|
-
this._configFilesUpdatedSinceLastUpload = new Set();
|
|
33
35
|
this._appData = {};
|
|
34
36
|
this._devServerMessage = constants_1.LOCAL_DEV_SERVER_MESSAGE_TYPES.INITIAL;
|
|
35
37
|
this._listeners = {};
|
|
@@ -45,10 +47,11 @@ class LocalDevState {
|
|
|
45
47
|
get targetTestingAccountId() {
|
|
46
48
|
return this._targetTestingAccountId;
|
|
47
49
|
}
|
|
50
|
+
get profile() {
|
|
51
|
+
return this._profile;
|
|
52
|
+
}
|
|
48
53
|
get projectConfig() {
|
|
49
|
-
return
|
|
50
|
-
...this._projectConfig,
|
|
51
|
-
};
|
|
54
|
+
return structuredClone(this._projectConfig);
|
|
52
55
|
}
|
|
53
56
|
get projectDir() {
|
|
54
57
|
return this._projectDir;
|
|
@@ -63,34 +66,29 @@ class LocalDevState {
|
|
|
63
66
|
return this._debug;
|
|
64
67
|
}
|
|
65
68
|
get deployedBuild() {
|
|
66
|
-
return
|
|
67
|
-
...this._deployedBuild,
|
|
68
|
-
});
|
|
69
|
+
return this._deployedBuild && structuredClone(this._deployedBuild);
|
|
69
70
|
}
|
|
70
71
|
get isGithubLinked() {
|
|
71
72
|
return this._isGithubLinked;
|
|
72
73
|
}
|
|
73
74
|
get projectNodes() {
|
|
74
|
-
return
|
|
75
|
+
return structuredClone(this._projectNodes);
|
|
75
76
|
}
|
|
76
77
|
set projectNodes(nodes) {
|
|
77
78
|
this._projectNodes = nodes;
|
|
78
79
|
this.runListeners('projectNodes');
|
|
79
80
|
}
|
|
80
|
-
get
|
|
81
|
-
return this.
|
|
82
|
-
}
|
|
83
|
-
get configFilesUpdatedSinceLastUpload() {
|
|
84
|
-
return this._configFilesUpdatedSinceLastUpload;
|
|
81
|
+
get projectNodesAtLastUpload() {
|
|
82
|
+
return structuredClone(this._projectNodesAtLastUpload);
|
|
85
83
|
}
|
|
86
|
-
|
|
87
|
-
this.
|
|
84
|
+
set projectNodesAtLastUpload(nodes) {
|
|
85
|
+
this._projectNodesAtLastUpload = nodes;
|
|
88
86
|
}
|
|
89
|
-
|
|
90
|
-
this.
|
|
87
|
+
get env() {
|
|
88
|
+
return this._env;
|
|
91
89
|
}
|
|
92
90
|
get appData() {
|
|
93
|
-
return
|
|
91
|
+
return structuredClone(this._appData);
|
|
94
92
|
}
|
|
95
93
|
getAppDataByUid(uid) {
|
|
96
94
|
return { ...this._appData[uid] };
|
|
@@ -21,7 +21,7 @@ class LocalDevWatcher {
|
|
|
21
21
|
}
|
|
22
22
|
handleWatchEvent(filePath, event, configPaths) {
|
|
23
23
|
if (configPaths.includes(filePath)) {
|
|
24
|
-
return this.localDevProcess.handleConfigFileChange(
|
|
24
|
+
return this.localDevProcess.handleConfigFileChange();
|
|
25
25
|
}
|
|
26
26
|
return this.localDevProcess.handleFileChange(filePath, event);
|
|
27
27
|
}
|
|
@@ -29,7 +29,7 @@ async function personalAccessKeyPrompt({ env, account, }) {
|
|
|
29
29
|
if (account) {
|
|
30
30
|
url = `${websiteOrigin}/personal-access-key/${account}`;
|
|
31
31
|
}
|
|
32
|
-
const {
|
|
32
|
+
const { personalAccessKeyBrowserOpenPrep: choice } = await (0, promptUtils_1.promptUser)([
|
|
33
33
|
PERSONAL_ACCESS_KEY_BROWSER_OPEN_PREP,
|
|
34
34
|
]);
|
|
35
35
|
if (!choice) {
|
|
@@ -94,7 +94,7 @@ const CLIENT_SECRET = {
|
|
|
94
94
|
},
|
|
95
95
|
};
|
|
96
96
|
const PERSONAL_ACCESS_KEY_BROWSER_OPEN_PREP = {
|
|
97
|
-
name: '
|
|
97
|
+
name: 'personalAccessKeyBrowserOpenPrep',
|
|
98
98
|
type: 'list',
|
|
99
99
|
message: 'Choose your preferred method of authentication',
|
|
100
100
|
choices: Object.values(en_1.lib.prompts.personalAccessKeyPrompt.personalAccessKeyPromptChoices),
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PromptOptionsArg, ProjectNameAndDestPromptResponse } from './selectProjectTemplatePrompt';
|
|
2
|
+
export declare function projectNameAndDestPrompt(promptOptions: PromptOptionsArg): Promise<ProjectNameAndDestPromptResponse>;
|
|
3
|
+
export declare function validateProjectDirectory(input?: string): string | boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.projectNameAndDestPrompt = projectNameAndDestPrompt;
|
|
7
|
+
exports.validateProjectDirectory = validateProjectDirectory;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
11
|
+
const en_1 = require("../../lang/en");
|
|
12
|
+
const promptUtils_1 = require("./promptUtils");
|
|
13
|
+
const constants_1 = require("../constants");
|
|
14
|
+
async function projectNameAndDestPrompt(promptOptions) {
|
|
15
|
+
const result = await (0, promptUtils_1.promptUser)([
|
|
16
|
+
{
|
|
17
|
+
name: 'name',
|
|
18
|
+
message: en_1.lib.prompts.projectNameAndDestPrompt.enterName,
|
|
19
|
+
when: !promptOptions.name,
|
|
20
|
+
validate: (input) => {
|
|
21
|
+
if (!input) {
|
|
22
|
+
return en_1.lib.prompts.projectNameAndDestPrompt.errors.nameRequired;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'dest',
|
|
29
|
+
message: en_1.lib.prompts.projectNameAndDestPrompt.enterDest,
|
|
30
|
+
when: !promptOptions.dest,
|
|
31
|
+
default: answers => {
|
|
32
|
+
const projectName = (0, path_2.sanitizeFileName)(promptOptions.name || answers.name);
|
|
33
|
+
return path_1.default.resolve((0, path_2.getCwd)(), projectName);
|
|
34
|
+
},
|
|
35
|
+
validate: validateProjectDirectory,
|
|
36
|
+
filter: input => {
|
|
37
|
+
return (0, path_2.untildify)(input);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
]);
|
|
41
|
+
if (!result.name) {
|
|
42
|
+
result.name = promptOptions.name;
|
|
43
|
+
}
|
|
44
|
+
if (!result.dest) {
|
|
45
|
+
result.dest = promptOptions.dest;
|
|
46
|
+
}
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function validateProjectDirectory(input) {
|
|
50
|
+
if (!input) {
|
|
51
|
+
return en_1.lib.prompts.projectNameAndDestPrompt.errors.destRequired;
|
|
52
|
+
}
|
|
53
|
+
if (fs_1.default.existsSync(path_1.default.resolve((0, path_2.getCwd)(), path_1.default.join(input, constants_1.PROJECT_CONFIG_FILE)))) {
|
|
54
|
+
return en_1.lib.prompts.projectNameAndDestPrompt.errors.invalidDest;
|
|
55
|
+
}
|
|
56
|
+
if (!(0, path_2.isValidPath)(input)) {
|
|
57
|
+
return en_1.lib.prompts.projectNameAndDestPrompt.errors.invalidCharacters;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentTemplate, ComponentTemplateChoice, ProjectTemplate } from '../../types/Projects';
|
|
2
|
+
export type SelectProjectTemplatePromptResponse = {
|
|
3
|
+
projectTemplate?: ProjectTemplate;
|
|
4
|
+
componentTemplates?: ComponentTemplate[];
|
|
5
|
+
};
|
|
6
|
+
type SelectProjectTemplatePromptResponseProjectTemplate = {
|
|
7
|
+
projectTemplate: ProjectTemplate;
|
|
8
|
+
componentTemplates: undefined;
|
|
9
|
+
};
|
|
10
|
+
type SelectProjectTemplatePromptResponseComponentTemplates = {
|
|
11
|
+
projectTemplate?: undefined;
|
|
12
|
+
componentTemplates?: ComponentTemplate[];
|
|
13
|
+
};
|
|
14
|
+
export type ProjectNameAndDestPromptResponse = {
|
|
15
|
+
name: string;
|
|
16
|
+
dest: string;
|
|
17
|
+
};
|
|
18
|
+
export type PromptOptionsArg = {
|
|
19
|
+
name?: string;
|
|
20
|
+
dest?: string;
|
|
21
|
+
template?: string;
|
|
22
|
+
features?: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function selectProjectTemplatePrompt(promptOptions: PromptOptionsArg, projectTemplates?: ProjectTemplate[], componentTemplates?: undefined): Promise<SelectProjectTemplatePromptResponseProjectTemplate>;
|
|
25
|
+
export declare function selectProjectTemplatePrompt(promptOptions: PromptOptionsArg, projectTemplates?: undefined, componentTemplates?: ComponentTemplateChoice[]): Promise<SelectProjectTemplatePromptResponseComponentTemplates>;
|
|
26
|
+
export {};
|
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
3
|
+
exports.selectProjectTemplatePrompt = selectProjectTemplatePrompt;
|
|
10
4
|
const promptUtils_1 = require("./promptUtils");
|
|
11
|
-
const constants_1 = require("../constants");
|
|
12
5
|
const en_1 = require("../../lang/en");
|
|
13
|
-
function validateProjectDirectory(input) {
|
|
14
|
-
if (!input) {
|
|
15
|
-
return en_1.lib.prompts.createProjectPrompt.errors.destRequired;
|
|
16
|
-
}
|
|
17
|
-
if (fs_1.default.existsSync(path_1.default.resolve((0, path_2.getCwd)(), path_1.default.join(input, constants_1.PROJECT_CONFIG_FILE)))) {
|
|
18
|
-
return en_1.lib.prompts.createProjectPrompt.errors.invalidDest;
|
|
19
|
-
}
|
|
20
|
-
if (!(0, path_2.isValidPath)(input)) {
|
|
21
|
-
return en_1.lib.prompts.createProjectPrompt.errors.invalidCharacters;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
6
|
function findTemplateByNameOrLabel(projectTemplates, templateNameOrLabel) {
|
|
26
7
|
return projectTemplates.find(t => t.name === templateNameOrLabel || t.label === templateNameOrLabel);
|
|
27
8
|
}
|
|
28
|
-
async function
|
|
9
|
+
async function selectProjectTemplatePrompt(promptOptions, projectTemplates, componentTemplates) {
|
|
29
10
|
const createProjectFromTemplate = !!projectTemplates && projectTemplates.length > 0;
|
|
30
11
|
const createProjectFromComponents = Array.isArray(componentTemplates) && componentTemplates?.length > 0;
|
|
31
12
|
const selectedComponents = [];
|
|
@@ -46,36 +27,12 @@ async function createProjectPrompt(promptOptions, projectTemplates, componentTem
|
|
|
46
27
|
!!promptOptions.template &&
|
|
47
28
|
!!findTemplateByNameOrLabel(projectTemplates, promptOptions.template);
|
|
48
29
|
const result = await (0, promptUtils_1.promptUser)([
|
|
49
|
-
{
|
|
50
|
-
name: 'name',
|
|
51
|
-
message: en_1.lib.prompts.createProjectPrompt.enterName,
|
|
52
|
-
when: !promptOptions.name,
|
|
53
|
-
validate: (input) => {
|
|
54
|
-
if (!input) {
|
|
55
|
-
return en_1.lib.prompts.createProjectPrompt.errors.nameRequired;
|
|
56
|
-
}
|
|
57
|
-
return true;
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: 'dest',
|
|
62
|
-
message: en_1.lib.prompts.createProjectPrompt.enterDest,
|
|
63
|
-
when: !promptOptions.dest,
|
|
64
|
-
default: answers => {
|
|
65
|
-
const projectName = (0, path_2.sanitizeFileName)(promptOptions.name || answers.name);
|
|
66
|
-
return path_1.default.resolve((0, path_2.getCwd)(), projectName);
|
|
67
|
-
},
|
|
68
|
-
validate: validateProjectDirectory,
|
|
69
|
-
filter: input => {
|
|
70
|
-
return (0, path_2.untildify)(input);
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
30
|
{
|
|
74
31
|
name: 'projectTemplate',
|
|
75
32
|
message: () => {
|
|
76
33
|
return promptOptions.template && !providedTemplateIsValid
|
|
77
|
-
? en_1.lib.prompts.
|
|
78
|
-
: en_1.lib.prompts.
|
|
34
|
+
? en_1.lib.prompts.selectProjectTemplatePrompt.errors.invalidTemplate(promptOptions.template)
|
|
35
|
+
: en_1.lib.prompts.selectProjectTemplatePrompt.selectTemplate;
|
|
79
36
|
},
|
|
80
37
|
when: createProjectFromTemplate && !providedTemplateIsValid,
|
|
81
38
|
type: 'list',
|
|
@@ -90,7 +47,7 @@ async function createProjectPrompt(promptOptions, projectTemplates, componentTem
|
|
|
90
47
|
},
|
|
91
48
|
{
|
|
92
49
|
name: 'componentTemplates',
|
|
93
|
-
message: en_1.lib.prompts.
|
|
50
|
+
message: en_1.lib.prompts.selectProjectTemplatePrompt.features,
|
|
94
51
|
when: !promptOptions.features &&
|
|
95
52
|
createProjectFromComponents &&
|
|
96
53
|
selectedComponents.length === 0,
|
|
@@ -98,12 +55,6 @@ async function createProjectPrompt(promptOptions, projectTemplates, componentTem
|
|
|
98
55
|
choices: componentTemplates,
|
|
99
56
|
},
|
|
100
57
|
]);
|
|
101
|
-
if (!result.name) {
|
|
102
|
-
result.name = promptOptions.name;
|
|
103
|
-
}
|
|
104
|
-
if (!result.dest) {
|
|
105
|
-
result.dest = promptOptions.dest;
|
|
106
|
-
}
|
|
107
58
|
if (!result.componentTemplates) {
|
|
108
59
|
result.componentTemplates = selectedComponents;
|
|
109
60
|
}
|
|
@@ -112,7 +63,7 @@ async function createProjectPrompt(promptOptions, projectTemplates, componentTem
|
|
|
112
63
|
}
|
|
113
64
|
if (projectTemplates && projectTemplates.length > 0) {
|
|
114
65
|
if (!result.projectTemplate) {
|
|
115
|
-
throw new Error(en_1.lib.prompts.
|
|
66
|
+
throw new Error(en_1.lib.prompts.selectProjectTemplatePrompt.errors.projectTemplateRequired);
|
|
116
67
|
}
|
|
117
68
|
return result;
|
|
118
69
|
}
|
package/lib/validation.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare function validateAccount(options: Arguments<{
|
|
|
4
4
|
account?: string;
|
|
5
5
|
accountId?: string;
|
|
6
6
|
derivedAccountId?: number;
|
|
7
|
-
|
|
7
|
+
userProvidedAccount?: string;
|
|
8
8
|
}>): Promise<boolean>;
|
|
9
9
|
export declare function validateCmsPublishMode(options: Arguments<{
|
|
10
10
|
cmsPublishMode?: CmsPublishMode;
|
package/lib/validation.js
CHANGED
|
@@ -50,18 +50,18 @@ const path_1 = require("@hubspot/local-dev-lib/path");
|
|
|
50
50
|
const commonOpts_1 = require("./commonOpts");
|
|
51
51
|
const index_1 = require("./errorHandlers/index");
|
|
52
52
|
async function validateAccount(options) {
|
|
53
|
-
const { derivedAccountId,
|
|
53
|
+
const { derivedAccountId, userProvidedAccount } = options;
|
|
54
54
|
const accountId = (0, config_1.getAccountId)(derivedAccountId);
|
|
55
55
|
if (!accountId) {
|
|
56
|
-
if (
|
|
57
|
-
logger_1.logger.error(`The account "${
|
|
56
|
+
if (userProvidedAccount) {
|
|
57
|
+
logger_1.logger.error(`The account "${userProvidedAccount}" could not be found in the config`);
|
|
58
58
|
}
|
|
59
59
|
else {
|
|
60
60
|
logger_1.logger.error('An account needs to be supplied either via "--account" or through setting a "defaultPortal"');
|
|
61
61
|
}
|
|
62
62
|
return false;
|
|
63
63
|
}
|
|
64
|
-
if (
|
|
64
|
+
if (userProvidedAccount && (0, config_1.loadConfigFromEnvironment)()) {
|
|
65
65
|
throw new Error('Cannot specify an account when environment variables are supplied. Please unset the environment variables or do not use the "--account" flag.');
|
|
66
66
|
}
|
|
67
67
|
const accountConfig = (0, config_1.getAccountConfig)(accountId);
|
|
@@ -14,17 +14,17 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
14
14
|
absoluteCurrentWorkingDirectory: string;
|
|
15
15
|
destination: string;
|
|
16
16
|
auth?: "oauth" | "static" | undefined;
|
|
17
|
-
name?: string | undefined;
|
|
18
17
|
distribution?: "marketplace" | "private" | undefined;
|
|
19
18
|
features?: ("card" | "settings" | "app-function" | "webhooks")[] | undefined;
|
|
19
|
+
name?: string | undefined;
|
|
20
20
|
}, {
|
|
21
21
|
projectBase: "app" | "empty";
|
|
22
22
|
absoluteCurrentWorkingDirectory: string;
|
|
23
23
|
destination: string;
|
|
24
24
|
auth?: "oauth" | "static" | undefined;
|
|
25
|
-
name?: string | undefined;
|
|
26
25
|
distribution?: "marketplace" | "private" | undefined;
|
|
27
26
|
features?: ("card" | "settings" | "app-function" | "webhooks")[] | undefined;
|
|
27
|
+
name?: string | undefined;
|
|
28
28
|
}>;
|
|
29
29
|
export type CreateProjectInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
30
30
|
export declare class CreateProjectTool extends Tool<CreateProjectInputSchema> {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.7.16-experimental.
|
|
3
|
+
"version": "7.7.16-experimental.4",
|
|
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
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "3.
|
|
9
|
-
"@hubspot/project-parsing-lib": "0.
|
|
8
|
+
"@hubspot/local-dev-lib": "3.11.0",
|
|
9
|
+
"@hubspot/project-parsing-lib": "0.5.0",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.6",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
12
12
|
"@hubspot/ui-extensions-dev-server": "0.9.2",
|
package/types/LocalDev.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { APP_INSTALLATION_STATES, LOCAL_DEV_SERVER_MESSAGE_TYPES } from '../lib/
|
|
|
8
8
|
export type LocalDevStateConstructorOptions = {
|
|
9
9
|
targetProjectAccountId: number;
|
|
10
10
|
targetTestingAccountId: number;
|
|
11
|
+
profile?: string;
|
|
11
12
|
projectConfig: ProjectConfig;
|
|
12
13
|
projectDir: string;
|
|
13
14
|
projectId: number;
|
package/types/Yargs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Options, CommandModule, Argv } from 'yargs';
|
|
|
2
2
|
import { CmsPublishMode } from '@hubspot/local-dev-lib/types/Files';
|
|
3
3
|
export type CommonArgs = {
|
|
4
4
|
derivedAccountId: number;
|
|
5
|
-
|
|
5
|
+
userProvidedAccount?: string;
|
|
6
6
|
d: boolean;
|
|
7
7
|
debug: boolean;
|
|
8
8
|
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ComponentTemplate, ComponentTemplateChoice, ProjectTemplate } from '../../types/Projects';
|
|
2
|
-
export type CreateProjectPromptResponse = {
|
|
3
|
-
name: string;
|
|
4
|
-
dest: string;
|
|
5
|
-
projectTemplate?: ProjectTemplate;
|
|
6
|
-
componentTemplates?: ComponentTemplate[];
|
|
7
|
-
};
|
|
8
|
-
type CreateProjectPromptResponseProjectTemplate = {
|
|
9
|
-
name: string;
|
|
10
|
-
dest: string;
|
|
11
|
-
projectTemplate: ProjectTemplate;
|
|
12
|
-
componentTemplates: undefined;
|
|
13
|
-
};
|
|
14
|
-
type CreateProjectPromptResponseComponentTemplates = {
|
|
15
|
-
name: string;
|
|
16
|
-
dest: string;
|
|
17
|
-
projectTemplate?: undefined;
|
|
18
|
-
componentTemplates?: ComponentTemplate[];
|
|
19
|
-
};
|
|
20
|
-
type PromptOptionsArg = {
|
|
21
|
-
name?: string;
|
|
22
|
-
dest?: string;
|
|
23
|
-
template?: string;
|
|
24
|
-
features?: string[];
|
|
25
|
-
};
|
|
26
|
-
export declare function createProjectPrompt(promptOptions: PromptOptionsArg, projectTemplates?: ProjectTemplate[], componentTemplates?: undefined): Promise<CreateProjectPromptResponseProjectTemplate>;
|
|
27
|
-
export declare function createProjectPrompt(promptOptions: PromptOptionsArg, projectTemplates?: undefined, componentTemplates?: ComponentTemplateChoice[]): Promise<CreateProjectPromptResponseComponentTemplates>;
|
|
28
|
-
export {};
|