@wagq/wa-cli 0.5.11 → 0.5.13
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 +28 -21
- package/lib/server/index.js +14 -13
- package/package.json +3 -2
- package/scripts/asyncDamlFetch.js +21 -0
- package/utils/string2data.js +7 -0
package/lib/daml/async.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
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
7
|
"逻辑编辑器": "actions.actionList",
|
|
@@ -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",
|
|
@@ -51,30 +53,35 @@ const getFiles = async () => {
|
|
|
51
53
|
return res.json();
|
|
52
54
|
})
|
|
53
55
|
.then((res) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
try{
|
|
57
|
+
const daml = JSON.parse(res.data.daml);
|
|
58
|
+
const pages = daml.app.subapps[0].actions.actionList || [];
|
|
59
|
+
const variables = daml.app.subapps[0].dataSource.dataList || [];
|
|
60
|
+
switch (type) {
|
|
61
|
+
case "逻辑编辑器":
|
|
62
|
+
pages.forEach(({ content, name: fileName }) => {
|
|
63
|
+
fs.writeFileSync(`${name}/${fileName}.js`, content, {
|
|
64
|
+
cwd: process.cwd(),
|
|
65
|
+
});
|
|
62
66
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
break;
|
|
68
|
+
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
|
+
});
|
|
69
78
|
});
|
|
70
|
-
|
|
79
|
+
break
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch(err) {
|
|
83
|
+
log.error("解析daml失败,请检查请求是否过期或无法访问")
|
|
71
84
|
}
|
|
72
|
-
|
|
73
|
-
pages.forEach(({ content, name: fileName }) => {
|
|
74
|
-
fs.writeFileSync(`${name}/${fileName}.js`, content, {
|
|
75
|
-
cwd: process.cwd(),
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
85
|
});
|
|
79
86
|
};
|
|
80
87
|
|
package/lib/server/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
const { spawn
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
// minimist(process.argv.slice(2))
|
|
1
|
+
const { spawn } = require('node:child_process'); // 使用 node: 前缀明确使用核心模块
|
|
4
2
|
|
|
5
3
|
const server = (filePath, argv) => {
|
|
6
4
|
const https = argv.https ?? false;
|
|
7
5
|
const port = argv.port ?? 3000;
|
|
8
6
|
|
|
9
7
|
try {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
const args = [filePath, '-p', port.toString()];
|
|
9
|
+
if (https) {
|
|
10
|
+
args.push('-S', '-C', 'cert.pem', '-K', 'key.pem');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const child = spawn('npx', ['http-server', ...args], {
|
|
14
|
+
cwd: process.cwd(),
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
shell: true
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
child.on('close', (code) => process.exit(code));
|
|
19
20
|
} catch (error) {
|
|
20
|
-
console.
|
|
21
|
+
console.error('启动失败:', error.message);
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
24
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wagq/wa-cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.13",
|
|
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
|
+
});
|