@wagq/wa-cli 0.6.21 → 0.6.22
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/asyncByApp.js +37 -12
- package/package.json +2 -1
- package/utils/cwd.js +5 -0
package/lib/daml/asyncByApp.js
CHANGED
|
@@ -2,6 +2,7 @@ const fs = require("fs");
|
|
|
2
2
|
const Prompt = require("inquirer");
|
|
3
3
|
const log = require("../../utils/log");
|
|
4
4
|
const string2Data = require("../../utils/string2Data");
|
|
5
|
+
const prettier = require("../../node_modules/prettier");
|
|
5
6
|
|
|
6
7
|
const catalogue = "pages";
|
|
7
8
|
|
|
@@ -128,6 +129,36 @@ const getDaml = async (lists, origin, appId, branchid, token, dirName) => {
|
|
|
128
129
|
}
|
|
129
130
|
};
|
|
130
131
|
|
|
132
|
+
const addJsDoc = (content, name, fileName) => {
|
|
133
|
+
const hasFileJsDoc = content.includes("@file");
|
|
134
|
+
// 添加标识
|
|
135
|
+
return hasFileJsDoc
|
|
136
|
+
? content
|
|
137
|
+
: `/** @file ${name}(逻辑名称:${fileName}) */
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @type {import("../../../../sass").CustomAction}
|
|
142
|
+
*/
|
|
143
|
+
${content}`;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const formatContent = async (content, filepath) => {
|
|
147
|
+
try {
|
|
148
|
+
const config = await prettier.resolveConfig("path/to/file", {
|
|
149
|
+
useCache: false,
|
|
150
|
+
});
|
|
151
|
+
content = await prettier.format(content, {
|
|
152
|
+
...config,
|
|
153
|
+
semi: false,
|
|
154
|
+
filepath,
|
|
155
|
+
});
|
|
156
|
+
return content;
|
|
157
|
+
} catch (err) {
|
|
158
|
+
return content;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
131
162
|
const generateLogic = async (dirName, daml, name) => {
|
|
132
163
|
try {
|
|
133
164
|
log.loading(`正在同步${name}的逻辑器`);
|
|
@@ -141,20 +172,14 @@ const generateLogic = async (dirName, daml, name) => {
|
|
|
141
172
|
}
|
|
142
173
|
);
|
|
143
174
|
const pages = daml.app.subapps[0]?.actions?.actionList || [];
|
|
144
|
-
pages.forEach(({ content, name: fileName }) => {
|
|
145
|
-
const
|
|
175
|
+
pages.forEach(async ({ content, name: fileName }) => {
|
|
176
|
+
const filePath = `${logicDir}/${fileName}.js`;
|
|
146
177
|
// 添加标识
|
|
147
|
-
content =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @type {import("../../../../sass").CustomAction}
|
|
154
|
-
*/
|
|
155
|
-
${content}`;
|
|
178
|
+
content = addJsDoc(content, name, fileName);
|
|
179
|
+
// 格式化
|
|
180
|
+
content = await formatContent(content, filePath);
|
|
156
181
|
|
|
157
|
-
fs.writeFileSync(
|
|
182
|
+
fs.writeFileSync(filePath, content, {
|
|
158
183
|
cwd: process.cwd(),
|
|
159
184
|
});
|
|
160
185
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wagq/wa-cli",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.22",
|
|
4
4
|
"description": "wa的脚手架",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"inquirer": "^12.4.1",
|
|
36
36
|
"minimist": "^1.2.8",
|
|
37
37
|
"ora": "^4.0.3",
|
|
38
|
+
"prettier": "^3.5.3",
|
|
38
39
|
"xlsx": "^0.18.5"
|
|
39
40
|
},
|
|
40
41
|
"directories": {
|