mushroom-cli 2.0.0-alpha.1 → 2.0.0-alpha.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/README.md +12 -0
- package/dist/gen/gen-csharp.js +42 -4
- package/dist/gen/gen-db-docs.js +9 -0
- package/dist/gen/gen-js-driver.js +9 -0
- package/dist/gen/gen-ts-driver.js +18 -0
- package/dist/gen.js +1 -1
- package/dist/merge.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -130,6 +130,18 @@ npx mushroom-cli parameters --no-check-update
|
|
|
130
130
|
|
|
131
131
|
## Version
|
|
132
132
|
|
|
133
|
+
### 2.0.0-alpha.3
|
|
134
|
+
|
|
135
|
+
New features:
|
|
136
|
+
|
|
137
|
+
- gen ts-driver, gen js-driver, gen db-docs, gen c#-driver: add the `entities` option (an array of regular expressions) to each alias project. When set, only entities whose name matches at least one of the patterns are generated. If omitted, all entities are generated as before
|
|
138
|
+
|
|
139
|
+
### 2.0.0-alpha.2
|
|
140
|
+
|
|
141
|
+
Improvement:
|
|
142
|
+
|
|
143
|
+
- gen C#-csharp: add `.editorconfig` file
|
|
144
|
+
|
|
133
145
|
### 2.0.0-alpha.1
|
|
134
146
|
|
|
135
147
|
Bug fixes:
|
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}
|
|
@@ -684,6 +713,15 @@ export function genCSharpDriver(args, projectName, project, alias, source) {
|
|
|
684
713
|
throw new Error(`Not found gen c#-driver configuration. Please run 'npx mushroom-cli config ${projectName} gen c#-driver OUTPUT_FILE.cs${alias === 'default' ? '' : ' alias ' + alias}' first`);
|
|
685
714
|
}
|
|
686
715
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
716
|
+
if (Array.isArray(aliasProject.entities)) {
|
|
717
|
+
for (const entityName in entities) {
|
|
718
|
+
if (Object.hasOwnProperty.call(entities, entityName)) {
|
|
719
|
+
if (aliasProject.entities.every((re) => !new RegExp(re).test(entityName))) {
|
|
720
|
+
delete entities[entityName];
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
}
|
|
687
725
|
const namespace = toCSharpName(source.name);
|
|
688
726
|
let strClasses = '';
|
|
689
727
|
let strEnumClasses = '';
|
package/dist/gen/gen-db-docs.js
CHANGED
|
@@ -167,6 +167,15 @@ export default function genDatabaseDocs(args, projectName, project, alias, sourc
|
|
|
167
167
|
throw new Error(`Not found gen db-docs configuration. Please run 'npx mushroom-cli config ${projectName} gen db-docs OUTPUT_FILE.html${alias === 'default' ? '' : ' alias ' + alias}' first`);
|
|
168
168
|
}
|
|
169
169
|
const entities = common.getEntities(source, aliasProject.allowRoles, true);
|
|
170
|
+
if (Array.isArray(aliasProject.entities)) {
|
|
171
|
+
for (const entityName in entities) {
|
|
172
|
+
if (Object.hasOwnProperty.call(entities, entityName)) {
|
|
173
|
+
if (aliasProject.entities.every((re) => !new RegExp(re).test(entityName))) {
|
|
174
|
+
delete entities[entityName];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
170
179
|
let code;
|
|
171
180
|
switch (source.db) {
|
|
172
181
|
case 'MongoDB':
|
|
@@ -23,6 +23,15 @@ export function genJavascriptDriverString(aliasProject, source) {
|
|
|
23
23
|
return '';
|
|
24
24
|
}
|
|
25
25
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
26
|
+
if (Array.isArray(aliasProject.entities)) {
|
|
27
|
+
for (const entityName in entities) {
|
|
28
|
+
if (Object.hasOwnProperty.call(entities, entityName)) {
|
|
29
|
+
if (aliasProject.entities.every((re) => !new RegExp(re).test(entityName))) {
|
|
30
|
+
delete entities[entityName];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
26
35
|
const extensionsImportLines = ['/* import all mushroom extensions */'];
|
|
27
36
|
const extensionsExportLines = [];
|
|
28
37
|
const extensionsCodeLines = ['/* using all mushroom extensions */'];
|
|
@@ -231,6 +231,15 @@ export function genTypescriptDriverString(aliasProject, source) {
|
|
|
231
231
|
return '';
|
|
232
232
|
}
|
|
233
233
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
234
|
+
if (Array.isArray(aliasProject.entities)) {
|
|
235
|
+
for (const entityName in entities) {
|
|
236
|
+
if (Object.hasOwnProperty.call(entities, entityName)) {
|
|
237
|
+
if (aliasProject.entities.every((re) => !new RegExp(re).test(entityName))) {
|
|
238
|
+
delete entities[entityName];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
234
243
|
const extensionsImportLines = ['/* import all mushroom extensions */'];
|
|
235
244
|
const extensionsExportLines = [];
|
|
236
245
|
const extensionsTypes = ['/* all mushroom extensions types */'];
|
|
@@ -419,6 +428,15 @@ export function genDtsString(aliasProject, source) {
|
|
|
419
428
|
return '';
|
|
420
429
|
}
|
|
421
430
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
431
|
+
if (Array.isArray(aliasProject.entities)) {
|
|
432
|
+
for (const entityName in entities) {
|
|
433
|
+
if (Object.hasOwnProperty.call(entities, entityName)) {
|
|
434
|
+
if (aliasProject.entities.every((re) => !new RegExp(re).test(entityName))) {
|
|
435
|
+
delete entities[entityName];
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
422
440
|
const extensionsImportLines = [];
|
|
423
441
|
const extensionsExportLines = [];
|
|
424
442
|
const extensionsTypes = [];
|
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.3",
|
|
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"
|