-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
86 lines (83 loc) · 2.77 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// @ts-check
const path = require("node:path");
const inquirer = require("inquirer");
const { PACKAGES, PACKAGE, InitializeProject } = require("./src");
(async () => {
try {
// 填写项目名
const r1 = await inquirer.prompt([
{
type: "input",
name: "projectScoped",
message: "请输入项目所属域 (please input project scoped)",
},
]);
const projectScoped = r1.projectScoped;
// 填写项目名
const r2 = await inquirer.prompt([
{
type: "input",
name: "projectName",
message: "请输入项目名称 (please input project name)",
},
]);
const projectName = r2.projectName;
if (!projectName) {
throw new Error(`必须填写项目名称`);
}
// 填写项目作者
const r3 = await inquirer.prompt([
{
type: "input",
name: "projectAuthor",
message: "请输入项目作者 (please input project author)",
},
]);
const projectAuthor = r3.projectAuthor || "";
// 填写项目描述
const r4 = await inquirer.prompt([
{
type: "input",
name: "projectDescription",
message: "请输入项目描述 (please input project description)",
},
]);
const projectDescription = r4.projectDescription || "";
// 是否需要生成测试文件夹
const r5 = await inquirer.prompt([
{
type: "confirm",
name: "isNeedTest",
message: "是否需要生成测试文件夹 (is need to generate test folder)",
default: true,
},
]);
const isNeedTest = r5.isNeedTest;
const opt_1 = "单包模式 (package)";
const opt_2 = "多包模式 (packages)";
// 是否需要生成测试文件夹
const r6 = await inquirer.prompt([
{
type: "rawlist",
name: "codeOrganization",
message: "代码组织方式 (code organization)",
choices: [opt_1, opt_2],
},
]);
const codeOrganization = r6.codeOrganization === opt_1 ? PACKAGE : PACKAGES;
const initializeProject = new InitializeProject();
initializeProject.init(
path.join(process.cwd(), projectName),
{
projectScoped,
projectName,
projectDescription,
projectAuthor,
isNeedTest,
},
codeOrganization,
);
} catch (error) {
console.log(error);
}
})();