mushroom-cli 1.1.0-alpha.20 → 1.1.0-alpha.21

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/common.js CHANGED
@@ -203,7 +203,8 @@ function processDeleteCommand(command, basePath, variables) {
203
203
 
204
204
  const deletedPath = path.join(basePath, input);
205
205
  if (fs.lstatSync(deletedPath).isDirectory()) {
206
- fs.rmdirSync(deletedPath, {recursive: true, force: true});
206
+ // fs.rmdirSync(deletedPath, {recursive: true, force: true});
207
+ fs.rmSync(deletedPath, {recursive: true, force: true});
207
208
  }
208
209
  else {
209
210
  fs.rmSync(deletedPath, {force: true});
package/docs/docs.html CHANGED
@@ -333,6 +333,9 @@
333
333
  </div>
334
334
  <div data-mt-cond='{"entity.features.vn_text.fields.length": {"$gt": 0}}'>
335
335
  Cho phép tìm kiếm tiếng Việt không dấu, không phân biệt hoa thường trên <span data-mt-cond='{"entity.features.vn_text.fields.length": {"$gt": 1}}'>các</span> trường: <code class="separated-items" data-mt-iterate='{"data": "$entity.features.vn_text.fields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">, </span></code>
336
+ <ul data-mt-cond='{"entity.features.vn_text.channels.length": {"$gt": 0}}' data-mt-iterate='{"data": "$entity.features.vn_text.channels"}'>
337
+ <li>Cho phép tìm kiếm theo kênh <code data-mt-attr='{"text": "$name"}'></code> trên <span data-mt-cond='{"fields.length": {"$gt": 1}}'>các</span> trường: <code class="separated-items" data-mt-iterate='{"data": "$fields"}'><span data-mt-attr='{"text": "$this"}'></span><span class="separator">, </span></code></li>
338
+ </ul>
336
339
  </div>
337
340
  <div data-mt-cond='{"action.requiredFilteringFields": {"$exists": true}}'>
338
341
  Bắt buộc phải lọc theo các trường:
@@ -3052,7 +3055,45 @@ password: string, required</pre>
3052
3055
  token: string
3053
3056
  }</pre><br />
3054
3057
  Thất bại:<br />
3055
- Http Status Code: <code>403</code>
3058
+ Http Status Code: <code>403</code><br />
3059
+ Mushroom code:
3060
+ <ul>
3061
+ <li>
3062
+ -1: Có lỗi nói chung (Mushroom Auth từ 1.5.0 trở về trước)
3063
+ </li>
3064
+ <li>
3065
+ 37000: đăng nhập thất bại (do sai account hoặc password) (Mushroom Auth từ 1.6.0 trở lên)
3066
+ <ul>
3067
+ <li>
3068
+ Nếu vẫn còn login quota
3069
+ <ul>
3070
+ <li>meta.remainingCount: number là số lượng quota còn lại</li>
3071
+ </ul>
3072
+ </li>
3073
+ <li>
3074
+ Nếu hết login quota
3075
+ <ul>
3076
+ <li>subCode:1</li>
3077
+ <li>meta.locked: true</li>
3078
+ <li>meta.lockedTime: datetime</li>
3079
+ <li>meta.lockedReason: string</li>
3080
+ <li>meta.releaseTime: datetime</li>
3081
+ <li>meta.serverTime: datatime</li>
3082
+ </ul>
3083
+ </li>
3084
+ </ul>
3085
+ </li>
3086
+ <li>
3087
+ 37001: khi tài khoản bị tạm khóa (đã hết login quota) (Mushroom Auth từ 1.6.0 trở lên)
3088
+ <ul>
3089
+ <li>meta.locked: true</li>
3090
+ <li>meta.lockedTime: datetime</li>
3091
+ <li>meta.lockedReason: string</li>
3092
+ <li>meta.releaseTime: datetime</li>
3093
+ <li>meta.serverTime: datatime</li>
3094
+ </ul>
3095
+ </li>
3096
+ </ul>
3056
3097
  </div>
3057
3098
 
3058
3099
  <div class="driver-snippet">
@@ -102,7 +102,7 @@ async function genDocs(args, projectName, project, alias, source) {
102
102
  const aliasProject = ((project.docs || {}).alias || {})[alias];
103
103
 
104
104
  if (!aliasProject) {
105
- throw new Error(`Not found gen docs configuration. Please run 'npx mr config ${projectName} gen docs OUTPUT_FILE.html${alias === "default" ? "" : " alias " + alias}' first`);
105
+ throw new Error(`Not found gen docs configuration. Please run 'npx mushroom-cli config ${projectName} gen docs OUTPUT_FILE.html${alias === "default" ? "" : " alias " + alias}' first`);
106
106
  }
107
107
 
108
108
  const entities = common.getEntities(source, aliasProject.allowRoles);
package/gen/gen-csharp.js CHANGED
@@ -269,7 +269,7 @@ function genCSharpMongoDbClasses(args, projectName, project, alias, source) {
269
269
  const aliasProject = ((project.csharpMongo || {}).alias || {})[alias];
270
270
 
271
271
  if (!aliasProject) {
272
- throw new Error(`Not found gen c#-mongo configuration. Please run 'npx mr config ${projectName} gen c#-mongo OUTPUT_FILE.cs${alias === "default" ? "" : " alias " + alias}' first`);
272
+ throw new Error(`Not found gen c#-mongo configuration. Please run 'npx mushroom-cli config ${projectName} gen c#-mongo OUTPUT_FILE.cs${alias === "default" ? "" : " alias " + alias}' first`);
273
273
  }
274
274
 
275
275
  if (aliasProject.outputToFolder) {
@@ -382,6 +382,25 @@ function genCSharpMongoDbClasses(args, projectName, project, alias, source) {
382
382
  }
383
383
  });
384
384
  }
385
+
386
+ const channels = entities[entityName].features?.vn_text?.channels;
387
+ if (channels != null) {
388
+ channels.forEach(channel => {
389
+ if (!channel.nativeBuilder || typeof channel.nativeBuilder !== "string" || channel.nativeBuilder.indexOf("lib:") !== 0) return;
390
+
391
+ out.vnTextChannels = out.vnTextChannels || [];
392
+ const method = channel.nativeBuilder.substr(4, channel.nativeBuilder.length - 4);
393
+ let type = channel.codeHint && channel.codeHint.nativeBuilder && channel.codeHint.nativeBuilder.csharp
394
+ ? channel.codeHint.nativeBuilder.csharp.methodType
395
+ : null;
396
+ if (type !== "non-static") type = "static";
397
+ out.vnTextChannels.push({
398
+ method: method,
399
+ source: `entity: ${entityName}, feature: vn_text, channel: ${channel.name}`,
400
+ type: type
401
+ });
402
+ });
403
+ }
385
404
  }
