@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.
Files changed (2) hide show
  1. package/lib/daml/async.js +32 -17
  2. 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
- pages.forEach(({ content, name: fileName }) => {
63
- fs.writeFileSync(`${name}/${fileName}.js`, content, {
64
- cwd: process.cwd(),
65
- });
66
- });
67
+ asyncPage = true
67
68
  break;
68
69
  case "变量编辑器":
69
- variables.forEach(({ key, value: variableValue }) => {
70
- fs.writeFileSync(`${name}/${key}.json`, JSON.stringify(variableValue, (key, value) => {
71
- if (typeof value === "string") {
72
- return string2Data(value);
73
- }
74
- return value;
75
- }, 2) , {
76
- cwd: process.cwd(),
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
- break
94
+ });
80
95
  }
81
96
  }
82
97
  catch(err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.5.13",
3
+ "version": "0.6.0",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {