mushroom-cli 1.1.0-alpha.13 → 1.1.0-alpha.14

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.
Files changed (2) hide show
  1. package/gen/gen-csharp.js +41 -2
  2. package/package.json +2 -2
package/gen/gen-csharp.js CHANGED
@@ -5,7 +5,7 @@ const package = require("./../package.json");
5
5
  //#region shared function
6
6
  const newLine = `
7
7
  `;
8
- const header = `// NOTE: This file was generated by Mushroom CLI (https://www.npmjs.com/package/mushroom-cli), please do not modify
8
+ const header = `// NOTE: Please do not modify this file
9
9
  // NOTE: Version and compatibility information: please see in Info.cs file
10
10
 
11
11
  // ReSharper disable CheckNamespace
@@ -289,6 +289,17 @@ function genCSharpMongoDbClasses(args, projectName, project, alias, source) {
289
289
  let strEnumClasses = "";
290
290
  let collectionNames = "";
291
291
  let resourceNames = "";
292
+ let roleNames = "";
293
+
294
+ source.roles?.forEach(role => {
295
+ if (!role.name) return;
296
+ roleNames += `
297
+ /// <summary>
298
+ /// ${role.description ?? ""}
299
+ /// </summary>
300
+ public static string ${toCSharpName(role.name)} => "${role.name}";
301
+ `;
302
+ });
292
303
 
293
304
  const out = {};
294
305
  for (let entityName in entities) {
@@ -474,6 +485,10 @@ ${collectionNames}
474
485
  {
475
486
  ${resourceNames}
476
487
  }
488
+
489
+ public static class RoleNames {
490
+ ${roleNames}
491
+ }
477
492
  }
478
493
 
479
494
  namespace ${namespace}.Resources
@@ -649,7 +664,7 @@ function genCSharpMongoDbClassesToFolder(projectName, alias, source, aliasProjec
649
664
  fs.unlinkSync(aliasProject.output); // xóa file nếu có
650
665
  } catch(e) {}
651
666
  try {
652
- fs.rmdirSync(aliasProject.output); // xóa thư mục nếu có
667
+ fs.rmdirSync(aliasProject.output, { recursive: true, force: true }); // xóa thư mục nếu có
653
668
  } catch(e) {}
654
669
  }
655
670
  fs.mkdirSync(aliasProject.output, { recursive: true, mode: 0755 });
@@ -660,6 +675,17 @@ function genCSharpMongoDbClassesToFolder(projectName, alias, source, aliasProjec
660
675
 
661
676
  let collectionNames = "";
662
677
  let resourceNames = "";
678
+ let roleNames = "";
679
+
680
+ source.roles?.forEach(role => {
681
+ if (!role.name) return;
682
+ roleNames += `
683
+ /// <summary>
684
+ /// ${role.description ?? ""}
685
+ /// </summary>
686
+ public static string ${toCSharpName(role.name)} => "${role.name}";
687
+ `;
688
+ });
663
689
 
664
690
  const out = {};
665
691
  for (let entityName in entities) {
@@ -835,6 +861,18 @@ ${resourceNames}
835
861
  }
836
862
  }
837
863
  `;
864
+
865
+ const roleNamesFileContent = `${header}
866
+
867
+ namespace ${namespace}
868
+ {
869
+ public static class RoleNames
870
+ {
871
+ ${roleNames}
872
+ }
873
+ }
874
+ `;
875
+
838
876
 
839
877
  const refactorHelperFileContent = `${header}
840
878
 
@@ -867,6 +905,7 @@ ${strJobReferences}
867
905
 
868
906
  fs.writeFileSync(aliasProject.output + "/DbConnector.cs", dbConnectorFileContent);
869
907
  fs.writeFileSync(aliasProject.output + "/ResourceNames.cs", resourceNamesFileContent);
908
+ fs.writeFileSync(aliasProject.output + "/RoleNames.cs", roleNamesFileContent);
870
909
  fs.writeFileSync(aliasProject.output + "/RefactorHelper.cs", refactorHelperFileContent);
871
910
  fs.writeFileSync(aliasProject.output + "/Info.cs", infoFileContent);
872
911
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.1.0-alpha.13",
3
+ "version": "1.1.0-alpha.14",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "mr.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@
17
17
  "author": "suco2007",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "jsdom": "^19.0.0",
20
+ "jsdom": "^20.0.0",
21
21
  "json5": "^2.2.1",
22
22
  "node-fetch": "^2.6.7",
23
23
  "open": "^8.4.0",