@wagq/wa-cli 0.5.7 → 0.5.9
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/daml/async.js +10 -1
- package/lib/init/index.js +26 -40
- package/package.json +1 -1
package/lib/daml/async.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const fs = require("fs");
|
|
2
2
|
const Prompt = require("inquirer");
|
|
3
|
+
const log = require("../../utils/log");
|
|
3
4
|
|
|
4
5
|
const initQuestions = () => [
|
|
5
6
|
{
|
|
@@ -14,7 +15,15 @@ const getFiles = async () => {
|
|
|
14
15
|
`${process.cwd()}/scripts/asyncDamlFetch.js`
|
|
15
16
|
);
|
|
16
17
|
if (!fnFile) {
|
|
17
|
-
|
|
18
|
+
log.error("scripts/asyncDamlFetch.js文件不存在")
|
|
19
|
+
const hasCatalogue = await fs.existsSync(`${process.cwd()}/scripts`);
|
|
20
|
+
if(!hasCatalogue){
|
|
21
|
+
await fs.mkdirSync("scripts", undefined, {
|
|
22
|
+
cwd: process.cwd(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
await fs.writeFileSync(`${process.cwd()}/scripts/asyncDamlFetch.js`)
|
|
26
|
+
log.info("已为您创建scripts/asyncDamlFetch.js文件,请将您的逻辑编辑器代码复制到该文件中后再次执行")
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
20
29
|
const fetchDaml = await require(`${process.cwd()}/scripts/asyncDamlFetch.js`);
|
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);
|