mushroom-cli 2.0.0-alpha.0 → 2.0.0-alpha.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/README.md +17 -0
- package/dist/docs/docs.v2.html +13 -13
- package/dist/docs/docs.v2.js +143 -73
- package/dist/gen/gen-csharp.js +33 -4
- package/dist/gen.js +1 -1
- package/dist/merge.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -130,6 +130,23 @@ npx mushroom-cli parameters --no-check-update
|
|
|
130
130
|
|
|
131
131
|
## Version
|
|
132
132
|
|
|
133
|
+
### 2.0.0-alpha.2
|
|
134
|
+
|
|
135
|
+
Improvement:
|
|
136
|
+
|
|
137
|
+
- gen C#-csharp: add `.editorconfig` file
|
|
138
|
+
|
|
139
|
+
### 2.0.0-alpha.1
|
|
140
|
+
|
|
141
|
+
Bug fixes:
|
|
142
|
+
|
|
143
|
+
- gen docs: fix trailing comma on the last field of each object in data specs and code snippet.
|
|
144
|
+
- gen docs: copy buttons no longer copy extra text
|
|
145
|
+
|
|
146
|
+
Improvement:
|
|
147
|
+
|
|
148
|
+
- gen docs: add copy buttons to data specs
|
|
149
|
+
|
|
133
150
|
### 2.0.0-alpha.0
|
|
134
151
|
|
|
135
152
|
Breaking changes:
|
package/dist/docs/docs.v2.html
CHANGED
|
@@ -4845,9 +4845,9 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
4845
4845
|
<div>
|
|
4846
4846
|
<h4>Dữ liệu trả về</h4>
|
|
4847
4847
|
Trường hợp không có <code>$fields</code>, kết quả trả về có dạng:
|
|
4848
|
-
<pre class="output-without-fields"></pre>
|
|
4848
|
+
<pre class="output-without-fields" data-language="object-spec"></pre>
|
|
4849
4849
|
Trường hợp <code class="separated-items">$fields=<span class="field-list"></span></code>, kết quả trả về có dạng:
|
|
4850
|
-
<pre class="output-with-fields"></pre>
|
|
4850
|
+
<pre class="output-with-fields" data-language="object-spec"></pre>
|
|
4851
4851
|
<div class="filters">
|
|
4852
4852
|
<h4>Lọc dữ liệu</h4>
|
|
4853
4853
|
<div class="defaultFilters">
|
|
@@ -4900,9 +4900,9 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
4900
4900
|
<div>
|
|
4901
4901
|
<h4>Dữ liệu trả về</h4>
|
|
4902
4902
|
Trường hợp không có <code>$fields</code>, kết quả trả về có dạng:
|
|
4903
|
-
<pre class="output-without-fields"></pre>
|
|
4903
|
+
<pre class="output-without-fields" data-language="object-spec"></pre>
|
|
4904
4904
|
Trường hợp <code class="separated-items">$fields=<span class="field-list"></span></code>, kết quả trả về có dạng:
|
|
4905
|
-
<pre class="output-with-fields"></pre>
|
|
4905
|
+
<pre class="output-with-fields" data-language="object-spec"></pre>
|
|
4906
4906
|
</div>
|
|
4907
4907
|
<div class="cache"></div>
|
|
4908
4908
|
<div class="description">
|
|
@@ -4922,7 +4922,7 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
4922
4922
|
</div>
|
|
4923
4923
|
<div>
|
|
4924
4924
|
<h4>Dữ liệu gửi lên</h4>
|
|
4925
|
-
<pre class="input-model"></pre>
|
|
4925
|
+
<pre class="input-model" data-language="object-spec"></pre>
|
|
4926
4926
|
</div>
|
|
4927
4927
|
<div>
|
|
4928
4928
|
<h4>Dữ liệu trả lại</h4>
|
|
@@ -4958,7 +4958,7 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
4958
4958
|
X-Mushroom-Create-Many: true
|
|
4959
4959
|
|
|
4960
4960
|
<h4>Dữ liệu gửi lên: Mảng của các đối tượng</h4>
|
|
4961
|
-
<pre class="input-model"></pre>
|
|
4961
|
+
<pre class="input-model" data-language="object-spec"></pre>
|
|
4962
4962
|
</div>
|
|
4963
4963
|
<div>
|
|
4964
4964
|
<h4>Dữ liệu trả lại</h4>
|
|
@@ -4985,7 +4985,7 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
4985
4985
|
</div>
|
|
4986
4986
|
<div>
|
|
4987
4987
|
<h4>Dữ liệu gửi lên: </h4>
|
|
4988
|
-
<pre class="input-model"></pre>
|
|
4988
|
+
<pre class="input-model" data-language="object-spec"></pre>
|
|
4989
4989
|
</div>
|
|
4990
4990
|
<div>
|
|
4991
4991
|
<h4>Dữ liệu trả lại</h4>
|
|
@@ -5012,7 +5012,7 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
5012
5012
|
</div>
|
|
5013
5013
|
<div>
|
|
5014
5014
|
<h4>Dữ liệu gửi lên: Mảng của các đối tượng</h4>
|
|
5015
|
-
<pre class="input-model"></pre>
|
|
5015
|
+
<pre class="input-model" data-language="object-spec"></pre>
|
|
5016
5016
|
</div>
|
|
5017
5017
|
<div>
|
|
5018
5018
|
<h4>Dữ liệu trả lại</h4>
|
|
@@ -5039,7 +5039,7 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
5039
5039
|
</div>
|
|
5040
5040
|
<div>
|
|
5041
5041
|
<h4>Dữ liệu gửi lên: </h4>
|
|
5042
|
-
<pre class="input-model"></pre>
|
|
5042
|
+
<pre class="input-model" data-language="object-spec"></pre>
|
|
5043
5043
|
Lưu ý:
|
|
5044
5044
|
<ul>
|
|
5045
5045
|
<li>Chỉ những trường dữ liệu gửi lên mới được cập nhật</li>
|
|
@@ -5125,11 +5125,11 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
5125
5125
|
</div>
|
|
5126
5126
|
<div class="request-body">
|
|
5127
5127
|
<h4>Request body</h4>
|
|
5128
|
-
<pre class="request-body-model"></pre>
|
|
5128
|
+
<pre class="request-body-model" data-language="object-spec"></pre>
|
|
5129
5129
|
</div>
|
|
5130
5130
|
<div class="response-body">
|
|
5131
5131
|
<h4>Response body</h4>
|
|
5132
|
-
<pre class="response-body-model"></pre>
|
|
5132
|
+
<pre class="response-body-model" data-language="object-spec"></pre>
|
|
5133
5133
|
</div>
|
|
5134
5134
|
</div>
|
|
5135
5135
|
|
|
@@ -5178,11 +5178,11 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
|
|
|
5178
5178
|
<h4>Dữ liệu trả về</h4>
|
|
5179
5179
|
<div class="output-model">
|
|
5180
5180
|
Mảng các object:
|
|
5181
|
-
<pre>{{outputModel:html}}</pre>
|
|
5181
|
+
<pre data-language="object-spec">{{outputModel:html}}</pre>
|
|
5182
5182
|
</div>
|
|
5183
5183
|
<div class="output-epmty-result">
|
|
5184
5184
|
Nếu không có phần tử nào, mảng giá trị sau sẽ được trả về:
|
|
5185
|
-
<pre>{{outputEmptyResult}}</pre>
|
|
5185
|
+
<pre data-language="object-spec">{{outputEmptyResult}}</pre>
|
|
5186
5186
|
</div>
|
|
5187
5187
|
</div>
|
|
5188
5188
|
</div>
|
package/dist/docs/docs.v2.js
CHANGED
|
@@ -213,10 +213,14 @@ function formatModel(obj, strIndent, options) {
|
|
|
213
213
|
|
|
214
214
|
var result = '';
|
|
215
215
|
var nextIndent = strIndent + ' ';
|
|
216
|
-
|
|
216
|
+
var keys = Object.keys(obj);
|
|
217
|
+
var lastIndex = keys.length - 1;
|
|
218
|
+
for (var i = 0; i <= lastIndex; i++) {
|
|
219
|
+
var m = keys[i];
|
|
217
220
|
if (!obj.hasOwnProperty(m)) continue;
|
|
218
221
|
|
|
219
222
|
var child = obj[m];
|
|
223
|
+
var comma = i < lastIndex ? ',' : '';
|
|
220
224
|
|
|
221
225
|
var validation = !options.optionalToAll && child.validation && child.validation.required ? 'required' : 'optional';
|
|
222
226
|
if (child.type === 'IdRef' && child.reference) {
|
|
@@ -246,7 +250,7 @@ function formatModel(obj, strIndent, options) {
|
|
|
246
250
|
if (options.mode === 'model') {
|
|
247
251
|
if (child.type === 'object')
|
|
248
252
|
result +=
|
|
249
|
-
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) +
|
|
253
|
+
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) + comma;
|
|
250
254
|
else if (child.type === 'array') {
|
|
251
255
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
252
256
|
if (child.items.type === 'object')
|
|
@@ -269,33 +273,33 @@ function formatModel(obj, strIndent, options) {
|
|
|
269
273
|
' ' +
|
|
270
274
|
comment +
|
|
271
275
|
`\r\n${nextIndent}`;
|
|
272
|
-
result += ']
|
|
276
|
+
result += ']' + comma;
|
|
273
277
|
} else if (child.type === 'datetime')
|
|
274
278
|
result +=
|
|
275
|
-
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + '
|
|
279
|
+
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + comma + ' ' + comment;
|
|
276
280
|
else if (child.type === 'boolean')
|
|
277
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + '
|
|
281
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + comma + ' ' + comment;
|
|
278
282
|
else if (child.type === 'integer' || child.type === 'long' || child.type === 'double')
|
|
279
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + '
|
|
280
|
-
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + '
|
|
283
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + comma + ' ' + comment;
|
|
284
|
+
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + comma + ' ' + comment;
|
|
281
285
|
} else if (options.mode === 'model_null') {
|
|
282
286
|
if (child.type === 'object')
|
|
283
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) +
|
|
287
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) + comma;
|
|
284
288
|
else if (child.type === 'array') {
|
|
285
289
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
286
290
|
if (child.items.type === 'object')
|
|
287
|
-
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']
|
|
288
|
-
else result += ']
|
|
289
|
-
} else result += `\r\n${nextIndent}"${m}": null
|
|
291
|
+
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']' + comma;
|
|
292
|
+
else result += ']' + comma + ' ' + comment;
|
|
293
|
+
} else result += `\r\n${nextIndent}"${m}": null${comma} ${comment}`;
|
|
290
294
|
} else if (options.mode === 'model_undefined') {
|
|
291
295
|
if (child.type === 'object')
|
|
292
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) +
|
|
296
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatModel(child.fields, nextIndent, options) + comma;
|
|
293
297
|
else if (child.type === 'array') {
|
|
294
298
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
295
299
|
if (child.items.type === 'object')
|
|
296
|
-
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']
|
|
297
|
-
else result += ']
|
|
298
|
-
} else result += `\r\n${nextIndent}"${m}": undefined
|
|
300
|
+
result += ' ' + comment + formatModel(child.items.fields, nextIndent, options) + ']' + comma + ' ';
|
|
301
|
+
else result += ']' + comma + ' ' + comment;
|
|
302
|
+
} else result += `\r\n${nextIndent}"${m}": undefined${comma} ${comment}`;
|
|
299
303
|
} else {
|
|
300
304
|
const fieldIdx = 'f_' + __field_idx.toString(36);
|
|
301
305
|
__field_idx++;
|
|
@@ -304,7 +308,7 @@ function formatModel(obj, strIndent, options) {
|
|
|
304
308
|
if (child.type === 'object') result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.fields, strIndent + ' ', options) + '</span>';
|
|
305
309
|
else if (child.type === 'array' && child.items.type === 'object')
|
|
306
310
|
result += ' ' + comment + '<span id="' + fieldIdx + '">' + formatModel(child.items.fields, strIndent + ' ', options) + '</span>';
|
|
307
|
-
else result += '
|
|
311
|
+
else result += ' ' + comment;
|
|
308
312
|
}
|
|
309
313
|
}
|
|
310
314
|
|
|
@@ -368,10 +372,14 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
368
372
|
|
|
369
373
|
var result = '';
|
|
370
374
|
var nextIndent = strIndent + ' ';
|
|
371
|
-
|
|
375
|
+
var keys = Object.keys(obj);
|
|
376
|
+
var lastIndex = keys.length - 1;
|
|
377
|
+
for (var i = 0; i <= lastIndex; i++) {
|
|
378
|
+
var m = keys[i];
|
|
372
379
|
if (!obj.hasOwnProperty(m)) continue;
|
|
373
380
|
|
|
374
381
|
var child = obj[m];
|
|
382
|
+
var comma = i < lastIndex ? ',' : '';
|
|
375
383
|
|
|
376
384
|
var validation = !options.optionalToAll && child.required ? 'required' : 'optional';
|
|
377
385
|
if (child.type === 'IdRef' && child.reference) {
|
|
@@ -395,7 +403,7 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
395
403
|
if (options.mode === 'model') {
|
|
396
404
|
if (child.type === 'object')
|
|
397
405
|
result +=
|
|
398
|
-
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) +
|
|
406
|
+
'\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) + comma;
|
|
399
407
|
else if (child.type === 'array') {
|
|
400
408
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
401
409
|
if (child.items.type === 'object')
|
|
@@ -418,40 +426,40 @@ function formatHintModel(obj, strIndent, options) {
|
|
|
418
426
|
' ' +
|
|
419
427
|
comment +
|
|
420
428
|
`\r\n${nextIndent}`;
|
|
421
|
-
result += ']
|
|
429
|
+
result += ']' + comma;
|
|
422
430
|
} else if (child.type === 'datetime')
|
|
423
431
|
result +=
|
|
424
|
-
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + '
|
|
432
|
+
`\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || 'ISODate_ISO_8601') + comma + ' ' + comment;
|
|
425
433
|
else if (child.type === 'boolean')
|
|
426
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + '
|
|
434
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || 'false') + comma + ' ' + comment;
|
|
427
435
|
else if (child.type === 'integer' || child.type === 'long' || child.type === 'double')
|
|
428
|
-
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + '
|
|
429
|
-
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + '
|
|
436
|
+
result += `\r\n${nextIndent}"${m}": ` + (child.defaultValue || '0') + comma + ' ' + comment;
|
|
437
|
+
else result += `\r\n${nextIndent}"${m}": ` + JSON.stringify(child.defaultValue || child.type) + comma + ' ' + comment;
|
|
430
438
|
} else if (options.mode === 'model_null') {
|
|
431
439
|
if (child.type === 'object')
|
|
432
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) +
|
|
440
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) + comma;
|
|
433
441
|
else if (child.type === 'array') {
|
|
434
442
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
435
443
|
if (child.items.type === 'object')
|
|
436
|
-
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']
|
|
437
|
-
else result += ']
|
|
438
|
-
} else result += `\r\n${nextIndent}"${m}": null
|
|
444
|
+
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']' + comma;
|
|
445
|
+
else result += ']' + comma + ' ' + comment;
|
|
446
|
+
} else result += `\r\n${nextIndent}"${m}": null${comma} ${comment}`;
|
|
439
447
|
} else if (options.mode === 'model_undefined') {
|
|
440
448
|
if (child.type === 'object')
|
|
441
|
-
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) +
|
|
449
|
+
result += '\r\n' + nextIndent + '"' + m + '": ' + comment + formatHintModel(child.fields, nextIndent, options) + comma;
|
|
442
450
|
else if (child.type === 'array') {
|
|
443
451
|
result += `\r\n${nextIndent}"${m}": [`;
|
|
444
452
|
if (child.items.type === 'object')
|
|
445
|
-
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']
|
|
446
|
-
else result += ']
|
|
447
|
-
} else result += `\r\n${nextIndent}"${m}": undefined
|
|
453
|
+
result += ' ' + comment + formatHintModel(child.items.fields, nextIndent, options) + ']' + comma + ' ';
|
|
454
|
+
else result += ']' + comma + ' ' + comment;
|
|
455
|
+
} else result += `\r\n${nextIndent}"${m}": undefined${comma} ${comment}`;
|
|
448
456
|
} else {
|
|
449
457
|
result += '\r\n' + strIndent + encodeHtml(m) + ': ' + encodeHtml(child.type);
|
|
450
458
|
if (child.type === 'array') result += child.items.type === 'object' ? ' of object' : ' of ' + child.items.type;
|
|
451
459
|
if (child.type === 'object') result += ' ' + comment + formatHintModel(child.fields, strIndent + ' ', options);
|
|
452
460
|
else if (child.type === 'array' && child.items.type === 'object')
|
|
453
461
|
result += ' ' + comment + formatHintModel(child.items.fields, strIndent + ' ', options);
|
|
454
|
-
else result += '
|
|
462
|
+
else result += ' ' + comment;
|
|
455
463
|
}
|
|
456
464
|
}
|
|
457
465
|
|
|
@@ -780,7 +788,6 @@ function renderEntityActionRolePage(entityName, actionName, grant) {
|
|
|
780
788
|
};
|
|
781
789
|
tabPage.innerHTML =
|
|
782
790
|
renderTemplate(template, data) + renderTemplate('template-project-entity-action-page-codeSnippets', data);
|
|
783
|
-
initDom(tabPage);
|
|
784
791
|
if (!action.deny) tabPage.querySelector('.deny-roles')?.remove();
|
|
785
792
|
|
|
786
793
|
if (!action.matches || !Array.isArray(action.matches) || !action.matches.length)
|
|
@@ -798,6 +805,7 @@ function renderEntityActionRolePage(entityName, actionName, grant) {
|
|
|
798
805
|
tabPage.querySelector('.description')?.remove();
|
|
799
806
|
}
|
|
800
807
|
callback(args);
|
|
808
|
+
initDom(tabPage);
|
|
801
809
|
}
|
|
802
810
|
|
|
803
811
|
function renderFindMany(args) {
|
|
@@ -1925,23 +1933,32 @@ function doCopy(e) {
|
|
|
1925
1933
|
const copyDom = this.parentNode.querySelector(this.dataset.copy);
|
|
1926
1934
|
|
|
1927
1935
|
if (window.ClipboardItem) {
|
|
1928
|
-
const content = copyDom
|
|
1936
|
+
const content = getVisibleText(copyDom);
|
|
1929
1937
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
1930
1938
|
const text = new ClipboardItem({ 'text/plain': blob });
|
|
1931
1939
|
navigator.clipboard.write([text]);
|
|
1932
1940
|
} else {
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1941
|
+
const clone = cloneVisible(copyDom);
|
|
1942
|
+
copyDom.parentNode.insertBefore(clone, copyDom);
|
|
1943
|
+
const savedDisplay = copyDom.style.display;
|
|
1944
|
+
copyDom.style.display = 'none';
|
|
1945
|
+
try {
|
|
1946
|
+
if (document.body.createTextRange) {
|
|
1947
|
+
const range = document.body.createTextRange();
|
|
1948
|
+
range.moveToElementText(clone);
|
|
1949
|
+
range.select();
|
|
1950
|
+
} else if (window.getSelection) {
|
|
1951
|
+
const selection = window.getSelection();
|
|
1952
|
+
const range = document.createRange();
|
|
1953
|
+
range.selectNodeContents(clone);
|
|
1954
|
+
selection.removeAllRanges();
|
|
1955
|
+
selection.addRange(range);
|
|
1956
|
+
}
|
|
1957
|
+
document.execCommand('copy');
|
|
1958
|
+
} finally {
|
|
1959
|
+
clone.remove();
|
|
1960
|
+
copyDom.style.display = savedDisplay;
|
|
1943
1961
|
}
|
|
1944
|
-
document.execCommand('copy');
|
|
1945
1962
|
}
|
|
1946
1963
|
|
|
1947
1964
|
copied();
|
|
@@ -1955,14 +1972,47 @@ function copied() {
|
|
|
1955
1972
|
setTimeout(() => dom.classList.remove('show'), 1000);
|
|
1956
1973
|
}
|
|
1957
1974
|
|
|
1975
|
+
function getVisibleText(element) {
|
|
1976
|
+
const clone = element.cloneNode(true);
|
|
1977
|
+
// Walk all elements in the clone; remove those that are hidden in the original DOM
|
|
1978
|
+
const originalAll = element.querySelectorAll('*');
|
|
1979
|
+
const cloneAll = clone.querySelectorAll('*');
|
|
1980
|
+
for (let i = cloneAll.length - 1; i >= 0; i--) {
|
|
1981
|
+
const style = window.getComputedStyle(originalAll[i]);
|
|
1982
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
1983
|
+
cloneAll[i].remove();
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
return clone.textContent || '';
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
function cloneVisible(element) {
|
|
1990
|
+
const clone = element.cloneNode(true);
|
|
1991
|
+
const originalAll = element.querySelectorAll('*');
|
|
1992
|
+
const cloneAll = clone.querySelectorAll('*');
|
|
1993
|
+
for (let i = cloneAll.length - 1; i >= 0; i--) {
|
|
1994
|
+
const style = window.getComputedStyle(originalAll[i]);
|
|
1995
|
+
if (style.display === 'none' || style.visibility === 'hidden') {
|
|
1996
|
+
cloneAll[i].remove();
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
return clone;
|
|
2000
|
+
}
|
|
2001
|
+
|
|
1958
2002
|
function initDom(dom) {
|
|
1959
2003
|
$('pre[data-language]', dom).each(function () {
|
|
1960
|
-
|
|
1961
|
-
holder
|
|
2004
|
+
let holder = this.querySelector(":scope > .command-bar");
|
|
2005
|
+
if (!holder) {
|
|
2006
|
+
holder = document.createElement('div');
|
|
2007
|
+
holder.className = 'command-bar';
|
|
2008
|
+
$(this).prepend(holder);
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
if (holder.querySelector(":scope > .command-item-copy")) return;
|
|
1962
2012
|
const copyButton = document.createElement('a');
|
|
2013
|
+
copyButton.className = 'command-item-copy';
|
|
1963
2014
|
copyButton.innerHTML = 'Copy';
|
|
1964
2015
|
holder.appendChild(copyButton);
|
|
1965
|
-
$(this).prepend(holder);
|
|
1966
2016
|
copyButton.onclick = function () {
|
|
1967
2017
|
if (location.protocol !== 'https:' && location.protocol !== 'file:') {
|
|
1968
2018
|
alert('Can not copy, please use https protocol!');
|
|
@@ -1972,23 +2022,32 @@ function initDom(dom) {
|
|
|
1972
2022
|
const commandBar = $(this).parent().detach();
|
|
1973
2023
|
try {
|
|
1974
2024
|
if (window.ClipboardItem) {
|
|
1975
|
-
const content = pre
|
|
2025
|
+
const content = getVisibleText(pre[0]);
|
|
1976
2026
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
1977
2027
|
const text = new ClipboardItem({ 'text/plain': blob });
|
|
1978
2028
|
navigator.clipboard.write([text]);
|
|
1979
2029
|
} else {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2030
|
+
const clone = cloneVisible(pre[0]);
|
|
2031
|
+
pre[0].parentNode.insertBefore(clone, pre[0]);
|
|
2032
|
+
const savedDisplay = pre[0].style.display;
|
|
2033
|
+
pre[0].style.display = 'none';
|
|
2034
|
+
try {
|
|
2035
|
+
if (document.body.createTextRange) {
|
|
2036
|
+
const range = document.body.createTextRange();
|
|
2037
|
+
range.moveToElementText(clone);
|
|
2038
|
+
range.select();
|
|
2039
|
+
} else if (window.getSelection) {
|
|
2040
|
+
const selection = window.getSelection();
|
|
2041
|
+
const range = document.createRange();
|
|
2042
|
+
range.selectNodeContents(clone);
|
|
2043
|
+
selection.removeAllRanges();
|
|
2044
|
+
selection.addRange(range);
|
|
2045
|
+
}
|
|
2046
|
+
document.execCommand('copy');
|
|
2047
|
+
} finally {
|
|
2048
|
+
clone.remove();
|
|
2049
|
+
pre[0].style.display = savedDisplay;
|
|
1990
2050
|
}
|
|
1991
|
-
document.execCommand('copy');
|
|
1992
2051
|
}
|
|
1993
2052
|
} finally {
|
|
1994
2053
|
pre.prepend(commandBar);
|
|
@@ -1998,8 +2057,10 @@ function initDom(dom) {
|
|
|
1998
2057
|
};
|
|
1999
2058
|
});
|
|
2000
2059
|
|
|
2001
|
-
$('pre[data-language=json] .command-bar', dom).each(function () {
|
|
2060
|
+
$('pre[data-language=json] .command-bar, pre[data-language=object-spec] .command-bar', dom).each(function () {
|
|
2061
|
+
if (this.querySelector(":scope > .command-item-copy-without-comment")) return;
|
|
2002
2062
|
const copyButton = document.createElement('a');
|
|
2063
|
+
copyButton.className = 'command-item-copy-without-comment';
|
|
2003
2064
|
copyButton.innerHTML = 'Copy (without comment)';
|
|
2004
2065
|
$(this).prepend(copyButton);
|
|
2005
2066
|
copyButton.onclick = function () {
|
|
@@ -2015,23 +2076,32 @@ function initDom(dom) {
|
|
|
2015
2076
|
});
|
|
2016
2077
|
try {
|
|
2017
2078
|
if (window.ClipboardItem) {
|
|
2018
|
-
const content = pre
|
|
2079
|
+
const content = getVisibleText(pre[0]);
|
|
2019
2080
|
const blob = new Blob([content], { type: 'text/plain' });
|
|
2020
2081
|
const text = new ClipboardItem({ 'text/plain': blob });
|
|
2021
2082
|
navigator.clipboard.write([text]);
|
|
2022
2083
|
} else {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2084
|
+
const clone = cloneVisible(pre[0]);
|
|
2085
|
+
pre[0].parentNode.insertBefore(clone, pre[0]);
|
|
2086
|
+
const savedDisplay = pre[0].style.display;
|
|
2087
|
+
pre[0].style.display = 'none';
|
|
2088
|
+
try {
|
|
2089
|
+
if (document.body.createTextRange) {
|
|
2090
|
+
const range = document.body.createTextRange();
|
|
2091
|
+
range.moveToElementText(clone);
|
|
2092
|
+
range.select();
|
|
2093
|
+
} else if (window.getSelection) {
|
|
2094
|
+
const selection = window.getSelection();
|
|
2095
|
+
const range = document.createRange();
|
|
2096
|
+
range.selectNodeContents(clone);
|
|
2097
|
+
selection.removeAllRanges();
|
|
2098
|
+
selection.addRange(range);
|
|
2099
|
+
}
|
|
2100
|
+
document.execCommand('copy');
|
|
2101
|
+
} finally {
|
|
2102
|
+
clone.remove();
|
|
2103
|
+
pre[0].style.display = savedDisplay;
|
|
2033
2104
|
}
|
|
2034
|
-
document.execCommand('copy');
|
|
2035
2105
|
}
|
|
2036
2106
|
} finally {
|
|
2037
2107
|
pre.prepend(commandBar);
|
package/dist/gen/gen-csharp.js
CHANGED
|
@@ -4,7 +4,8 @@ import { getExtensionEventsCode } from './csharp/extEvents.js';
|
|
|
4
4
|
const packageVersion = common.getPackageVersion();
|
|
5
5
|
const newLine = '\n';
|
|
6
6
|
const header = `// NOTE: Please do not modify this file
|
|
7
|
-
// NOTE: Version and compatibility information: please see in Info.cs file
|
|
7
|
+
// NOTE: Version and compatibility information: please see in Info.cs file`;
|
|
8
|
+
const resharperDisable = `
|
|
8
9
|
|
|
9
10
|
// ReSharper disable CheckNamespace
|
|
10
11
|
// ReSharper disable ClassCannotBeInstantiated
|
|
@@ -12,6 +13,7 @@ const header = `// NOTE: Please do not modify this file
|
|
|
12
13
|
// ReSharper disable EmptyNamespace
|
|
13
14
|
// ReSharper disable IdentifierTypo
|
|
14
15
|
// ReSharper disable InconsistentNaming
|
|
16
|
+
// ReSharper disable MemberCanBeMadeStatic.Local
|
|
15
17
|
// ReSharper disable PartialTypeWithSinglePart
|
|
16
18
|
// ReSharper disable RedundantTypeArgumentsOfMethod
|
|
17
19
|
// ReSharper disable RedundantUsingDirective
|
|
@@ -21,6 +23,31 @@ const header = `// NOTE: Please do not modify this file
|
|
|
21
23
|
// ReSharper disable UnusedParameter.Local
|
|
22
24
|
// ReSharper disable UnusedTypeParameter
|
|
23
25
|
`;
|
|
26
|
+
const resharperEditorConfig = `[*.cs]
|
|
27
|
+
# Disable Namespace & Class rules
|
|
28
|
+
resharper_check_namespace_highlighting = none
|
|
29
|
+
resharper_class_cannot_be_instantiated_highlighting = none
|
|
30
|
+
resharper_empty_namespace_highlighting = none
|
|
31
|
+
resharper_partial_type_with_single_part_highlighting = none
|
|
32
|
+
resharper_inconsistent_naming_highlighting = none
|
|
33
|
+
|
|
34
|
+
# Disable Typo checks
|
|
35
|
+
resharper_comment_typo_highlighting = none
|
|
36
|
+
resharper_identifier_typo_highlighting = none
|
|
37
|
+
resharper_string_literal_typo_highlighting = none
|
|
38
|
+
|
|
39
|
+
# Disable Redundant code rules
|
|
40
|
+
resharper_redundant_type_arguments_of_method_highlighting = none
|
|
41
|
+
resharper_redundant_using_directive_highlighting = none
|
|
42
|
+
|
|
43
|
+
# Disable Unused elements
|
|
44
|
+
resharper_unused_member_global_highlighting = none
|
|
45
|
+
resharper_unused_member_local_highlighting = none
|
|
46
|
+
resharper_unused_parameter_local_highlighting = none
|
|
47
|
+
resharper_unused_type_parameter_highlighting = none
|
|
48
|
+
|
|
49
|
+
# Disable Code Suggestions
|
|
50
|
+
resharper_member_can_be_made_static_local_highlighting = none`;
|
|
24
51
|
const infoContent = `// Mushroom CLI version: ${packageVersion} (https://www.npmjs.com/package/mushroomjs)${newLine}// Compatible with Mushroom Server version: 0.3 or higher (https://www.nuget.org/packages/Mushroom/)`;
|
|
25
52
|
const helperMethods = `
|
|
26
53
|
public delegate T GetT<out T>(Mushroom.ActionArguments arg);
|
|
@@ -532,7 +559,7 @@ ${roleNames}
|
|
|
532
559
|
#if DEBUG
|
|
533
560
|
namespace ${namespace}
|
|
534
561
|
{
|
|
535
|
-
class RefactorHelper
|
|
562
|
+
internal class RefactorHelper
|
|
536
563
|
{
|
|
537
564
|
private RefactorHelper() { }
|
|
538
565
|
${helperMethods}
|
|
@@ -555,12 +582,14 @@ ${strExtensionEventHandlers}
|
|
|
555
582
|
fs.writeFileSync(aliasProject.output + '/RoleNames.cs', roleNamesFileContent);
|
|
556
583
|
fs.writeFileSync(aliasProject.output + '/RefactorHelper.cs', refactorHelperFileContent);
|
|
557
584
|
fs.writeFileSync(aliasProject.output + '/Info.cs', infoContent);
|
|
585
|
+
fs.writeFileSync(aliasProject.output + '/.editorconfig', resharperEditorConfig);
|
|
558
586
|
common.logInfo(`Generated CSharp MongoDb Classes for ${projectName}@${alias} to folder ${aliasProject.output}`);
|
|
559
587
|
}
|
|
560
588
|
else {
|
|
561
589
|
const fullCode = `${infoContent}
|
|
562
590
|
|
|
563
|
-
|
|
591
|
+
// NOTE: Please do not modify this file
|
|
592
|
+
${resharperDisable}
|
|
564
593
|
|
|
565
594
|
namespace ${namespace}
|
|
566
595
|
{
|
|
@@ -599,7 +628,7 @@ ${out.strEnumClasses ?? ''}
|
|
|
599
628
|
#if DEBUG
|
|
600
629
|
namespace ${namespace}.CodeHelper
|
|
601
630
|
{
|
|
602
|
-
class RefactorHelper
|
|
631
|
+
internal class RefactorHelper
|
|
603
632
|
{
|
|
604
633
|
private RefactorHelper() { }
|
|
605
634
|
${helperMethods}
|
package/dist/gen.js
CHANGED
|
@@ -55,7 +55,7 @@ export default async function gen(args) {
|
|
|
55
55
|
}
|
|
56
56
|
if (!master || typeof master !== 'object')
|
|
57
57
|
throw new Error(`Invalid api project configuration. Please re-check file ${project.src}`);
|
|
58
|
-
let source
|
|
58
|
+
let source;
|
|
59
59
|
if (Array.isArray(master.fragments)) {
|
|
60
60
|
common.logInfo('Process master file', project.src);
|
|
61
61
|
source = masterFile.processMasterFile(path.dirname(project.src), master);
|
package/dist/merge.js
CHANGED
|
@@ -50,7 +50,7 @@ export default async function merge(args) {
|
|
|
50
50
|
}
|
|
51
51
|
if (!master || typeof master !== 'object')
|
|
52
52
|
throw new Error(`Invalid api project configuration. Please re-check file ${project.src}`);
|
|
53
|
-
let projectApi
|
|
53
|
+
let projectApi;
|
|
54
54
|
if (Array.isArray(master.fragments)) {
|
|
55
55
|
common.logInfo('Process master file:', project.src);
|
|
56
56
|
projectApi = masterFile.processMasterFile(path.dirname(project.src), master);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mushroom-cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"description": "Mushroom CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
"readline-sync": "^1.4.10"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@eslint/js": "^
|
|
41
|
+
"@eslint/js": "^10.0.1",
|
|
42
42
|
"@types/html-minifier-terser": "^7.0.2",
|
|
43
43
|
"@types/node": "^22.15.29",
|
|
44
44
|
"@types/readline-sync": "^1.4.8",
|
|
45
45
|
"copyfiles": "^2.4.1",
|
|
46
|
-
"eslint": "^
|
|
46
|
+
"eslint": "^10.8.1",
|
|
47
47
|
"husky": "^9.1.7",
|
|
48
|
-
"lint-staged": "^
|
|
48
|
+
"lint-staged": "^17.3.0",
|
|
49
49
|
"only-allow": "^1.2.2",
|
|
50
|
-
"prettier": "^3.
|
|
50
|
+
"prettier": "^3.9.6",
|
|
51
51
|
"typescript": "^5.9.3",
|
|
52
|
-
"typescript-eslint": "^8.
|
|
52
|
+
"typescript-eslint": "^8.67.0"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=14.13.1"
|