@wagq/wa-cli 0.5.10 → 0.5.12

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 CHANGED
@@ -1,9 +1,10 @@
1
1
  const fs = require("fs");
2
2
  const Prompt = require("inquirer");
3
3
  const log = require("../../utils/log");
4
+ const string2Data = require("../../utils/string2Data");
4
5
 
5
6
  const typePath = {
6
- "逻辑编辑器": "actions.actionList ",
7
+ "逻辑编辑器": "actions.actionList",
7
8
  "变量编辑器": "dataSource.dataList"
8
9
  }
9
10
 
@@ -12,6 +13,7 @@ const initQuestions = () => [
12
13
  type: "input",
13
14
  name: "name",
14
15
  message: "请输入备注信息(会将所有逻辑编辑器文件保存在这个文件夹里)",
16
+ default: "asyncData"
15
17
  },
16
18
  {
17
19
  type: "list",
@@ -52,14 +54,29 @@ const getFiles = async () => {
52
54
  })
53
55
  .then((res) => {
54
56
  const daml = JSON.parse(res.data.daml);
55
- const dataPath = typePath[type];
56
- const pages = daml.app.subapps[0][dataPath];
57
-
58
- pages.forEach(({ content, name: fileName }) => {
59
- fs.writeFileSync(`${name}/${fileName}.js`, content, {
60
- cwd: process.cwd(),
61
- });
62
- });
57
+ const pages = daml.app.subapps[0].actions.actionList;
58
+ const variables = daml.app.subapps[0].dataSource.dataList;
59
+ switch (type) {
60
+ case "逻辑编辑器":
61
+ pages.forEach(({ content, name: fileName }) => {
62
+ fs.writeFileSync(`${name}/${fileName}.js`, content, {
63
+ cwd: process.cwd(),
64
+ });
65
+ });
66
+ break;
67
+ case "变量编辑器":
68
+ variables.forEach(({ key, value: variableValue }) => {
69
+ fs.writeFileSync(`${name}/${key}.json`, JSON.stringify(variableValue, (key, value) => {
70
+ if (typeof value === "string") {
71
+ return string2Data(value);
72
+ }
73
+ return value;
74
+ }, 2) , {
75
+ cwd: process.cwd(),
76
+ });
77
+ });
78
+ break
79
+ }
63
80
  });
64
81
  };
65
82
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.5.10",
3
+ "version": "0.5.12",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "pub": "npm publish --access public --registry=https://registry.npmjs.org"
8
+ "pub": "npm publish --access public --registry=https://registry.npmjs.org",
9
+ "dev": "node ./bin/wa.js"
9
10
  },
10
11
  "keywords": [
11
12
  "wa的脚手架"
@@ -0,0 +1,21 @@
1
+ module.exports = () => fetch("https://kuai.haier.net/api/assembler/page/getPageDaml", {
2
+ "headers": {
3
+ "accept": "application/json, text/plain, */*",
4
+ "accept-language": "zh,ja;q=0.9,zh-CN;q=0.8,en;q=0.7,ko;q=0.6,vi;q=0.5,zh-TW;q=0.4",
5
+ "access-token": "eyJhbGciOiJSUzI1NiJ9.eyJhY2NvdW50TnVtYmVyIjoiQTIwMDIwMzciLCJ1YyI6IjEiLCJpbnN0YW5jZUlkIjoxMjY5OTc5NTQ1MzE5NTQ3OTMxLCJsb2dpbk5hbWUiOiJBMjAwMjAzNyIsImRvbWFpbiI6IklETSIsInRlbmFudElkIjoxLCJpZCI6MjUwMzI1MTE0Mzg3LCJsb2dpblNvdXJjZSI6IjYiLCJqdGkiOiIxOTE4NWU0YS0xMzg5LTQ0ZDMtODc4Mi04YWRlZmE3MTUwNjkiLCJuYmYiOjE3NDM5ODkxMTcsImV4cCI6MTc0NDA0MTYwMH0.ixuwyhyc5ERDugwHjZOzwr99-W1mU0Np5DXnNUKtS9UEzhurx7Van-EBH9Lst4hQ3L5OxIFQoB1csg3pwBwoRgOTPt_Tc0adrBf7ls4_iW0E9GDoYSa6A9ZvVpky3HSh1Pf8BS3Ze3ZmES6uMn6Kw2U5uh-ODNQ3iSPauib70qlVTNJowSGuBO9I5-oL2RHY8UB6lTZ8PqB3Y2gPUGhA28S2E7ndu8gpcYi4KA0FBr4BrT3CJzVwExX3-c84lb639oJmRBaOlLPj98WMJZO_5-sulirtzW-EA5GoDwbiKNk91E7RvsD06-uBGhfurMH9xxPEYI6Ujacbgd1y6MhNJA",
6
+ "appid": "1838489793203609601",
7
+ "branchid": "1909063264443768834",
8
+ "content-type": "application/json",
9
+ "sec-ch-ua": "\"Chromium\";v=\"134\", \"Not:A-Brand\";v=\"24\", \"Google Chrome\";v=\"134\"",
10
+ "sec-ch-ua-mobile": "?0",
11
+ "sec-ch-ua-platform": "\"Windows\"",
12
+ "sec-fetch-dest": "empty",
13
+ "sec-fetch-mode": "cors",
14
+ "sec-fetch-site": "same-origin",
15
+ "cookie": "_tea_utm_cache_1229=undefined; JSESSIONID=4E1AD8E2D965470470347AD152208693",
16
+ "Referer": "https://kuai.haier.net/mate?appId=1838489793203609601&pageId=1909063270470983681&branchId=1909063264443768834",
17
+ "Referrer-Policy": "strict-origin-when-cross-origin"
18
+ },
19
+ "body": "{\"pageId\":\"1909063270470983681\",\"appId\":\"1838489793203609601\"}",
20
+ "method": "POST"
21
+ });
@@ -0,0 +1,7 @@
1
+ module.exports = (str) => {
2
+ try {
3
+ return new Function('return ' + str)();
4
+ } catch (error) {
5
+ return str;
6
+ }
7
+ }