@wagq/wa-cli 0.5.12 → 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 CHANGED
@@ -53,29 +53,34 @@ const getFiles = async () => {
53
53
  return res.json();
54
54
  })
55
55
  .then((res) => {
56
- const daml = JSON.parse(res.data.daml);
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(),
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
+ });
64
66
  });
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(),
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
+ });
76
78
  });
77
- });
78
- break
79
+ break
80
+ }
81
+ }
82
+ catch(err) {
83
+ log.error("解析daml失败,请检查请求是否过期或无法访问")
79
84
  }
80
85
  });
81
86
  };
@@ -1,23 +1,24 @@
1
- const { spawn, exec, execSync } = require("child_process");
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 child = spawn(
11
- "http-server",
12
- [filePath, "-p", port, https ? `-S -C cert.pem -K key.pem` : ""],
13
- {
14
- cwd: process.cwd(),
15
- stdio: "inherit",
16
- }
17
- );
18
- child.on("close", (code) => process.exit(code));
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.log(error);
21
+ console.error('启动失败:', error.message);
21
22
  }
22
23
  };
23
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {