@wagq/wa-cli 0.5.9 → 0.5.10
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 +16 -5
- package/package.json +1 -1
package/lib/daml/async.js
CHANGED
|
@@ -2,12 +2,23 @@ const fs = require("fs");
|
|
|
2
2
|
const Prompt = require("inquirer");
|
|
3
3
|
const log = require("../../utils/log");
|
|
4
4
|
|
|
5
|
+
const typePath = {
|
|
6
|
+
"逻辑编辑器": "actions.actionList ",
|
|
7
|
+
"变量编辑器": "dataSource.dataList"
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
const initQuestions = () => [
|
|
6
11
|
{
|
|
7
12
|
type: "input",
|
|
8
13
|
name: "name",
|
|
9
14
|
message: "请输入备注信息(会将所有逻辑编辑器文件保存在这个文件夹里)",
|
|
10
15
|
},
|
|
16
|
+
{
|
|
17
|
+
type: "list",
|
|
18
|
+
name: "type",
|
|
19
|
+
message: "请选择同步数据类型",
|
|
20
|
+
choices: Reflect.ownKeys(typePath)
|
|
21
|
+
}
|
|
11
22
|
];
|
|
12
23
|
|
|
13
24
|
const getFiles = async () => {
|
|
@@ -15,20 +26,19 @@ const getFiles = async () => {
|
|
|
15
26
|
`${process.cwd()}/scripts/asyncDamlFetch.js`
|
|
16
27
|
);
|
|
17
28
|
if (!fnFile) {
|
|
18
|
-
log.error("scripts/asyncDamlFetch.js文件不存在")
|
|
19
29
|
const hasCatalogue = await fs.existsSync(`${process.cwd()}/scripts`);
|
|
20
30
|
if(!hasCatalogue){
|
|
21
31
|
await fs.mkdirSync("scripts", undefined, {
|
|
22
32
|
cwd: process.cwd(),
|
|
23
33
|
});
|
|
24
34
|
}
|
|
25
|
-
await fs.writeFileSync(`${process.cwd()}/scripts/asyncDamlFetch.js
|
|
26
|
-
log.
|
|
35
|
+
await fs.writeFileSync(`${process.cwd()}/scripts/asyncDamlFetch.js`, '')
|
|
36
|
+
log.error("scripts/asyncDamlFetch.js文件不存在, 已为您创建scripts/asyncDamlFetch.js文件,请将您的逻辑编辑器代码复制到该文件中后再次执行")
|
|
27
37
|
return;
|
|
28
38
|
}
|
|
29
39
|
const fetchDaml = await require(`${process.cwd()}/scripts/asyncDamlFetch.js`);
|
|
30
40
|
|
|
31
|
-
const { name } = await Prompt.default.prompt(initQuestions());
|
|
41
|
+
const { name, type } = await Prompt.default.prompt(initQuestions());
|
|
32
42
|
const exist = await fs.existsSync(name);
|
|
33
43
|
if (!exist) {
|
|
34
44
|
await fs.mkdirSync(String(name), undefined, {
|
|
@@ -42,7 +52,8 @@ const getFiles = async () => {
|
|
|
42
52
|
})
|
|
43
53
|
.then((res) => {
|
|
44
54
|
const daml = JSON.parse(res.data.daml);
|
|
45
|
-
const
|
|
55
|
+
const dataPath = typePath[type];
|
|
56
|
+
const pages = daml.app.subapps[0][dataPath];
|
|
46
57
|
|
|
47
58
|
pages.forEach(({ content, name: fileName }) => {
|
|
48
59
|
fs.writeFileSync(`${name}/${fileName}.js`, content, {
|