386
405
 
387
406
  if (out.strEnumClasses)
@@ -413,6 +432,19 @@ function genCSharpMongoDbClasses(args, projectName, project, alias, source) {
413
432
  }, {});
414
433
  const strViewHandlerReferences = Object.keys(viewHandlers).map(method => viewHandlers[method].map(ev => ` // ${ev.source}`).join(newLine) + newLine + ` RegisterCustomViewMethod(${getCSharpFunc(method, viewHandlers[method][0].type)});`).join(newLine);
415
434
 
435
+ const vnTextChannels = (out.vnTextChannels || []).reduce((prev, cur) => {
436
+ if (cur.method in prev) {
437
+ if (prev[cur.method].indexOf(cur.source) === -1) {
438
+ prev[cur.method].push(cur);
439
+ }
440
+ }
441
+ else {
442
+ prev[cur.method] = [cur];
443
+ }
444
+ return prev;
445
+ }, {});
446
+ const strVnTextChannels = Object.keys(vnTextChannels).map(method => vnTextChannels[method].map(channel => ` // ${channel.source}`).join(newLine) + newLine + ` RegisterCustomVnTextBuilderMethod(${getCSharpFunc(method, vnTextChannels[method][0].type)});`).join(newLine);
447
+
416
448
  const eventHandlers = (out.eventHandlers || []).reduce((prev, cur) => {
417
449
  if (cur.method in prev) {
418
450
  if (prev[cur.method].indexOf(cur.source) === -1) {
@@ -507,6 +539,7 @@ namespace ${namespace}.CodeHelper
507
539
  private void RegisterCustomMethod(System.Action<Mushroom.ActionArguments> fn) { }
508
540
  private void RegisterCustomViewMethod(System.Func<Mushroom.ViewArguments, System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<object>>> fn) { }
509
541
  private void RegisterCustomViewMethod(System.Action<Mushroom.ViewArguments> fn) { }
542
+ private void RegisterCustomVnTextBuilderMethod(System.Func<System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.IEnumerable<string>> fn) { }
510
543
  private void RegisterEvent(System.Func<object, Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
511
544
  private void RegisterEvent(System.Action<object, Mushroom.ActionArguments> fn) { }
512
545
  private void RegisterJob<T>() where T : Mushroom.Job.JobBase { }
@@ -514,6 +547,7 @@ namespace ${namespace}.CodeHelper
514
547
  {
515
548
  ${strDelegatorReferences}
516
549
  ${strViewHandlerReferences}
550
+ ${strVnTextChannels}
517
551
  ${strEventHandlerReferences}
518
552
  ${strJobReferences}
519
553
  }
@@ -674,7 +708,8 @@ function genCSharpMongoDbClassesToFolder(projectName, alias, source, aliasProjec
674
708
  fs.unlinkSync(aliasProject.output); // xóa file nếu có
675
709
  } catch(e) {}
676
710
  try {
677
- fs.rmdirSync(aliasProject.output, { recursive: true, force: true }); // xóa thư mục nếu có
711
+ // fs.rmdirSync(aliasProject.output, { recursive: true, force: true }); // xóa thư mục nếu có
712
+ fs.rmSync(aliasProject.output, { recursive: true, force: true }); // xóa thư mục nếu có
678
713
  } catch(e) {}
679
714
  }
680
715
  fs.mkdirSync(aliasProject.output, { recursive: true, mode: 0755 });
@@ -785,6 +820,25 @@ function genCSharpMongoDbClassesToFolder(projectName, alias, source, aliasProjec
785
820
  }
786
821
  });
787
822
  }
823
+
824
+ const channels = entities[entityName].features?.vn_text?.channels;
825
+ if (channels != null) {
826
+ channels.forEach(channel => {
827
+ if (!channel.nativeBuilder || typeof channel.nativeBuilder !== "string" || channel.nativeBuilder.indexOf("lib:") !== 0) return;
828
+
829
+ out.vnTextChannels = out.vnTextChannels || [];
830
+ const method = channel.nativeBuilder.substr(4, channel.nativeBuilder.length - 4);
831
+ let type = channel.codeHint && channel.codeHint.nativeBuilder && channel.codeHint.nativeBuilder.csharp
832
+ ? channel.codeHint.nativeBuilder.csharp.methodType
833
+ : null;
834
+ if (type !== "non-static") type = "static";
835
+ out.vnTextChannels.push({
836
+ method: method,
837
+ source: `entity: ${entityName}, feature: vn_text, channel: ${channel.name}`,
838
+ type: type
839
+ });
840
+ });
841
+ }
788
842
  }
