@wagq/wa-cli 0.5.9 → 0.5.10-beta.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 +15 -2
- 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 () => {
|
|
@@ -17,6 +28,7 @@ const getFiles = async () => {
|
|
|
17
28
|
if (!fnFile) {
|
|
18
29
|
log.error("scripts/asyncDamlFetch.js文件不存在")
|
|
19
30
|
const hasCatalogue = await fs.existsSync(`${process.cwd()}/scripts`);
|
|
31
|
+
log.info(hasCatalogue)
|
|
20
32
|
if(!hasCatalogue){
|
|
21
33
|
await fs.mkdirSync("scripts", undefined, {
|
|
22
34
|
cwd: process.cwd(),
|
|
@@ -28,7 +40,7 @@ const getFiles = async () => {
|
|
|
28
40
|
}
|
|
29
41
|
const fetchDaml = await require(`${process.cwd()}/scripts/asyncDamlFetch.js`);
|
|
30
42
|
|
|
31
|
-
const { name } = await Prompt.default.prompt(initQuestions());
|
|
43
|
+
const { name, type } = await Prompt.default.prompt(initQuestions());
|
|
32
44
|
const exist = await fs.existsSync(name);
|
|
33
45
|
if (!exist) {
|
|
34
46
|
await fs.mkdirSync(String(name), undefined, {
|
|
@@ -42,7 +54,8 @@ const getFiles = async () => {
|
|
|
42
54
|
})
|
|
43
55
|
.then((res) => {
|
|
44
56
|
const daml = JSON.parse(res.data.daml);
|
|
45
|
-
const
|
|
57
|
+
const dataPath = typePath[type];
|
|
58
|
+
const pages = daml.app.subapps[0][dataPath];
|
|
46
59
|
|
|
47
60
|
pages.forEach(({ content, name: fileName }) => {
|
|
48
61
|
fs.writeFileSync(`${name}/${fileName}.js`, content, {
|