mushroom-cli 1.2.0-alpha.2 → 1.2.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/README.md +280 -111
- package/dist/check-update.js +6 -0
- package/dist/common.js +272 -0
- package/dist/config.js +394 -0
- package/dist/docs/bootstrap-theme.min.css +6 -0
- package/dist/docs/bootstrap.min.css +6 -0
- package/dist/docs/bootstrap.min.js +7 -0
- package/{docs → dist/docs}/doc-mt.js +103 -1
- package/{docs → dist/docs}/docs.html +83 -22
- package/dist/docs/docs.v2.html +5086 -0
- package/dist/docs/docs.v2.js +1922 -0
- package/dist/docs/jquery.min.js +4 -0
- package/dist/gen/gen-api-docs-v1.js +110 -0
- package/dist/gen/gen-api-docs.js +306 -0
- package/{gen → dist/gen}/gen-csharp.js +1246 -1414
- package/{gen → dist/gen}/gen-db-docs.js +204 -222
- package/{gen → dist/gen}/gen-js-driver-tarball.js +81 -101
- package/{gen → dist/gen}/gen-js-driver.js +116 -133
- package/dist/gen/gen-ts-driver.js +596 -0
- package/{gen.js → dist/gen.js} +109 -120
- package/{help.js → dist/help.js} +53 -55
- package/dist/init/init-json.js +92 -0
- package/dist/init/init-netcore.js +30 -0
- package/dist/init.js +23 -0
- package/dist/master-file/master-file.js +185 -0
- package/dist/merge.js +70 -0
- package/dist/mr.js +77 -0
- package/dist/types.js +1 -0
- package/dist/update/tsCode.js +82 -0
- package/dist/update.js +20 -0
- package/package.json +64 -27
- package/check-update.js +0 -9
- package/common.js +0 -236
- package/config.js +0 -445
- package/gen/gen-api-docs.js +0 -125
- package/gen/gen-ts-driver.js +0 -460
- package/init/init-json.js +0 -106
- package/init/init-netcore.js +0 -32
- package/init.js +0 -28
- package/master-file/master-file.js +0 -234
- package/merge.js +0 -84
- package/mr.js +0 -82
- package/update/tsCode.js +0 -20
- package/update.js +0 -24
- /package/{docs → dist/docs}/mt-dom-1.0.js +0 -0
- /package/{docs → dist/docs}/mt.extension.js +0 -0
package/init/init-netcore.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const { spawn } = require("child_process");
|
|
3
|
-
const common = require("../common.js");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function fetchFromGit() {
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
const git = spawn("git", ["clone", "https://tfs.siten.vn/tfs/Siten/CodeBase/_git/Mushroom", "-b", "full_extensions", "--single-branch"]);
|
|
9
|
-
git.stdout.on('data', (data) => {
|
|
10
|
-
console.log(`GIT: ${data}`);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
git.stderr.on('data', (data) => {
|
|
14
|
-
console.error(`GIT: ${data}`);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
git.on('close', (code) => {
|
|
18
|
-
if (code) {
|
|
19
|
-
reject(new Error(`GIT exited with code ${code}`));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
resolve();
|
|
23
|
-
});
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function initNetCore(args) {
|
|
28
|
-
await fetchFromGit();
|
|
29
|
-
common.processTemplate("Mushroom", "mushroom-template.json");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = initNetCore;
|
package/init.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const help = require("./help.js");
|
|
2
|
-
|
|
3
|
-
const initJson = require("./init/init-json");
|
|
4
|
-
const initNetCore = require("./init/init-netcore");
|
|
5
|
-
|
|
6
|
-
async function init(args) {
|
|
7
|
-
const configCommand = args[1];
|
|
8
|
-
switch(configCommand) {
|
|
9
|
-
case "json":
|
|
10
|
-
initJson(args);
|
|
11
|
-
break;
|
|
12
|
-
case "netcore":
|
|
13
|
-
await initNetCore(args);
|
|
14
|
-
break;
|
|
15
|
-
case "":
|
|
16
|
-
case undefined:
|
|
17
|
-
case "help":
|
|
18
|
-
case "man":
|
|
19
|
-
help("init");
|
|
20
|
-
break;
|
|
21
|
-
default:
|
|
22
|
-
help(args, true);
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = init;
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const JSON5 = require("json5");
|
|
4
|
-
|
|
5
|
-
function transformValidationNode(validation) {
|
|
6
|
-
if (!validation || typeof validation !== "object")
|
|
7
|
-
return;
|
|
8
|
-
|
|
9
|
-
if (!("min" in validation) && "gte" in validation) {
|
|
10
|
-
validation.min = validation.gte;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (!("max" in validation) && "lte" in validation) {
|
|
14
|
-
validation.max = validation.lte;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function transformEntityFieldNode(field) {
|
|
20
|
-
if (!field || typeof field !== "object")
|
|
21
|
-
return;
|
|
22
|
-
|
|
23
|
-
transformValidationNode(field.validation);
|
|
24
|
-
if (Array.isArray(field.items))
|
|
25
|
-
transformValidationNode(field.items.validation);
|
|
26
|
-
|
|
27
|
-
if (!field.fields || typeof field.fields !== "object")
|
|
28
|
-
return;
|
|
29
|
-
|
|
30
|
-
for (var fieldName in field.fields) {
|
|
31
|
-
transformEntityFieldNode(field.fields[fieldName]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function transformViewNode(view) {
|
|
36
|
-
if (!view || !Array.isArray(view.parameters))
|
|
37
|
-
return;
|
|
38
|
-
|
|
39
|
-
view.parameters.forEach(p => transformValidationNode(p.validation));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function mergeApiProject(totalProject, fragmentProject, options) {
|
|
43
|
-
if (totalProject.name != null && fragmentProject.name != null && fragmentProject.name != totalProject.name)
|
|
44
|
-
throw new Error(`Unable merge project '${fragmentProject.name}' into '${totalProject.name}'`);
|
|
45
|
-
if (totalProject.version != null && fragmentProject.version != null && fragmentProject.version != totalProject.version)
|
|
46
|
-
throw new Error(`Unable merge project '${fragmentProject.version}' into '${totalProject.version}'`);
|
|
47
|
-
|
|
48
|
-
if (fragmentProject.environmentVariables != null) {
|
|
49
|
-
totalProject.environmentVariables = totalProject.environmentVariables || {};
|
|
50
|
-
|
|
51
|
-
for (var name in fragmentProject.environmentVariables) {
|
|
52
|
-
if (name in totalProject.environmentVariables) {
|
|
53
|
-
switch (options.environmentVariable.duplicateNameHandling) {
|
|
54
|
-
case "override":
|
|
55
|
-
totalProject.environmentVariables[name] = fragmentProject.environmentVariables[name];
|
|
56
|
-
break;
|
|
57
|
-
case "ignore":
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
throw new Error(`Duplicate environment variables: ${name}. Can config dublicate name handling behavior at options.environmentVariable.duplicateNameHandling`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else
|
|
64
|
-
totalProject.environmentVariables[name] = fragmentProject.environmentVariables[name];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (fragmentProject.entities != null) {
|
|
69
|
-
totalProject.entities = totalProject.entities || [];
|
|
70
|
-
|
|
71
|
-
fragmentProject.entities.forEach(entity => {
|
|
72
|
-
|
|
73
|
-
var found = totalProject.entities.some((entityInTotal, i) => {
|
|
74
|
-
if (entityInTotal.name !== entity.name){
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
switch (options.entity.duplicateNameHandling) {
|
|
78
|
-
case "override":
|
|
79
|
-
totalProject.entities[i] = entity;
|
|
80
|
-
return true;
|
|
81
|
-
case "ignore":
|
|
82
|
-
return true;
|
|
83
|
-
default:
|
|
84
|
-
throw new Error("Duplicate entity: " + entity.name + ". Can config dublicate name handling behavior at options.entity.duplicateNameHandling");
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (found)
|
|
89
|
-
return;
|
|
90
|
-
|
|
91
|
-
totalProject.entities.push(entity);
|
|
92
|
-
// console.log("add new entity: " + entity.name + "; totalProject.entities.length=" + totalProject.entities.length);
|
|
93
|
-
|
|
94
|
-
if (!entity.fields || typeof entity.fields !== "object")
|
|
95
|
-
return;
|
|
96
|
-
|
|
97
|
-
for (var fieldName in entity.fields) {
|
|
98
|
-
transformEntityFieldNode(entity.fields[fieldName]);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (fragmentProject.views != null) {
|
|
104
|
-
totalProject.views = totalProject.views || {};
|
|
105
|
-
|
|
106
|
-
for (var viewName in fragmentProject.views)
|
|
107
|
-
{
|
|
108
|
-
if (viewName in totalProject.views)
|
|
109
|
-
{
|
|
110
|
-
switch (options.view.duplicateNameHandling)
|
|
111
|
-
{
|
|
112
|
-
case "override":
|
|
113
|
-
totalProject.views[viewName] = fragmentProject.views[viewName];
|
|
114
|
-
break;
|
|
115
|
-
case "ignore":
|
|
116
|
-
continue;
|
|
117
|
-
default:
|
|
118
|
-
throw new Error("Duplicate global view: " + viewName + ". Can config dublicate name handling behavior at options.views.duplicateNameHandling");
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else
|
|
122
|
-
totalProject.views[viewName] = fragmentProject.views[viewName];
|
|
123
|
-
|
|
124
|
-
if (!fragmentProject.views[viewName] || Array.isArray(fragmentProject.views[viewName])) {
|
|
125
|
-
delete fragmentProject.views[viewName];
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
fragmentProject.views[viewName].forEach(transformViewNode);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
for (var name in fragmentProject) {
|
|
135
|
-
if (name === "environmentVariables" || name === "entities" || name === "views" || name === "$schema")
|
|
136
|
-
continue;
|
|
137
|
-
|
|
138
|
-
totalProject[name] = fragmentProject[name];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return totalProject;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function processMasterFile(basePath, master) {
|
|
145
|
-
if (master.fragments == null || master.fragments.Length == 0)
|
|
146
|
-
return null;
|
|
147
|
-
|
|
148
|
-
const options = master.options || {
|
|
149
|
-
formatIndent: false
|
|
150
|
-
};
|
|
151
|
-
options.environmentVariable = options.environmentVariable || { duplicateNameHandling: "raiseException" };
|
|
152
|
-
options.entity = options.entity || { duplicateNameHandling: "raiseException" };
|
|
153
|
-
options.view = options.view || { duplicateNameHandling: "raiseException" };
|
|
154
|
-
|
|
155
|
-
let apiProject = {};
|
|
156
|
-
master.fragments.forEach(fragment => {
|
|
157
|
-
let apiProjectFragment;
|
|
158
|
-
const fragmentPath = path.join(basePath, fragment.path)
|
|
159
|
-
console.log("merging fragment file: " + fragmentPath);
|
|
160
|
-
try {
|
|
161
|
-
const content = fs.readFileSync(fragmentPath).toString();
|
|
162
|
-
apiProjectFragment = JSON5.parse(content);
|
|
163
|
-
}
|
|
164
|
-
catch (e) {
|
|
165
|
-
if (fragment.optional){
|
|
166
|
-
console.warn(fragmentPath + " not found or unable to parse");
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
console.error(fragmentPath + " not found or unable to parse");
|
|
170
|
-
throw e;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
apiProject = mergeApiProject(apiProject, apiProjectFragment, master.options);
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
if (apiProject == null)
|
|
177
|
-
return null;
|
|
178
|
-
|
|
179
|
-
apiProject["$schema"] = "http://schema.siten.vn/mushroom/project.json";
|
|
180
|
-
|
|
181
|
-
if (apiProject.entities == null)
|
|
182
|
-
apiProject.entities = [];
|
|
183
|
-
|
|
184
|
-
apiProject.entities.forEach(entity => {
|
|
185
|
-
if (entity.actions == null)
|
|
186
|
-
entity.actions = [];
|
|
187
|
-
|
|
188
|
-
for (let actionName in entity.actions) {
|
|
189
|
-
if (actionName != "findMany" && actionName != "findById" || entity.actions[actionName] == null)
|
|
190
|
-
continue;
|
|
191
|
-
|
|
192
|
-
entity.actions[actionName].forEach(action => {
|
|
193
|
-
if (action.fields) {
|
|
194
|
-
action.defaultFields = action.fields.split(',');
|
|
195
|
-
delete action.fields;
|
|
196
|
-
}
|
|
197
|
-
if (action.allowFields) {
|
|
198
|
-
action.returnableFields = action.allowFields.split(',');
|
|
199
|
-
delete action.allowFields;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (actionName != "findMany")
|
|
203
|
-
return;
|
|
204
|
-
if (action.sorting) {
|
|
205
|
-
action.defaultSortings = action.sorting.split(',').map(f => {
|
|
206
|
-
const c = f.charAt(0);
|
|
207
|
-
return {
|
|
208
|
-
field: c === "+" || c === "-" ? f.substring(1) : f,
|
|
209
|
-
type: c === "-" ? "Desc" : "Asc"
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
delete action.sorting;
|
|
213
|
-
}
|
|
214
|
-
if (action.allowSorting)
|
|
215
|
-
{
|
|
216
|
-
action.allowSortings = action.allowSorting.split(',').map(f => {
|
|
217
|
-
const c = f.charAt(0);
|
|
218
|
-
return {
|
|
219
|
-
field: c === "+" || c === "-" ? f.substring(1) : f,
|
|
220
|
-
type: c === "-" ? "Desc" : c === "+" ? "Asc" : "Both"
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
delete action.allowSorting;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
return apiProject;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
module.exports = {
|
|
233
|
-
processMasterFile: processMasterFile
|
|
234
|
-
};
|
package/merge.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const JSON5 = require("json5");
|
|
4
|
-
const common = require("./common.js");
|
|
5
|
-
const help = require("./help.js");
|
|
6
|
-
|
|
7
|
-
const masterFile = require("./master-file/master-file");
|
|
8
|
-
|
|
9
|
-
async function merge(args) {
|
|
10
|
-
let projectName = args[1];
|
|
11
|
-
const output = args[2];
|
|
12
|
-
|
|
13
|
-
if (!projectName || !output) {
|
|
14
|
-
help(args);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
let alias = "default";
|
|
19
|
-
const atIndex = projectName.indexOf("@");
|
|
20
|
-
if (atIndex !== -1) {
|
|
21
|
-
alias = projectName.substring(atIndex + 1);
|
|
22
|
-
projectName = projectName.substring(0, atIndex);
|
|
23
|
-
if (!projectName) {
|
|
24
|
-
help(args);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (!alias)
|
|
29
|
-
alias = "default";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let mushroomConfig;
|
|
33
|
-
try {
|
|
34
|
-
const mushroomConfigContent = fs.readFileSync("./mushroom-config.json").toString();
|
|
35
|
-
mushroomConfig = JSON.parse(mushroomConfigContent);
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
console.error("mushroom-config.json not found or unable to parse");
|
|
39
|
-
throw e;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (!mushroomConfig || typeof mushroomConfig !== "object")
|
|
43
|
-
throw new Error(`Invalid configuration. Please re-check file mushroom-config.json`);
|
|
44
|
-
|
|
45
|
-
if (!mushroomConfig || !mushroomConfig.projects || !mushroomConfig.projects[projectName])
|
|
46
|
-
throw new Error(`Project not found (${projectName})`);
|
|
47
|
-
|
|
48
|
-
const project = mushroomConfig.projects[projectName];
|
|
49
|
-
if (!project.src)
|
|
50
|
-
throw new Error("Project source (src) not found");
|
|
51
|
-
|
|
52
|
-
var source;
|
|
53
|
-
try {
|
|
54
|
-
const sourceContent = fs.readFileSync(project.src).toString();
|
|
55
|
-
source = JSON5.parse(sourceContent);
|
|
56
|
-
}
|
|
57
|
-
catch(e) {
|
|
58
|
-
console.error(project.src + " not found or unable to parse");
|
|
59
|
-
throw e;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!source || typeof source !== "object")
|
|
63
|
-
throw new Error(`Invalid api project configuration. Please re-check file ${project.src}`);
|
|
64
|
-
|
|
65
|
-
if (Array.isArray(source.fragments)) {
|
|
66
|
-
console.log("Process master file: " + project.src);
|
|
67
|
-
source = masterFile.processMasterFile(path.dirname(project.src), source);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!source || typeof source !== "object") {
|
|
71
|
-
throw new Error(`${!source}\t${typeof source}\tInvalid api project configuration. Please re-check file ${project.src}`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (source.name !== projectName) {
|
|
75
|
-
throw new Error(`Project name is mismatched (${projectName} & ${source.name})`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
common.ensureFolder(output);
|
|
79
|
-
|
|
80
|
-
fs.writeFileSync(output, JSON.stringify(source));
|
|
81
|
-
console.log(`Merged ${projectName}@${alias} then saved to ${output}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = merge;
|
package/mr.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const init = require("./init");
|
|
4
|
-
const config = require("./config");
|
|
5
|
-
const gen = require("./gen");
|
|
6
|
-
const merge = require("./merge");
|
|
7
|
-
const update = require("./update");
|
|
8
|
-
const help = require("./help");
|
|
9
|
-
|
|
10
|
-
const pkg = require("./package.json");
|
|
11
|
-
const checkUpdate = require("./check-update");
|
|
12
|
-
|
|
13
|
-
const versionGroup = pkg.version.match(/([^-]+)(-(\w+).*)?/);
|
|
14
|
-
const currentDistTag = versionGroup[3] ? versionGroup[3] : "latest";
|
|
15
|
-
console.log("Mushroom CLI version " + pkg.version);
|
|
16
|
-
|
|
17
|
-
async function run(args) {
|
|
18
|
-
let debugMode = false;
|
|
19
|
-
if (args.indexOf("--debug") !== -1) {
|
|
20
|
-
debugMode = true;
|
|
21
|
-
args = args.filter(arg => arg !== "--debug");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
let checkUpdateTask;
|
|
25
|
-
if (args.indexOf("--no-check-update") !== -1){
|
|
26
|
-
args = args.filter(arg => arg !== "--no-check-update");
|
|
27
|
-
checkUpdateTask = null;
|
|
28
|
-
}
|
|
29
|
-
else{
|
|
30
|
-
checkUpdateTask = checkUpdate();
|
|
31
|
-
checkUpdateTask.catch(() => {});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
switch(args[0]) {
|
|
36
|
-
case "init":
|
|
37
|
-
await init(args);
|
|
38
|
-
break;
|
|
39
|
-
case "config":
|
|
40
|
-
await config(args);
|
|
41
|
-
break;
|
|
42
|
-
case "gen":
|
|
43
|
-
await gen(args);
|
|
44
|
-
break;
|
|
45
|
-
case "merge":
|
|
46
|
-
merge(args);
|
|
47
|
-
break;
|
|
48
|
-
case "update":
|
|
49
|
-
await update(args);
|
|
50
|
-
break;
|
|
51
|
-
case "":
|
|
52
|
-
case undefined:
|
|
53
|
-
console.log(`Mushroom CLI`);
|
|
54
|
-
break;
|
|
55
|
-
case "help":
|
|
56
|
-
case "man":
|
|
57
|
-
help(args.slice(1).join());
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
help(args, true);
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
console.error(debugMode ? e : e.message);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (checkUpdateTask !== null)
|
|
70
|
-
try {
|
|
71
|
-
var data = await checkUpdateTask;
|
|
72
|
-
if (data["dist-tags"] && data["dist-tags"][currentDistTag] && data["dist-tags"][currentDistTag] !== pkg.version) {
|
|
73
|
-
console.warn(`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]}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch(e) {
|
|
77
|
-
if (debugMode) console.log(e);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const [,, ...args] = process.argv;
|
|
82
|
-
run(args);
|
package/update/tsCode.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const fs = require("fs");
|
|
2
|
-
const fetch = require('node-fetch');
|
|
3
|
-
|
|
4
|
-
async function updateTsCode(options) {
|
|
5
|
-
if (!options.output) {
|
|
6
|
-
console.error("Missing output file path");
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
if (!options.input) {
|
|
10
|
-
console.error("Missing remote url");
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
console.log(`Fetch ${options.input}`);
|
|
14
|
-
const res = await fetch(options.input);
|
|
15
|
-
console.log(`Write to ${options.output}`);
|
|
16
|
-
fs.writeFileSync(options.output, await res.text());
|
|
17
|
-
console.log(`Finish update ts-code`);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = updateTsCode;
|
package/update.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
|
File without changes
|
|
File without changes
|