pinokiod 3.0.30 → 3.0.32

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.
@@ -3,74 +3,18 @@ const fetch = require('cross-fetch')
3
3
  const { rimraf } = require('rimraf')
4
4
  const decompress = require('decompress');
5
5
  class Node {
6
- constructor () {
7
- let bin = this.kernel.bin
8
- if (bin.platform === "darwin") {
9
- if (bin.arch === "x64") {
10
- this.url = "https://nodejs.org/dist/v18.16.0/node-v18.16.0-darwin-x64.tar.gz"
11
- } else if (bin.arch === "arm64") {
12
- this.url = "https://nodejs.org/dist/v18.16.0/node-v18.16.0-darwin-arm64.tar.gz"
13
- }
14
- this.path = bin.path("node", "bin")
15
- } else if (bin.platform === "win32") {
16
- //this.url = "https://nodejs.org/dist/v18.16.0/node-v18.16.0-win-x64.zip"
17
- this.url = "https://github.com/cocktailpeanut/nodejs/releases/download/v18.6.0/node-v18.16.0-win-x64.zip"
18
- this.path = bin.path("node")
19
- } else {
20
- if (bin.arch === "x64") {
21
- this.url = "https://nodejs.org/download/release/v18.16.0/node-v18.16.0-linux-x64.tar.gz"
22
- } else if (bin.arch === "arm64") {
23
- this.url = "https://nodejs.org/download/release/v18.16.0/node-v18.16.0-linux-arm64.tar.gz"
24
- }
25
- this.path = bin.path("node", "bin")
26
- }
6
+ async install(req, ondata) {
7
+ await this.kernel.bin.exec({
8
+ message: "conda install -y nodejs=22.12.0 -c conda-forge"
9
+ }, ondata)
27
10
  }
28
- async uninstall(req, ondata) {
29
- ondata({ raw: "cleaning up\r\n" })
30
- const folder = this.kernel.bin.path("node")
31
- await rimraf(folder)
32
- ondata({ raw: "finished cleaning up\r\n" })
11
+ async installed() {
12
+ return this.kernel.bin.installed.conda.has("nodejs")
33
13
  }
34
- async install(req, ondata) {
35
- const url_chunks = this.url.split("/")
36
- const filename = url_chunks[url_chunks.length-1]
37
- const filename_without_extension = filename.replace(/(\.tar\.gz|\.zip)/, "")
38
- const bin_folder = this.kernel.bin.path()
39
- console.log({ url_chunks, filename, filename_without_extension, bin_folder })
40
- await fs.promises.mkdir(bin_folder, { recursive: true }).catch((e) => {console.log(e) })
41
- console.log("mkdir finished")
42
- const download_path = this.kernel.bin.path(filename)
43
- console.log("download_path", download_path)
44
- ondata({ raw: "fetching " + this.url + "\r\n" })
45
- const response = await fetch(this.url, {
46
- headers: {
47
- 'User-Agent': 'curl/7.47.0'
48
- }
49
- });
50
- const fileStream = fs.createWriteStream(download_path)
51
- await new Promise((resolve, reject) => {
52
- response.body.pipe(fileStream);
53
- response.body.on("error", (err) => {
54
- console.log("ERROR", err)
55
- reject(err);
56
- });
57
- fileStream.on("finish", () => {
58
- resolve();
59
- });
60
- });
61
- console.log("FINISHED Downloading node.js")
62
-
63
- try {
64
- const node_folder = this.kernel.bin.path("node")
65
- ondata({ raw: `decompressing to ${node_folder}...\r\n` })
66
- await decompress(download_path, node_folder, { strip: 1})
67
-
68
- // delete the file
69
- ondata({ raw: "removing the compressed file " + download_path + "\r\n"})
70
- await fs.promises.rm(download_path)
71
- } catch (e) {
72
- ondata({ raw: e.toString() + "\r\n" })
73
- }
14
+ async uninstall(req, ondata) {
15
+ await this.kernel.bin.exec({
16
+ message: "conda remove nodejs",
17
+ }, ondata)
74
18
  }
75
19
  }
76
20
  module.exports = Node
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.0.30",
3
+ "version": "3.0.32",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -467,9 +467,11 @@ class Server {
467
467
  name: "git",
468
468
  }, {
469
469
  name: "zip",
470
+ }, {
471
+ name: "node",
470
472
  }, {
471
473
  type: "conda",
472
- name: ["nodejs", "ffmpeg", ],
474
+ name: "ffmpeg",
473
475
  args: "-c conda-forge"
474
476
  }]
475
477
  let platform = os.platform()
@@ -747,9 +749,11 @@ class Server {
747
749
  name: "git",
748
750
  }, {
749
751
  name: "zip",
752
+ }, {
753
+ name: "node",
750
754
  }, {
751
755
  type: "conda",
752
- name: ["nodejs", "ffmpeg", ],
756
+ name: "ffmpeg",
753
757
  args: "-c conda-forge"
754
758
  }]
755
759
  let platform = os.platform()