mushroom-cli 1.1.0-alpha.1 → 1.1.0-alpha.5
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/check-update.js +1 -1
- package/gen/gen-api-docs.js +11 -1
- package/gen/gen-js-driver-tarball.js +1 -1
- package/gen/gen-js-driver.js +8 -6
- package/mr.js +6 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,6 +26,10 @@ Config gen javascript driver
|
|
|
26
26
|
|
|
27
27
|
npx mr config gen projectName js-driver ./src/api/mushroom.api.js [alias aliasName] [roles Admin,User-Contributor] [tarball tarballName]
|
|
28
28
|
|
|
29
|
+
Config gen typescript driver
|
|
30
|
+
|
|
31
|
+
npx mr config gen projectName ts-driver ./src/api/mushroom.api.ts [alias aliasName] [roles Admin,User-Contributor]
|
|
32
|
+
|
|
29
33
|
Config gen entities for Mushroom project in CSharp and using MongoDb
|
|
30
34
|
|
|
31
35
|
npx mr config gen projectName c#-mongo ./API/Generated.cs [alias aliasName]
|
|
@@ -44,10 +48,18 @@ Generate database docs (html format)
|
|
|
44
48
|
|
|
45
49
|
npx mr gen projectName[@aliasName] db-docs [tmp]
|
|
46
50
|
|
|
51
|
+
Generate npm package (tarball file)
|
|
52
|
+
|
|
53
|
+
npx mr gen projectName[@aliasName] js-driver-tarball
|
|
54
|
+
|
|
47
55
|
Generate javascript driver
|
|
48
56
|
|
|
49
57
|
npx mr gen projectName[@aliasName] js-driver
|
|
50
58
|
|
|
59
|
+
Generate typescript driver
|
|
60
|
+
|
|
61
|
+
npx mr gen projectName[@aliasName] ts-driver
|
|
62
|
+
|
|
51
63
|
Generate entities for Mushroom project in CSharp and using MongoDb
|
|
52
64
|
|
|
53
65
|
npx mr gen projectName[@aliasName] c#-mongo
|
package/check-update.js
CHANGED
package/gen/gen-api-docs.js
CHANGED
|
@@ -9,6 +9,8 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
|
|
|
9
9
|
console.log('Received html');
|
|
10
10
|
console.log("Parsing html");
|
|
11
11
|
|
|
12
|
+
const roles = aliasProject.allowRoles.includes("*") ? source.roles : source.roles?.filter(r => aliasProject.allowRoles.includes(r.name));
|
|
13
|
+
|
|
12
14
|
html = html.replace(/^\uFEFF/, '');
|
|
13
15
|
html = html.replace(/<script src=(["'])\/\//g, "<script src=$1http://");
|
|
14
16
|
html = html.replace("</body>", `<script data-mt-cond='{"x": 1}'>
|
|
@@ -16,9 +18,11 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
|
|
|
16
18
|
window.data.description = ${JSON.stringify(source.description)};
|
|
17
19
|
window.data.rootUrl = ${JSON.stringify(common.getRootUrl(source))};
|
|
18
20
|
window.data.environmentVariables = ${JSON.stringify(source.environmentVariables)};
|
|
21
|
+
window.data.roles = ${JSON.stringify(roles)};
|
|
19
22
|
window.data.entities = ${JSON.stringify(entities)};
|
|
20
23
|
window.data.features = ${JSON.stringify(aliasProject.features)};
|
|
21
|
-
try{
|
|
24
|
+
try {
|
|
25
|
+
console.info("MUSHROOM-CLI: START");
|
|
22
26
|
window.generateDocument();
|
|
23
27
|
console.info("MUSHROOM-CLI: FINISH");
|
|
24
28
|
}
|
|
@@ -31,6 +35,12 @@ function processGenDocs(aliasProject, entities, source, html, args, projectName,
|
|
|
31
35
|
return new Promise((resolve, reject) => {
|
|
32
36
|
const virtualConsole = new jsdom.VirtualConsole();
|
|
33
37
|
virtualConsole.on("info", function(msg, err) {
|
|
38
|
+
if (typeof msg != "string") return;
|
|
39
|
+
|
|
40
|
+
if (msg.indexOf("MUSHROOM-CLI:") === 0) {
|
|
41
|
+
console.log("GenDocEngine:" + msg.substr("MUSHROOM-CLI:".length));
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
if (msg === "MUSHROOM-CLI: FAIL"){
|
|
35
45
|
dom = null;
|
|
36
46
|
reject(err);
|
|
@@ -47,7 +47,7 @@ async function genJavascriptDriverTarball(args, projectName, project, alias, sou
|
|
|
47
47
|
"main": "${tarballName}.js",
|
|
48
48
|
"types": "${tarballName}.d.ts",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"mushroomjs": "^1.1.0-alpha.
|
|
50
|
+
"mushroomjs": "^1.1.0-alpha.7"${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? ',\n "mushroomjs-auth": "^1.1.0-alpha.4"' : ""}${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? ',\n "mushroomjs-file": "^1.1.0-alpha.1"' : ""}
|
|
51
51
|
}
|
|
52
52
|
}`;
|
|
53
53
|
|
package/gen/gen-js-driver.js
CHANGED
|
@@ -30,13 +30,12 @@ function genJavascriptDriverString(aliasProject, source) {
|
|
|
30
30
|
|
|
31
31
|
const entities = common.getEntities(source, aliasProject.allowRoles);
|
|
32
32
|
|
|
33
|
-
let code = `import mushroom from "mushroomjs";
|
|
33
|
+
let code = `import mushroom, {defineAsyncResource} from "mushroomjs";
|
|
34
|
+
${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? 'import { useAuth, AuthLocalStorage } from "mushroomjs-auth";' : ""}
|
|
35
|
+
${Array.isArray(aliasProject.features) && aliasProject.features.includes("file") ? 'import { useFile } from "mushroomjs-file";' : ""}
|
|
34
36
|
|
|
35
37
|
"use strict";
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
const rootApiUrl = ${JSON.stringify(common.getRootUrl(source))};
|
|
39
|
-
|
|
40
39
|
`;
|
|
41
40
|
for (let entityName in entities) {
|
|
42
41
|
if (!entities.hasOwnProperty(entityName))
|
|
@@ -61,11 +60,14 @@ const rootApiUrl = ${JSON.stringify(common.getRootUrl(source))};
|
|
|
61
60
|
|
|
62
61
|
views[viewName] = {};
|
|
63
62
|
}
|
|
64
|
-
code += `
|
|
63
|
+
code += `defineAsyncResource({name:${JSON.stringify(entityName)},actions:${JSON.stringify(actions)},views:${JSON.stringify(views)}});
|
|
65
64
|
`;
|
|
66
65
|
}
|
|
67
66
|
code += `
|
|
68
|
-
mushroom.$using(
|
|
67
|
+
mushroom.$using(${JSON.stringify(common.getRootUrl(source))});
|
|
68
|
+
|
|
69
|
+
${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "useAuth(AuthLocalStorage);" : ""}
|
|
70
|
+
${Array.isArray(aliasProject.features) && aliasProject.features.includes("auth") ? "useFile();" : ""}
|
|
69
71
|
|
|
70
72
|
export default mushroom;`;
|
|
71
73
|
|
package/mr.js
CHANGED
|
@@ -8,6 +8,10 @@ const help = require("./help.js");
|
|
|
8
8
|
const package = require("./package.json");
|
|
9
9
|
const checkUpdate = require("./check-update");
|
|
10
10
|
|
|
11
|
+
const versionGroup = package.version.match(/([^-]+)(-(\w+).*)?/);
|
|
12
|
+
const currentDistTag = versionGroup[3] ? versionGroup[3] : "latest";
|
|
13
|
+
console.log("Mushroom CLI version " + package.version);
|
|
14
|
+
|
|
11
15
|
async function run(args) {
|
|
12
16
|
let debugMode = false;
|
|
13
17
|
if (args.indexOf("--debug") !== -1) {
|
|
@@ -59,8 +63,8 @@ async function run(args) {
|
|
|
59
63
|
if (checkUpdateTask !== null)
|
|
60
64
|
try {
|
|
61
65
|
var data = await checkUpdateTask;
|
|
62
|
-
if (data
|
|
63
|
-
console.warn(
|
|
66
|
+
if (data["dist-tags"] && data["dist-tags"][currentDistTag] && data["dist-tags"][currentDistTag] !== package.version) {
|
|
67
|
+
console.warn(`YOUR mushroom-cli VERSION IS NOT LATEST (dist-tags: ${currentDistTag}). PLEASE RUN: npm i mushroom-cli@${data["dist-tags"][currentDistTag]}`);
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
catch(e) {
|