mushroom-cli 1.2.0 → 1.2.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 CHANGED
@@ -132,15 +132,30 @@ npx mushroom-cli parameters --no-check-update
132
132
 
133
133
  ## Version
134
134
 
135
+ ### 1.2.2
136
+
137
+ New features:
138
+
139
+ - gen ts-driver, js-driver: adding binaryResponse to `_raw_http_method_` actions
140
+
141
+ ### 1.2.1
142
+
143
+ Improvement/Changes:
144
+
145
+ - gen docs: fix bugs
146
+ - gen c#-mongo: fix signarute for RegisterCustomViewMethod method
147
+ - init netcore:
148
+ - change: show warning message when replacing content in unexisting file (instead of throwing error)
149
+
135
150
  ### 1.2.0
136
151
 
137
152
  New features:
138
153
 
139
154
  - Support merge command
140
155
  - Support type for View result
141
- - gen-ts-driver: Support offline mode
156
+ - gen ts-driver: Support offline mode
142
157
  - init netcore: Support some new set-functions: `ToLowerCase`, `ToUpperCase`, `Trim`, `Replace`, `New-RandomNumber`, `New-RandomString`
143
- - gen-docs: New gen docs engine v1.2 - deal with very big api docs
158
+ - gen docs: New gen docs engine v1.2 - deal with very big api docs
144
159
  - support minify
145
160
  - allow user to add and change API root url
146
161
  - add `JavascriptParamModel`, `JavascriptRequestBodyModel`, `JavascriptResultModel` tab in code snippets of custom methods
@@ -183,7 +198,7 @@ Fixed bugs:
183
198
  - gen docs
184
199
  - Generate wrong required field for view parameter
185
200
  - doesn't exclude fields of object in an array
186
- - gen-ts
201
+ - gen ts-driver
187
202
  - add null value for nullable field type
188
203
 
189
204
  ### 1.1.1
package/dist/common.js CHANGED
@@ -260,10 +260,14 @@ function processReplaceCommand(command, basePath, variables) {
260
260
  const pattern = new RegExp(command.pattern ?? '', 'g');
261
261
  const replacement = replaceVariables(command.replacement ?? '', variables);
262
262
  files.forEach((file) => {
263
- const filePath = replaceVariables(file, variables);
264
- let content = fs.readFileSync(path.join(basePath, filePath)).toString();
263
+ const filePath = path.join(basePath, replaceVariables(file, variables));
264
+ if (!fs.existsSync(filePath)) {
265
+ console.warn(`File ${file} does not exist, skipping...`);
266
+ return;
267
+ }
268
+ let content = fs.readFileSync(filePath).toString();
265
269
  content = content.replace(pattern, () => replacement);
266
- fs.writeFileSync(path.join(basePath, filePath), content);
270
+ fs.writeFileSync(filePath, content);
267
271
  });
268
272
  }
