mushroom-cli 1.1.0 → 1.1.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/.vscode/settings.json +3 -0
- package/README.md +91 -91
- package/check-update.js +9 -9
- package/common.js +237 -236
- package/config.js +475 -445
- package/docs/doc-mt.js +526 -421
- package/docs/docs.html +5380 -5129
- package/docs/mt-dom-1.0.js +1398 -1268
- package/docs/mt.extension.js +199 -174
- package/gen/gen-api-docs.js +157 -125
- package/gen/gen-csharp.js +1687 -1414
- package/gen/gen-db-docs.js +238 -222
- package/gen/gen-js-driver-tarball.js +119 -101
- package/gen/gen-js-driver.js +154 -133
- package/gen/gen-ts-driver.js +482 -451
- package/gen.js +146 -120
- package/help.js +51 -55
- package/init/init-json.js +110 -106
- package/init/init-netcore.js +37 -32
- package/init.js +27 -28
- package/master-file/master-file.js +254 -234
- package/mr.js +80 -78
- package/package.json +27 -27
- package/update/tsCode.js +90 -20
- package/update.js +24 -24
package/mr.js
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const init = require("./init.js");
|
|
4
|
-
const config = require("./config.js");
|
|
5
|
-
const gen = require("./gen.js");
|
|
6
|
-
const update = require("./update.js");
|
|
7
|
-
const help = require("./help.js");
|
|
8
|
-
|
|
9
|
-
const pkg = require("./package.json");
|
|
10
|
-
const checkUpdate = require("./check-update");
|
|
11
|
-
|
|
12
|
-
const versionGroup = pkg.version.match(/([^-]+)(-(\w+).*)?/);
|
|
13
|
-
const currentDistTag = versionGroup[3] ? versionGroup[3] : "latest";
|
|
14
|
-
console.log("Mushroom CLI version " +
|
|
15
|
-
|
|
16
|
-
async function run(args) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const init = require("./init.js");
|
|
4
|
+
const config = require("./config.js");
|
|
5
|
+
const gen = require("./gen.js");
|
|
6
|
+
const update = require("./update.js");
|
|
7
|
+
const help = require("./help.js");
|
|
8
|
+
|
|
9
|
+
const pkg = require("./package.json");
|
|
10
|
+
const checkUpdate = require("./check-update");
|
|
11
|
+
|
|
12
|
+
const versionGroup = pkg.version.match(/([^-]+)(-(\w+).*)?/);
|
|
13
|
+
const currentDistTag = versionGroup[3] ? versionGroup[3] : "latest";
|
|
14
|
+
console.log("Mushroom CLI version " + pkg.version);
|
|
15
|
+
|
|
16
|
+
async function run(args) {
|
|
17
|
+
let debugMode = false;
|
|
18
|
+
if (args.indexOf("--debug") !== -1) {
|
|
19
|
+
debugMode = true;
|
|
20
|
+
args = args.filter((arg) => arg !== "--debug");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let checkUpdateTask;
|
|
24
|
+
if (args.indexOf("--no-check-update") !== -1) {
|
|
25
|
+
args = args.filter((arg) => arg !== "--no-check-update");
|
|
26
|
+
checkUpdateTask = null;
|
|
27
|
+
} else {
|
|
28
|
+
checkUpdateTask = checkUpdate();
|
|
29
|
+
checkUpdateTask.catch(() => {});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
switch (args[0]) {
|
|
34
|
+
case "init":
|
|
35
|
+
await init(args);
|
|
36
|
+
break;
|
|
37
|
+
case "config":
|
|
38
|
+
config(args);
|
|
39
|
+
break;
|
|
40
|
+
case "gen":
|
|
41
|
+
await gen(args);
|
|
42
|
+
break;
|
|
43
|
+
case "update":
|
|
44
|
+
await update(args);
|
|
45
|
+
break;
|
|
46
|
+
case "":
|
|
47
|
+
case undefined:
|
|
48
|
+
console.log(`Mushroom CLI`);
|
|
49
|
+
break;
|
|
50
|
+
case "help":
|
|
51
|
+
case "man":
|
|
52
|
+
help(args.slice(1).join());
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
help(args, true);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
} catch (e) {
|
|
59
|
+
console.error(debugMode ? e : e.message);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (checkUpdateTask !== null)
|
|
63
|
+
try {
|
|
64
|
+
const data = await checkUpdateTask;
|
|
65
|
+
if (
|
|
66
|
+
data["dist-tags"] &&
|
|
67
|
+
data["dist-tags"][currentDistTag] &&
|
|
68
|
+
data["dist-tags"][currentDistTag] !== pkg.version
|
|
69
|
+
) {
|
|
70
|
+
console.warn(
|
|
71
|
+
`YOUR mushroom-cli VERSION IS NOT LATEST (dist-tags: ${currentDistTag}). PLEASE RUN: npm i mushroom-cli@${data["dist-tags"][currentDistTag]} OR yarn add mushroom-cli@^${data["dist-tags"][currentDistTag]}`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
if (debugMode) console.log(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const [, , ...args] = process.argv;
|
|
80
|
+
run(args);
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mushroom-cli",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Mushroom CLI",
|
|
5
|
-
"main": "mr.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"release": "npm publish --access public"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"Mushroom",
|
|
11
|
-
"CLI"
|
|
12
|
-
],
|
|
13
|
-
"bin": {
|
|
14
|
-
"mushroom-cli": "mr.js",
|
|
15
|
-
"mr": "mr.js"
|
|
16
|
-
},
|
|
17
|
-
"author": "suco2007",
|
|
18
|
-
"license": "ISC",
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"jsdom": "^
|
|
21
|
-
"json5": "^2.2.3",
|
|
22
|
-
"node-fetch": "^2.6.7",
|
|
23
|
-
"open": "^8.4.0",
|
|
24
|
-
"readline-sync": "^1.4.10",
|
|
25
|
-
"targz": "^1.0.1"
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mushroom-cli",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Mushroom CLI",
|
|
5
|
+
"main": "mr.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"release": "npm publish --access public"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"Mushroom",
|
|
11
|
+
"CLI"
|
|
12
|
+
],
|
|
13
|
+
"bin": {
|
|
14
|
+
"mushroom-cli": "mr.js",
|
|
15
|
+
"mr": "mr.js"
|
|
16
|
+
},
|
|
17
|
+
"author": "suco2007",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"jsdom": "^24.1.1",
|
|
21
|
+
"json5": "^2.2.3",
|
|
22
|
+
"node-fetch": "^2.6.7",
|
|
23
|
+
"open": "^8.4.0",
|
|
24
|
+
"readline-sync": "^1.4.10",
|
|
25
|
+
"targz": "^1.0.1"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/update/tsCode.js
CHANGED
|
@@ -1,20 +1,90 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const fetch = require(
|
|
3
|
-
|
|
4
|
-
async function updateTsCode(options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const fetch = require("node-fetch");
|
|
3
|
+
|
|
4
|
+
async function updateTsCode(options) {
|
|
5
|
+
if (options.input || options.output) {
|
|
6
|
+
// legacy way
|
|
7
|
+
if (!options.output) {
|
|
8
|
+
console.error("Missing output file path");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (!options.input) {
|
|
12
|
+
console.error("Missing remote url");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
pullAsync(options.input, output);
|
|
16
|
+
console.log("Finish update ts-code");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// new way, using mushroom-config.json file
|
|
21
|
+
if (!fs.existsSync("mushroom-config.json")) {
|
|
22
|
+
console.error("Missing mushroom-config.json file");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const configJson = fs.readFileSync("mushroom-config.json");
|
|
26
|
+
const config = JSON.parse(configJson);
|
|
27
|
+
if (!config.update) {
|
|
28
|
+
console.error("Missing 'update' in mushroom-config.json file");
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!config.update["ts-code"]) {
|
|
32
|
+
console.error("Missing 'update.ts-code' in mushroom-config.json file");
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const steps = config.update["ts-code"].steps;
|
|
37
|
+
if (!steps) {
|
|
38
|
+
console.error(
|
|
39
|
+
"Missing 'update.ts-code.steps' in mushroom-config.json file",
|
|
40
|
+
);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i < steps.length; i++) {
|
|
45
|
+
const step = steps[i];
|
|
46
|
+
switch (step.action) {
|
|
47
|
+
case "pull":
|
|
48
|
+
await pullAsync(step.source, step.destination);
|
|
49
|
+
break;
|
|
50
|
+
case "replace-content":
|
|
51
|
+
replaceContent(step.source, step.search, step.replacement);
|
|
52
|
+
break;
|
|
53
|
+
case "replace-regex":
|
|
54
|
+
replaceContent(step.source, step.pattern, step.replacement);
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
console.warn(`Unsupported step action: ${step.action}`);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
console.log("Finish update ts-code");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function pullAsync(input, output) {
|
|
65
|
+
console.log(`Fetch ${input}`);
|
|
66
|
+
const res = await fetch(input);
|
|
67
|
+
console.log(`Write to ${output}`);
|
|
68
|
+
fs.writeFileSync(output, await res.text());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function replaceContent(input, search, replacement) {
|
|
72
|
+
console.log(`Replace ${search} by ${replacement} in ${input} file`);
|
|
73
|
+
const content = fs.readFileSync(input).toString();
|
|
74
|
+
if (!content) return;
|
|
75
|
+
const output = content.replace(
|
|
76
|
+
new RegExp(search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
|
|
77
|
+
replacement,
|
|
78
|
+
);
|
|
79
|
+
fs.writeFileSync(input, output);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function replaceRegex(input, pattern, replacement) {
|
|
83
|
+
console.log(`Replace pattern ${pattern} by ${replacement} in ${input} file`);
|
|
84
|
+
const content = fs.readFileSync(input).toString();
|
|
85
|
+
if (!content) return;
|
|
86
|
+
const output = content.replace(new RegExp(pattern, "g"), replacement);
|
|
87
|
+
fs.writeFileSync(input, output);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
module.exports = updateTsCode;
|
package/update.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
const help = require("./help.js");
|
|
2
|
-
const updateTsCode = require("./update/tsCode");
|
|
3
|
-
|
|
4
|
-
async function update(args) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = update;
|
|
1
|
+
const help = require("./help.js");
|
|
2
|
+
const updateTsCode = require("./update/tsCode");
|
|
3
|
+
|
|
4
|
+
async function update(args) {
|
|
5
|
+
let command = args[1];
|
|
6
|
+
|
|
7
|
+
switch (command) {
|
|
8
|
+
case "ts-code":
|
|
9
|
+
await updateTsCode({
|
|
10
|
+
input: args[3],
|
|
11
|
+
output: args[2],
|
|
12
|
+
});
|
|
13
|
+
break;
|
|
14
|
+
case "help":
|
|
15
|
+
case "man":
|
|
16
|
+
help(args);
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
help(args, true);
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = update;
|