@wagq/wa-cli 0.5.13 → 0.6.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/lib/daml/async.js +32 -17
- package/package.json +1 -1
package/lib/daml/async.js
CHANGED
|
@@ -5,14 +5,15 @@ const string2Data = require("../../utils/string2Data");
|
|
|
5
5
|
|
|
6
6
|
const typePath = {
|
|
7
7
|
"逻辑编辑器": "actions.actionList",
|
|
8
|
-
"变量编辑器": "dataSource.dataList"
|
|
8
|
+
"变量编辑器": "dataSource.dataList",
|
|
9
|
+
"变量与逻辑": "变量与逻辑"
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
const initQuestions = () => [
|
|
12
13
|
{
|
|
13
14
|
type: "input",
|
|
14
15
|
name: "name",
|
|
15
|
-
message: "请输入备注信息(
|
|
16
|
+
message: "请输入备注信息(会将所有逻辑编辑器文件保存在这个文件夹里,默认值是asyncData)",
|
|
16
17
|
default: "asyncData"
|
|
17
18
|
},
|
|
18
19
|
{
|
|
@@ -57,26 +58,40 @@ const getFiles = async () => {
|
|
|
57
58
|
const daml = JSON.parse(res.data.daml);
|
|
58
59
|
const pages = daml.app.subapps[0].actions.actionList || [];
|
|
59
60
|
const variables = daml.app.subapps[0].dataSource.dataList || [];
|
|
61
|
+
|
|
62
|
+
let asyncPage = false
|
|
63
|
+
let asyncVariable = false
|
|
64
|
+
|
|
60
65
|
switch (type) {
|
|
61
66
|
case "逻辑编辑器":
|
|
62
|
-
|
|
63
|
-
fs.writeFileSync(`${name}/${fileName}.js`, content, {
|
|
64
|
-
cwd: process.cwd(),
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
+
asyncPage = true
|
|
67
68
|
break;
|
|
68
69
|
case "变量编辑器":
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
asyncVariable = true
|
|
71
|
+
break;
|
|
72
|
+
case "变量与逻辑":
|
|
73
|
+
asyncPage = true
|
|
74
|
+
asyncVariable = true
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if(asyncPage) {
|
|
78
|
+
pages.forEach(({ content, name: fileName }) => {
|
|
79
|
+
fs.writeFileSync(`${name}/${fileName}.js`, content, {
|
|
80
|
+
cwd: process.cwd(),
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if(asyncVariable) {
|
|
85
|
+
variables.forEach(({ key, value: variableValue }) => {
|
|
86
|
+
fs.writeFileSync(`${name}/${key}.json`, JSON.stringify(variableValue, (key, value) => {
|
|
87
|
+
if (typeof value === "string") {
|
|
88
|
+
return string2Data(value);
|
|
89
|
+
}
|
|
90
|
+
return value;
|
|
91
|
+
}, 2) , {
|
|
92
|
+
cwd: process.cwd(),
|
|
78
93
|
});
|
|
79
|
-
|
|
94
|
+
});
|
|
80
95
|
}
|
|
81
96
|
}
|
|
82
97
|
catch(err) {
|