@hubspot/cli 7.5.1-beta.0 → 7.5.2-beta.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/commands/project/add.d.ts +5 -2
- package/commands/project/add.js +43 -80
- package/commands/project/create.d.ts +2 -8
- package/commands/project/create.js +84 -55
- package/commands/project/dev/unifiedFlow.js +1 -0
- package/lang/en.d.ts +49 -3
- package/lang/en.js +51 -5
- package/lang/en.lyaml +1 -1
- package/lib/constants.d.ts +12 -0
- package/lib/constants.js +13 -1
- package/lib/projects/add/legacyAddComponent.d.ts +5 -0
- package/lib/projects/add/legacyAddComponent.js +48 -0
- package/lib/projects/add/v3AddComponent.d.ts +8 -0
- package/lib/projects/add/v3AddComponent.js +85 -0
- package/lib/projects/components.d.ts +2 -0
- package/lib/projects/components.js +82 -0
- package/lib/projects/create/index.d.ts +23 -0
- package/lib/projects/create/index.js +33 -0
- package/lib/projects/create/legacy.d.ts +6 -0
- package/lib/projects/{create.js → create/legacy.js} +20 -11
- package/lib/projects/create/v3.d.ts +27 -0
- package/lib/projects/create/v3.js +158 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +2 -2
- package/lib/projects/localDev/AppDevModeInterface.js +30 -2
- package/lib/projects/localDev/LocalDevProcess.d.ts +4 -0
- package/lib/projects/localDev/LocalDevProcess.js +12 -0
- package/lib/projects/localDev/LocalDevState.d.ts +8 -2
- package/lib/projects/localDev/LocalDevState.js +18 -1
- package/lib/projects/localDev/LocalDevWebsocketServer.d.ts +1 -0
- package/lib/projects/localDev/LocalDevWebsocketServer.js +18 -0
- package/lib/prompts/createProjectPrompt.d.ts +14 -5
- package/lib/prompts/createProjectPrompt.js +36 -13
- package/lib/prompts/projectAddPrompt.d.ts +5 -1
- package/lib/prompts/projectAddPrompt.js +35 -7
- package/package.json +4 -3
- package/types/LocalDev.d.ts +9 -0
- package/types/Projects.d.ts +19 -2
- package/lib/projects/create.d.ts +0 -5
|
@@ -8,6 +8,10 @@ declare class LocalDevProcess {
|
|
|
8
8
|
private devServerManager;
|
|
9
9
|
constructor(options: LocalDevStateConstructorOptions);
|
|
10
10
|
get projectDir(): string;
|
|
11
|
+
get projectId(): number;
|
|
12
|
+
get projectName(): string;
|
|
13
|
+
get targetProjectAccountId(): number;
|
|
14
|
+
get targetTestingAccountId(): number;
|
|
11
15
|
get projectNodes(): {
|
|
12
16
|
[key: string]: IntermediateRepresentationNodeLocalDev;
|
|
13
17
|
};
|
|
@@ -28,6 +28,18 @@ class LocalDevProcess {
|
|
|
28
28
|
get projectDir() {
|
|
29
29
|
return this.state.projectDir;
|
|
30
30
|
}
|
|
31
|
+
get projectId() {
|
|
32
|
+
return this.state.projectId;
|
|
33
|
+
}
|
|
34
|
+
get projectName() {
|
|
35
|
+
return this.state.projectName;
|
|
36
|
+
}
|
|
37
|
+
get targetProjectAccountId() {
|
|
38
|
+
return this.state.targetProjectAccountId;
|
|
39
|
+
}
|
|
40
|
+
get targetTestingAccountId() {
|
|
41
|
+
return this.state.targetTestingAccountId;
|
|
42
|
+
}
|
|
31
43
|
get projectNodes() {
|
|
32
44
|
return this.state.projectNodes;
|
|
33
45
|
}
|
|
@@ -2,13 +2,14 @@ import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
|
2
2
|
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
3
3
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
4
|
import { ProjectConfig } from '../../../types/Projects';
|
|
5
|
-
import { LocalDevStateConstructorOptions, LocalDevStateListener } from '../../../types/LocalDev';
|
|
5
|
+
import { LocalDevStateConstructorOptions, LocalDevStateListener, AppLocalDevData } from '../../../types/LocalDev';
|
|
6
6
|
declare class LocalDevState {
|
|
7
7
|
private _targetProjectAccountId;
|
|
8
8
|
private _targetTestingAccountId;
|
|
9
9
|
private _projectConfig;
|
|
10
10
|
private _projectDir;
|
|
11
11
|
private _projectId;
|
|
12
|
+
private _projectName;
|
|
12
13
|
private _debug;
|
|
13
14
|
private _deployedBuild?;
|
|
14
15
|
private _isGithubLinked;
|
|
@@ -16,13 +17,15 @@ declare class LocalDevState {
|
|
|
16
17
|
private _env;
|
|
17
18
|
private _listeners;
|
|
18
19
|
private _configFilesUpdatedSinceLastUpload;
|
|
19
|
-
|
|
20
|
+
private _appData;
|
|
21
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }: LocalDevStateConstructorOptions);
|
|
20
22
|
private runListeners;
|
|
21
23
|
get targetProjectAccountId(): number;
|
|
22
24
|
get targetTestingAccountId(): number;
|
|
23
25
|
get projectConfig(): ProjectConfig;
|
|
24
26
|
get projectDir(): string;
|
|
25
27
|
get projectId(): number;
|
|
28
|
+
get projectName(): string;
|
|
26
29
|
get debug(): boolean;
|
|
27
30
|
get deployedBuild(): Build | undefined;
|
|
28
31
|
get isGithubLinked(): boolean;
|
|
@@ -36,6 +39,9 @@ declare class LocalDevState {
|
|
|
36
39
|
get configFilesUpdatedSinceLastUpload(): Set<string>;
|
|
37
40
|
addUpdatedConfigFileUpdatedSinceLastUpload(filePath: string): void;
|
|
38
41
|
resetConfigFilesUpdatedSinceLastUpload(): void;
|
|
42
|
+
get appData(): Record<string, AppLocalDevData>;
|
|
43
|
+
getAppDataByUid(uid: string): AppLocalDevData | undefined;
|
|
44
|
+
setAppDataForUid(uid: string, appData: AppLocalDevData): void;
|
|
39
45
|
addListener<K extends keyof LocalDevState>(key: K, listener: LocalDevStateListener<K>, callOnInit?: boolean): void;
|
|
40
46
|
}
|
|
41
47
|
export default LocalDevState;
|
|
@@ -6,6 +6,7 @@ class LocalDevState {
|
|
|
6
6
|
_projectConfig;
|
|
7
7
|
_projectDir;
|
|
8
8
|
_projectId;
|
|
9
|
+
_projectName;
|
|
9
10
|
_debug;
|
|
10
11
|
_deployedBuild;
|
|
11
12
|
_isGithubLinked;
|
|
@@ -13,18 +14,21 @@ class LocalDevState {
|
|
|
13
14
|
_env;
|
|
14
15
|
_listeners;
|
|
15
16
|
_configFilesUpdatedSinceLastUpload;
|
|
16
|
-
|
|
17
|
+
_appData;
|
|
18
|
+
constructor({ targetProjectAccountId, targetTestingAccountId, projectConfig, projectDir, projectId, projectName, debug, deployedBuild, isGithubLinked, initialProjectNodes, env, }) {
|
|
17
19
|
this._targetProjectAccountId = targetProjectAccountId;
|
|
18
20
|
this._targetTestingAccountId = targetTestingAccountId;
|
|
19
21
|
this._projectConfig = projectConfig;
|
|
20
22
|
this._projectDir = projectDir;
|
|
21
23
|
this._projectId = projectId;
|
|
24
|
+
this._projectName = projectName;
|
|
22
25
|
this._debug = debug || false;
|
|
23
26
|
this._deployedBuild = deployedBuild;
|
|
24
27
|
this._isGithubLinked = isGithubLinked;
|
|
25
28
|
this._projectNodes = initialProjectNodes;
|
|
26
29
|
this._env = env;
|
|
27
30
|
this._configFilesUpdatedSinceLastUpload = new Set();
|
|
31
|
+
this._appData = {};
|
|
28
32
|
this._listeners = {};
|
|
29
33
|
}
|
|
30
34
|
runListeners(key) {
|
|
@@ -49,6 +53,9 @@ class LocalDevState {
|
|
|
49
53
|
get projectId() {
|
|
50
54
|
return this._projectId;
|
|
51
55
|
}
|
|
56
|
+
get projectName() {
|
|
57
|
+
return this._projectName;
|
|
58
|
+
}
|
|
52
59
|
get debug() {
|
|
53
60
|
return this._debug;
|
|
54
61
|
}
|
|
@@ -79,6 +86,16 @@ class LocalDevState {
|
|
|
79
86
|
resetConfigFilesUpdatedSinceLastUpload() {
|
|
80
87
|
this._configFilesUpdatedSinceLastUpload.clear();
|
|
81
88
|
}
|
|
89
|
+
get appData() {
|
|
90
|
+
return { ...this._appData };
|
|
91
|
+
}
|
|
92
|
+
getAppDataByUid(uid) {
|
|
93
|
+
return { ...this._appData[uid] };
|
|
94
|
+
}
|
|
95
|
+
setAppDataForUid(uid, appData) {
|
|
96
|
+
this._appData[uid] = appData;
|
|
97
|
+
this.runListeners('appData');
|
|
98
|
+
}
|
|
82
99
|
addListener(key, listener, callOnInit = false) {
|
|
83
100
|
if (!this._listeners[key]) {
|
|
84
101
|
this._listeners[key] = [];
|
|
@@ -75,6 +75,17 @@ class LocalDevWebsocketServer {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
+
sendProjectData() {
|
|
79
|
+
this.sendMessage({
|
|
80
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPDATE_PROJECT_DATA,
|
|
81
|
+
data: {
|
|
82
|
+
projectName: this.localDevProcess.projectName,
|
|
83
|
+
projectId: this.localDevProcess.projectId,
|
|
84
|
+
targetProjectAccountId: this.localDevProcess.targetProjectAccountId,
|
|
85
|
+
targetTestingAccountId: this.localDevProcess.targetTestingAccountId,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
78
89
|
setupStateListeners() {
|
|
79
90
|
this.localDevProcess.addStateListener('projectNodes', nodes => {
|
|
80
91
|
this.sendMessage({
|
|
@@ -82,6 +93,12 @@ class LocalDevWebsocketServer {
|
|
|
82
93
|
data: nodes,
|
|
83
94
|
});
|
|
84
95
|
}, true);
|
|
96
|
+
this.localDevProcess.addStateListener('appData', appData => {
|
|
97
|
+
this.sendMessage({
|
|
98
|
+
type: constants_1.LOCAL_DEV_UI_MESSAGE_SEND_TYPES.UPDATE_APP_DATA,
|
|
99
|
+
data: appData,
|
|
100
|
+
});
|
|
101
|
+
}, true);
|
|
85
102
|
}
|
|
86
103
|
async start() {
|
|
87
104
|
const portManagerIsRunning = await (0, portManager_1.isPortManagerServerRunning)();
|
|
@@ -99,6 +116,7 @@ class LocalDevWebsocketServer {
|
|
|
99
116
|
return;
|
|
100
117
|
}
|
|
101
118
|
this._websocket = ws;
|
|
119
|
+
this.sendProjectData();
|
|
102
120
|
this.setupMessageHandlers();
|
|
103
121
|
this.setupStateListeners();
|
|
104
122
|
});
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
-
import { ProjectTemplate } from '../../types/Projects';
|
|
2
|
-
type
|
|
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 = {
|
|
3
9
|
name: string;
|
|
4
10
|
dest: string;
|
|
5
11
|
projectTemplate: ProjectTemplate;
|
|
12
|
+
componentTemplates: undefined;
|
|
6
13
|
};
|
|
7
|
-
type
|
|
14
|
+
type CreateProjectPromptResponseComponentTemplates = {
|
|
8
15
|
name: string;
|
|
9
16
|
dest: string;
|
|
10
17
|
projectTemplate?: undefined;
|
|
18
|
+
componentTemplates?: ComponentTemplate[];
|
|
11
19
|
};
|
|
12
20
|
type PromptOptionsArg = {
|
|
13
21
|
name?: string;
|
|
14
22
|
dest?: string;
|
|
15
23
|
template?: string;
|
|
24
|
+
features?: string[];
|
|
16
25
|
};
|
|
17
|
-
export declare function createProjectPrompt(promptOptions: PromptOptionsArg, projectTemplates
|
|
18
|
-
export declare function createProjectPrompt(promptOptions: PromptOptionsArg, projectTemplates?: undefined): Promise<
|
|
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>;
|
|
19
28
|
export {};
|
|
@@ -8,43 +8,58 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const path_2 = require("@hubspot/local-dev-lib/path");
|
|
10
10
|
const promptUtils_1 = require("./promptUtils");
|
|
11
|
-
const lang_1 = require("../lang");
|
|
12
11
|
const constants_1 = require("../constants");
|
|
12
|
+
const en_1 = require("../../lang/en");
|
|
13
13
|
function validateProjectDirectory(input) {
|
|
14
14
|
if (!input) {
|
|
15
|
-
return
|
|
15
|
+
return en_1.lib.prompts.createProjectPrompt.errors.destRequired;
|
|
16
16
|
}
|
|
17
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
|
|
18
|
+
return en_1.lib.prompts.createProjectPrompt.errors.invalidDest;
|
|
19
19
|
}
|
|
20
20
|
if (!(0, path_2.isValidPath)(input)) {
|
|
21
|
-
return
|
|
21
|
+
return en_1.lib.prompts.createProjectPrompt.errors.invalidCharacters;
|
|
22
22
|
}
|
|
23
23
|
return true;
|
|
24
24
|
}
|
|
25
25
|
function findTemplateByNameOrLabel(projectTemplates, templateNameOrLabel) {
|
|
26
26
|
return projectTemplates.find(t => t.name === templateNameOrLabel || t.label === templateNameOrLabel);
|
|
27
27
|
}
|
|
28
|
-
async function createProjectPrompt(promptOptions, projectTemplates) {
|
|
28
|
+
async function createProjectPrompt(promptOptions, projectTemplates, componentTemplates) {
|
|
29
29
|
const createProjectFromTemplate = !!projectTemplates && projectTemplates.length > 0;
|
|
30
|
+
const createProjectFromComponents = Array.isArray(componentTemplates) && componentTemplates?.length > 0;
|
|
31
|
+
const selectedComponents = [];
|
|
32
|
+
if (createProjectFromComponents && promptOptions.features) {
|
|
33
|
+
componentTemplates.forEach(template => {
|
|
34
|
+
if (!template.value) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (promptOptions.features?.includes(template.value.type)) {
|
|
38
|
+
if (template.disabled) {
|
|
39
|
+
throw new Error(`Cannot create project with template '${template.value.type}'. Reasons: ${template.disabled}`);
|
|
40
|
+
}
|
|
41
|
+
selectedComponents.push(template.value);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
30
45
|
const providedTemplateIsValid = createProjectFromTemplate &&
|
|
31
46
|
!!promptOptions.template &&
|
|
32
47
|
!!findTemplateByNameOrLabel(projectTemplates, promptOptions.template);
|
|
33
48
|
const result = await (0, promptUtils_1.promptUser)([
|
|
34
49
|
{
|
|
35
50
|
name: 'name',
|
|
36
|
-
message:
|
|
51
|
+
message: en_1.lib.prompts.createProjectPrompt.enterName,
|
|
37
52
|
when: !promptOptions.name,
|
|
38
53
|
validate: (input) => {
|
|
39
54
|
if (!input) {
|
|
40
|
-
return
|
|
55
|
+
return en_1.lib.prompts.createProjectPrompt.errors.nameRequired;
|
|
41
56
|
}
|
|
42
57
|
return true;
|
|
43
58
|
},
|
|
44
59
|
},
|
|
45
60
|
{
|
|
46
61
|
name: 'dest',
|
|
47
|
-
message:
|
|
62
|
+
message: en_1.lib.prompts.createProjectPrompt.enterDest,
|
|
48
63
|
when: !promptOptions.dest,
|
|
49
64
|
default: answers => {
|
|
50
65
|
const projectName = (0, path_2.sanitizeFileName)(promptOptions.name || answers.name);
|
|
@@ -59,10 +74,8 @@ async function createProjectPrompt(promptOptions, projectTemplates) {
|
|
|
59
74
|
name: 'projectTemplate',
|
|
60
75
|
message: () => {
|
|
61
76
|
return promptOptions.template && !providedTemplateIsValid
|
|
62
|
-
?
|
|
63
|
-
|
|
64
|
-
})
|
|
65
|
-
: (0, lang_1.i18n)(`lib.prompts.createProjectPrompt.selectTemplate`);
|
|
77
|
+
? en_1.lib.prompts.createProjectPrompt.errors.invalidTemplate(promptOptions.template)
|
|
78
|
+
: en_1.lib.prompts.createProjectPrompt.selectTemplate;
|
|
66
79
|
},
|
|
67
80
|
when: createProjectFromTemplate && !providedTemplateIsValid,
|
|
68
81
|
type: 'list',
|
|
@@ -75,6 +88,13 @@ async function createProjectPrompt(promptOptions, projectTemplates) {
|
|
|
75
88
|
})
|
|
76
89
|
: undefined,
|
|
77
90
|
},
|
|
91
|
+
{
|
|
92
|
+
name: 'componentTemplates',
|
|
93
|
+
message: '[--features] Which features would you like your app to include?',
|
|
94
|
+
when: createProjectFromComponents && selectedComponents.length === 0,
|
|
95
|
+
type: 'checkbox',
|
|
96
|
+
choices: componentTemplates,
|
|
97
|
+
},
|
|
78
98
|
]);
|
|
79
99
|
if (!result.name) {
|
|
80
100
|
result.name = promptOptions.name;
|
|
@@ -82,12 +102,15 @@ async function createProjectPrompt(promptOptions, projectTemplates) {
|
|
|
82
102
|
if (!result.dest) {
|
|
83
103
|
result.dest = promptOptions.dest;
|
|
84
104
|
}
|
|
105
|
+
if (!result.componentTemplates) {
|
|
106
|
+
result.componentTemplates = selectedComponents;
|
|
107
|
+
}
|
|
85
108
|
if (providedTemplateIsValid) {
|
|
86
109
|
result.projectTemplate = findTemplateByNameOrLabel(projectTemplates, promptOptions.template);
|
|
87
110
|
}
|
|
88
111
|
if (projectTemplates && projectTemplates.length > 0) {
|
|
89
112
|
if (!result.projectTemplate) {
|
|
90
|
-
throw new Error(
|
|
113
|
+
throw new Error(en_1.lib.prompts.createProjectPrompt.errors.projectTemplateRequired);
|
|
91
114
|
}
|
|
92
115
|
return result;
|
|
93
116
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { ComponentTemplate } from '../../types/Projects';
|
|
1
|
+
import { ComponentTemplate, ComponentTemplateChoice } from '../../types/Projects';
|
|
2
2
|
type ProjectAddPromptResponse = {
|
|
3
3
|
componentTemplate: ComponentTemplate;
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
|
6
|
+
type ProjectAddPromptResponseV3 = {
|
|
7
|
+
componentTemplate: ComponentTemplate[];
|
|
8
|
+
};
|
|
6
9
|
export declare function projectAddPrompt(components: ComponentTemplate[], promptOptions?: {
|
|
7
10
|
name?: string;
|
|
8
11
|
type?: string;
|
|
9
12
|
}): Promise<ProjectAddPromptResponse>;
|
|
13
|
+
export declare function projectAddPromptV3(components: ComponentTemplateChoice[], selectedFeatures: string[] | undefined): Promise<ProjectAddPromptResponseV3>;
|
|
10
14
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.projectAddPrompt = projectAddPrompt;
|
|
4
|
+
exports.projectAddPromptV3 = projectAddPromptV3;
|
|
4
5
|
const promptUtils_1 = require("./promptUtils");
|
|
5
|
-
const
|
|
6
|
+
const en_1 = require("../../lang/en");
|
|
6
7
|
function findComponentByPathOrLabel(components, componentPathOrLabel) {
|
|
7
8
|
return components.find(c => c.path === componentPathOrLabel || c.label === componentPathOrLabel);
|
|
8
9
|
}
|
|
@@ -14,10 +15,8 @@ async function projectAddPrompt(components, promptOptions = {}) {
|
|
|
14
15
|
name: 'componentTemplate',
|
|
15
16
|
message: () => {
|
|
16
17
|
return promptOptions.type && !providedTypeIsValid
|
|
17
|
-
?
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
: (0, lang_1.i18n)(`lib.prompts.projectAddPrompt.selectType`);
|
|
18
|
+
? en_1.lib.prompts.projectAddPrompt.errors.invalidType(promptOptions.type)
|
|
19
|
+
: en_1.lib.prompts.projectAddPrompt.selectType;
|
|
21
20
|
},
|
|
22
21
|
when: !providedTypeIsValid,
|
|
23
22
|
type: 'list',
|
|
@@ -30,11 +29,11 @@ async function projectAddPrompt(components, promptOptions = {}) {
|
|
|
30
29
|
},
|
|
31
30
|
{
|
|
32
31
|
name: 'name',
|
|
33
|
-
message:
|
|
32
|
+
message: en_1.lib.prompts.projectAddPrompt.enterName,
|
|
34
33
|
when: !promptOptions.name,
|
|
35
34
|
validate: (input) => {
|
|
36
35
|
if (!input) {
|
|
37
|
-
return
|
|
36
|
+
return en_1.lib.prompts.projectAddPrompt.errors.nameRequired;
|
|
38
37
|
}
|
|
39
38
|
return true;
|
|
40
39
|
},
|
|
@@ -48,3 +47,32 @@ async function projectAddPrompt(components, promptOptions = {}) {
|
|
|
48
47
|
}
|
|
49
48
|
return result;
|
|
50
49
|
}
|
|
50
|
+
async function projectAddPromptV3(components, selectedFeatures) {
|
|
51
|
+
const selectedComponents = [];
|
|
52
|
+
if (selectedFeatures) {
|
|
53
|
+
components.forEach(template => {
|
|
54
|
+
if (!template.value) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (selectedFeatures?.includes(template.value.type)) {
|
|
58
|
+
if (template.disabled) {
|
|
59
|
+
throw new Error(en_1.lib.prompts.projectAddPrompt.errors.cannotAddFeature(template.value.type, template.disabled));
|
|
60
|
+
}
|
|
61
|
+
selectedComponents.push(template.value);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const result = await (0, promptUtils_1.promptUser)([
|
|
66
|
+
{
|
|
67
|
+
name: 'componentTemplate',
|
|
68
|
+
message: en_1.lib.prompts.projectAddPrompt.selectType,
|
|
69
|
+
when: selectedComponents.length === 0,
|
|
70
|
+
type: 'checkbox',
|
|
71
|
+
choices: components,
|
|
72
|
+
},
|
|
73
|
+
]);
|
|
74
|
+
if (!result.componentTemplate) {
|
|
75
|
+
result.componentTemplate = selectedComponents;
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "7.5.
|
|
3
|
+
"version": "7.5.2-beta.0",
|
|
4
4
|
"description": "The official CLI for developing on HubSpot",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/HubSpot/hubspot-cli",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@hubspot/local-dev-lib": "3.7.
|
|
8
|
+
"@hubspot/local-dev-lib": "3.7.1",
|
|
9
9
|
"@hubspot/project-parsing-lib": "0.3.0",
|
|
10
10
|
"@hubspot/serverless-dev-runtime": "7.0.2",
|
|
11
11
|
"@hubspot/theme-preview-dev-server": "0.0.10",
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
"release": "yarn ts-node ./scripts/release.ts release",
|
|
81
81
|
"hs": "yarn build && node ./dist/bin/hs",
|
|
82
82
|
"hs-debug": "yarn build && NODE_DEBUG=http* node --inspect-brk ./dist/bin/hs",
|
|
83
|
-
"update-ldl": "yarn add --exact @hubspot/local-dev-lib@latest"
|
|
83
|
+
"update-ldl": "yarn add --exact @hubspot/local-dev-lib@latest",
|
|
84
|
+
"view-unreleased-changes": "node ./scripts/unreleasedChanges.js"
|
|
84
85
|
},
|
|
85
86
|
"lint-staged": {
|
|
86
87
|
"**/*.{js,ts,scss,css}": [
|
package/types/LocalDev.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { IntermediateRepresentationNodeLocalDev } from '@hubspot/project-parsing-lib/src/lib/types';
|
|
2
2
|
import { Build } from '@hubspot/local-dev-lib/types/Build';
|
|
3
3
|
import { Environment } from '@hubspot/local-dev-lib/types/Config';
|
|
4
|
+
import { ValueOf } from '@hubspot/local-dev-lib/types/Utils';
|
|
4
5
|
import { ProjectConfig } from './Projects';
|
|
5
6
|
import LocalDevState from '../lib/projects/localDev/LocalDevState';
|
|
7
|
+
import { APP_INSTALLATION_STATES } from '../lib/constants';
|
|
6
8
|
export type LocalDevStateConstructorOptions = {
|
|
7
9
|
targetProjectAccountId: number;
|
|
8
10
|
targetTestingAccountId: number;
|
|
9
11
|
projectConfig: ProjectConfig;
|
|
10
12
|
projectDir: string;
|
|
11
13
|
projectId: number;
|
|
14
|
+
projectName: string;
|
|
12
15
|
debug?: boolean;
|
|
13
16
|
deployedBuild?: Build;
|
|
14
17
|
isGithubLinked: boolean;
|
|
@@ -22,3 +25,9 @@ export type LocalDevWebsocketMessage = {
|
|
|
22
25
|
data?: unknown;
|
|
23
26
|
};
|
|
24
27
|
export type LocalDevStateListener<K extends keyof LocalDevState> = (value: LocalDevState[K]) => void;
|
|
28
|
+
export type AppLocalDevData = {
|
|
29
|
+
id: number;
|
|
30
|
+
clientId: string;
|
|
31
|
+
name: string;
|
|
32
|
+
installationState: ValueOf<typeof APP_INSTALLATION_STATES>;
|
|
33
|
+
};
|
package/types/Projects.d.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { Build, SubbuildStatus } from '@hubspot/local-dev-lib/types/Build';
|
|
2
2
|
import { Deploy, SubdeployStatus } from '@hubspot/local-dev-lib/types/Deploy';
|
|
3
|
+
import { appComponent, marketplaceDistribution, oAuth, privateDistribution, staticAuth } from '../lib/constants';
|
|
3
4
|
export type ProjectTemplate = {
|
|
4
5
|
name: string;
|
|
5
6
|
label: string;
|
|
6
7
|
path: string;
|
|
7
|
-
insertPath: string;
|
|
8
8
|
};
|
|
9
9
|
export type ComponentTemplate = {
|
|
10
10
|
path: string;
|
|
11
11
|
label: string;
|
|
12
|
-
|
|
12
|
+
type: string;
|
|
13
|
+
parentComponent?: string;
|
|
14
|
+
supportedAuthTypes?: string[];
|
|
15
|
+
supportedDistributions?: string[];
|
|
16
|
+
};
|
|
17
|
+
export type ComponentTemplateChoice = {
|
|
18
|
+
name: string;
|
|
19
|
+
value: ComponentTemplate;
|
|
20
|
+
disabled?: string | boolean;
|
|
13
21
|
};
|
|
14
22
|
export type ProjectConfig = {
|
|
15
23
|
name: string;
|
|
@@ -32,9 +40,18 @@ export type ProjectPollStatusFunctionText = {
|
|
|
32
40
|
TYPE_KEY: string;
|
|
33
41
|
SUBTASK_NAME_KEY: string;
|
|
34
42
|
};
|
|
43
|
+
export type ParentComponent = {
|
|
44
|
+
label: string;
|
|
45
|
+
type: typeof appComponent;
|
|
46
|
+
authType: typeof staticAuth | typeof oAuth;
|
|
47
|
+
distribution: typeof privateDistribution | typeof marketplaceDistribution;
|
|
48
|
+
path: string;
|
|
49
|
+
};
|
|
35
50
|
export type ProjectTemplateRepoConfig = {
|
|
36
51
|
projects?: ProjectTemplate[];
|
|
37
52
|
components?: ComponentTemplate[];
|
|
53
|
+
defaultFiles?: string;
|
|
54
|
+
parentComponents?: ParentComponent[];
|
|
38
55
|
};
|
|
39
56
|
export type ProjectPollResult = {
|
|
40
57
|
succeeded: boolean;
|
package/lib/projects/create.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { RepoPath } from '@hubspot/local-dev-lib/types/Github';
|
|
2
|
-
import { ProjectTemplate, ComponentTemplate } from '../../types/Projects';
|
|
3
|
-
export declare const EMPTY_PROJECT_TEMPLATE_NAME = "no-template";
|
|
4
|
-
export declare function getProjectComponentListFromRepo(githubRef: string): Promise<ComponentTemplate[]>;
|
|
5
|
-
export declare function getProjectTemplateListFromRepo(templateSource: RepoPath, githubRef: string): Promise<ProjectTemplate[]>;
|