269
273
  function replaceVariables(str, variables) {
@@ -376,7 +376,7 @@
376
376
  <div class="panel panel-primary" id="extension-env-vars-user_id">
377
377
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$env-vars.user_id">
378
378
  <span>$$user_id</span>
379
- <span class="description">[Builtin] Mã người dùng hiện tại</span>
379
+ <span class="description">[Built-in] Mã người dùng hiện tại</span>
380
380
  </div>
381
381
  <div class="panel-body">
382
382
  <div>
@@ -388,7 +388,7 @@
388
388
  <div class="panel panel-primary" id="extension-env-vars-user_ip">
389
389
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$env-vars.user_ip">
390
390
  <span>$$user_ip</span>
391
- <span class="description">[Builtin] IP của người dùng hiện tại</span>
391
+ <span class="description">[Built-in] IP của người dùng hiện tại</span>
392
392
  </div>
393
393
  <div class="panel-body">
394
394
  <div>
@@ -400,7 +400,7 @@
400
400
  <div class="panel panel-primary" id="extension-env-vars-now">
401
401
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$env-vars.now">
402
402
  <span>$$now</span>
403
- <span class="description">[Builtin] Thời điểm hiện tại</span>
403
+ <span class="description">[Built-in] Thời điểm hiện tại</span>
404
404
  </div>
405
405
  <div class="panel-body">
406
406
  <div>
@@ -448,7 +448,7 @@
448
448
  <div class="panel panel-primary" id="extension-env-vars-today">
449
449
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$env-vars.today">
450
450
  <span>$$today</span>
451
- <span class="description">[Builtin] Ngày hôm nay</span>
451
+ <span class="description">[Built-in] Ngày hôm nay</span>
452
452
  </div>
453
453
  <div class="panel-body">
454
454
  <div>
@@ -496,7 +496,7 @@
496
496
  <div class="panel panel-primary" id="extension-env-vars-hash">
497
497
  <div class="panel-heading" onclick="toggleParentClass.call(this)" data-toggled-class="show" data-hash="$env-vars.hash">
498
498
  <span>$$hash:value</span>
499
- <span class="description">[Builtin] Băm giá trị</span>
499
+ <span class="description">[Built-in] Băm giá trị</span>
500
500
  </div>
501
501
  <div class="panel-body">
502
502
  <div>
@@ -2779,7 +2779,7 @@ catch (error) {
2779
2779
 
2780
2780
  <div class="mushroom-docs-template" id="template-project-entity">
2781
2781
  <div class="entity" id="entity-{{name}}">
2782
- <h2 data-hash="{{name}}" onclick="renderEntity.call(this, '{{name}}'); toggleParentClass.call(this)" data-toggled-class="expand">
2782
+ <h2 data-hash="{{name}}" title="{{name}} - {{description}}" onclick="renderEntity.call(this, '{{name}}'); toggleParentClass.call(this)" data-toggled-class="expand">
2783
2783
  <span class="entity-name">{{name}}</span>
2784
2784
  <span class="copy" title="Copy" data-copy=".entity-name" onclick="doCopy.call(this, event)"></span>
2785
2785
  <div class="description">{{description}}</div>
@@ -5127,7 +5127,8 @@ API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
5127
5127
  <div class="panel panel-primary" id="action-{{entityName}}-views-{{viewName}}">
5128
5128
  <div class="panel-heading" onclick="renderEntityView.call(this, '{{entityName}}', '{{viewName}}'); toggleParentClass.call(this)" data-toggled-class="show" data-hash="{{entityName}}.views.{{viewName}}">
5129
5129
  <span>GET</span>
5130
- <span>{{actionApiUrl}}</span>
5130
+ <span class="contain-root-url">{{actionApiUrl}}</span>
5131
+ <span class="copy" title="Copy" data-copy=".contain-root-url" onclick="doCopy.call(this, event)"></span>
5131
5132
  <span class="description">{{description}}</span>
5132
5133
  </div>
5133
5134
  <div class="panel-body">
@@ -30,11 +30,11 @@ function renderTemplate(templateId, data) {
30
30
  }
31
31
 
32
32
  function getApiDomain(url) {
33
- const m = url.match(/^(\w+:)?\/\/(([\w-]+\.)+\w+(:\d+)?)/);
33
+ const m = url.match(/^(\w+:)?\/\/(([\w-]+\.)*\w+(:\d+)?)/);
34
34
  return m ? m[2] : 'your host';
35
35
  }
36
36
  function getApiPath(url) {
37
- const m = url.match(/^(\w+:)?\/\/([\w-]+\.)+\w+(:\d+)?/);
37
+ const m = url.match(/^(\w+:)?\/\/([\w-]+\.)*\w+(:\d+)?/);
38
38
  return m ? url.substring(m[0].length) : url;
39
39
  }
40
40
 
@@ -1750,6 +1750,7 @@ window.codeSnippets = {
1750
1750
  renderTemplate('template-codeSnippets-view-cURL', {
1751
1751
  rootUrl: localStorage.selected_root_url,
1752
1752
  entityName: args.entityName,
1753
+ viewName: args.viewName,
1753
1754
  tokenDisplay: args.view.grant !== '*' ? 'inline' : 'none',
1754
1755
  parameters: args.view.parameters
1755
1756
  ? '?' +
@@ -481,7 +481,7 @@ namespace ${namespace}.CodeHelper
481
481
  private void RegisterCustomMethod(System.Func<Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
482
482
  private void RegisterCustomMethod(System.Action<Mushroom.ActionArguments> fn) { }
483
483
  private void RegisterCustomViewMethod(System.Func<Mushroom.ViewArguments, System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<object>>> fn) { }
484
- private void RegisterCustomViewMethod(System.Action<Mushroom.ViewArguments> fn) { }
484
+ private void RegisterCustomViewMethod(System.Func<Mushroom.ViewArguments, System.Collections.Generic.IEnumerable<object>> fn) { }
485
485
  private void RegisterCustomVnTextBuilderMethod(System.Func<System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.IEnumerable<string>> fn) { }
486
486
  private void RegisterEvent(System.Func<object, Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
487
487
  private void RegisterEvent(System.Action<object, Mushroom.ActionArguments> fn) { }
@@ -838,7 +838,7 @@ namespace ${namespace}
838
838
  private void RegisterCustomMethod(System.Func<Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
839
839
  private void RegisterCustomMethod(System.Action<Mushroom.ActionArguments> fn) { }
840
840
  private void RegisterCustomViewMethod(System.Func<Mushroom.ViewArguments, System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<object>>> fn) { }
841
- private void RegisterCustomViewMethod(System.Action<Mushroom.ViewArguments> fn) { }
841
+ private void RegisterCustomViewMethod(System.Func<Mushroom.ViewArguments, System.Collections.Generic.IEnumerable<object>> fn) { }
842
842
  private void RegisterCustomVnTextBuilderMethod(System.Func<System.Collections.Generic.IEnumerable<string>, System.Collections.Generic.IEnumerable<string>> fn) { }
843
843
  private void RegisterEvent(System.Func<object, Mushroom.ActionArguments, System.Threading.Tasks.Task> fn) { }
844
844
  private void RegisterEvent(System.Action<object, Mushroom.ActionArguments> fn) { }
@@ -66,6 +66,7 @@ exports.extensions = extensions;
66
66
  let clientCache = undefined;
67
67
  let includeTotal = undefined;
68
68
  let offlineMode = undefined;
69
+ let binaryResponse = undefined;
69
70
  if ((actionName === 'findById' || actionName === 'findMany') && entity.actions[actionName]) {
70
71
  if (isAllowCache(entity.actions[actionName], true))
71
72
  clientCache = true;
@@ -77,10 +78,16 @@ exports.extensions = extensions;
77
78
  entity.actions[actionName].some((a) => a.offlineMode === 'allow'))
78
79
  offlineMode = 'allow';
79
80
  }
81
+ else if (actionName.indexOf('_raw_http_method_') === 0) {
82
+ if (entity.actions[actionName]?.some((action) => action.codeHint?.delegator?.isBinaryResponse)) {
83
+ binaryResponse = true;
84
+ }
85
+ }
80
86
  actions[actionName] = {
81
87
  clientCache,
82
88
  includeTotal,
83
89
  offlineMode,
90
+ binaryResponse,
84
91
  };
85
92
  }
86
93
  const views = {};
@@ -356,6 +356,9 @@ export interface CustomMethodBodyRequest<TBody> extends MushroomRequest {
356
356
  const customCode = generateCustomMethodCode(entityName, actionName, entity.actions[actionName]);
357
357
  customMethodCode += customCode.methodCode;
358
358
  code += customCode.classesCode;
359
+ if (entity.actions[actionName]?.some((action) => action.codeHint?.delegator?.isBinaryResponse)) {
360
+ actions[actionName].binaryResponse = true;
361
+ }
359
362
  break;
360
363
  }
361
364
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "dist/mr.js",
6
6
  "type": "module",
@@ -42,21 +42,21 @@
42
42
  "targz": "^1.0.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@eslint/js": "^9.28.0",
45
+ "@eslint/js": "^9.34.0",
46
46
  "@types/jsdom": "^21.1.7",
47
47
  "@types/minify": "^9.1.4",
48
48
  "@types/node": "^22.15.29",
49
- "@types/node-fetch": "^2.6.12",
49
+ "@types/node-fetch": "^2.6.13",
50
50
  "@types/readline-sync": "^1.4.8",
51
51
  "@types/targz": "^1.0.5",
52
52
  "copyfiles": "^2.4.1",
53
- "eslint": "^9.28.0",
53
+ "eslint": "^9.34.0",
54
54
  "husky": "^9.1.7",
55
55
  "lint-staged": "^16.1.0",
56
56
  "only-allow": "^1.2.1",
57
57
  "prettier": "^3.5.3",
58
58
  "typescript": "^5.8.3",
59
- "typescript-eslint": "^8.33.0"
59
+ "typescript-eslint": "^8.41.0"
60
60
  },
61
61
  "engines": {
62
62
  "node": ">=14.0.0"