@wagq/wa-cli 0.5.7 → 0.5.8
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/lib/init/index.js +26 -40
- package/package.json +1 -1
package/lib/init/index.js
CHANGED
|
@@ -13,10 +13,10 @@ const urls = {
|
|
|
13
13
|
vue单页面后台: { remote: "sdmu-gaoqi/vite-vue" },
|
|
14
14
|
vue多页面项目: { remote: "sdmu-gaoqi/vite-vue-multiple" },
|
|
15
15
|
vite: { bin: viteBin },
|
|
16
|
-
uniapp: { bin: uniAppBin },
|
|
16
|
+
'uniapp(unibest)': { bin: uniAppBin },
|
|
17
17
|
"vscode插件-vue版": { remote: "sdmu-gaoqi/vscode-plugin#vue" },
|
|
18
18
|
"vscode插件-react版": { remote: "sdmu-gaoqi/vscode-plugin#react" },
|
|
19
|
-
'umi': {
|
|
19
|
+
'umi': { bin: 'npx create-umi@latest' }
|
|
20
20
|
};
|
|
21
21
|
const modeOptions = Object.keys(urls);
|
|
22
22
|
|
|
@@ -27,50 +27,36 @@ const initQuestions = () => [
|
|
|
27
27
|
message: `请选择模板`,
|
|
28
28
|
choices: modeOptions,
|
|
29
29
|
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
const nameOptions = () => [
|
|
30
33
|
{
|
|
31
34
|
type: "input",
|
|
32
|
-
name: "
|
|
33
|
-
message:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
];
|
|
35
|
+
name: "libraryName",
|
|
36
|
+
message: `请输入项目名`,
|
|
37
|
+
}
|
|
38
|
+
] // 项目nam
|
|
37
39
|
|
|
38
40
|
const init = async () => {
|
|
39
41
|
try {
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const initByVite = bin === viteBin;
|
|
45
|
-
const initByUniApp = bin === uniAppBin;
|
|
42
|
+
const { selectMode } = await Prompt.default.prompt(initQuestions());
|
|
43
|
+
const { remote, bin } = urls?.[selectMode];
|
|
44
|
+
const needName = !!remote
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
stdio: "inherit",
|
|
62
|
-
cwd: process.cwd(),
|
|
63
|
-
shell: true,
|
|
64
|
-
});
|
|
65
|
-
} else {
|
|
66
|
-
if (!remote) {
|
|
67
|
-
throw new Error(`未找到${selectMode}模板`);
|
|
68
|
-
}
|
|
69
|
-
await clone(remote, name);
|
|
70
|
-
await after(name, selectMode);
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
log.info("程序提前结束");
|
|
46
|
+
if(needName) {
|
|
47
|
+
const { libraryName } = await Prompt.default.prompt(nameOptions());
|
|
48
|
+
await check(libraryName);
|
|
49
|
+
await clone(remote, libraryName);
|
|
50
|
+
await after(libraryName, selectMode);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const info = `准备从${selectMode}创建`
|
|
54
|
+
log.info(info)
|
|
55
|
+
execSync(bin, {
|
|
56
|
+
stdio: "inherit",
|
|
57
|
+
cwd: process.cwd(),
|
|
58
|
+
shell: true,
|
|
59
|
+
});
|
|
74
60
|
}
|
|
75
61
|
} catch (error) {
|
|
76
62
|
log.error(error);
|