pinokiod 3.6.30 → 3.6.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.
- package/kernel/api/index.js +24 -89
- package/kernel/bin/index.js +4 -127
- package/kernel/bin/node.js +0 -5
- package/kernel/index.js +3 -39
- package/kernel/shell.js +17 -34
- package/kernel/shells.js +0 -1
- package/kernel/util.js +7 -28
- package/package.json +1 -1
- package/script/index.js +0 -12
- package/server/index.js +187 -270
- package/server/public/pinokio-black.png +0 -0
- package/server/public/style.css +0 -5
- package/server/socket.js +34 -87
- package/server/views/app.ejs +2 -14
- package/server/views/editor.ejs +2 -12
- package/server/views/index.ejs +36 -27
- package/server/views/terminal.ejs +12 -56
- package/kernel/store.js +0 -58
- package/server/public/pinokio-black2.png +0 -0
package/kernel/api/index.js
CHANGED
|
@@ -121,10 +121,8 @@ class Api {
|
|
|
121
121
|
async stop(req, ondata) {
|
|
122
122
|
// 1. set the "stop" flag for the uri, so the next execution in the queue for the uri will NOT queue another task
|
|
123
123
|
// 2. stream a message closing the socket
|
|
124
|
-
console.log("> stop", req)
|
|
125
124
|
|
|
126
125
|
let requestPath = this.filePath(req.params.uri)
|
|
127
|
-
console.log({ requestPath })
|
|
128
126
|
|
|
129
127
|
|
|
130
128
|
|
|
@@ -354,20 +352,13 @@ class Api {
|
|
|
354
352
|
let modpath
|
|
355
353
|
if (matched_repo.length > 0) {
|
|
356
354
|
let repo_uri = matched_repo[0]
|
|
357
|
-
if (!repo_uri.endsWith(".git")) {
|
|
358
|
-
repo_uri = repo_uri + ".git"
|
|
359
|
-
}
|
|
360
355
|
|
|
361
|
-
let
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
} else {
|
|
365
|
-
let relative_path = uri
|
|
366
|
-
.replace(repo_uri, "") // remove the git repo uri
|
|
367
|
-
.slice(1) // remove the leading '/' for relative path
|
|
368
|
-
modpath = path.resolve(repopath, relative_path)
|
|
369
|
-
}
|
|
356
|
+
let relative_path = uri
|
|
357
|
+
.replace(repo_uri, "") // remove the git repo uri
|
|
358
|
+
.slice(1) // remove the leading '/' for relative path
|
|
370
359
|
|
|
360
|
+
let repopath = this.gitPath[repo_uri]
|
|
361
|
+
modpath = path.resolve(repopath, relative_path)
|
|
371
362
|
} else {
|
|
372
363
|
//console.log("no matching gitpath")
|
|
373
364
|
}
|
|
@@ -831,7 +822,6 @@ class Api {
|
|
|
831
822
|
// }
|
|
832
823
|
this.ondata(m)
|
|
833
824
|
})
|
|
834
|
-
console.log("EXEC RESULT", { result })
|
|
835
825
|
}
|
|
836
826
|
|
|
837
827
|
|
|
@@ -1136,35 +1126,6 @@ class Api {
|
|
|
1136
1126
|
this.process(request, resolve)
|
|
1137
1127
|
})
|
|
1138
1128
|
}
|
|
1139
|
-
async get_default(repo_path) {
|
|
1140
|
-
let p = path.resolve(repo_path, "pinokio.js")
|
|
1141
|
-
// call 'process' based on the current status
|
|
1142
|
-
let config = (await this.loader.load(p)).resolved
|
|
1143
|
-
if (config && config.menu) {
|
|
1144
|
-
if (typeof config.menu === "function") {
|
|
1145
|
-
if (config.menu.constructor.name === "AsyncFunction") {
|
|
1146
|
-
config.menu = await config.menu(this.kernel, this.kernel.info)
|
|
1147
|
-
} else {
|
|
1148
|
-
config.menu = config.menu(this.kernel, this.kernel.info)
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
// find the default item in the menu
|
|
1152
|
-
let running = config.menu.filter((item) => {
|
|
1153
|
-
return item.default
|
|
1154
|
-
})
|
|
1155
|
-
if (running.length > 0) {
|
|
1156
|
-
let r = running[0]
|
|
1157
|
-
if (r.href) {
|
|
1158
|
-
if (r.href.startsWith("http")) {
|
|
1159
|
-
return r.href
|
|
1160
|
-
} else {
|
|
1161
|
-
let href = path.resolve(repo_path, r.href)
|
|
1162
|
-
return href
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
1129
|
async process(request, done) {
|
|
1169
1130
|
/**************************************************************
|
|
1170
1131
|
*
|
|
@@ -1211,64 +1172,38 @@ class Api {
|
|
|
1211
1172
|
console.timeEnd("shell.init")
|
|
1212
1173
|
|
|
1213
1174
|
if (request.uri){
|
|
1214
|
-
|
|
1215
1175
|
this.counter++;
|
|
1216
1176
|
// API Call
|
|
1217
1177
|
|
|
1218
1178
|
request.path = this.resolvePath(this.userdir, request.uri)
|
|
1179
|
+
let { cwd, script } = await this.resolveScript(request.path)
|
|
1180
|
+
request.cwd = cwd
|
|
1219
1181
|
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
// the script is requesting a uri of the git repo
|
|
1227
|
-
// look for pinokio.js
|
|
1228
|
-
let p = path.resolve(request.path, "pinokio.js")
|
|
1229
|
-
let exists = await this.exists(p)
|
|
1230
|
-
console.log({ p, exists })
|
|
1231
|
-
if (exists) {
|
|
1232
|
-
await this.launch(request, p)
|
|
1233
|
-
} else {
|
|
1234
|
-
this.ondata({
|
|
1235
|
-
id: request.path,
|
|
1236
|
-
type: "error",
|
|
1237
|
-
data: "uri doesn't exist \r\n" + JSON.stringify(request, null, 2)
|
|
1238
|
-
})
|
|
1239
|
-
}
|
|
1182
|
+
if (!script) {
|
|
1183
|
+
this.ondata({
|
|
1184
|
+
id: request.path,
|
|
1185
|
+
type: "error",
|
|
1186
|
+
data: "the endpoint does not exist: " + request.uri,
|
|
1187
|
+
})
|
|
1240
1188
|
} else {
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1189
|
+
// 3. Check if the resolved endpoint has the "run" attribute and it's an array
|
|
1190
|
+
//if (script.run && Array.isArray(script.run)) {
|
|
1191
|
+
if (script.run) {
|
|
1192
|
+
|
|
1193
|
+
this.running[request.path] = true
|
|
1194
|
+
|
|
1195
|
+
this.done[request.path] = done
|
|
1244
1196
|
|
|
1245
|
-
|
|
1197
|
+
this.queue(request, script.run[0], request.input, 0, script.run.length, cwd, request.input)
|
|
1198
|
+
|
|
1199
|
+
} else {
|
|
1246
1200
|
this.ondata({
|
|
1247
1201
|
id: request.path,
|
|
1248
1202
|
type: "error",
|
|
1249
|
-
data: "
|
|
1203
|
+
data: "missing attribute: run"
|
|
1250
1204
|
})
|
|
1251
|
-
} else {
|
|
1252
|
-
// 3. Check if the resolved endpoint has the "run" attribute and it's an array
|
|
1253
|
-
//if (script.run && Array.isArray(script.run)) {
|
|
1254
|
-
if (script.run) {
|
|
1255
|
-
|
|
1256
|
-
this.running[request.path] = true
|
|
1257
|
-
|
|
1258
|
-
this.done[request.path] = done
|
|
1259
|
-
|
|
1260
|
-
this.queue(request, script.run[0], request.input, 0, script.run.length, cwd, request.input)
|
|
1261
|
-
|
|
1262
|
-
} else {
|
|
1263
|
-
this.ondata({
|
|
1264
|
-
id: request.path,
|
|
1265
|
-
type: "error",
|
|
1266
|
-
data: "missing attribute: run"
|
|
1267
|
-
})
|
|
1268
|
-
}
|
|
1269
1205
|
}
|
|
1270
1206
|
}
|
|
1271
|
-
|
|
1272
1207
|
} else if (request.method) {
|
|
1273
1208
|
let pass = 0;
|
|
1274
1209
|
while(true) {
|
package/kernel/bin/index.js
CHANGED
|
@@ -588,24 +588,6 @@ class Bin {
|
|
|
588
588
|
}
|
|
589
589
|
// }
|
|
590
590
|
}
|
|
591
|
-
async path_exists(req, ondata) {
|
|
592
|
-
let abspath = this.kernel.api.resolvePath(this.kernel.api.userdir, req.params.uri)
|
|
593
|
-
if (abspath) {
|
|
594
|
-
console.log({ abspath })
|
|
595
|
-
let exists = await new Promise(r=>fs.access(abspath, fs.constants.F_OK, e => r(!e)))
|
|
596
|
-
return exists
|
|
597
|
-
} else {
|
|
598
|
-
return false
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
async install2(req, ondata) {
|
|
602
|
-
let { requirements, install_required, requirements_pending, error } = await this.check_bin()
|
|
603
|
-
req.params = JSON.stringify(requirements)
|
|
604
|
-
if (this.install_required) {
|
|
605
|
-
let res = await this.install(req, ondata)
|
|
606
|
-
return res
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
591
|
async install(req, ondata) {
|
|
610
592
|
/*
|
|
611
593
|
req.params := {
|
|
@@ -625,8 +607,6 @@ class Bin {
|
|
|
625
607
|
this.client = null
|
|
626
608
|
}
|
|
627
609
|
|
|
628
|
-
console.log("install", req)
|
|
629
|
-
|
|
630
610
|
let requirements = JSON.parse(req.params)
|
|
631
611
|
|
|
632
612
|
for(let x=0; x<10; x++) {
|
|
@@ -700,29 +680,17 @@ class Bin {
|
|
|
700
680
|
//}
|
|
701
681
|
await this.init()
|
|
702
682
|
}
|
|
703
|
-
async installed(r) {
|
|
704
|
-
if (Array.isArray(r.name)) {
|
|
705
|
-
for(let name of r.name) {
|
|
706
|
-
let installed = await this._installed(name, r.type)
|
|
707
|
-
if (!installed) return false
|
|
708
|
-
}
|
|
709
|
-
return true
|
|
710
|
-
} else {
|
|
711
|
-
let installed = await this._installed(r.name, r.type)
|
|
712
|
-
return installed
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
683
|
async _installed(name, type) {
|
|
716
684
|
if (type === "conda") {
|
|
717
|
-
return this.installed.conda.has(name)
|
|
685
|
+
return this.kernel.bin.installed.conda.has(name)
|
|
718
686
|
} else if (type === "pip") {
|
|
719
|
-
return this.installed.pip && this.installed.pip.has(name)
|
|
687
|
+
return this.kernel.bin.installed.pip && this.kernel.bin.installed.pip.has(name)
|
|
720
688
|
} else if (type === "brew") {
|
|
721
|
-
return this.installed.brew.has(name)
|
|
689
|
+
return this.kernel.bin.installed.brew.has(name)
|
|
722
690
|
} else {
|
|
723
691
|
// check kernel/bin/<module>.installed()
|
|
724
692
|
let filepath = path.resolve(__dirname, "..", "kernel", "bin", name + ".js")
|
|
725
|
-
let mod = this.mod[name]
|
|
693
|
+
let mod = this.kernel.bin.mod[name]
|
|
726
694
|
let installed = false
|
|
727
695
|
if (mod.installed) {
|
|
728
696
|
installed = await mod.installed()
|
|
@@ -730,97 +698,6 @@ class Bin {
|
|
|
730
698
|
return installed
|
|
731
699
|
}
|
|
732
700
|
}
|
|
733
|
-
async check_bin() {
|
|
734
|
-
let requirements = [
|
|
735
|
-
{ name: "conda", },
|
|
736
|
-
{ name: "git", },
|
|
737
|
-
{ name: "zip", },
|
|
738
|
-
{ name: "node", },
|
|
739
|
-
{ name: "ffmpeg", }
|
|
740
|
-
]
|
|
741
|
-
let platform = os.platform()
|
|
742
|
-
if (platform === "win32") {
|
|
743
|
-
requirements.push({ name: "registry" })
|
|
744
|
-
requirements.push({ name: "vs" })
|
|
745
|
-
}
|
|
746
|
-
if (platform === "darwin") {
|
|
747
|
-
requirements.push({ name: "brew" })
|
|
748
|
-
}
|
|
749
|
-
if (platform === "linux") {
|
|
750
|
-
requirements.push({ name: "gxx" })
|
|
751
|
-
}
|
|
752
|
-
if (this.kernel.gpu === "nvidia") {
|
|
753
|
-
requirements.push({ name: "cuda", })
|
|
754
|
-
}
|
|
755
|
-
requirements = requirements.concat([
|
|
756
|
-
{ name: "py" },
|
|
757
|
-
{ name: "cloudflared" },
|
|
758
|
-
{ name: "playwright" },
|
|
759
|
-
{ name: "huggingface" },
|
|
760
|
-
{ name: "uv" }
|
|
761
|
-
])
|
|
762
|
-
|
|
763
|
-
let requirements_pending = !this.installed_initialized
|
|
764
|
-
let install_required = true
|
|
765
|
-
if (!requirements_pending) {
|
|
766
|
-
install_required = false
|
|
767
|
-
for(let i=0; i<requirements.length; i++) {
|
|
768
|
-
let r = requirements[i]
|
|
769
|
-
console.time(r.name)
|
|
770
|
-
let installed = await this.installed(r)
|
|
771
|
-
console.log({ r, installed })
|
|
772
|
-
console.timeEnd(r.name)
|
|
773
|
-
requirements[i].installed = installed
|
|
774
|
-
if (!installed) {
|
|
775
|
-
install_required = true
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
let error = null
|
|
781
|
-
try {
|
|
782
|
-
this.compatible()
|
|
783
|
-
} catch (e) {
|
|
784
|
-
error = e.message
|
|
785
|
-
install_required = true
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
this.install_required = install_required
|
|
789
|
-
this.requirements_pending = requirements_pending
|
|
790
|
-
|
|
791
|
-
console.log("check_bin finished 2")
|
|
792
|
-
return {
|
|
793
|
-
error,
|
|
794
|
-
requirements,
|
|
795
|
-
install_required,
|
|
796
|
-
requirements_pending
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
winBuildNumber() {
|
|
801
|
-
let osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
|
|
802
|
-
let buildNumber = 0;
|
|
803
|
-
if (osVersion && osVersion.length === 4) {
|
|
804
|
-
buildNumber = parseInt(osVersion[3]);
|
|
805
|
-
}
|
|
806
|
-
return buildNumber;
|
|
807
|
-
}
|
|
808
|
-
compatible() {
|
|
809
|
-
if (this.kernel.platform === "win32") {
|
|
810
|
-
let buildNumber = this.winBuildNumber()
|
|
811
|
-
if (buildNumber < 18309) {
|
|
812
|
-
// must use conpty for node-pty, and conpty is only supported in win>=18309
|
|
813
|
-
console.log("Windows buildNumber", buildNumber)
|
|
814
|
-
throw new Error(`Pinokio supports Windows release 18309 and up (current system: ${buildNumber}`)
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
// if (buildNumber > 25000) {
|
|
818
|
-
// console.log("Windows buildNumber", buildNumber)
|
|
819
|
-
// throw new Error(`Pinokio does not currently support Windows Canary (versions 25000 and up). The current system is ${buildNumber}`)
|
|
820
|
-
//
|
|
821
|
-
// }
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
701
|
async sh(params, ondata) {
|
|
825
702
|
let response = await this.kernel.shell.run(params, null, ondata)
|
|
826
703
|
return response
|
package/kernel/bin/node.js
CHANGED
|
@@ -19,11 +19,6 @@ class Node {
|
|
|
19
19
|
async installed() {
|
|
20
20
|
return this.kernel.bin.installed.conda.has("nodejs") && this.kernel.bin.installed.conda.has("pnpm")
|
|
21
21
|
}
|
|
22
|
-
env() {
|
|
23
|
-
return {
|
|
24
|
-
PATH: [this.kernel.path("bin/npm/bin")]
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
22
|
async uninstall(req, ondata) {
|
|
28
23
|
await this.kernel.bin.exec({
|
|
29
24
|
message: "conda remove nodejs pnpm",
|
package/kernel/index.js
CHANGED
|
@@ -26,7 +26,6 @@ const Config = require("./pinokio.json")
|
|
|
26
26
|
const Info = require('./info')
|
|
27
27
|
const Pipe = require("../pipe")
|
|
28
28
|
const Cloudflare = require('./api/cloudflare')
|
|
29
|
-
const Store = require('./store')
|
|
30
29
|
const VARS = {
|
|
31
30
|
pip: {
|
|
32
31
|
install: {
|
|
@@ -43,29 +42,7 @@ class Kernel {
|
|
|
43
42
|
schema = "<=3.7.0"
|
|
44
43
|
constructor(store) {
|
|
45
44
|
this.fetch = fetch
|
|
46
|
-
|
|
47
|
-
// STORE
|
|
48
|
-
// Previously custom STORE could be passed in. This was to support both electron and server based initialization
|
|
49
|
-
// But this creates complexity because the store location is not fixed
|
|
50
|
-
// Migrating it to ~/.pinokio/config.json
|
|
51
|
-
//
|
|
52
|
-
// 1. does ~/.pinokio exist?
|
|
53
|
-
// - load from that file
|
|
54
|
-
// 2. does ~/.pinokio NOT exist?
|
|
55
|
-
// - save the passed in options to the `~/.pinokio`
|
|
56
|
-
// - load the config
|
|
57
|
-
|
|
58
|
-
this.store = new Store()
|
|
59
|
-
let exists = this.store.exists()
|
|
60
|
-
console.log("Store exists?", exists)
|
|
61
|
-
if (!exists) {
|
|
62
|
-
console.log("doesn't exist")
|
|
63
|
-
// clone the store to the new store
|
|
64
|
-
this.store.clone(store.store)
|
|
65
|
-
// load from the store (this will be the last time this is used, since the next time it loads, it will load from the new store)
|
|
66
|
-
}
|
|
67
|
-
console.log("this.store", this.store.store())
|
|
68
|
-
|
|
45
|
+
this.store = store
|
|
69
46
|
this.arch = os.arch()
|
|
70
47
|
this.os = os
|
|
71
48
|
this.platform = os.platform()
|
|
@@ -409,7 +386,6 @@ class Kernel {
|
|
|
409
386
|
}
|
|
410
387
|
}
|
|
411
388
|
async init(options) {
|
|
412
|
-
console.time(">>>>>>>>>>>>>> A")
|
|
413
389
|
let home = this.store.get("home")
|
|
414
390
|
|
|
415
391
|
// reset shells if they exist
|
|
@@ -476,9 +452,7 @@ class Kernel {
|
|
|
476
452
|
}
|
|
477
453
|
this.procs = {}
|
|
478
454
|
this.template = new Template()
|
|
479
|
-
console.timeEnd(">>>>>>>>>>>>>> A")
|
|
480
455
|
try {
|
|
481
|
-
console.time(">>>>>>>>>>>>>> B")
|
|
482
456
|
if (this.homedir) {
|
|
483
457
|
|
|
484
458
|
// 0. create homedir
|
|
@@ -516,17 +490,14 @@ class Kernel {
|
|
|
516
490
|
|
|
517
491
|
|
|
518
492
|
}
|
|
519
|
-
console.timeEnd(">>>>>>>>>>>>>> B")
|
|
520
493
|
|
|
521
494
|
// let contents = await fs.promises.readdir(this.homedir)
|
|
522
495
|
//await this.bin.init()
|
|
523
496
|
let ts = Date.now()
|
|
524
|
-
console.time(">>>>>>>>>>>>>> C bin.init")
|
|
525
497
|
this.bin.init().then(() => {
|
|
526
498
|
console.log("bin init finished")
|
|
527
499
|
if (this.homedir) {
|
|
528
500
|
this.shell.init().then(async () => {
|
|
529
|
-
this.bin.check_bin()
|
|
530
501
|
if (this.envs) {
|
|
531
502
|
this.template.update({
|
|
532
503
|
env: this.envs,
|
|
@@ -593,16 +564,12 @@ class Kernel {
|
|
|
593
564
|
})
|
|
594
565
|
}
|
|
595
566
|
})
|
|
596
|
-
console.timeEnd(">>>>>>>>>>>>>> C bin.init")
|
|
597
567
|
let ts2 = Date.now()
|
|
598
|
-
console.time(">>>>>>>>>>>>>> D api.init")
|
|
599
568
|
await this.api.init()
|
|
600
|
-
console.timeEnd(">>>>>>>>>>>>>> D api.init")
|
|
601
569
|
|
|
602
570
|
//await this.shell.init()
|
|
603
571
|
|
|
604
572
|
if (this.homedir) {
|
|
605
|
-
console.time(">>>>>>>>>>>>>> E template.init")
|
|
606
573
|
await this.template.init({
|
|
607
574
|
kernel: this,
|
|
608
575
|
system,
|
|
@@ -612,18 +579,15 @@ class Kernel {
|
|
|
612
579
|
return this.api.get_proxy_url("/proxy", port)
|
|
613
580
|
},
|
|
614
581
|
})
|
|
615
|
-
console.timeEnd(">>>>>>>>>>>>>> E template.init")
|
|
616
|
-
console.time(">>>>>>>>>>>>>> F sys.init")
|
|
617
582
|
this.sys = new Sysinfo()
|
|
583
|
+
console.time("sys init")
|
|
618
584
|
await this.sys.init(this)
|
|
619
|
-
console.timeEnd("
|
|
585
|
+
console.timeEnd("sys init")
|
|
620
586
|
let info = this.sys.info
|
|
621
587
|
|
|
622
588
|
this.sysinfo = info
|
|
623
589
|
|
|
624
|
-
console.time(">>>>>>>>>>>>>> G getInfo")
|
|
625
590
|
await this.getInfo()
|
|
626
|
-
console.timeEnd(">>>>>>>>>>>>>> G getInfo")
|
|
627
591
|
|
|
628
592
|
await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
|
|
629
593
|
await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
|
package/kernel/shell.js
CHANGED
|
@@ -103,9 +103,6 @@ class Shell {
|
|
|
103
103
|
if (this.env.CMAKE_GENERATOR) {
|
|
104
104
|
delete this.env.CMAKE_GENERATOR
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
this.env.NPM_CONFIG_PREFIX = this.kernel.path("bin/npm")
|
|
108
|
-
this.env.npm_config_prefix = this.kernel.path("bin/npm")
|
|
109
106
|
|
|
110
107
|
// if (this.env.CUDA_HOME) {
|
|
111
108
|
// delete this.env.CUDA_HOME
|
|
@@ -123,6 +120,7 @@ class Shell {
|
|
|
123
120
|
|
|
124
121
|
this.env.CMAKE_OBJECT_PATH_MAX = 1024
|
|
125
122
|
this.env.PYTORCH_ENABLE_MPS_FALLBACK = 1
|
|
123
|
+
this.env.TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD = 1
|
|
126
124
|
// this.env.PIP_REQUIRE_VIRTUALENV = "true"
|
|
127
125
|
// this.env.NPM_CONFIG_USERCONFIG = this.kernel.path("user_npmrc")
|
|
128
126
|
// this.env.NPM_CONFIG_GLOBALCONFIG = this.kernel.path("global_npmrc")
|
|
@@ -277,12 +275,11 @@ class Shell {
|
|
|
277
275
|
return response
|
|
278
276
|
} else {
|
|
279
277
|
let response = await this.request(params, async (stream) => {
|
|
280
|
-
if (
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
// }
|
|
278
|
+
if (stream.prompt) {
|
|
279
|
+
this.resolve()
|
|
280
|
+
} else {
|
|
281
|
+
if (ondata) ondata(stream)
|
|
282
|
+
}
|
|
286
283
|
})
|
|
287
284
|
return response
|
|
288
285
|
}
|
|
@@ -291,10 +288,7 @@ class Shell {
|
|
|
291
288
|
}
|
|
292
289
|
emit(message) {
|
|
293
290
|
if (this.ptyProcess) {
|
|
294
|
-
|
|
295
|
-
if (this.input) {
|
|
296
|
-
this.ptyProcess.write(message)
|
|
297
|
-
}
|
|
291
|
+
this.ptyProcess.write(message)
|
|
298
292
|
}
|
|
299
293
|
}
|
|
300
294
|
send(message, newline, cb) {
|
|
@@ -376,9 +370,6 @@ class Shell {
|
|
|
376
370
|
|
|
377
371
|
// not connected => make a new connection => which means get a new prompt
|
|
378
372
|
// if already connected => no need for a new prompt
|
|
379
|
-
if (params.input) {
|
|
380
|
-
this.input = params.input
|
|
381
|
-
}
|
|
382
373
|
if (params.persistent) {
|
|
383
374
|
this.persistent = params.persistent
|
|
384
375
|
}
|
|
@@ -910,7 +901,6 @@ class Shell {
|
|
|
910
901
|
}
|
|
911
902
|
}
|
|
912
903
|
kill(message, force) {
|
|
913
|
-
console.log("KILL")
|
|
914
904
|
|
|
915
905
|
this.done = true
|
|
916
906
|
this.ready = false
|
|
@@ -1018,11 +1008,6 @@ ${cleaned}
|
|
|
1018
1008
|
|
|
1019
1009
|
}
|
|
1020
1010
|
stream(msg, callback) {
|
|
1021
|
-
if (msg === "\u0007") {
|
|
1022
|
-
// Ignore bell sound escape character because it slows down everything and makes redundant sound
|
|
1023
|
-
callback()
|
|
1024
|
-
return
|
|
1025
|
-
}
|
|
1026
1011
|
this.vt.write(msg, () => {
|
|
1027
1012
|
let buf = this.vts.serialize()
|
|
1028
1013
|
let cleaned = this.stripAnsi(buf)
|
|
@@ -1030,10 +1015,8 @@ ${cleaned}
|
|
|
1030
1015
|
id: this.id,
|
|
1031
1016
|
raw: msg,
|
|
1032
1017
|
cleaned,
|
|
1033
|
-
state: cleaned
|
|
1034
|
-
shell_id: this.id
|
|
1018
|
+
state: cleaned
|
|
1035
1019
|
}
|
|
1036
|
-
this.state = cleaned
|
|
1037
1020
|
if (this.cb) this.cb(response)
|
|
1038
1021
|
|
|
1039
1022
|
// Decide whether to kill or continue
|
|
@@ -1048,15 +1031,15 @@ ${cleaned}
|
|
|
1048
1031
|
// 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)
|
|
1049
1032
|
setTimeout(() => {
|
|
1050
1033
|
if (cache === cleaned) {
|
|
1051
|
-
if (this.
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1034
|
+
if (this.persistent) {
|
|
1035
|
+
if (this.cb) this.cb({
|
|
1036
|
+
//raw: cached_msg,
|
|
1037
|
+
//raw: msg,
|
|
1038
|
+
//raw: "",
|
|
1039
|
+
cleaned,
|
|
1040
|
+
state: cleaned,
|
|
1041
|
+
prompt: true
|
|
1042
|
+
})
|
|
1060
1043
|
callback()
|
|
1061
1044
|
} else {
|
|
1062
1045
|
callback()
|
package/kernel/shells.js
CHANGED
package/kernel/util.js
CHANGED
|
@@ -14,9 +14,6 @@ const groupReplacement = "$$$";
|
|
|
14
14
|
const h = "[^\\S\\r\\n]"; // simulate `\h`
|
|
15
15
|
const returnPattern = /\r/g;
|
|
16
16
|
const returnReplacement = "\\r";
|
|
17
|
-
const {
|
|
18
|
-
glob
|
|
19
|
-
} = require('glob')
|
|
20
17
|
|
|
21
18
|
|
|
22
19
|
// asar handling for go-get-folder-size
|
|
@@ -39,20 +36,26 @@ const du = async (folderpath) => {
|
|
|
39
36
|
const is_port_available = async (port) => {
|
|
40
37
|
return new Promise((resolve) => {
|
|
41
38
|
const server = http.createServer();
|
|
39
|
+
console.log("> Checking port availability", port)
|
|
42
40
|
try {
|
|
43
41
|
server.listen(port, (err) => {
|
|
44
42
|
if (err) {
|
|
43
|
+
console.log("> [1 port not available]", err)
|
|
45
44
|
resolve(false); // Port is occupied
|
|
46
45
|
} else {
|
|
46
|
+
console.log("> [2 port available] test server started. closing test server now.")
|
|
47
47
|
server.close(() => {
|
|
48
|
+
console.log("> Test server closed.")
|
|
48
49
|
resolve(true); // Port is free
|
|
49
50
|
}); // Close the server immediately after testing
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
53
|
server.on('error', (err) => {
|
|
54
|
+
console.log("> [3 port not available]", err);
|
|
53
55
|
resolve(false); // Port is occupied
|
|
54
56
|
});
|
|
55
57
|
} catch (e) {
|
|
58
|
+
console.log("> [4 port not available]", err)
|
|
56
59
|
resolve(false) // port not available
|
|
57
60
|
}
|
|
58
61
|
});
|
|
@@ -196,30 +199,6 @@ const escapeStringRegexp = (string) => {
|
|
|
196
199
|
.replace(/-/g, '\\x2d');
|
|
197
200
|
}
|
|
198
201
|
|
|
199
|
-
const find_python = async (root) => {
|
|
200
|
-
let python_pattern
|
|
201
|
-
if (os.platform() === "win32") {
|
|
202
|
-
python_pattern = "**/python.exe";
|
|
203
|
-
} else {
|
|
204
|
-
python_pattern = "**/python"; // Matches python, python3, python3.x
|
|
205
|
-
}
|
|
206
|
-
const pythonBinaries = await glob(python_pattern, { nodir: true, cwd: root });
|
|
207
|
-
return pythonBinaries
|
|
208
|
-
}
|
|
209
|
-
const find_venv = async (root) => {
|
|
210
|
-
let python_pattern
|
|
211
|
-
if (os.platform() === "win32") {
|
|
212
|
-
python_pattern = "**/python.exe";
|
|
213
|
-
} else {
|
|
214
|
-
python_pattern = "**/python"; // Matches python, python3, python3.x
|
|
215
|
-
}
|
|
216
|
-
const pythonBinaries = await glob(python_pattern, { nodir: true, cwd: root, absolute: true });
|
|
217
|
-
const venvs = pythonBinaries.map((p) => {
|
|
218
|
-
return path.resolve(p, "../..")
|
|
219
|
-
})
|
|
220
|
-
return venvs
|
|
221
|
-
}
|
|
222
|
-
|
|
223
202
|
const update_env = async (filepath, changes) => {
|
|
224
203
|
const env = await fs.promises.readFile(filepath, "utf8")
|
|
225
204
|
let append = false;
|
|
@@ -257,5 +236,5 @@ const update_env = async (filepath, changes) => {
|
|
|
257
236
|
await fs.promises.writeFile(filepath, newval)
|
|
258
237
|
};
|
|
259
238
|
module.exports = {
|
|
260
|
-
parse_env, log_path, api_path, update_env, parse_env_detail, openfs, port_running, du, is_port_available
|
|
239
|
+
parse_env, log_path, api_path, update_env, parse_env_detail, openfs, port_running, du, is_port_available
|
|
261
240
|
}
|
package/package.json
CHANGED
package/script/index.js
CHANGED
|
@@ -4,16 +4,6 @@ const os = require('os')
|
|
|
4
4
|
const platform = os.platform()
|
|
5
5
|
const Server = require('../server')
|
|
6
6
|
class Store {
|
|
7
|
-
constructor() {
|
|
8
|
-
let o
|
|
9
|
-
try {
|
|
10
|
-
let str = fs.readFileSync(path.resolve(__dirname, "pinokio.json"), "utf8")
|
|
11
|
-
o = JSON.parse(str)
|
|
12
|
-
} catch(e) {
|
|
13
|
-
o = {}
|
|
14
|
-
}
|
|
15
|
-
this.store = o
|
|
16
|
-
}
|
|
17
7
|
set(key, val) {
|
|
18
8
|
let o
|
|
19
9
|
try {
|
|
@@ -23,7 +13,6 @@ class Store {
|
|
|
23
13
|
o = {}
|
|
24
14
|
}
|
|
25
15
|
o[key] = val
|
|
26
|
-
this.store = o
|
|
27
16
|
fs.writeFileSync(path.resolve(__dirname, "pinokio.json"), JSON.stringify(o, null, 2))
|
|
28
17
|
}
|
|
29
18
|
get(key) {
|
|
@@ -42,7 +31,6 @@ class Store {
|
|
|
42
31
|
console.log("before delete", o)
|
|
43
32
|
delete o[key]
|
|
44
33
|
console.log("after delete", o)
|
|
45
|
-
this.store = o
|
|
46
34
|
fs.writeFileSync(path.resolve(__dirname, "pinokio.json"), JSON.stringify(o, null, 2))
|
|
47
35
|
} catch (e) {
|
|
48
36
|
}
|