mushroom-cli 1.1.1 → 1.1.2
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/.vscode/settings.json +3 -0
- package/README.md +91 -91
- package/check-update.js +9 -9
- package/common.js +237 -236
- package/config.js +475 -445
- package/docs/doc-mt.js +526 -421
- package/docs/docs.html +5380 -5129
- package/docs/mt-dom-1.0.js +1398 -1269
- package/docs/mt.extension.js +199 -174
- package/gen/gen-api-docs.js +157 -123
- package/gen/gen-csharp.js +1687 -1410
- package/gen/gen-db-docs.js +238 -222
- package/gen/gen-js-driver-tarball.js +119 -99
- package/gen/gen-js-driver.js +154 -133
- package/gen/gen-ts-driver.js +482 -451
- package/gen.js +146 -119
- package/help.js +51 -55
- package/init/init-json.js +110 -104
- package/init/init-netcore.js +37 -32
- package/init.js +27 -28
- package/master-file/master-file.js +254 -233
- package/mr.js +80 -78
- package/package.json +27 -27
- package/update/tsCode.js +90 -85
- package/update.js +24 -24
- package/sonarqube.yml +0 -18
package/config.js
CHANGED
|
@@ -1,445 +1,475 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const help = require("./help.js");
|
|
3
|
-
const JSON5 = require("json5");
|
|
4
|
-
|
|
5
|
-
//#region common function
|
|
6
|
-
function saveConfig(mushroomConfig, success) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
if (
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const help = require("./help.js");
|
|
3
|
+
const JSON5 = require("json5");
|
|
4
|
+
|
|
5
|
+
//#region common function
|
|
6
|
+
function saveConfig(mushroomConfig, success) {
|
|
7
|
+
mushroomConfig["$schema"] =
|
|
8
|
+
"https://schema.siten.vn/mushroom/mushroom-cli.json";
|
|
9
|
+
fs.writeFile(
|
|
10
|
+
"./mushroom-config.json",
|
|
11
|
+
JSON.stringify(mushroomConfig, null, " "),
|
|
12
|
+
(err) => {
|
|
13
|
+
if (err) throw err;
|
|
14
|
+
|
|
15
|
+
if (typeof success === "function") success();
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
|
|
21
|
+
//#region config add
|
|
22
|
+
function configAdd(args) {
|
|
23
|
+
const filePath = args[2];
|
|
24
|
+
|
|
25
|
+
if (!filePath) {
|
|
26
|
+
help("config add", true);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const fileContent = fs.readFileSync(filePath).toString();
|
|
31
|
+
const project = JSON5.parse(fileContent);
|
|
32
|
+
if (!project.name) {
|
|
33
|
+
throw new TypeError(`Missing name in ${filePath}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let mushroomConfigContent;
|
|
37
|
+
try {
|
|
38
|
+
mushroomConfigContent = fs
|
|
39
|
+
.readFileSync("./mushroom-config.json")
|
|
40
|
+
.toString();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
mushroomConfigContent = null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let mushroomConfig = mushroomConfigContent
|
|
46
|
+
? JSON.parse(mushroomConfigContent)
|
|
47
|
+
: {};
|
|
48
|
+
mushroomConfig.projects = mushroomConfig.projects || {};
|
|
49
|
+
mushroomConfig.projects[project.name] =
|
|
50
|
+
mushroomConfig.projects[project.name] || {};
|
|
51
|
+
mushroomConfig.projects[project.name].src = filePath;
|
|
52
|
+
|
|
53
|
+
saveConfig(mushroomConfig, () =>
|
|
54
|
+
console.log(`Added ${filePath}, project name: ${project.name}`),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
|
|
59
|
+
//#region config gen
|
|
60
|
+
function configGenDocs(args, mushroomConfig, projectName) {
|
|
61
|
+
const path = args[4];
|
|
62
|
+
if (!path) {
|
|
63
|
+
help(args);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let index = 5;
|
|
68
|
+
let parameters = {
|
|
69
|
+
features: [],
|
|
70
|
+
allowRoles: ["*"],
|
|
71
|
+
denyRoles: [],
|
|
72
|
+
};
|
|
73
|
+
let alias = "default";
|
|
74
|
+
while (index < args.length) {
|
|
75
|
+
switch (args[index]) {
|
|
76
|
+
case "features":
|
|
77
|
+
index++;
|
|
78
|
+
const strFeatures = args[index];
|
|
79
|
+
if (strFeatures) parameters.features = strFeatures.split(",");
|
|
80
|
+
break;
|
|
81
|
+
case "roles":
|
|
82
|
+
index++;
|
|
83
|
+
const strRoles = args[index];
|
|
84
|
+
if (strRoles) {
|
|
85
|
+
const minusIndex = strRoles.indexOf("-");
|
|
86
|
+
let grantedRoles =
|
|
87
|
+
minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
88
|
+
const deniedRoles =
|
|
89
|
+
minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
90
|
+
if (!grantedRoles) grantedRoles = "*";
|
|
91
|
+
parameters.allowRoles = grantedRoles.split(",");
|
|
92
|
+
if (deniedRoles) parameters.denyRoles = deniedRoles.split(",");
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
case "alias":
|
|
96
|
+
index++;
|
|
97
|
+
const strAlias = args[index];
|
|
98
|
+
if (strAlias) alias = strAlias;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
index++;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const project = mushroomConfig.projects[projectName];
|
|
105
|
+
project.docs = project.docs || {};
|
|
106
|
+
project.docs.alias = project.docs.alias || {};
|
|
107
|
+
const projectAlias = (project.docs.alias[alias] =
|
|
108
|
+
project.docs.alias[alias] || {});
|
|
109
|
+
for (const key in parameters) {
|
|
110
|
+
if (parameters.hasOwnProperty(key)) {
|
|
111
|
+
const value = parameters[key];
|
|
112
|
+
projectAlias[key] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
projectAlias.output = path;
|
|
116
|
+
saveConfig(mushroomConfig, () =>
|
|
117
|
+
console.log(`Saved configuration of gen docs for ${projectName}@${alias}`),
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function configGenDatabaseDocs(args, mushroomConfig, projectName) {
|
|
122
|
+
const path = args[4];
|
|
123
|
+
if (!path) {
|
|
124
|
+
help(args);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let index = 5;
|
|
129
|
+
let parameters = {
|
|
130
|
+
features: [],
|
|
131
|
+
};
|
|
132
|
+
let alias = "default";
|
|
133
|
+
while (index < args.length) {
|
|
134
|
+
switch (args[index]) {
|
|
135
|
+
case "features":
|
|
136
|
+
index++;
|
|
137
|
+
const strFeatures = args[index];
|
|
138
|
+
if (strFeatures) parameters.features = strFeatures.split(",");
|
|
139
|
+
break;
|
|
140
|
+
case "alias":
|
|
141
|
+
index++;
|
|
142
|
+
const strAlias = args[index];
|
|
143
|
+
if (strAlias) alias = strAlias;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
index++;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const project = mushroomConfig.projects[projectName];
|
|
150
|
+
project.dbDocs = project.dbDocs || {};
|
|
151
|
+
project.dbDocs.alias = project.dbDocs.alias || {};
|
|
152
|
+
const projectAlias = (project.dbDocs.alias[alias] =
|
|
153
|
+
project.dbDocs.alias[alias] || {});
|
|
154
|
+
for (const key in parameters) {
|
|
155
|
+
if (parameters.hasOwnProperty(key)) {
|
|
156
|
+
const value = parameters[key];
|
|
157
|
+
projectAlias[key] = value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
projectAlias.output = path;
|
|
161
|
+
saveConfig(mushroomConfig, () =>
|
|
162
|
+
console.log(
|
|
163
|
+
`Saved configuration of gen db-docs for ${projectName}@${alias}`,
|
|
164
|
+
),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function configGenJavascriptDriver(args, mushroomConfig, projectName) {
|
|
169
|
+
const path = args[4];
|
|
170
|
+
if (!path) {
|
|
171
|
+
help(args);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let index = 5;
|
|
176
|
+
let parameters = {
|
|
177
|
+
allowRoles: ["*"],
|
|
178
|
+
denyRoles: [],
|
|
179
|
+
};
|
|
180
|
+
let alias = "default";
|
|
181
|
+
let tarball = undefined;
|
|
182
|
+
while (index < args.length) {
|
|
183
|
+
switch (args[index]) {
|
|
184
|
+
case "roles":
|
|
185
|
+
index++;
|
|
186
|
+
const strRoles = args[index];
|
|
187
|
+
if (strRoles) {
|
|
188
|
+
const minusIndex = strRoles.indexOf("-");
|
|
189
|
+
let grantedRoles =
|
|
190
|
+
minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
191
|
+
const deniedRoles =
|
|
192
|
+
minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
193
|
+
if (!grantedRoles) grantedRoles = "*";
|
|
194
|
+
parameters.allowRoles = grantedRoles.split(",");
|
|
195
|
+
if (deniedRoles) parameters.denyRoles = deniedRoles.split(",");
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
case "alias":
|
|
199
|
+
index++;
|
|
200
|
+
const strAlias = args[index];
|
|
201
|
+
if (strAlias) alias = strAlias;
|
|
202
|
+
break;
|
|
203
|
+
case "tarball":
|
|
204
|
+
index++;
|
|
205
|
+
const strTarball = args[index];
|
|
206
|
+
if (strTarball) tarball = strTarball;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
index++;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const project = mushroomConfig.projects[projectName];
|
|
213
|
+
project.jsDriver = project.jsDriver || {};
|
|
214
|
+
project.jsDriver.alias = project.jsDriver.alias || {};
|
|
215
|
+
const projectAlias = (project.jsDriver.alias[alias] =
|
|
216
|
+
project.jsDriver.alias[alias] || {});
|
|
217
|
+
for (const key in parameters) {
|
|
218
|
+
if (parameters.hasOwnProperty(key)) {
|
|
219
|
+
const value = parameters[key];
|
|
220
|
+
projectAlias[key] = value;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
projectAlias.tarballName = tarball;
|
|
224
|
+
projectAlias.output = path;
|
|
225
|
+
saveConfig(mushroomConfig, () =>
|
|
226
|
+
console.log(
|
|
227
|
+
`Saved configuration of gen javascript driver for ${projectName}@${alias}`,
|
|
228
|
+
),
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function configGenTypescriptDriver(args, mushroomConfig, projectName) {
|
|
233
|
+
const path = args[4];
|
|
234
|
+
if (!path) {
|
|
235
|
+
help(args);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let index = 5;
|
|
240
|
+
let parameters = {
|
|
241
|
+
allowRoles: ["*"],
|
|
242
|
+
denyRoles: [],
|
|
243
|
+
};
|
|
244
|
+
let alias = "default";
|
|
245
|
+
while (index < args.length) {
|
|
246
|
+
switch (args[index]) {
|
|
247
|
+
case "roles":
|
|
248
|
+
index++;
|
|
249
|
+
const strRoles = args[index];
|
|
250
|
+
if (strRoles) {
|
|
251
|
+
const minusIndex = strRoles.indexOf("-");
|
|
252
|
+
let grantedRoles =
|
|
253
|
+
minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
254
|
+
const deniedRoles =
|
|
255
|
+
minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
256
|
+
if (!grantedRoles) grantedRoles = "*";
|
|
257
|
+
parameters.allowRoles = grantedRoles.split(",");
|
|
258
|
+
if (deniedRoles) parameters.denyRoles = deniedRoles.split(",");
|
|
259
|
+
}
|
|
260
|
+
break;
|
|
261
|
+
case "alias":
|
|
262
|
+
index++;
|
|
263
|
+
const strAlias = args[index];
|
|
264
|
+
if (strAlias) alias = strAlias;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
index++;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const project = mushroomConfig.projects[projectName];
|
|
271
|
+
project.tsDriver = project.tsDriver || {};
|
|
272
|
+
project.tsDriver.alias = project.tsDriver.alias || {};
|
|
273
|
+
const projectAlias = (project.tsDriver.alias[alias] =
|
|
274
|
+
project.tsDriver.alias[alias] || {});
|
|
275
|
+
for (const key in parameters) {
|
|
276
|
+
if (parameters.hasOwnProperty(key)) {
|
|
277
|
+
const value = parameters[key];
|
|
278
|
+
projectAlias[key] = value;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
projectAlias.output = path;
|
|
282
|
+
saveConfig(mushroomConfig, () =>
|
|
283
|
+
console.log(
|
|
284
|
+
`Saved configuration of gen javascript driver for ${projectName}@${alias}`,
|
|
285
|
+
),
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function configGenCSharpMongo(args, mushroomConfig, projectName) {
|
|
290
|
+
const path = args[4];
|
|
291
|
+
if (!path) {
|
|
292
|
+
help(args);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let index = 5;
|
|
297
|
+
let parameters = {};
|
|
298
|
+
let alias = "default";
|
|
299
|
+
while (index < args.length) {
|
|
300
|
+
switch (args[index]) {
|
|
301
|
+
case "alias":
|
|
302
|
+
index++;
|
|
303
|
+
const strAlias = args[index];
|
|
304
|
+
if (strAlias) alias = strAlias;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
index++;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const project = mushroomConfig.projects[projectName];
|
|
311
|
+
project.csharpMongo = project.csharpMongo || {};
|
|
312
|
+
project.csharpMongo.alias = project.csharpMongo.alias || {};
|
|
313
|
+
const projectAlias = (project.csharpMongo.alias[alias] =
|
|
314
|
+
project.csharpMongo.alias[alias] || {});
|
|
315
|
+
for (const key in parameters) {
|
|
316
|
+
if (parameters.hasOwnProperty(key)) {
|
|
317
|
+
const value = parameters[key];
|
|
318
|
+
projectAlias[key] = value;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
projectAlias.output = path;
|
|
322
|
+
saveConfig(mushroomConfig, () =>
|
|
323
|
+
console.log(
|
|
324
|
+
`Saved configuration of gen CSharp/MongoDb classes for ${projectName}@${alias}`,
|
|
325
|
+
),
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function configGenCSharpDriver(args, mushroomConfig, projectName) {
|
|
330
|
+
const path = args[4];
|
|
331
|
+
if (!path) {
|
|
332
|
+
help(args);
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let index = 5;
|
|
337
|
+
let parameters = {
|
|
338
|
+
allowRoles: ["*"],
|
|
339
|
+
denyRoles: [],
|
|
340
|
+
features: ["auth", "file", "mail"],
|
|
341
|
+
accessModifier: "internal",
|
|
342
|
+
};
|
|
343
|
+
let alias = "default";
|
|
344
|
+
while (index < args.length) {
|
|
345
|
+
switch (args[index]) {
|
|
346
|
+
case "roles":
|
|
347
|
+
index++;
|
|
348
|
+
const strRoles = args[index];
|
|
349
|
+
if (strRoles) {
|
|
350
|
+
const minusIndex = strRoles.indexOf("-");
|
|
351
|
+
let grantedRoles =
|
|
352
|
+
minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
353
|
+
const deniedRoles =
|
|
354
|
+
minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
355
|
+
if (!grantedRoles) grantedRoles = "*";
|
|
356
|
+
parameters.allowRoles = grantedRoles.split(",");
|
|
357
|
+
if (deniedRoles) parameters.denyRoles = deniedRoles.split(",");
|
|
358
|
+
}
|
|
359
|
+
break;
|
|
360
|
+
case "alias":
|
|
361
|
+
index++;
|
|
362
|
+
const strAlias = args[index];
|
|
363
|
+
if (strAlias) alias = strAlias;
|
|
364
|
+
break;
|
|
365
|
+
case "access-modifier":
|
|
366
|
+
index++;
|
|
367
|
+
const strAccessModifier = args[index];
|
|
368
|
+
if (strAccessModifier) parameters.accessModifier = strAccessModifier;
|
|
369
|
+
break;
|
|
370
|
+
case "features":
|
|
371
|
+
index++;
|
|
372
|
+
const strFeatures = args[index];
|
|
373
|
+
if (strFeatures) {
|
|
374
|
+
parameters.features = strFeatures.split(",");
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
index++;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const project = mushroomConfig.projects[projectName];
|
|
382
|
+
project.csharpDriver = project.csharpDriver || {};
|
|
383
|
+
project.csharpDriver.alias = project.csharpDriver.alias || {};
|
|
384
|
+
const projectAlias = (project.csharpDriver.alias[alias] =
|
|
385
|
+
project.csharpDriver.alias[alias] || {});
|
|
386
|
+
for (const key in parameters) {
|
|
387
|
+
if (parameters.hasOwnProperty(key)) {
|
|
388
|
+
const value = parameters[key];
|
|
389
|
+
projectAlias[key] = value;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
projectAlias.output = path;
|
|
393
|
+
saveConfig(mushroomConfig, () =>
|
|
394
|
+
console.log(
|
|
395
|
+
`Saved configuration of gen CSharp driver for ${projectName}@${alias}`,
|
|
396
|
+
),
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function configGen(args) {
|
|
401
|
+
const projectName = args[2];
|
|
402
|
+
|
|
403
|
+
let mushroomConfig;
|
|
404
|
+
try {
|
|
405
|
+
const mushroomConfigContent = fs
|
|
406
|
+
.readFileSync("./mushroom-config.json")
|
|
407
|
+
.toString();
|
|
408
|
+
mushroomConfig = JSON.parse(mushroomConfigContent);
|
|
409
|
+
} catch (e) {
|
|
410
|
+
console.error("mushroom-config.json not found or unable to parse");
|
|
411
|
+
throw e;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (
|
|
415
|
+
!mushroomConfig ||
|
|
416
|
+
!mushroomConfig.projects ||
|
|
417
|
+
!mushroomConfig.projects[projectName]
|
|
418
|
+
)
|
|
419
|
+
throw new Error(`Project not found (${projectName})`);
|
|
420
|
+
|
|
421
|
+
const type = args[3];
|
|
422
|
+
switch (type) {
|
|
423
|
+
case "docs":
|
|
424
|
+
configGenDocs(args, mushroomConfig, projectName);
|
|
425
|
+
break;
|
|
426
|
+
case "db-docs":
|
|
427
|
+
configGenDatabaseDocs(args, mushroomConfig, projectName);
|
|
428
|
+
break;
|
|
429
|
+
case "js-driver":
|
|
430
|
+
configGenJavascriptDriver(args, mushroomConfig, projectName);
|
|
431
|
+
break;
|
|
432
|
+
case "ts-driver":
|
|
433
|
+
configGenTypescriptDriver(args, mushroomConfig, projectName);
|
|
434
|
+
break;
|
|
435
|
+
case "c#-mongo":
|
|
436
|
+
configGenCSharpMongo(args, mushroomConfig, projectName);
|
|
437
|
+
break;
|
|
438
|
+
case "c#-driver":
|
|
439
|
+
configGenCSharpDriver(args, mushroomConfig, projectName);
|
|
440
|
+
break;
|
|
441
|
+
case "":
|
|
442
|
+
case undefined:
|
|
443
|
+
case "help":
|
|
444
|
+
case "man":
|
|
445
|
+
help(args);
|
|
446
|
+
break;
|
|
447
|
+
default:
|
|
448
|
+
help(args, true);
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
|
|
454
|
+
function config(args) {
|
|
455
|
+
const configCommand = args[1];
|
|
456
|
+
switch (configCommand) {
|
|
457
|
+
case "add":
|
|
458
|
+
configAdd(args);
|
|
459
|
+
break;
|
|
460
|
+
case "gen":
|
|
461
|
+
configGen(args);
|
|
462
|
+
break;
|
|
463
|
+
case "":
|
|
464
|
+
case undefined:
|
|
465
|
+
case "help":
|
|
466
|
+
case "man":
|
|
467
|
+
help("config");
|
|
468
|
+
break;
|
|
469
|
+
default:
|
|
470
|
+
help(args, true);
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
module.exports = config;
|