@wagq/wa-cli 0.6.22 → 0.6.23
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 +35 -10
- package/package.json +1 -1
package/lib/daml/asyncByApp.js
CHANGED
|
@@ -14,6 +14,13 @@ const initQuestions = () => [
|
|
|
14
14
|
choices: [true, false],
|
|
15
15
|
default: true,
|
|
16
16
|
},
|
|
17
|
+
{
|
|
18
|
+
type: "list",
|
|
19
|
+
name: "prettier",
|
|
20
|
+
message: "是否使用prettier格式化代码",
|
|
21
|
+
choices: [true, false],
|
|
22
|
+
default: true,
|
|
23
|
+
},
|
|
17
24
|
];
|
|
18
25
|
|
|
19
26
|
const handleIgnore = async (ignore, catalogue) => {
|
|
@@ -86,7 +93,15 @@ const getList = async (origin, appId, branchid, token) => {
|
|
|
86
93
|
}
|
|
87
94
|
};
|
|
88
95
|
|
|
89
|
-
const getDaml = async (
|
|
96
|
+
const getDaml = async ({
|
|
97
|
+
lists,
|
|
98
|
+
origin,
|
|
99
|
+
appId,
|
|
100
|
+
branchid,
|
|
101
|
+
token,
|
|
102
|
+
basePath,
|
|
103
|
+
prettier,
|
|
104
|
+
}) => {
|
|
90
105
|
try {
|
|
91
106
|
lists.forEach(async ({ name, id }) => {
|
|
92
107
|
const request = () =>
|
|
@@ -120,8 +135,8 @@ const getDaml = async (lists, origin, appId, branchid, token, dirName) => {
|
|
|
120
135
|
.then((res) => res.json())
|
|
121
136
|
.then(async (res) => {
|
|
122
137
|
const daml = JSON.parse(res.data.daml);
|
|
123
|
-
await generateLogic(
|
|
124
|
-
await generateVariable(
|
|
138
|
+
await generateLogic(basePath, daml, name, prettier);
|
|
139
|
+
await generateVariable(basePath, daml, name);
|
|
125
140
|
});
|
|
126
141
|
});
|
|
127
142
|
} catch (err) {
|
|
@@ -159,7 +174,7 @@ const formatContent = async (content, filepath) => {
|
|
|
159
174
|
}
|
|
160
175
|
};
|
|
161
176
|
|
|
162
|
-
const generateLogic = async (dirName, daml, name) => {
|
|
177
|
+
const generateLogic = async (dirName, daml, name, prettier) => {
|
|
163
178
|
try {
|
|
164
179
|
log.loading(`正在同步${name}的逻辑器`);
|
|
165
180
|
const logicDir = `${dirName}/${name}/logic`;
|
|
@@ -174,10 +189,12 @@ const generateLogic = async (dirName, daml, name) => {
|
|
|
174
189
|
const pages = daml.app.subapps[0]?.actions?.actionList || [];
|
|
175
190
|
pages.forEach(async ({ content, name: fileName }) => {
|
|
176
191
|
const filePath = `${logicDir}/${fileName}.js`;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
192
|
+
if (prettier) {
|
|
193
|
+
// 添加标识
|
|
194
|
+
content = addJsDoc(content, name, fileName);
|
|
195
|
+
// 格式化
|
|
196
|
+
content = await formatContent(content, filePath);
|
|
197
|
+
}
|
|
181
198
|
|
|
182
199
|
fs.writeFileSync(filePath, content, {
|
|
183
200
|
cwd: process.cwd(),
|
|
@@ -257,7 +274,7 @@ const checkDamlrc = async () => {
|
|
|
257
274
|
const main = async () => {
|
|
258
275
|
await checkDamlrc();
|
|
259
276
|
const settings = require(`${process.cwd()}/.damlrc.json`) || [];
|
|
260
|
-
const { ignore } = await Prompt.default.prompt(initQuestions());
|
|
277
|
+
const { ignore, prettier } = await Prompt.default.prompt(initQuestions());
|
|
261
278
|
settings.forEach(async ({ appName, origin, token, appId, branchid }) => {
|
|
262
279
|
const basePath = `${appName}/${catalogue}`;
|
|
263
280
|
const exist = await fs.existsSync(basePath);
|
|
@@ -278,7 +295,15 @@ const main = async () => {
|
|
|
278
295
|
await handleIgnore(ignore, basePath);
|
|
279
296
|
const lists = await getList(origin, appId, branchid, token);
|
|
280
297
|
log.info(`请求${appName}页面列表成功,条数为${lists.length}`);
|
|
281
|
-
await getDaml(
|
|
298
|
+
await getDaml({
|
|
299
|
+
lists,
|
|
300
|
+
origin,
|
|
301
|
+
appId,
|
|
302
|
+
branchid,
|
|
303
|
+
token,
|
|
304
|
+
basePath,
|
|
305
|
+
prettier,
|
|
306
|
+
});
|
|
282
307
|
});
|
|
283
308
|
};
|
|
284
309
|
|