pinokiod 3.2.197 → 3.2.200
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 +19 -3
- package/kernel/api/local/index.js +1 -1
- package/kernel/bin/conda.js +0 -4
- package/kernel/bin/index.js +29 -33
- package/kernel/index.js +32 -14
- package/kernel/shell.js +5 -7
- package/package.json +2 -1
- package/server/index.js +86 -61
- package/server/views/pre.ejs +2 -2
package/kernel/api/index.js
CHANGED
|
@@ -623,10 +623,26 @@ class Api {
|
|
|
623
623
|
|
|
624
624
|
rpc.args = args
|
|
625
625
|
|
|
626
|
-
if (
|
|
627
|
-
|
|
626
|
+
if (rpc.hasOwnProperty("next")) {
|
|
627
|
+
console.log("next already exists, don't touch", rpc.next)
|
|
628
|
+
if (typeof rpc.next === "string") {
|
|
629
|
+
let run = script.run
|
|
630
|
+
console.log("run", run)
|
|
631
|
+
for(let i=0; i<run.length; i++) {
|
|
632
|
+
let step = run[i]
|
|
633
|
+
if (step && step.id === rpc.next) {
|
|
634
|
+
rpc.next = i
|
|
635
|
+
break
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
628
639
|
} else {
|
|
629
|
-
|
|
640
|
+
if (i < script.run.length-1) {
|
|
641
|
+
rpc.next = i+1
|
|
642
|
+
} else {
|
|
643
|
+
rpc.next = null
|
|
644
|
+
}
|
|
645
|
+
console.log("next is not set. compute the next value", rpc.next)
|
|
630
646
|
}
|
|
631
647
|
|
|
632
648
|
if (rpc.hasOwnProperty("when")) {
|
|
@@ -64,7 +64,7 @@ class Local {
|
|
|
64
64
|
*/
|
|
65
65
|
|
|
66
66
|
let current_env = await Environment.get2(req.parent.path, kernel)
|
|
67
|
-
console.log({ current_env })
|
|
67
|
+
// console.log({ current_env })
|
|
68
68
|
|
|
69
69
|
// if the key at current_env.PINOKIO_SHARE_VAR (by default it's 'url') is the variable being set, trigger the share logic
|
|
70
70
|
if (current_env.PINOKIO_SHARE_VAR && current_env.PINOKIO_SHARE_VAR in req.params) {
|
package/kernel/bin/conda.js
CHANGED
|
@@ -96,13 +96,11 @@ create_default_packages:
|
|
|
96
96
|
// console.log("conda list check", { stream })
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
console.log("CONDA", res.response)
|
|
100
99
|
let lines = res.response.split(/[\r\n]+/)
|
|
101
100
|
let conda_check = {}
|
|
102
101
|
let conda = new Set()
|
|
103
102
|
let start = false
|
|
104
103
|
for(let line of lines) {
|
|
105
|
-
console.log({ line, start })
|
|
106
104
|
if (start) {
|
|
107
105
|
let chunks = line.split(/\s+/).filter(x => x)
|
|
108
106
|
if (chunks.length > 1) {
|
|
@@ -122,7 +120,6 @@ create_default_packages:
|
|
|
122
120
|
let channel = chunks[3]
|
|
123
121
|
let coerced = semver.coerce(version)
|
|
124
122
|
let mamba_requirement = ">=24.11.1"
|
|
125
|
-
console.log({ name, channel, version })
|
|
126
123
|
if (semver.satisfies(coerced, mamba_requirement) && channel === "conda-forge") {
|
|
127
124
|
conda_check.mamba = true
|
|
128
125
|
}
|
|
@@ -133,7 +130,6 @@ create_default_packages:
|
|
|
133
130
|
if (name === "sqlite") {
|
|
134
131
|
let coerced = semver.coerce(version)
|
|
135
132
|
let sqlite_requirement = ">=3.47.2"
|
|
136
|
-
console.log({ coerced, version, sqlite_requirement })
|
|
137
133
|
if (semver.satisfies(coerced, sqlite_requirement)) {
|
|
138
134
|
console.log("semver satisfied")
|
|
139
135
|
conda_check.sqlite = true
|
package/kernel/bin/index.js
CHANGED
|
@@ -142,9 +142,7 @@ class Bin {
|
|
|
142
142
|
this.vs_path_env = mod.mod.env(this.kernel)
|
|
143
143
|
return null
|
|
144
144
|
} else {
|
|
145
|
-
console.log({ mod })
|
|
146
145
|
if (mod.mod.env) {
|
|
147
|
-
console.log("env", mod.mod.env)
|
|
148
146
|
return mod.mod.env(this.kernel)
|
|
149
147
|
} else {
|
|
150
148
|
return null
|
|
@@ -243,10 +241,8 @@ class Bin {
|
|
|
243
241
|
// console.log("conda list check", { stream })
|
|
244
242
|
})
|
|
245
243
|
|
|
246
|
-
console.log("CONDA", res.response)
|
|
247
244
|
let lines = res.response.split(/[\r\n]+/)
|
|
248
245
|
for(let line of lines) {
|
|
249
|
-
console.log({ line, start })
|
|
250
246
|
if (start) {
|
|
251
247
|
let chunks = line.split(/\s+/).filter(x => x)
|
|
252
248
|
if (chunks.length > 1) {
|
|
@@ -274,7 +270,7 @@ class Bin {
|
|
|
274
270
|
if (name === "sqlite") {
|
|
275
271
|
let coerced = semver.coerce(version)
|
|
276
272
|
let sqlite_requirement = ">=3.47.2"
|
|
277
|
-
console.log({ coerced, version, sqlite_requirement })
|
|
273
|
+
// console.log({ coerced, version, sqlite_requirement })
|
|
278
274
|
if (semver.satisfies(coerced, sqlite_requirement)) {
|
|
279
275
|
console.log("semver satisfied")
|
|
280
276
|
conda_check.sqlite = true
|
|
@@ -325,38 +321,38 @@ class Bin {
|
|
|
325
321
|
// Try 3 times, because sometimes conda just silently quits with no error message
|
|
326
322
|
for(let i=0; i<5; i++) {
|
|
327
323
|
await this.tryList()
|
|
328
|
-
console.log(`> conda list ${i}`, Array.from(this.installed.conda))
|
|
324
|
+
// console.log(`> conda list ${i}`, Array.from(this.installed.conda))
|
|
329
325
|
if (this.installed.conda.size > 0) {
|
|
330
326
|
break
|
|
331
327
|
}
|
|
332
328
|
}
|
|
333
329
|
}
|
|
334
330
|
|
|
335
|
-
// 2. pip
|
|
336
|
-
let pip = new Set()
|
|
337
|
-
if (conda_exists) {
|
|
338
|
-
// conda comes with pip
|
|
339
|
-
console.log("## check pip")
|
|
340
|
-
start = false
|
|
341
|
-
res = await this.exec({ message: `pip list` }, (stream) => {
|
|
342
|
-
|
|
343
|
-
})
|
|
344
|
-
console.log("PIP", res.response)
|
|
345
|
-
lines = res.response.split(/[\r\n]+/)
|
|
346
|
-
for(let line of lines) {
|
|
347
|
-
if (start) {
|
|
348
|
-
let chunks = line.split(/\s+/).filter(x => x)
|
|
349
|
-
if (chunks.length > 1) {
|
|
350
|
-
pip.add(chunks[0])
|
|
351
|
-
}
|
|
352
|
-
} else {
|
|
353
|
-
if (/-------.*/i.test(line)) {
|
|
354
|
-
start = true
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
this.installed.pip = pip
|
|
331
|
+
// // 2. pip
|
|
332
|
+
// let pip = new Set()
|
|
333
|
+
// if (conda_exists) {
|
|
334
|
+
// // conda comes with pip
|
|
335
|
+
// console.log("## check pip")
|
|
336
|
+
// start = false
|
|
337
|
+
// res = await this.exec({ message: `pip list` }, (stream) => {
|
|
338
|
+
//// console.log("pip list check", { stream })
|
|
339
|
+
// })
|
|
340
|
+
// console.log("PIP", res.response)
|
|
341
|
+
// lines = res.response.split(/[\r\n]+/)
|
|
342
|
+
// for(let line of lines) {
|
|
343
|
+
// if (start) {
|
|
344
|
+
// let chunks = line.split(/\s+/).filter(x => x)
|
|
345
|
+
// if (chunks.length > 1) {
|
|
346
|
+
// pip.add(chunks[0])
|
|
347
|
+
// }
|
|
348
|
+
// } else {
|
|
349
|
+
// if (/-------.*/i.test(line)) {
|
|
350
|
+
// start = true
|
|
351
|
+
// }
|
|
352
|
+
// }
|
|
353
|
+
// }
|
|
354
|
+
// }
|
|
355
|
+
// this.installed.pip = pip
|
|
360
356
|
|
|
361
357
|
|
|
362
358
|
if (this.platform === "darwin") {
|
|
@@ -427,7 +423,7 @@ class Bin {
|
|
|
427
423
|
} else {
|
|
428
424
|
e4 = false
|
|
429
425
|
}
|
|
430
|
-
console.log({ e, e2, e3, e4
|
|
426
|
+
console.log("BREW CHECK", { e, e2, e3, e4 })
|
|
431
427
|
this.brew_installed = e && e2 && e3 && e4
|
|
432
428
|
|
|
433
429
|
}
|
|
@@ -644,7 +640,7 @@ class Bin {
|
|
|
644
640
|
if (type === "conda") {
|
|
645
641
|
return this.kernel.bin.installed.conda.has(name)
|
|
646
642
|
} else if (type === "pip") {
|
|
647
|
-
return this.kernel.bin.installed.pip.has(name)
|
|
643
|
+
return this.kernel.bin.installed.pip && this.kernel.bin.installed.pip.has(name)
|
|
648
644
|
} else if (type === "brew") {
|
|
649
645
|
return this.kernel.bin.installed.brew.has(name)
|
|
650
646
|
} else {
|
package/kernel/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const Api = require("./api")
|
|
|
14
14
|
const Python = require("./python")
|
|
15
15
|
//const Template = require('./template')
|
|
16
16
|
const Template = require('jimini')
|
|
17
|
+
const which = require('which')
|
|
17
18
|
const Shells = require("./shells")
|
|
18
19
|
const Key = require("./key")
|
|
19
20
|
const Script = require('./script')
|
|
@@ -35,7 +36,8 @@ const VARS = {
|
|
|
35
36
|
class Kernel {
|
|
36
37
|
//schema = ">=1.0.0"
|
|
37
38
|
//schema = "<=2.1.0"
|
|
38
|
-
schema = "<=3.2.0"
|
|
39
|
+
//schema = "<=3.2.0"
|
|
40
|
+
schema = "<=3.3.0"
|
|
39
41
|
constructor(store) {
|
|
40
42
|
this.fetch = fetch
|
|
41
43
|
this.store = store
|
|
@@ -221,6 +223,25 @@ class Kernel {
|
|
|
221
223
|
async wait(options) {
|
|
222
224
|
await waitOn(options)
|
|
223
225
|
}
|
|
226
|
+
async getInfo(){
|
|
227
|
+
let info = this.sysinfo
|
|
228
|
+
await this.update_sysinfo()
|
|
229
|
+
let i = {
|
|
230
|
+
platform: this.platform,
|
|
231
|
+
arch: this.arch,
|
|
232
|
+
running: this.api.running,
|
|
233
|
+
home: this.homedir,
|
|
234
|
+
vars: this.vars,
|
|
235
|
+
memory: this.memory,
|
|
236
|
+
procs: this.procs,
|
|
237
|
+
gpu: this.gpu,
|
|
238
|
+
gpus: this.gpus,
|
|
239
|
+
version: this.version,
|
|
240
|
+
...info
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
this.i = i
|
|
244
|
+
}
|
|
224
245
|
|
|
225
246
|
async synchronize_proxies() {
|
|
226
247
|
let proxy_registry_path = path.resolve(this.homedir, "proxy_registry")
|
|
@@ -308,7 +329,6 @@ class Kernel {
|
|
|
308
329
|
this.template = new Template()
|
|
309
330
|
try {
|
|
310
331
|
let grant_permission = false
|
|
311
|
-
console.log(">>>>>> this.homedir", this.homedir)
|
|
312
332
|
if (this.homedir) {
|
|
313
333
|
|
|
314
334
|
// 0. create homedir
|
|
@@ -356,7 +376,10 @@ class Kernel {
|
|
|
356
376
|
if (this.envs) {
|
|
357
377
|
this.template.update({
|
|
358
378
|
env: this.envs,
|
|
359
|
-
envs: this.envs
|
|
379
|
+
envs: this.envs,
|
|
380
|
+
which: (name) => {
|
|
381
|
+
return which.sync(name, { nothrow: true, path: this.envs.PATH })
|
|
382
|
+
}
|
|
360
383
|
})
|
|
361
384
|
}
|
|
362
385
|
// console.log({ grant_permission })
|
|
@@ -380,9 +403,7 @@ class Kernel {
|
|
|
380
403
|
|
|
381
404
|
//await this.shell.init()
|
|
382
405
|
|
|
383
|
-
console.log("homedir", this.homedir)
|
|
384
406
|
if (this.homedir) {
|
|
385
|
-
console.log("> 1")
|
|
386
407
|
await this.template.init({
|
|
387
408
|
kernel: this,
|
|
388
409
|
system,
|
|
@@ -392,19 +413,16 @@ class Kernel {
|
|
|
392
413
|
return this.api.get_proxy_url("/proxy", port)
|
|
393
414
|
},
|
|
394
415
|
})
|
|
395
|
-
console.log("> 2")
|
|
396
416
|
this.sys = new Sysinfo()
|
|
397
417
|
await this.sys.init(this)
|
|
398
418
|
let info = this.sys.info
|
|
399
|
-
|
|
400
|
-
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify({
|
|
401
|
-
platform: this.platform,
|
|
402
|
-
arch: this.arch,
|
|
403
|
-
home: this.homedir,
|
|
404
|
-
...info
|
|
405
|
-
}, null, 2))
|
|
419
|
+
|
|
406
420
|
this.sysinfo = info
|
|
407
|
-
|
|
421
|
+
|
|
422
|
+
await this.getInfo()
|
|
423
|
+
|
|
424
|
+
await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
425
|
+
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
|
|
408
426
|
/*
|
|
409
427
|
this.sys = new Sysinfo()
|
|
410
428
|
await this.sys.init(this)
|
package/kernel/shell.js
CHANGED
|
@@ -659,7 +659,7 @@ class Shell {
|
|
|
659
659
|
if (params.venv) {
|
|
660
660
|
let env_path = path.resolve(params.path, params.venv)
|
|
661
661
|
let activate_path = (this.platform === 'win32' ? path.resolve(env_path, "Scripts", "activate") : path.resolve(env_path, "bin", "activate"))
|
|
662
|
-
let deactivate_path = (this.platform === 'win32' ? path.resolve(env_path, "Scripts", "deactivate") :
|
|
662
|
+
let deactivate_path = (this.platform === 'win32' ? path.resolve(env_path, "Scripts", "deactivate") : "deactivate")
|
|
663
663
|
let env_exists = await this.exists(env_path)
|
|
664
664
|
if (env_exists) {
|
|
665
665
|
venv_activation = [
|
|
@@ -671,7 +671,7 @@ class Shell {
|
|
|
671
671
|
`python -m venv ${env_path}`,
|
|
672
672
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
673
673
|
`python -m pip install --upgrade pip setuptools wheel`,
|
|
674
|
-
|
|
674
|
+
deactivate_path,
|
|
675
675
|
(this.platform === 'win32' ? `${timeout} /t 1 > nul` : 'sleep 1'),
|
|
676
676
|
(this.platform === "win32" ? `${activate_path} ${env_path}` : `source ${activate_path} ${env_path}`),
|
|
677
677
|
(this.platform === 'win32' ? `${timeout} /t 1 > nul` : 'sleep 1'),
|
|
@@ -721,9 +721,9 @@ class Shell {
|
|
|
721
721
|
this.queue.push(data)
|
|
722
722
|
}
|
|
723
723
|
});
|
|
724
|
-
this.ptyProcess.onExit((result) => {
|
|
725
|
-
console.log(">>>>>>>>>>>>>>>>>>> exec onExit", result)
|
|
726
|
-
})
|
|
724
|
+
// this.ptyProcess.onExit((result) => {
|
|
725
|
+
// console.log(">>>>>>>>>>>>>>>>>>> exec onExit", result)
|
|
726
|
+
// })
|
|
727
727
|
}
|
|
728
728
|
} catch (e) {
|
|
729
729
|
console.log("** Error", e)
|
|
@@ -747,7 +747,6 @@ class Shell {
|
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
749
|
kill(message, force) {
|
|
750
|
-
console.log("> KILL", { message, force })
|
|
751
750
|
|
|
752
751
|
this.done = true
|
|
753
752
|
this.ready = false
|
|
@@ -877,7 +876,6 @@ ${cleaned}
|
|
|
877
876
|
let cached_msg = msg
|
|
878
877
|
// todo: may need to handle cases when the command returns immediately with no output (example: 'which brew' returns immediately with no text if brew doesn't exist)
|
|
879
878
|
setTimeout(() => {
|
|
880
|
-
console.log({ cache, cleaned })
|
|
881
879
|
if (cache === cleaned) {
|
|
882
880
|
if (this.persistent) {
|
|
883
881
|
if (this.cb) this.cb({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pinokiod",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.200",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"systeminformation": "^5.18.4",
|
|
60
60
|
"uuid": "^9.0.0",
|
|
61
61
|
"wait-on": "^7.2.0",
|
|
62
|
+
"which": "^5.0.0",
|
|
62
63
|
"ws": "^8.13.0",
|
|
63
64
|
"xterm-addon-fit": "^0.8.0",
|
|
64
65
|
"xterm-addon-serialize": "^0.9.0",
|
package/server/index.js
CHANGED
|
@@ -229,7 +229,7 @@ class Server {
|
|
|
229
229
|
let error = null
|
|
230
230
|
if (config && config.version) {
|
|
231
231
|
let coerced = semver.coerce(config.version)
|
|
232
|
-
console.log("version", { coerced, v: config.version })
|
|
232
|
+
// console.log("version", { coerced, v: config.version })
|
|
233
233
|
if (semver.satisfies(coerced, this.kernel.schema)) {
|
|
234
234
|
console.log("semver satisfied", config.version, this.kernel.schema)
|
|
235
235
|
} else {
|
|
@@ -1761,7 +1761,7 @@ class Server {
|
|
|
1761
1761
|
if (type === "conda") {
|
|
1762
1762
|
return this.kernel.bin.installed.conda.has(name)
|
|
1763
1763
|
} else if (type === "pip") {
|
|
1764
|
-
return this.kernel.bin.installed.pip.has(name)
|
|
1764
|
+
return this.kernel.bin.installed.pip && this.kernel.bin.installed.pip.has(name)
|
|
1765
1765
|
} else if (type === "brew") {
|
|
1766
1766
|
return this.kernel.bin.installed.brew.has(name)
|
|
1767
1767
|
} else {
|
|
@@ -2101,6 +2101,25 @@ class Server {
|
|
|
2101
2101
|
|
|
2102
2102
|
console.log("available port", this.port)
|
|
2103
2103
|
|
|
2104
|
+
let version = this.kernel.store.get("version")
|
|
2105
|
+
let home = this.kernel.store.get("home")
|
|
2106
|
+
console.log({ home, version })
|
|
2107
|
+
if (home) {
|
|
2108
|
+
if (version === this.version.pinokiod) {
|
|
2109
|
+
console.log("version up to date")
|
|
2110
|
+
} else {
|
|
2111
|
+
console.log("not up to date. update py.")
|
|
2112
|
+
// remove ~/bin/miniconda/py
|
|
2113
|
+
let p = path.resolve(home, "bin/py")
|
|
2114
|
+
console.log(`[TRY] reset ${p}`)
|
|
2115
|
+
await fse.remove(p)
|
|
2116
|
+
console.log(`[DONE] reset ${p}`)
|
|
2117
|
+
console.log("[TRY] Updating to the new version")
|
|
2118
|
+
this.kernel.store.set("version", this.version.pinokiod)
|
|
2119
|
+
console.log("[DONE] Updating to the new version")
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2104
2123
|
// initialize kernel
|
|
2105
2124
|
await this.kernel.init({ port: this.port})
|
|
2106
2125
|
|
|
@@ -2131,64 +2150,64 @@ class Server {
|
|
|
2131
2150
|
// }
|
|
2132
2151
|
await this.startLogging()
|
|
2133
2152
|
|
|
2134
|
-
// check version from this.store
|
|
2135
|
-
let version = this.kernel.store.get("version")
|
|
2136
|
-
// if the version is different from package.json version, run update logic
|
|
2137
|
-
console.log({_homedir: this.kernel.homedir, version, pinokiod: this.version.pinokiod })
|
|
2138
|
-
if (this.kernel.homedir) {
|
|
2139
|
-
if (version === this.version.pinokiod) {
|
|
2140
|
-
console.log("version up to date")
|
|
2141
|
-
} else {
|
|
2142
|
-
// update the py module if it's already installed
|
|
2143
|
-
console.log("not up to date")
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
await new Promise((resolve, reject) => {
|
|
2159
|
-
let interval = setInterval(async () => {
|
|
2160
|
-
console.log("checking mod.py")
|
|
2161
|
-
if (this.kernel.bin.mod && this.kernel.bin.mod.py) {
|
|
2162
|
-
console.log("mod.py initialized!")
|
|
2163
|
-
let installed = await this.kernel.bin.mod.py.installed()
|
|
2164
|
-
console.log("py installed", installed)
|
|
2165
|
-
if (installed) {
|
|
2166
|
-
// update
|
|
2167
|
-
console.log("update py")
|
|
2168
|
-
await this.kernel.exec({
|
|
2169
|
-
message: "git pull",
|
|
2170
|
-
path: this.kernel.path("bin/py")
|
|
2171
|
-
}, (e) => {
|
|
2172
|
-
console.log(e)
|
|
2173
|
-
})
|
|
2174
|
-
}
|
|
2175
|
-
// after updating, set the version
|
|
2176
|
-
console.log("set the version", this.version.pinokiod)
|
|
2177
|
-
this.kernel.store.set("version", this.version.pinokiod)
|
|
2178
|
-
console.log("RESTART")
|
|
2179
|
-
clearInterval(interval)
|
|
2180
|
-
resolve()
|
|
2181
|
-
} else {
|
|
2182
|
-
console.log("mod.py not initialized yet")
|
|
2183
|
-
}
|
|
2184
|
-
}, 1000)
|
|
2185
|
-
})
|
|
2186
|
-
this.listening = true // set this.listening = true so all http connections get reset when restarting
|
|
2187
|
-
await this.start(options)
|
|
2188
|
-
console.log("RESTARTED")
|
|
2189
|
-
return
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2153
|
+
// // check version from this.store
|
|
2154
|
+
// //let version = this.kernel.store.get("version")
|
|
2155
|
+
// // if the version is different from package.json version, run update logic
|
|
2156
|
+
// console.log({_homedir: this.kernel.homedir, version, pinokiod: this.version.pinokiod })
|
|
2157
|
+
// if (this.kernel.homedir) {
|
|
2158
|
+
// if (version === this.version.pinokiod) {
|
|
2159
|
+
// console.log("version up to date")
|
|
2160
|
+
// } else {
|
|
2161
|
+
// // update the py module if it's already installed
|
|
2162
|
+
// console.log("not up to date")
|
|
2163
|
+
//
|
|
2164
|
+
//// // give full permission to pinokio folder on windows
|
|
2165
|
+
//// if (this.kernel.platform === "win32") {
|
|
2166
|
+
//// console.log("1 Give full permission")
|
|
2167
|
+
//// await this.kernel.bin.exec({
|
|
2168
|
+
//// sudo: true,
|
|
2169
|
+
//// message: `icacls ${this.kernel.homedir} /grant Users:(OI)(CI)F /T`
|
|
2170
|
+
//// }, (stream) => {
|
|
2171
|
+
//// console.log({ stream })
|
|
2172
|
+
//// })
|
|
2173
|
+
//// console.log("1 Give full permission done")
|
|
2174
|
+
//// }
|
|
2175
|
+
//
|
|
2176
|
+
//
|
|
2177
|
+
// await new Promise((resolve, reject) => {
|
|
2178
|
+
// let interval = setInterval(async () => {
|
|
2179
|
+
// console.log("checking mod.py")
|
|
2180
|
+
// if (this.kernel.bin.mod && this.kernel.bin.mod.py) {
|
|
2181
|
+
// console.log("mod.py initialized!")
|
|
2182
|
+
// let installed = await this.kernel.bin.mod.py.installed()
|
|
2183
|
+
// console.log("py installed", installed)
|
|
2184
|
+
// if (installed) {
|
|
2185
|
+
// // update
|
|
2186
|
+
// console.log("update py")
|
|
2187
|
+
// await this.kernel.exec({
|
|
2188
|
+
// message: "git pull",
|
|
2189
|
+
// path: this.kernel.path("bin/py")
|
|
2190
|
+
// }, (e) => {
|
|
2191
|
+
// console.log(e)
|
|
2192
|
+
// })
|
|
2193
|
+
// }
|
|
2194
|
+
// // after updating, set the version
|
|
2195
|
+
// console.log("set the version", this.version.pinokiod)
|
|
2196
|
+
// this.kernel.store.set("version", this.version.pinokiod)
|
|
2197
|
+
// console.log("RESTART")
|
|
2198
|
+
// clearInterval(interval)
|
|
2199
|
+
// resolve()
|
|
2200
|
+
// } else {
|
|
2201
|
+
// console.log("mod.py not initialized yet")
|
|
2202
|
+
// }
|
|
2203
|
+
// }, 1000)
|
|
2204
|
+
// })
|
|
2205
|
+
// this.listening = true // set this.listening = true so all http connections get reset when restarting
|
|
2206
|
+
// await this.start(options)
|
|
2207
|
+
// console.log("RESTARTED")
|
|
2208
|
+
// return
|
|
2209
|
+
// }
|
|
2210
|
+
// }
|
|
2192
2211
|
|
|
2193
2212
|
|
|
2194
2213
|
|
|
@@ -2223,7 +2242,7 @@ class Server {
|
|
|
2223
2242
|
|
|
2224
2243
|
|
|
2225
2244
|
//let home = this.kernel.homedir
|
|
2226
|
-
let home = this.kernel.store.get("home")
|
|
2245
|
+
//let home = this.kernel.store.get("home")
|
|
2227
2246
|
this.app.get("/", ex(async (req, res) => {
|
|
2228
2247
|
if (req.query.mode !== "settings" && !home) {
|
|
2229
2248
|
res.redirect("/?mode=settings")
|
|
@@ -3057,6 +3076,12 @@ class Server {
|
|
|
3057
3076
|
await compressing.zip.compressDir(folder, zipPath)
|
|
3058
3077
|
res.json({ success: true })
|
|
3059
3078
|
}))
|
|
3079
|
+
this.app.get("/pinokio/info", ex(async (req, res) => {
|
|
3080
|
+
console.time("getInfo")
|
|
3081
|
+
await this.kernel.getInfo()
|
|
3082
|
+
console.timeEnd("getInfo")
|
|
3083
|
+
res.json(this.kernel.i || {})
|
|
3084
|
+
}))
|
|
3060
3085
|
this.app.get("/pinokio/port", ex(async (req, res) => {
|
|
3061
3086
|
let port = await this.kernel.port()
|
|
3062
3087
|
res.json({ result: port })
|
package/server/views/pre.ejs
CHANGED
|
@@ -126,9 +126,9 @@ footer a.btn {
|
|
|
126
126
|
<div class='title'><%=item.title%></div>
|
|
127
127
|
<div class='description'><%=item.description%></div>
|
|
128
128
|
<% if (item.href.startsWith("http")) { %>
|
|
129
|
-
<a target="_blank" features="browser" href='<%=item.href%>' class='btn'><i class="fa-solid fa-square-arrow-up-right"></i>
|
|
129
|
+
<a target="_blank" features="browser" href='<%=item.href%>' class='btn'><i class="fa-solid fa-square-arrow-up-right"></i> Install</a>
|
|
130
130
|
<% } else { %>
|
|
131
|
-
<button class='btn' data-filepath="<%=item.href%>"><i class="fa-solid fa-square-arrow-up-right"></i>
|
|
131
|
+
<button class='btn' data-filepath="<%=item.href%>"><i class="fa-solid fa-square-arrow-up-right"></i> Install</button>
|
|
132
132
|
<% } %>
|
|
133
133
|
</div>
|
|
134
134
|
<!--
|