@wagq/wa-cli 0.5.2 → 0.5.3

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/config/command.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const init = require("../lib/init");
2
2
  const server = require("../lib/server");
3
3
  const xlsx2Config = require("../lib/locale/xlsx2Config");
4
+ const asyncDaml = require("../lib/daml/async");
4
5
 
5
6
  const command = [
6
7
  {
@@ -60,6 +61,13 @@ const command = [
60
61
  ],
61
62
  action: xlsx2Config,
62
63
  },
64
+ {
65
+ name: 'daml',
66
+ description: '同步低代码文件到本地',
67
+ action: () => {
68
+ asyncDaml()
69
+ }
70
+ }
63
71
  ];
64
72
 
65
73
  module.exports = command;
@@ -0,0 +1,46 @@
1
+ const fs = require("fs");
2
+ const Prompt = require("inquirer");
3
+
4
+ const initQuestions = () => [
5
+ {
6
+ type: "input",
7
+ name: "name",
8
+ message: "请输入备注信息(会将所有逻辑编辑器文件保存在这个文件夹里)",
9
+ },
10
+ ];
11
+
12
+ const getFiles = async () => {
13
+ const fnFile = await fs.existsSync(
14
+ `${process.cwd()}/scripts/asyncDamlFetch.js`
15
+ );
16
+ if (!fnFile) {
17
+ console.log("scripts/asyncDamlFetch.js文件不存在");
18
+ return;
19
+ }
20
+ const fetchDaml = await require(`${process.cwd()}/scripts/asyncDamlFetch.js`);
21
+
22
+ const { name } = await Prompt.default.prompt(initQuestions());
23
+ const exist = await fs.existsSync(name);
24
+ if (!exist) {
25
+ await fs.mkdirSync(String(name), undefined, {
26
+ cwd: process.cwd(),
27
+ });
28
+ }
29
+
30
+ fetchDaml()
31
+ .then((res) => {
32
+ return res.json();
33
+ })
34
+ .then((res) => {
35
+ const daml = JSON.parse(res.data.daml);
36
+ const pages = daml.app.subapps[0].actions.actionList;
37
+
38
+ pages.forEach(({ content, name: fileName }) => {
39
+ fs.writeFileSync(`${name}/${fileName}.js`, content, {
40
+ cwd: process.cwd(),
41
+ });
42
+ });
43
+ });
44
+ };
45
+
46
+ getFiles();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wagq/wa-cli",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "wa的脚手架",
5
5
  "main": "index.js",
6
6
  "scripts": {