789
843
 
790
844
 
@@ -814,6 +868,19 @@ function genCSharpMongoDbClassesToFolder(projectName, alias, source, aliasProjec
814
868
  }, {});
815
869
  const strViewHandlerReferences = Object.keys(viewHandlers).map(method => viewHandlers[method].map(ev => ` // ${ev.source}`).join(newLine) + newLine + ` RegisterCustomViewMethod(${getCSharpFunc(method, viewHandlers[method][0].type)});`).join(newLine);
816
870
 
871
+ const vnTextChannels = (out.vnTextChannels || []).reduce((prev, cur) => {
872
+ if (cur.method in prev) {
873
+ if (prev[cur.method].indexOf(cur.source) === -1) {
874
+ prev[cur.method].push(cur);
875
+ }
876
+ }
877
+ else {
878
+ prev[cur.method] = [cur];
879
+ }
880
+ return prev;
881
+ }, {});
882
+ const strVnTextChannels = Object.keys(vnTextChannels).map(method => vnTextChannels[method].map(channel => ` // ${channel.source}`).join(newLine) + newLine + ` RegisterCustomVnTextBuilderMethod(${getCSharpFunc(method, vnTextChannels[method][0].type)});`).join(newLine);
883
+
817
884
  const eventHandlers = (out.eventHandlers || []).reduce((prev, cur) => {
818
885
  if (cur.method in prev) {
819
886
  if (prev[cur.method].indexOf(cur.source) === -1) {
@@ -901,6 +968,7 @@ namespace ${namespace}
901
968
  private void RegisterCustomMethod(System.Action<Mushroom.ActionArguments> fn) { }
902
969
  private void RegisterCustomViewMethod(System.Func<Mushroom.ViewArguments, System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<object>>> fn) { }
903
970
  private void RegisterCustomViewMethod(System.Action<Mushroom.ViewArguments> fn) { }
971
+ private void RegisterCustomVnTextBuilderMethod(System.Func<System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.IEnumerable<string>> fn) { }
904
972
  private void RegisterEvent(System.Func<object, Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
905
973
  private void RegisterEvent(System.Action<object, Mushroom.ActionArguments> fn) { }
906
974
  private void RegisterJob<T>() where T : Mushroom.Job.JobBase { }
@@ -908,6 +976,7 @@ namespace ${namespace}
908
976
  {
909
977
  ${strDelegatorReferences}
910
978
  ${strViewHandlerReferences}
979
+ ${strVnTextChannels}
911
980
  ${strEventHandlerReferences}
912
981
  ${strJobReferences}
913
982
  }
@@ -991,7 +1060,7 @@ function genCSharpDriver(args, projectName, project, alias, source) {
991
1060
  const aliasProject = ((project.csharpDriver || {}).alias || {})[alias];
992
1061
 
993
1062
  if (!aliasProject) {
994
- throw new Error(`Not found gen c#-driver configuration. Please run 'npx mr config ${projectName} gen c#-driver OUTPUT_FILE.cs${alias === "default" ? "" : " alias " + alias}' first`);
1063
+ 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`);
995
1064
  }
996
1065
 
997
1066
  const entities = common.getEntities(source, aliasProject.allowRoles);
@@ -175,7 +175,7 @@ function genDatabaseDocs(args, projectName, project, alias, source) {
175
175
  const aliasProject = ((project.dbDocs || {}).alias || {})[alias];
176
176
 
177
177
  if (!aliasProject) {
178
- throw new Error(`Not found gen db-docs configuration. Please run 'npx mr config ${projectName} gen db-docs OUTPUT_FILE.html${alias === "default" ? "" : " alias " + alias}' first`);
178
+ 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`);
179
179
  }
180
180
 
181
181
  const entities = common.getEntities(source, aliasProject.allowRoles, true);
@@ -63,7 +63,8 @@ async function genJavascriptDriverTarball(args, projectName, project, alias, sou
63
63
 
64
64
  if (fs.existsSync(dirPath)) {
65
65
  console.log("Clean up tarball folder");
66
- fs.rmdirSync(dirPath, { recursive: true });
66
+ // fs.rmdirSync(dirPath, { recursive: true });
67
+ fs.rmSync(dirPath, { recursive: true });
67
68
  }
68
69
 
69
70
  const tarballFileName = path.join(path.dirname(aliasProject.output), tarballName + ".tar.gz");
@@ -92,7 +93,8 @@ async function genJavascriptDriverTarball(args, projectName, project, alias, sou
92
93
  await compressAsync(dirPath, tarballFileName, tarballName);
93
94
 
94
95
  console.log("Generated tarball file");
95
- fs.rmdirSync(dirPath, { recursive: true });
96
+ // fs.rmdirSync(dirPath, { recursive: true });
97
+ fs.rmSync(dirPath, { recursive: true });
96
98
  console.log("Cleaned up tarball folder");
97
99
  }
98
100
 
@@ -109,7 +109,7 @@ function genJavascriptDriver(args, projectName, project, alias, source) {
109
109
  const aliasProject = ((project.jsDriver || {}).alias || {})[alias];
110
110
 
111
111
  if (!aliasProject) {
112
- throw new Error(`Not found gen js-driver configuration. Please run 'npx mr config gen ${projectName} js-driver OUTPUT_FILE.js${alias === "default" ? "" : " alias " + alias}' first`);
112
+ throw new Error(`Not found gen js-driver configuration. Please run 'npx mushroom-cli config gen ${projectName} js-driver OUTPUT_FILE.js${alias === "default" ? "" : " alias " + alias}' first`);
113
113
  }
114
114
 
115
115
  let code = genJavascriptDriverString(aliasProject, source);
@@ -432,7 +432,7 @@ function genTypescriptDriver(args, projectName, project, alias, source) {
432
432
  const aliasProject = ((project.tsDriver || {}).alias || {})[alias];
433
433
 
434
434
  if (!aliasProject) {
435
- throw new Error(`Not found gen ts-driver configuration. Please run 'npx mr config gen ${projectName} ts-driver OUTPUT_FILE.ts${alias === "default" ? "" : " alias " + alias}' first`);
435
+ throw new Error(`Not found gen ts-driver configuration. Please run 'npx mushroom-cli config gen ${projectName} ts-driver OUTPUT_FILE.ts${alias === "default" ? "" : " alias " + alias}' first`);
436
436
  }
437
437
 
438
438
  const code = genTypescriptDriverString(aliasProject, source);
package/help.js CHANGED
@@ -10,46 +10,46 @@ function help(key, wrong) {
10
10
  }
11
11
  else
12
12
  console.log(`Init a mushroom json file
13
- npx mr init json ./api/SampleProject.json [silent]
13
+ npx mushroom-cli init json ./api/SampleProject.json [silent]
14
14
 
15
15
  Init a dotnet core project which pre-install Mushroom Server
16
- npx mr init netcore
16
+ npx mushroom-cli init netcore
17
17
 
18
18
  Add the mushroom json file into mushroom-config.json
19
- npx mr config add ./api/yourProjectName.json
19
+ npx mushroom-cli config add ./api/yourProjectName.json
20
20
 
21
21
  Config gen docs api
22
- npx mr config gen projectName docs ./wwwroot/docs.html [alias aliasName] [features file,auth,mail,driver] [roles Admin,User-Contributor]
22
+ npx mushroom-cli config gen projectName docs ./wwwroot/docs.html [alias aliasName] [features file,auth,mail,driver] [roles Admin,User-Contributor]
23
23
 
24
24
  Generate docs api (html format)
25
- npx mr gen projectName[@aliasName] docs [tmp]
25
+ npx mushroom-cli gen projectName[@aliasName] docs [tmp]
26
26
 
27
27
  Config gen database docs
28
- npx mr config gen projectName db-docs ./wwwroot/db-docs.html [alias aliasName] [features file,auth,mail]
28
+ npx mushroom-cli config gen projectName db-docs ./wwwroot/db-docs.html [alias aliasName] [features file,auth,mail]
29
29
 
30
30
  Generate database docs (html format)
31
- npx mr gen projectName[@aliasName] db-docs [tmp]
31
+ npx mushroom-cli gen projectName[@aliasName] db-docs [tmp]
32
32
 
33
33
  Config gen javascript driver
34
- npx mr config gen projectName js-driver ./src/api/mushroom.api.js [alias aliasName] [roles Admin,User-Contributor] [tarball tarballName]
34
+ npx mushroom-cli config gen projectName js-driver ./src/api/mushroom.api.js [alias aliasName] [roles Admin,User-Contributor] [tarball tarballName]
35
35
 
36
36
  Generate javascript driver
37
- npx mr gen projectName[@aliasName] js-driver
37
+ npx mushroom-cli gen projectName[@aliasName] js-driver
38
38
 
39
39
  Config gen entities for Mushroom project in CSharp and using MongoDb
40
- npx mr config gen projectName c#-mongo ./API/Generated.cs [alias aliasName]
40
+ npx mushroom-cli config gen projectName c#-mongo ./API/Generated.cs [alias aliasName]
41
41
 
42
42
  Generate entities for Mushroom project in CSharp and using MongoDb
43
- npx mr gen projectName[@aliasName] c#-mongo
43
+ npx mushroom-cli gen projectName[@aliasName] c#-mongo
44
44
 
45
45
  Config gen entities for CSharp project which calls Mushroom API
46
- npx mr config gen projectName c#-driver ./API/Generated.cs [roles Admin,User-Contributor] [alias aliasName]
46
+ npx mushroom-cli config gen projectName c#-driver ./API/Generated.cs [roles Admin,User-Contributor] [alias aliasName]
47
47
 
48
48
  Generate entities for CSharp project which calls Mushroom API
49
- npx mr gen projectName[@aliasName] c#-driver
49
+ npx mushroom-cli gen projectName[@aliasName] c#-driver
50
50
 
51
51
  Disable checking for update:
52
- npx mr parameters --no-check-update`);
52
+ npx mushroom-cli parameters --no-check-update`);
53
53
  }
54
54
 
55
55
  module.exports = help;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.1.0-alpha.20",
3
+ "version": "1.1.0-alpha.21",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "mr.js",
6
6
  "scripts": {