pinokiod 3.6.35 → 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.
- package/kernel/bin/index.js +38 -26
- package/kernel/index.js +12 -2
- package/package.json +2 -2
- package/server/index.js +6 -10
package/kernel/bin/index.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
@@ -1981,6 +1981,7 @@ class Server {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
}
|
|
1983
1983
|
async setConfig(config) {
|
|
1984
|
+
console.log("setConfig", config)
|
|
1984
1985
|
let home = this.kernel.store.get("home")
|
|
1985
1986
|
let theme = this.kernel.store.get("theme")
|
|
1986
1987
|
// let drive = this.kernel.store.get("drive")
|
|
@@ -2050,16 +2051,11 @@ class Server {
|
|
|
2050
2051
|
// if (config.HTTPS_PROXY) {
|
|
2051
2052
|
// updated.HTTPS_PROXY = config.HTTPS_PROXY
|
|
2052
2053
|
// }
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
}
|
|
2059
|
-
let fullpath = path.resolve(this.kernel.homedir, "ENVIRONMENT")
|
|
2060
|
-
console.log({ updated })
|
|
2061
|
-
await Util.update_env(fullpath, updated)
|
|
2062
|
-
}
|
|
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)
|
|
2063
2059
|
}
|
|
2064
2060
|
async startLogging(homedir) {
|
|
2065
2061
|
console.log(">>>>>>> startLogging", homedir)
|