mushroom-cli 1.1.0-alpha.10 → 1.1.0-alpha.11
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 +1 -1
- package/config.js +8 -8
- package/gen/gen-api-docs.js +1 -1
- package/gen/gen-csharp.js +7 -7
- package/gen/gen-js-driver.js +18 -6
- package/gen/gen-ts-driver.js +3 -3
- package/gen.js +2 -2
- package/master-file/master-file.js +2 -2
- package/package.json +1 -1
package/common.js
CHANGED
package/config.js
CHANGED
|
@@ -75,8 +75,8 @@ function configGenDocs(args, mushroomConfig, projectName){
|
|
|
75
75
|
const strRoles = args[index];
|
|
76
76
|
if (strRoles) {
|
|
77
77
|
const minusIndex = strRoles.indexOf("-");
|
|
78
|
-
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.
|
|
79
|
-
const deniedRoles = minusIndex == -1 ? "" : strRoles.
|
|
78
|
+
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
79
|
+
const deniedRoles = minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
80
80
|
if (!grantedRoles)
|
|
81
81
|
grantedRoles = "*";
|
|
82
82
|
parameters.allowRoles = grantedRoles.split(",");
|
|
@@ -173,8 +173,8 @@ function configGenJavascriptDriver(args, mushroomConfig, projectName){
|
|
|
173
173
|
const strRoles = args[index];
|
|
174
174
|
if (strRoles) {
|
|
175
175
|
const minusIndex = strRoles.indexOf("-");
|
|
176
|
-
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.
|
|
177
|
-
const deniedRoles = minusIndex == -1 ? "" : strRoles.
|
|
176
|
+
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
177
|
+
const deniedRoles = minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
178
178
|
if (!grantedRoles)
|
|
179
179
|
grantedRoles = "*";
|
|
180
180
|
parameters.allowRoles = grantedRoles.split(",");
|
|
@@ -233,8 +233,8 @@ function configGenTypescriptDriver(args, mushroomConfig, projectName){
|
|
|
233
233
|
const strRoles = args[index];
|
|
234
234
|
if (strRoles) {
|
|
235
235
|
const minusIndex = strRoles.indexOf("-");
|
|
236
|
-
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.
|
|
237
|
-
const deniedRoles = minusIndex == -1 ? "" : strRoles.
|
|
236
|
+
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
237
|
+
const deniedRoles = minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
238
238
|
if (!grantedRoles)
|
|
239
239
|
grantedRoles = "*";
|
|
240
240
|
parameters.allowRoles = grantedRoles.split(",");
|
|
@@ -325,8 +325,8 @@ function configGenCSharpDriver(args, mushroomConfig, projectName){
|
|
|
325
325
|
const strRoles = args[index];
|
|
326
326
|
if (strRoles) {
|
|
327
327
|
const minusIndex = strRoles.indexOf("-");
|
|
328
|
-
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.
|
|
329
|
-
const deniedRoles = minusIndex == -1 ? "" : strRoles.
|
|
328
|
+
let grantedRoles = minusIndex == -1 ? strRoles : strRoles.substring(0, minusIndex);
|
|
329
|
+
const deniedRoles = minusIndex == -1 ? "" : strRoles.substring(minusIndex + 1);
|
|
330
330
|
if (!grantedRoles)
|
|
331
331
|
grantedRoles = "*";
|
|
332
332
|
parameters.allowRoles = grantedRoles.split(",");
|
package/gen/gen-api-docs.js
CHANGED
|
@@ -38,7 +38,7 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
|
|
|
38
38
|
if (typeof msg != "string") return;
|
|
39
39
|
|
|
40
40
|
if (msg.indexOf("MUSHROOM-CLI:") === 0) {
|
|
41
|
-
console.log("GenDocEngine:" + msg.
|
|
41
|
+
console.log("GenDocEngine:" + msg.substring("MUSHROOM-CLI:".length));
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
if (msg === "MUSHROOM-CLI: FAIL"){
|
package/gen/gen-csharp.js
CHANGED
|
@@ -25,7 +25,7 @@ function toCSharpName(str) {
|
|
|
25
25
|
return "_";
|
|
26
26
|
const name = toVietnameseNonTongue(str).replace(/\W/g, "_");
|
|
27
27
|
const c = name.charAt(0);
|
|
28
|
-
return ('0' <= c && c <= '9' ? '_' : "") + c.toUpperCase() + name.
|
|
28
|
+
return ('0' <= c && c <= '9' ? '_' : "") + c.toUpperCase() + name.substring(1);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function getCSharpTypeFromMushroomType(source, type, required) {
|
|
@@ -240,7 +240,7 @@ function getCSharpFunc(methodName, methodType) {
|
|
|
240
240
|
if (methodType === "static") return methodName;
|
|
241
241
|
const idx = methodName.lastIndexOf('.');
|
|
242
242
|
if (idx === -1) return methodName;
|
|
243
|
-
return `new ${methodName.
|
|
243
|
+
return `new ${methodName.substring(0, idx)}()${methodName.substring(idx)}`;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
function genCSharpMongoDbClasses(args, projectName, project, alias, source) {
|
|
@@ -391,7 +391,7 @@ function genCSharpMongoDbClasses(args, projectName, project, alias, source) {
|
|
|
391
391
|
const strJobReferences = Array.isArray(source.jobs)
|
|
392
392
|
? source.jobs
|
|
393
393
|
.filter(job => job !== null && typeof(job) === "object" && job.action && typeof (job.action) === "string" && job.action.indexOf("lib:") === 0)
|
|
394
|
-
.map(job => ` RegisterJob<${job.action.
|
|
394
|
+
.map(job => ` RegisterJob<${job.action.substring(4).split(',')[0]}>();`)
|
|
395
395
|
.join("\r\n")
|
|
396
396
|
: "";
|
|
397
397
|
|
|
@@ -689,7 +689,7 @@ function genCSharpDriver(args, projectName, project, alias, source) {
|
|
|
689
689
|
if (actionName.indexOf("_raw_http_method_"))
|
|
690
690
|
break;
|
|
691
691
|
|
|
692
|
-
var customMethod = toCSharpName(actionName.
|
|
692
|
+
var customMethod = toCSharpName(actionName.substring("_raw_http_method_".length));
|
|
693
693
|
|
|
694
694
|
codeConnectors += ` public async System.Threading.Tasks.Task<${className}${customMethod}Result> ${customMethod}(${className}${customMethod}Arg arg)
|
|
695
695
|
{
|
|
@@ -738,11 +738,11 @@ function genCSharpDriver(args, projectName, project, alias, source) {
|
|
|
738
738
|
|
|
739
739
|
partial void BuildCustomUrl();
|
|
740
740
|
|
|
741
|
-
private string OriginUrl => "${entityName}s/${actionName.
|
|
741
|
+
private string OriginUrl => "${entityName}s/${actionName.substring("_raw_http_method_".length)}";
|
|
742
742
|
|
|
743
|
-
private string CustomUrl { get; set; } = "${entityName}s/${actionName.
|
|
743
|
+
private string CustomUrl { get; set; } = "${entityName}s/${actionName.substring("_raw_http_method_".length)}";
|
|
744
744
|
|
|
745
|
-
public override string Method { get; } = "${actionName.
|
|
745
|
+
public override string Method { get; } = "${actionName.substring("_raw_http_method_".length)}";
|
|
746
746
|
|
|
747
747
|
public ${className}${customMethod}Body Data { get; set; }
|
|
748
748
|
|
package/gen/gen-js-driver.js
CHANGED
|
@@ -36,23 +36,34 @@ function genJavascriptDriverString(aliasProject, source) {
|
|
|
36
36
|
|
|
37
37
|
if (Array.isArray(aliasProject.features)) {
|
|
38
38
|
if (aliasProject.features.includes("auth")) {
|
|
39
|
-
extensionsImportLines.push('import * as AuthExtension from "mushroomjs-auth";');
|
|
39
|
+
extensionsImportLines.push('//import * as AuthExtension from "mushroomjs-auth";');
|
|
40
|
+
extensionsImportLines.push('var AuthExtension = require("mushroomjs-auth");');
|
|
40
41
|
extensionsExportLines.push('Auth: AuthExtension');
|
|
41
42
|
extensionsCodeLines.push("AuthExtension.useAuth(AuthExtension.AuthLocalStorage);");
|
|
42
43
|
}
|
|
43
44
|
if (aliasProject.features.includes("file")) {
|
|
44
|
-
extensionsImportLines.push('import * as FileExtension from "mushroomjs-file";');
|
|
45
|
+
extensionsImportLines.push('//import * as FileExtension from "mushroomjs-file";');
|
|
46
|
+
extensionsImportLines.push('var FileExtension = require("mushroomjs-file");');
|
|
45
47
|
extensionsExportLines.push('File: FileExtension');
|
|
46
48
|
extensionsCodeLines.push("FileExtension.useFile();");
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
let code =
|
|
51
|
-
|
|
52
|
+
let code = `//import mushroom, {defineAsyncResource} from "mushroomjs";
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
var mushroom_1 = require("mushroomjs");
|
|
55
|
+
var mushroom = mushroom_1.default;
|
|
56
|
+
var defineAsyncResource = mushroom_1.defineAsyncResource;
|
|
57
|
+
|
|
58
|
+
//export * from "mushroomjs";
|
|
59
|
+
for (var m in mushroom_1) exports[m] = mushroom_1[m];
|
|
60
|
+
|
|
52
61
|
${extensionsImportLines.join("\n")}
|
|
53
|
-
export const extensions = {
|
|
62
|
+
//export const extensions = {
|
|
63
|
+
var extensions = {
|
|
54
64
|
${extensionsExportLines.join(",\n ")}
|
|
55
65
|
};
|
|
66
|
+
exports.extensions = extensions;
|
|
56
67
|
|
|
57
68
|
"use strict";
|
|
58
69
|
|
|
@@ -88,7 +99,8 @@ mushroom.$using(${JSON.stringify(common.getRootUrl(source))});
|
|
|
88
99
|
|
|
89
100
|
${extensionsCodeLines.join('\n')}
|
|
90
101
|
|
|
91
|
-
export default mushroom
|
|
102
|
+
//export default mushroom;
|
|
103
|
+
exports.default = mushroom;`;
|
|
92
104
|
|
|
93
105
|
return code;
|
|
94
106
|
}
|
package/gen/gen-ts-driver.js
CHANGED
|
@@ -38,7 +38,7 @@ function toTypeScriptClassName(str) {
|
|
|
38
38
|
return "_";
|
|
39
39
|
const name = toVietnameseNonTongue(str).replace(/\W/g, "_");
|
|
40
40
|
const c = name.charAt(0);
|
|
41
|
-
return ('0' <= c && c <= '9' ? '_' : "") + c.toUpperCase() + name.
|
|
41
|
+
return ('0' <= c && c <= '9' ? '_' : "") + c.toUpperCase() + name.substring(1);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function getCSharpTypeFromMushroomType(type) {
|
|
@@ -196,7 +196,7 @@ export type IdValue = ${source.idType == "AutoIncInt" || source.idType == "AutoI
|
|
|
196
196
|
}
|
|
197
197
|
default: {
|
|
198
198
|
if (actionName.indexOf("_raw_http_method_") === 0) {
|
|
199
|
-
customMethodCode += ` ${actionName.
|
|
199
|
+
customMethodCode += ` ${actionName.substring("_raw_http_method_".length)}Async: (rawRequest: MushroomRequest) => Promise<MushroomResponse<any>>,
|
|
200
200
|
`;
|
|
201
201
|
break;
|
|
202
202
|
}
|
|
@@ -363,7 +363,7 @@ export declare type IdValue = ${source.idType == "AutoIncInt" || source.idType =
|
|
|
363
363
|
}
|
|
364
364
|
default: {
|
|
365
365
|
if (actionName.indexOf("_raw_http_method_") === 0) {
|
|
366
|
-
customMethodCode += ` ${actionName.
|
|
366
|
+
customMethodCode += ` ${actionName.substring("_raw_http_method_".length)}Async: (rawRequest: MushroomRequest) => Promise<MushroomResponse<any>>,
|
|
367
367
|
`;
|
|
368
368
|
break;
|
|
369
369
|
}
|
package/gen.js
CHANGED
|
@@ -24,8 +24,8 @@ async function gen(args) {
|
|
|
24
24
|
|
|
25
25
|
const atIndex = projectName.indexOf("@");
|
|
26
26
|
if (atIndex !== -1) {
|
|
27
|
-
alias = projectName.
|
|
28
|
-
projectName = projectName.
|
|
27
|
+
alias = projectName.substring(atIndex + 1);
|
|
28
|
+
projectName = projectName.substring(0, atIndex);
|
|
29
29
|
if (!projectName) {
|
|
30
30
|
help(args);
|
|
31
31
|
return;
|
|
@@ -205,7 +205,7 @@ function processMasterFile(basePath, master) {
|
|
|
205
205
|
action.defaultSortings = action.sorting.split(',').map(f => {
|
|
206
206
|
const c = f.charAt(0);
|
|
207
207
|
return {
|
|
208
|
-
field: c === "+" || c === "-" ? f.
|
|
208
|
+
field: c === "+" || c === "-" ? f.substring(1) : f,
|
|
209
209
|
type: c === "-" ? "Desc" : "Asc"
|
|
210
210
|
}
|
|
211
211
|
});
|
|
@@ -216,7 +216,7 @@ function processMasterFile(basePath, master) {
|
|
|
216
216
|
action.allowSortings = action.allowSorting.split(',').map(f => {
|
|
217
217
|
const c = f.charAt(0);
|
|
218
218
|
return {
|
|
219
|
-
field: c === "+" || c === "-" ? f.
|
|
219
|
+
field: c === "+" || c === "-" ? f.substring(1) : f,
|
|
220
220
|
type: c === "-" ? "Desc" : c === "+" ? "Asc" : "Both"
|
|
221
221
|
}
|
|
222
222
|
});
|