pinokiod 3.6.34 → 3.6.37

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.
@@ -4,6 +4,7 @@ const _ = require('lodash')
4
4
  const path = require('path')
5
5
  const { rimraf } = require('rimraf')
6
6
  const { DownloaderHelper } = require('node-downloader-helper');
7
+ const { ProxyAgent } = require('proxy-agent');
7
8
 
8
9
  //const Cmake = require("./cmake")
9
10
  const Python = require('./python')
@@ -23,7 +24,7 @@ const { glob } = require('glob')
23
24
  const fakeUa = require('fake-useragent');
24
25
  const fse = require('fs-extra')
25
26
  const semver = require('semver')
26
- const { bootstrap } = require('global-agent')
27
+ //const { bootstrap } = require('global-agent')
27
28
  const Environment = require('../environment')
28
29
  //const imageToAscii = require("image-to-ascii");
29
30
 
@@ -54,15 +55,27 @@ class Bin {
54
55
  // })
55
56
  // }
56
57
  async download(url, dest, ondata) {
58
+ console.log("DOWNLOAD process.env", process.env)
59
+ const agent = new ProxyAgent();
57
60
  const userAgent = fakeUa()
58
61
  console.log("download userAgent", userAgent)
59
- const dl = new DownloaderHelper(url, this.path(), {
62
+ const opts = {
60
63
  fileName: dest,
61
64
  override: true,
62
65
  headers: {
63
66
  "User-Agent": userAgent
64
67
  }
65
- })
68
+ }
69
+ if (process.env.HTTP_PROXY && process.env.HTTP_PROXY.length > 0) {
70
+ opts.httpRequestOptions = { agent }
71
+ opts.httpsRequestOptions = { agent }
72
+ }
73
+ if (process.env.HTTPS_PROXY && process.env.HTTPS_PROXY.length > 0) {
74
+ opts.httpRequestOptions = { agent }
75
+ opts.httpsRequestOptions = { agent }
76
+ }
77
+ console.log("opts", opts)
78
+ const dl = new DownloaderHelper(url, this.path(), opts)
66
79
  ondata({ raw: `\r\nDownloading ${url} to ${this.path()}...\r\n` })
67
80
  let res = await new Promise((resolve, reject) => {
68
81
  dl.on('end', () => {
@@ -174,6 +187,7 @@ class Bin {
174
187
  return e
175
188
  }
176
189
  async init() {
190
+ console.log("kernel.bin.init", this.kernel.homedir)
177
191
  if (this.kernel.homedir) {
178
192
  const bin_folder = this.path()
179
193
  await fs.promises.mkdir(bin_folder, { recursive: true }).catch((e) => { })
@@ -182,36 +196,34 @@ class Bin {
182
196
  process.env.PLAYWRIGHT_BROWSERS_PATH = playwright_folder
183
197
  }
184
198
  // await fs.promises.mkdir(playwright_folder, { recursive: true }).catch((e) => { })
185
- }
199
+ let system_env = await Environment.get(this.kernel.homedir)
200
+ console.log("***********", { system_env })
186
201
 
187
- let system_env = await Environment.get(this.kernel.homedir)
188
- console.log("***********", { system_env })
189
-
190
- if (system_env.HTTP_PROXY) {
191
- process.env.GLOBAL_AGENT_HTTP_PROXY = system_env.HTTP_PROXY
192
- } else {
193
- if (process.env.GLOBAL_AGENT_HTTP_PROXY) {
194
- delete process.env.GLOBAL_AGENT_HTTP_PROXY
202
+ if (system_env.HTTP_PROXY) {
203
+ process.env.HTTP_PROXY = system_env.HTTP_PROXY
204
+ } else {
205
+ if (process.env.HTTP_PROXY) {
206
+ delete process.env.HTTP_PROXY
207
+ }
195
208
  }
196
- }
197
- if (system_env.HTTPS_PROXY) {
198
- process.env.GLOBAL_AGENT_HTTPS_PROXY = system_env.HTTPS_PROXY
199
- } else {
200
- if (process.env.GLOBAL_AGENT_HTTPS_PROXY) {
201
- delete process.env.GLOBAL_AGENT_HTTPS_PROXY
209
+ if (system_env.HTTPS_PROXY) {
210
+ process.env.HTTPS_PROXY = system_env.HTTPS_PROXY
211
+ } else {
212
+ if (process.env.HTTPS_PROXY) {
213
+ delete process.env.HTTPS_PROXY
214
+ }
202
215
  }
203
- }
204
- if (system_env.NO_PROXY) {
205
- process.env.GLOBAL_AGENT_NO_PROXY = system_env.NO_PROXY
206
- } else {
207
- if (process.env.GLOBAL_AGENT_NO_PROXY) {
208
- delete process.env.GLOBAL_AGENT_NO_PROXY
216
+ if (system_env.NO_PROXY) {
217
+ process.env.NO_PROXY = system_env.NO_PROXY
218
+ } else {
219
+ if (process.env.NO_PROXY) {
220
+ delete process.env.NO_PROXY
221
+ }
209
222
  }
210
223
  }
211
224
 
212
- bootstrap();
213
225
 
214
- console.log("process.env", process.env)
226
+ // bootstrap();
215
227
 
216
228
  // ORDERING MATTERS.
217
229
  // General purpose package managers like conda, conda needs to come at the end
package/kernel/index.js CHANGED
@@ -480,6 +480,16 @@ class Kernel {
480
480
  let str = await Environment.ENV("system", this.homedir)
481
481
  await fs.promises.writeFile(path.resolve(this.homedir, "ENVIRONMENT"), str)
482
482
  }
483
+
484
+ const updated = {
485
+ HTTP_PROXY: (this.store.get("HTTP_PROXY") || ""),
486
+ HTTPS_PROXY: (this.store.get("HTTPS_PROXY") || ""),
487
+ NO_PROXY: (this.store.get("NO_PROXY") || "")
488
+ }
489
+ let fullpath = path.resolve(this.homedir, "ENVIRONMENT")
490
+ console.log("> update env", { fullpath, updated })
491
+ await Util.update_env(fullpath, updated)
492
+
483
493
  // 2. mkdir all the folders if not already created
484
494
  await Environment.init_folders(this.homedir)
485
495
 
@@ -604,10 +614,10 @@ class Kernel {
604
614
 
605
615
  await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
606
616
  await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
617
+ let pwpath = this.bin.path("playwright/node_modules/playwright")
618
+ this.playwright = (await this.loader.load(pwpath)).resolved
607
619
  }
608
620
 
609
- let pwpath = this.bin.path("playwright/node_modules/playwright")
610
- this.playwright = (await this.loader.load(pwpath)).resolved
611
621
  } catch (e) {
612
622
  console.log("### ERROR", e)
613
623
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.6.34",
3
+ "version": "3.6.37",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,7 +31,6 @@
31
31
  "fs-extra": "^11.1.1",
32
32
  "glob": "^10.3.3",
33
33
  "glob-gitignore": "^1.0.14",
34
- "global-agent": "^3.0.0",
35
34
  "go-get-folder-size": "^0.5.5",
36
35
  "http-proxy": "^1.18.1",
37
36
  "http-proxy-middleware": "^3.0.0",
@@ -50,6 +49,7 @@
50
49
  "node-gradio-client": "^0.14.6",
51
50
  "pdrive": "^0.0.26",
52
51
  "portfinder-cp": "^1.0.34",
52
+ "proxy-agent": "^6.5.0",
53
53
  "qrcode": "^1.5.3",
54
54
  "random-useragent": "^0.5.0",
55
55
  "rimraf": "^5.0.0",
package/server/index.js CHANGED
@@ -573,7 +573,10 @@ class Server {
573
573
  query: req.query
574
574
  })
575
575
  } else if (pathComponents.length === 0 && req.query.mode === "settings") {
576
- let system_env = await Environment.get(this.kernel.homedir)
576
+ let system_env = {}
577
+ if (this.kernel.homedir) {
578
+ system_env = await Environment.get(this.kernel.homedir)
579
+ }
577
580
  let configArray = [{
578
581
  key: "home",
579
582
  description: [
@@ -1978,6 +1981,7 @@ class Server {
1978
1981
  }
1979
1982
  }
1980
1983
  async setConfig(config) {
1984
+ console.log("setConfig", config)
1981
1985
  let home = this.kernel.store.get("home")
1982
1986
  let theme = this.kernel.store.get("theme")
1983
1987
  // let drive = this.kernel.store.get("drive")
@@ -2047,14 +2051,11 @@ class Server {
2047
2051
  // if (config.HTTPS_PROXY) {
2048
2052
  // updated.HTTPS_PROXY = config.HTTPS_PROXY
2049
2053
  // }
2050
- const updated = {
2051
- HTTP_PROXY: config.HTTP_PROXY,
2052
- HTTPS_PROXY: config.HTTPS_PROXY,
2053
- NO_PROXY: config.NO_PROXY,
2054
- }
2055
- let fullpath = path.resolve(this.kernel.homedir, "ENVIRONMENT")
2056
- console.log({ updated })
2057
- await Util.update_env(fullpath, updated)
2054
+
2055
+
2056
+ this.kernel.store.set("HTTP_PROXY", config.HTTP_PROXY)
2057
+ this.kernel.store.set("HTTPS_PROXY", config.HTTPS_PROXY)
2058
+ this.kernel.store.set("NO_PROXY", config.NO_PROXY)
2058
2059
  }
2059
2060
  async startLogging(homedir) {
2060
2061
  console.log(">>>>>>> startLogging", homedir)
@@ -2366,7 +2367,10 @@ class Server {
2366
2367
  } else {
2367
2368
  _home = path.resolve(os.homedir(), "pinokio")
2368
2369
  }
2369
- let system_env = await Environment.get(this.kernel.homedir)
2370
+ let system_env = {}
2371
+ if (this.kernel.homedir) {
2372
+ system_env = await Environment.get(this.kernel.homedir)
2373
+ }
2370
2374
  let configArray = [{
2371
2375
  key: "home",
2372
2376
  description: [