mushroom-cli 1.1.0-alpha.2 → 1.1.0-alpha.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mushroom-cli",
3
- "version": "1.1.0-alpha.2",
3
+ "version": "1.1.0-alpha.20",
4
4
  "description": "Mushroom CLI",
5
5
  "main": "mr.js",
6
6
  "scripts": {
@@ -17,10 +17,10 @@
17
17
  "author": "suco2007",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "jsdom": "^16.2.2",
21
- "json5": "^2.1.2",
22
- "node-fetch": "^2.6.0",
23
- "open": "^7.0.3",
20
+ "jsdom": "^20.0.0",
21
+ "json5": "^2.2.1",
22
+ "node-fetch": "^2.6.7",
23
+ "open": "^8.4.0",
24
24
  "readline-sync": "^1.4.10",
25
25
  "targz": "^1.0.1"
26
26
  }
@@ -0,0 +1,20 @@
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 ADDED
@@ -0,0 +1,24 @@
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;