pinokiod 3.6.32 → 3.6.34
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/api/index.js +3 -8
- package/kernel/bin/conda.js +12 -11
- package/kernel/bin/index.js +39 -7
- package/kernel/environment.js +6 -0
- package/kernel/index.js +15 -60
- package/kernel/sysinfo.js +5 -4
- package/kernel/util.js +1 -0
- package/package.json +2 -1
- package/server/index.js +68 -2
- package/server/views/settings.ejs +39 -7
package/kernel/api/index.js
CHANGED
|
@@ -567,14 +567,9 @@ class Api {
|
|
|
567
567
|
|
|
568
568
|
}
|
|
569
569
|
async step (request, rawrpc, input, i, total, args) {
|
|
570
|
-
|
|
571
|
-
await Promise.all([this.init, this.kernel.update_sysinfo])
|
|
572
|
-
|
|
573
|
-
// await this.init()
|
|
574
|
-
//
|
|
575
|
-
// console.time("api.update_sysinfo")
|
|
576
|
-
// await this.kernel.update_sysinfo()
|
|
577
|
-
// console.timeEnd("api.update_sysinfo")
|
|
570
|
+
console.time("STEP INIT")
|
|
571
|
+
await Promise.all([this.init(), this.kernel.update_sysinfo()])
|
|
572
|
+
console.timeEnd("STEP INIT")
|
|
578
573
|
|
|
579
574
|
// clear global regular expression object RegExp.lastMatch (memory leak prevention)
|
|
580
575
|
let r = /\s*/g.exec("");
|
package/kernel/bin/conda.js
CHANGED
|
@@ -80,8 +80,8 @@ report_errors: false`)
|
|
|
80
80
|
// }
|
|
81
81
|
let pinned_exists = await this.kernel.exists("bin/miniconda/conda-meta")
|
|
82
82
|
if (pinned_exists) {
|
|
83
|
-
await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda ==24.11.3
|
|
84
|
-
sqlite ==3.47.2`)
|
|
83
|
+
await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda ==24.11.3`)
|
|
84
|
+
//sqlite ==3.47.2`)
|
|
85
85
|
// await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.9.0`)
|
|
86
86
|
// await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.11.2
|
|
87
87
|
//conda-libmamba-solver=24.11.1`)
|
|
@@ -139,14 +139,14 @@ sqlite ==3.47.2`)
|
|
|
139
139
|
// Use sqlite to check if `conda update -y --all` went through successfully
|
|
140
140
|
// sometimes it just fails silently so need to check
|
|
141
141
|
if (name === "sqlite") {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
let coerced = semver.coerce(version)
|
|
143
|
+
let sqlite_requirement = ">=3.47.2"
|
|
144
|
+
if (semver.satisfies(coerced, sqlite_requirement)) {
|
|
145
|
+
console.log("semver satisfied")
|
|
146
|
+
|
|
147
147
|
conda_check.sqlite = true
|
|
148
148
|
} else {
|
|
149
|
-
console.log("
|
|
149
|
+
console.log("semver NOT satisfied")
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
}
|
|
@@ -207,8 +207,8 @@ sqlite ==3.47.2`)
|
|
|
207
207
|
let pinned_exists = await this.kernel.exists("bin/miniconda/conda-meta")
|
|
208
208
|
if (pinned_exists) {
|
|
209
209
|
//await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.11.1`)
|
|
210
|
-
await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda ==24.11.3
|
|
211
|
-
sqlite ==3.47.2`)
|
|
210
|
+
await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda ==24.11.3`)
|
|
211
|
+
//sqlite ==3.47.2`)
|
|
212
212
|
// await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.9.0`)
|
|
213
213
|
// await fs.promises.writeFile(this.kernel.path('bin/miniconda/conda-meta/pinned'), `conda=24.11.2
|
|
214
214
|
//conda-libmamba-solver=24.11.1`)
|
|
@@ -251,7 +251,8 @@ sqlite ==3.47.2`)
|
|
|
251
251
|
//"conda install -y conda-libmamba-solver=24.11.1 conda=24.7.1",
|
|
252
252
|
//"conda install -y conda-libmamba-solver=24.11.1 conda=24.11.2",
|
|
253
253
|
//"conda update -y conda-libmamba-solver",
|
|
254
|
-
"conda update -y conda sqlite",// -vvv --debug",
|
|
254
|
+
//"conda update -y conda sqlite",// -vvv --debug",
|
|
255
|
+
"conda update -y conda",// -vvv --debug",
|
|
255
256
|
"conda update -y --all",// -vvv --debug",
|
|
256
257
|
// "python -m pip install --upgrade pip setuptools wheel",
|
|
257
258
|
// "python -m ensurepip --upgrade",
|
package/kernel/bin/index.js
CHANGED
|
@@ -23,6 +23,8 @@ const { glob } = require('glob')
|
|
|
23
23
|
const fakeUa = require('fake-useragent');
|
|
24
24
|
const fse = require('fs-extra')
|
|
25
25
|
const semver = require('semver')
|
|
26
|
+
const { bootstrap } = require('global-agent')
|
|
27
|
+
const Environment = require('../environment')
|
|
26
28
|
//const imageToAscii = require("image-to-ascii");
|
|
27
29
|
|
|
28
30
|
|
|
@@ -181,6 +183,36 @@ class Bin {
|
|
|
181
183
|
}
|
|
182
184
|
// await fs.promises.mkdir(playwright_folder, { recursive: true }).catch((e) => { })
|
|
183
185
|
}
|
|
186
|
+
|
|
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
|
|
195
|
+
}
|
|
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
|
|
202
|
+
}
|
|
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
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
bootstrap();
|
|
213
|
+
|
|
214
|
+
console.log("process.env", process.env)
|
|
215
|
+
|
|
184
216
|
// ORDERING MATTERS.
|
|
185
217
|
// General purpose package managers like conda, conda needs to come at the end
|
|
186
218
|
|
|
@@ -309,15 +341,15 @@ class Bin {
|
|
|
309
341
|
// Use sqlite to check if `conda update -y --all` went through successfully
|
|
310
342
|
// sometimes it just fails silently so need to check
|
|
311
343
|
if (name === "sqlite") {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
344
|
+
let coerced = semver.coerce(version)
|
|
345
|
+
let sqlite_requirement = ">=3.47.2"
|
|
346
|
+
// console.log({ coerced, version, sqlite_requirement })
|
|
347
|
+
if (semver.satisfies(coerced, sqlite_requirement)) {
|
|
348
|
+
console.log("semver satisfied")
|
|
349
|
+
|
|
318
350
|
conda_check.sqlite = true
|
|
319
351
|
} else {
|
|
320
|
-
console.log("
|
|
352
|
+
console.log("semver NOT satisfied")
|
|
321
353
|
}
|
|
322
354
|
}
|
|
323
355
|
}
|
package/kernel/environment.js
CHANGED
|
@@ -400,6 +400,12 @@ const get2 = async (filepath, kernel) => {
|
|
|
400
400
|
let api_env = await get(api_path)
|
|
401
401
|
let process_env = kernel.envs || process.env
|
|
402
402
|
let current_env = Object.assign({}, process_env, default_env, api_env)
|
|
403
|
+
for(let key in current_env) {
|
|
404
|
+
let val = current_env[key]
|
|
405
|
+
if (typeof val === 'String' && val.trim() === "") {
|
|
406
|
+
delete current_env[key]
|
|
407
|
+
}
|
|
408
|
+
}
|
|
403
409
|
return current_env
|
|
404
410
|
}
|
|
405
411
|
|
package/kernel/index.js
CHANGED
|
@@ -234,9 +234,14 @@ class Kernel {
|
|
|
234
234
|
async wait(options) {
|
|
235
235
|
await waitOn(options)
|
|
236
236
|
}
|
|
237
|
-
async getInfo(){
|
|
237
|
+
async getInfo(refresh){
|
|
238
238
|
let info = this.sysinfo
|
|
239
|
-
|
|
239
|
+
console.time(">>>>> updateSysinfo")
|
|
240
|
+
console.log("refresh", refresh)
|
|
241
|
+
if (refresh) {
|
|
242
|
+
await this.update_sysinfo()
|
|
243
|
+
}
|
|
244
|
+
console.timeEnd(">>>>> updateSysinfo")
|
|
240
245
|
let i = {
|
|
241
246
|
version: this.version,
|
|
242
247
|
platform: this.platform,
|
|
@@ -565,11 +570,14 @@ class Kernel {
|
|
|
565
570
|
}
|
|
566
571
|
})
|
|
567
572
|
let ts2 = Date.now()
|
|
573
|
+
console.time(">>>> 6 api.init")
|
|
568
574
|
await this.api.init()
|
|
575
|
+
console.timeEnd(">>>> 6 api.init")
|
|
569
576
|
|
|
570
577
|
//await this.shell.init()
|
|
571
578
|
|
|
572
579
|
if (this.homedir) {
|
|
580
|
+
console.time(">>>> 7 template.init")
|
|
573
581
|
await this.template.init({
|
|
574
582
|
kernel: this,
|
|
575
583
|
system,
|
|
@@ -579,80 +587,27 @@ class Kernel {
|
|
|
579
587
|
return this.api.get_proxy_url("/proxy", port)
|
|
580
588
|
},
|
|
581
589
|
})
|
|
590
|
+
console.timeEnd(">>>> 7 template.init")
|
|
582
591
|
this.sys = new Sysinfo()
|
|
583
592
|
console.time("sys init")
|
|
593
|
+
console.time(">>>> 8 sys.init")
|
|
584
594
|
await this.sys.init(this)
|
|
595
|
+
console.timeEnd(">>>> 8 sys.init")
|
|
585
596
|
console.timeEnd("sys init")
|
|
586
597
|
let info = this.sys.info
|
|
587
598
|
|
|
588
599
|
this.sysinfo = info
|
|
589
600
|
|
|
601
|
+
console.time(">>>> 9 getInfo")
|
|
590
602
|
await this.getInfo()
|
|
603
|
+
console.timeEnd(">>>> 9 getInfo")
|
|
591
604
|
|
|
592
605
|
await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
593
606
|
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
|
|
594
|
-
|
|
595
|
-
/*
|
|
596
|
-
this.sys = new Sysinfo()
|
|
597
|
-
await this.sys.init(this)
|
|
598
|
-
let info = this.sys.info
|
|
599
|
-
await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
600
|
-
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify({
|
|
601
|
-
platform: this.platform,
|
|
602
|
-
arch: this.arch,
|
|
603
|
-
home: this.homedir,
|
|
604
|
-
...info
|
|
605
|
-
}, null, 2))
|
|
606
|
-
this.sysinfo = info
|
|
607
|
-
console.time("template.init")
|
|
608
|
-
await this.template.init({
|
|
609
|
-
kernel: this,
|
|
610
|
-
system,
|
|
611
|
-
platform: this.platform,
|
|
612
|
-
arch: this.arch,
|
|
613
|
-
proxy: (port) => {
|
|
614
|
-
return this.api.get_proxy_url("/proxy", port)
|
|
615
|
-
},
|
|
616
|
-
...info
|
|
617
|
-
})
|
|
618
|
-
console.timeEnd("template.init")
|
|
619
|
-
console.time("update_sysinfo")
|
|
620
|
-
await this.update_sysinfo()
|
|
621
|
-
console.timeEnd("update_sysinfo")
|
|
622
|
-
*/
|
|
623
|
-
// console.log("> 4")
|
|
624
|
-
// this.shell.init().then(() => {
|
|
625
|
-
// if (this.envs) {
|
|
626
|
-
// this.template.update({
|
|
627
|
-
// env: this.envs,
|
|
628
|
-
// envs: this.envs
|
|
629
|
-
// })
|
|
630
|
-
// }
|
|
631
|
-
// })
|
|
632
|
-
//await this.shell.init()
|
|
633
607
|
}
|
|
634
608
|
|
|
635
|
-
//let pwpath = this.bin.path("playwright/js/node_modules/playwright")
|
|
636
609
|
let pwpath = this.bin.path("playwright/node_modules/playwright")
|
|
637
610
|
this.playwright = (await this.loader.load(pwpath)).resolved
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
// let pwpath
|
|
641
|
-
// if (this.platform === "win32") {
|
|
642
|
-
// pwpath = this.bin.path("miniconda/node_modules/playwright")
|
|
643
|
-
// } else {
|
|
644
|
-
// pwpath = this.bin.path("miniconda/lib/node_modules/playwright")
|
|
645
|
-
// }
|
|
646
|
-
|
|
647
|
-
// await this.template.init()
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
// let PuppeteerPath = this.bin.path("puppet", "node_modules", "puppeteer")
|
|
651
|
-
// this.puppet = (await this.loader.load(PuppeteerPath)).resolved
|
|
652
|
-
// this.puppet.setGlobalOptions({
|
|
653
|
-
// userDataDir: this.bin.path("puppet")
|
|
654
|
-
// });
|
|
655
|
-
|
|
656
611
|
} catch (e) {
|
|
657
612
|
console.log("### ERROR", e)
|
|
658
613
|
}
|
package/kernel/sysinfo.js
CHANGED
|
@@ -5,12 +5,12 @@ class Sysinfo {
|
|
|
5
5
|
async init(kernel) {
|
|
6
6
|
this.kernel = kernel
|
|
7
7
|
this.info = {}
|
|
8
|
-
await Promise.all([this.static, this.refresh])
|
|
8
|
+
await Promise.all([this.static(), this.refresh()])
|
|
9
9
|
// await this.static()
|
|
10
10
|
// await this.refresh()
|
|
11
11
|
}
|
|
12
12
|
async static() {
|
|
13
|
-
await Promise.all([this.gpus, this.system, this.cpu, this.os, this.audio, this.env])
|
|
13
|
+
await Promise.all([this.gpus(), this.system(), this.cpu(), this.os(), this.audio(), this.env()])
|
|
14
14
|
// await this.gpus()
|
|
15
15
|
// await this.system()
|
|
16
16
|
// await this.cpu()
|
|
@@ -25,12 +25,12 @@ class Sysinfo {
|
|
|
25
25
|
// await this.time()
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
await Promise.all([this.memory, this.battery, this.proc, this.bluetooth])
|
|
28
|
+
await Promise.all([this.memory(), this.battery(), this.proc(), this.bluetooth()])
|
|
29
29
|
// await this.memory()
|
|
30
30
|
// await this.battery()
|
|
31
31
|
// await this.proc()
|
|
32
32
|
// await this.bluetooth()
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
// await this.net()
|
|
@@ -75,6 +75,7 @@ class Sysinfo {
|
|
|
75
75
|
this.info.gpus = gpus
|
|
76
76
|
this.info.gpu = gpu
|
|
77
77
|
this.info.gpu_model = gpu_model
|
|
78
|
+
console.log("> this.info", this.info)
|
|
78
79
|
|
|
79
80
|
}
|
|
80
81
|
// async time() {
|
package/kernel/util.js
CHANGED
|
@@ -200,6 +200,7 @@ const escapeStringRegexp = (string) => {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
const update_env = async (filepath, changes) => {
|
|
203
|
+
console.log("UPDATE_ENV", { filepath, changes })
|
|
203
204
|
const env = await fs.promises.readFile(filepath, "utf8")
|
|
204
205
|
let append = false;
|
|
205
206
|
const newval = Object.keys(changes).reduce((result, varname) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.34",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
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",
|
|
34
35
|
"go-get-folder-size": "^0.5.5",
|
|
35
36
|
"http-proxy": "^1.18.1",
|
|
36
37
|
"http-proxy-middleware": "^3.0.0",
|
package/server/index.js
CHANGED
|
@@ -75,6 +75,7 @@ class Server {
|
|
|
75
75
|
process.env.WEBKIT_DISABLE_DMABUF_RENDERER = 1
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
|
|
78
79
|
// process.env.CONDA_LIBMAMBA_SOLVER_DEBUG_LIBSOLV = 1
|
|
79
80
|
}
|
|
80
81
|
stop() {
|
|
@@ -572,6 +573,7 @@ class Server {
|
|
|
572
573
|
query: req.query
|
|
573
574
|
})
|
|
574
575
|
} else if (pathComponents.length === 0 && req.query.mode === "settings") {
|
|
576
|
+
let system_env = await Environment.get(this.kernel.homedir)
|
|
575
577
|
let configArray = [{
|
|
576
578
|
key: "home",
|
|
577
579
|
description: [
|
|
@@ -588,6 +590,21 @@ class Server {
|
|
|
588
590
|
key: "theme",
|
|
589
591
|
val: this.theme,
|
|
590
592
|
options: ["light", "dark"]
|
|
593
|
+
}, {
|
|
594
|
+
key: "HTTP_PROXY",
|
|
595
|
+
val: (system_env.HTTP_PROXY || ""),
|
|
596
|
+
show_on_click: "#proxy",
|
|
597
|
+
placeholder: "(Advanced) Only set if you are behind a proxy"
|
|
598
|
+
}, {
|
|
599
|
+
key: "HTTPS_PROXY",
|
|
600
|
+
val: (system_env.HTTPS_PROXY || ""),
|
|
601
|
+
show_on_click: "#proxy",
|
|
602
|
+
placeholder: "(Advanced) Only set if you are behind a proxy"
|
|
603
|
+
}, {
|
|
604
|
+
key: "NO_PROXY",
|
|
605
|
+
val: (system_env.NO_PROXY || ""),
|
|
606
|
+
show_on_click: "#proxy",
|
|
607
|
+
placeholder: "(Advanced) Only set if you are behind a proxy"
|
|
591
608
|
}]
|
|
592
609
|
let folders = {}
|
|
593
610
|
if (this.kernel.homedir) {
|
|
@@ -597,6 +614,7 @@ class Server {
|
|
|
597
614
|
drive: path.resolve(this.kernel.homedir, "drive"),
|
|
598
615
|
}
|
|
599
616
|
}
|
|
617
|
+
console.log({ configArray })
|
|
600
618
|
res.render("settings", {
|
|
601
619
|
platform,
|
|
602
620
|
version: this.version,
|
|
@@ -899,6 +917,7 @@ class Server {
|
|
|
899
917
|
let install_required = true
|
|
900
918
|
if (!requirements_pending) {
|
|
901
919
|
install_required = false
|
|
920
|
+
console.time(">>>>>>>>>> 1")
|
|
902
921
|
for(let i=0; i<requirements.length; i++) {
|
|
903
922
|
let r = requirements[i]
|
|
904
923
|
|
|
@@ -912,6 +931,7 @@ class Server {
|
|
|
912
931
|
}
|
|
913
932
|
}
|
|
914
933
|
}
|
|
934
|
+
console.timeEnd(">>>>>>>>>> 1")
|
|
915
935
|
}
|
|
916
936
|
|
|
917
937
|
let error = null
|
|
@@ -2016,6 +2036,25 @@ class Server {
|
|
|
2016
2036
|
home = this.kernel.store.get("home")
|
|
2017
2037
|
theme = this.kernel.store.get("theme")
|
|
2018
2038
|
let new_home = this.kernel.store.get("new_home")
|
|
2039
|
+
|
|
2040
|
+
// Handle environment variables
|
|
2041
|
+
// HTTP_PROXY
|
|
2042
|
+
// HTTPS_PROXY
|
|
2043
|
+
// const updated = { }
|
|
2044
|
+
// if (config.HTTP_PROXY) {
|
|
2045
|
+
// updated.HTTP_PROXY = config.HTTP_PROXY
|
|
2046
|
+
// }
|
|
2047
|
+
// if (config.HTTPS_PROXY) {
|
|
2048
|
+
// updated.HTTPS_PROXY = config.HTTPS_PROXY
|
|
2049
|
+
// }
|
|
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)
|
|
2019
2058
|
}
|
|
2020
2059
|
async startLogging(homedir) {
|
|
2021
2060
|
console.log(">>>>>>> startLogging", homedir)
|
|
@@ -2053,11 +2092,13 @@ class Server {
|
|
|
2053
2092
|
}
|
|
2054
2093
|
}
|
|
2055
2094
|
async start(options) {
|
|
2095
|
+
console.time("SERVER START")
|
|
2056
2096
|
this.debug = false
|
|
2057
2097
|
if (options) {
|
|
2058
2098
|
this.debug = options.debug
|
|
2059
2099
|
this.browser = options.browser
|
|
2060
2100
|
}
|
|
2101
|
+
console.time(">>>> 1")
|
|
2061
2102
|
|
|
2062
2103
|
if (this.listening) {
|
|
2063
2104
|
// stop proxies
|
|
@@ -2084,10 +2125,14 @@ class Server {
|
|
|
2084
2125
|
// } catch (e) {
|
|
2085
2126
|
// }
|
|
2086
2127
|
}
|
|
2128
|
+
console.timeEnd(">>>> 1")
|
|
2087
2129
|
|
|
2088
2130
|
// configure from kernel.store
|
|
2131
|
+
console.time(">>>> 2")
|
|
2089
2132
|
await this.syncConfig()
|
|
2133
|
+
console.timeEnd(">>>> 2")
|
|
2090
2134
|
|
|
2135
|
+
console.time(">>>> 3")
|
|
2091
2136
|
try {
|
|
2092
2137
|
let _home = this.kernel.store.get("home")
|
|
2093
2138
|
console.log({ _home })
|
|
@@ -2097,6 +2142,7 @@ class Server {
|
|
|
2097
2142
|
} catch (e) {
|
|
2098
2143
|
console.log("start logging attempt", e)
|
|
2099
2144
|
}
|
|
2145
|
+
console.timeEnd(">>>> 3")
|
|
2100
2146
|
|
|
2101
2147
|
// determine port if port is not passed in
|
|
2102
2148
|
|
|
@@ -2153,12 +2199,16 @@ class Server {
|
|
|
2153
2199
|
}
|
|
2154
2200
|
|
|
2155
2201
|
// initialize kernel
|
|
2202
|
+
console.time(">>>> 4 kernel.init")
|
|
2156
2203
|
await this.kernel.init({ port: this.port})
|
|
2204
|
+
console.timeEnd(">>>> 4 kernel.init")
|
|
2157
2205
|
|
|
2206
|
+
console.time(">>>> 5 kernel.initHome")
|
|
2158
2207
|
console.log({ needInitHome })
|
|
2159
2208
|
if (needInitHome) {
|
|
2160
2209
|
await this.kernel.initHome()
|
|
2161
2210
|
}
|
|
2211
|
+
console.timeEnd(">>>> 5 kernel.initHome")
|
|
2162
2212
|
|
|
2163
2213
|
if (this.kernel.homedir) {
|
|
2164
2214
|
let ex = await this.kernel.exists(this.kernel.homedir, "ENVIRONMENT")
|
|
@@ -2316,6 +2366,7 @@ class Server {
|
|
|
2316
2366
|
} else {
|
|
2317
2367
|
_home = path.resolve(os.homedir(), "pinokio")
|
|
2318
2368
|
}
|
|
2369
|
+
let system_env = await Environment.get(this.kernel.homedir)
|
|
2319
2370
|
let configArray = [{
|
|
2320
2371
|
key: "home",
|
|
2321
2372
|
description: [
|
|
@@ -2333,6 +2384,21 @@ class Server {
|
|
|
2333
2384
|
key: "theme",
|
|
2334
2385
|
val: this.theme,
|
|
2335
2386
|
options: ["light", "dark"]
|
|
2387
|
+
}, {
|
|
2388
|
+
key: "HTTP_PROXY",
|
|
2389
|
+
val: (system_env.HTTP_PROXY || ""),
|
|
2390
|
+
show_on_click: "#proxy",
|
|
2391
|
+
placeholder: "(Advanced) Only set if you are behind a proxy"
|
|
2392
|
+
}, {
|
|
2393
|
+
key: "HTTPS_PROXY",
|
|
2394
|
+
val: (system_env.HTTPS_PROXY || ""),
|
|
2395
|
+
show_on_click: "#proxy",
|
|
2396
|
+
placeholder: "(Advanced) Only set if you are behind a proxy"
|
|
2397
|
+
}, {
|
|
2398
|
+
key: "NO_PROXY",
|
|
2399
|
+
val: (system_env.NO_PROXY || ""),
|
|
2400
|
+
show_on_click: "#proxy",
|
|
2401
|
+
placeholder: "(Advanced) Only set if you are behind a proxy"
|
|
2336
2402
|
}]
|
|
2337
2403
|
let folders = {}
|
|
2338
2404
|
if (this.kernel.homedir) {
|
|
@@ -3124,7 +3190,7 @@ class Server {
|
|
|
3124
3190
|
res.json({ success: true })
|
|
3125
3191
|
}))
|
|
3126
3192
|
this.app.get("/pinokio/info", ex(async (req, res) => {
|
|
3127
|
-
await this.kernel.getInfo()
|
|
3193
|
+
await this.kernel.getInfo(true)
|
|
3128
3194
|
let info = Object.assign({}, this.kernel.i)
|
|
3129
3195
|
info.launch_complete = this.kernel.launch_complete
|
|
3130
3196
|
console.log("kernel.launch_complete", this.kernel.launch_complete)
|
|
@@ -3378,7 +3444,6 @@ class Server {
|
|
|
3378
3444
|
this.start({ debug: this.debug, browser: this.browser })
|
|
3379
3445
|
}))
|
|
3380
3446
|
this.app.post("/config", ex(async (req, res) => {
|
|
3381
|
-
console.log("/config", { body: req.body })
|
|
3382
3447
|
try {
|
|
3383
3448
|
await this.setConfig(req.body)
|
|
3384
3449
|
res.json({ success: true })
|
|
@@ -3430,6 +3495,7 @@ class Server {
|
|
|
3430
3495
|
server: this.listening
|
|
3431
3496
|
});
|
|
3432
3497
|
})
|
|
3498
|
+
console.timeEnd("SERVER START")
|
|
3433
3499
|
|
|
3434
3500
|
}
|
|
3435
3501
|
}
|
|
@@ -194,6 +194,12 @@ hr {
|
|
|
194
194
|
margin-bottom: 10px;
|
|
195
195
|
text-align: center;
|
|
196
196
|
}
|
|
197
|
+
#proxy {
|
|
198
|
+
text-decoration: underline;
|
|
199
|
+
margin-left: 10px;
|
|
200
|
+
display: inline-block;
|
|
201
|
+
cursor: pointer;
|
|
202
|
+
}
|
|
197
203
|
</style>
|
|
198
204
|
<script src="/hotkeys.min.js"></script>
|
|
199
205
|
<script src="/sweetalert2.js"></script>
|
|
@@ -266,7 +272,7 @@ hr {
|
|
|
266
272
|
</div>
|
|
267
273
|
<form>
|
|
268
274
|
<% config.forEach((c) => { %>
|
|
269
|
-
<div class='item'
|
|
275
|
+
<div class='item <%=c.show_on_click ? "hidden" : ""%>' <%=c.show_on_click ? "data-onclick=" + c.show_on_click : ""%>>
|
|
270
276
|
<label><%=c.key%></label>
|
|
271
277
|
<% if (c.options) { %>
|
|
272
278
|
<select name="<%=c.key%>">
|
|
@@ -298,6 +304,7 @@ hr {
|
|
|
298
304
|
<% }) %>
|
|
299
305
|
<br>
|
|
300
306
|
<button id='save' class='btn disabled'>Save</button>
|
|
307
|
+
<a id='proxy'>Running behind proxy?</a>
|
|
301
308
|
</form>
|
|
302
309
|
<div class='loading hidden'>
|
|
303
310
|
<i class="fa-solid fa-circle-notch fa-spin"></i> Stand by. Do not close this window..
|
|
@@ -485,6 +492,11 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
485
492
|
// let sep = "<%=platform === 'win32' ? '\\' : '/'%>"
|
|
486
493
|
// document.querySelector("[name=drive]").value = e.target.value + sep + "drive"
|
|
487
494
|
// })
|
|
495
|
+
document.querySelector("#proxy").addEventListener("click", (e) => {
|
|
496
|
+
document.querySelectorAll("[data-onclick='#proxy']").forEach((el) => {
|
|
497
|
+
el.classList.remove("hidden")
|
|
498
|
+
})
|
|
499
|
+
})
|
|
488
500
|
document.querySelector("#back").addEventListener("click", (e) => {
|
|
489
501
|
history.back()
|
|
490
502
|
})
|
|
@@ -523,6 +535,11 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
523
535
|
document.querySelector("[name=home]").focus()
|
|
524
536
|
return
|
|
525
537
|
}
|
|
538
|
+
if (val.length === 0) {
|
|
539
|
+
alert("Please set the home path")
|
|
540
|
+
document.querySelector("[name=home]").focus()
|
|
541
|
+
return
|
|
542
|
+
}
|
|
526
543
|
|
|
527
544
|
// let drive = document.querySelector(`[name=drive]`).value
|
|
528
545
|
// if (/.*\s+.*/.test(drive)) {
|
|
@@ -536,15 +553,30 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
536
553
|
document.querySelector("#save").classList.add("hidden")
|
|
537
554
|
document.querySelector("[name=home]").setAttribute("disabled", "disabled")
|
|
538
555
|
// document.querySelector("[name=drive]").setAttribute("disabled", "disabled")
|
|
539
|
-
let theme = document.querySelector(`[name=theme]`).value
|
|
556
|
+
// let theme = document.querySelector(`[name=theme]`).value
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
let body = {}
|
|
560
|
+
let els = document.querySelectorAll(".item [name]")
|
|
561
|
+
for(let el of els) {
|
|
562
|
+
let name = el.getAttribute("name")
|
|
563
|
+
// if (el.value && el.value.length > 0) {
|
|
564
|
+
body[name] = el.value
|
|
565
|
+
// }
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
console.log("body", body)
|
|
569
|
+
|
|
570
|
+
|
|
540
571
|
let r = await fetch("/config", {
|
|
541
572
|
method: "post",
|
|
542
573
|
headers: { "Content-Type": "application/json" },
|
|
543
|
-
body: JSON.stringify(
|
|
544
|
-
|
|
545
|
-
//
|
|
546
|
-
|
|
547
|
-
|
|
574
|
+
body: JSON.stringify(body)
|
|
575
|
+
// body: JSON.stringify({
|
|
576
|
+
// home: (val && val.length > 0 ? val : null),
|
|
577
|
+
//// drive: (drive && drive.length > 0 ? drive : null),
|
|
578
|
+
// theme
|
|
579
|
+
// })
|
|
548
580
|
}).then((res) => {
|
|
549
581
|
return res.json()
|
|
550
582
|
})
|