pinokiod 3.2.138 → 3.2.141
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 +116 -71
- package/kernel/bin/node.js +3 -3
- package/kernel/index.js +17 -13
- package/package.json +1 -1
package/kernel/bin/index.js
CHANGED
|
@@ -135,6 +135,7 @@ class Bin {
|
|
|
135
135
|
// return a single merged env object, constructed from all the modules
|
|
136
136
|
|
|
137
137
|
// 1. get the module envs
|
|
138
|
+
console.log("this.mods=",this.mods)
|
|
138
139
|
let envs = this.mods.map((mod) => {
|
|
139
140
|
if (mod.name === "vs") {
|
|
140
141
|
// don't include vs now
|
|
@@ -165,6 +166,9 @@ class Bin {
|
|
|
165
166
|
if (this.kernel.homedir) {
|
|
166
167
|
const bin_folder = this.path()
|
|
167
168
|
await fs.promises.mkdir(bin_folder, { recursive: true }).catch((e) => { })
|
|
169
|
+
const playwright_folder = path.resolve(bin_folder, "playwright/browsers")
|
|
170
|
+
process.env.PLAYWRIGHT_BROWSERS_PATH = playwright_folder
|
|
171
|
+
await fs.promises.mkdir(playwright_folder, { recursive: true }).catch((e) => { })
|
|
168
172
|
}
|
|
169
173
|
// ORDERING MATTERS.
|
|
170
174
|
// General purpose package managers like conda, conda needs to come at the end
|
|
@@ -173,6 +177,7 @@ class Bin {
|
|
|
173
177
|
return file.endsWith(".js") && file !== "index.js" && file !== "cmake.js"
|
|
174
178
|
})
|
|
175
179
|
|
|
180
|
+
console.log("*bin.init")
|
|
176
181
|
|
|
177
182
|
this.mods = []
|
|
178
183
|
for(let filename of modfiles) {
|
|
@@ -234,9 +239,12 @@ class Bin {
|
|
|
234
239
|
let start
|
|
235
240
|
let conda_check = {}
|
|
236
241
|
let conda = new Set()
|
|
242
|
+
console.log("Before running conda list")
|
|
237
243
|
res = await this.exec({ message: `conda list` }, (stream) => {
|
|
244
|
+
process.stdout.write(stream.raw)
|
|
238
245
|
// console.log("conda list check", { stream })
|
|
239
246
|
})
|
|
247
|
+
console.log("After running conda list")
|
|
240
248
|
|
|
241
249
|
console.log("CONDA", res.response)
|
|
242
250
|
let lines = res.response.split(/[\r\n]+/)
|
|
@@ -466,6 +474,82 @@ class Bin {
|
|
|
466
474
|
// await this.mod(name).rm({}, ondata)
|
|
467
475
|
// await this.mod(name).install(options, ondata)
|
|
468
476
|
//}
|
|
477
|
+
async tryInstall(requirement, i, total, ondata) {
|
|
478
|
+
let current_platform = os.platform()
|
|
479
|
+
let current_arch = os.arch()
|
|
480
|
+
let current_gpu = this.kernel.gpu
|
|
481
|
+
let type = requirement.type
|
|
482
|
+
let platform = requirement.platform
|
|
483
|
+
let arch = requirement.arch
|
|
484
|
+
let gpu = requirement.gpu
|
|
485
|
+
let name = requirement.name
|
|
486
|
+
|
|
487
|
+
// name := ["protobuf", "rust", "cmake"]
|
|
488
|
+
// => 'conda install protobuf rust cmake'
|
|
489
|
+
if (Array.isArray(name)) {
|
|
490
|
+
name = name.join(" ")
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
let install = requirement.install // custom install command
|
|
494
|
+
let args = requirement.args || ""
|
|
495
|
+
if (requirement.installed) {
|
|
496
|
+
console.log("Already installed", requirement)
|
|
497
|
+
} else {
|
|
498
|
+
console.log("Not yet installed", requirement)
|
|
499
|
+
/*
|
|
500
|
+
{
|
|
501
|
+
platform: win32|darwin|linux|<none>,
|
|
502
|
+
arch: x64|arm64,
|
|
503
|
+
gpu: nvidia|amd|null,
|
|
504
|
+
type: conda|pip|brew|npm,
|
|
505
|
+
name: <package name>,
|
|
506
|
+
install: <custom install command>, // example: "brew install hashicorp/tap/vault"
|
|
507
|
+
args: <install flags>
|
|
508
|
+
}
|
|
509
|
+
*/
|
|
510
|
+
console.log({ gpu, current_gpu })
|
|
511
|
+
//let percent = Math.floor(( i / requirements.length ) * 100)
|
|
512
|
+
let progress = `(${i}/${total})`
|
|
513
|
+
if ( (!platform ||platform === current_platform || (Array.isArray(platform) && platform.includes(current_platform))) &&
|
|
514
|
+
(!arch || arch === current_arch) &&
|
|
515
|
+
(!gpu || gpu === current_gpu) ) {
|
|
516
|
+
if (type === "conda") {
|
|
517
|
+
const message = (install ? install : `conda install ${name} -y ${args}`)
|
|
518
|
+
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
519
|
+
await this.exec({ message }, ondata)
|
|
520
|
+
} else if (type === "pip") {
|
|
521
|
+
const message = (install ? install : `pip install ${name} ${args}`)
|
|
522
|
+
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
523
|
+
await this.exec({ message }, ondata)
|
|
524
|
+
} else if (type === "brew") {
|
|
525
|
+
const message = (install ? install : `brew install ${name} ${args}`)
|
|
526
|
+
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
527
|
+
await this.exec({ message }, ondata)
|
|
528
|
+
} else {
|
|
529
|
+
// find the mod
|
|
530
|
+
for(let m of this.mods) {
|
|
531
|
+
if (m.name === name) {
|
|
532
|
+
//await m.mod.install(this, ondata)
|
|
533
|
+
const message = `${m.mod.description ? '<br>' + m.mod.description : ''}`
|
|
534
|
+
ondata({ html: `<b>${progress} Installing ${name}</b>${message}` }, "notify")
|
|
535
|
+
console.log("## Before m.mod.install", requirement)
|
|
536
|
+
await m.mod.install(requirement, ondata, this.kernel)
|
|
537
|
+
|
|
538
|
+
// // 2 second delay to fix conda issue
|
|
539
|
+
// await new Promise((resolve, reject) => {
|
|
540
|
+
// setTimeout(() => {
|
|
541
|
+
// resolve()
|
|
542
|
+
// }, 2000)
|
|
543
|
+
// })
|
|
544
|
+
console.log("## After m.mod.install", requirement)
|
|
545
|
+
break
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
469
553
|
async install(req, ondata) {
|
|
470
554
|
/*
|
|
471
555
|
req.params := {
|
|
@@ -486,85 +570,46 @@ class Bin {
|
|
|
486
570
|
}
|
|
487
571
|
|
|
488
572
|
let requirements = JSON.parse(req.params)
|
|
489
|
-
let current_platform = os.platform()
|
|
490
|
-
let current_arch = os.arch()
|
|
491
|
-
let current_gpu = this.kernel.gpu
|
|
492
573
|
let i = 0;
|
|
493
574
|
for(let requirement of requirements) {
|
|
494
575
|
i++;
|
|
495
|
-
|
|
496
|
-
let
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if (requirement.installed) {
|
|
510
|
-
console.log("Already installed", requirement)
|
|
511
|
-
} else {
|
|
512
|
-
console.log("Not yet installed", requirement)
|
|
513
|
-
/*
|
|
514
|
-
{
|
|
515
|
-
platform: win32|darwin|linux|<none>,
|
|
516
|
-
arch: x64|arm64,
|
|
517
|
-
gpu: nvidia|amd|null,
|
|
518
|
-
type: conda|pip|brew|npm,
|
|
519
|
-
name: <package name>,
|
|
520
|
-
install: <custom install command>, // example: "brew install hashicorp/tap/vault"
|
|
521
|
-
args: <install flags>
|
|
522
|
-
}
|
|
523
|
-
*/
|
|
524
|
-
console.log({ gpu, current_gpu })
|
|
525
|
-
//let percent = Math.floor(( i / requirements.length ) * 100)
|
|
526
|
-
let progress = `(${i}/${requirements.length})`
|
|
527
|
-
if ( (!platform ||platform === current_platform || (Array.isArray(platform) && platform.includes(current_platform))) &&
|
|
528
|
-
(!arch || arch === current_arch) &&
|
|
529
|
-
(!gpu || gpu === current_gpu) ) {
|
|
530
|
-
if (type === "conda") {
|
|
531
|
-
const message = (install ? install : `conda install ${name} -y ${args}`)
|
|
532
|
-
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
533
|
-
await this.exec({ message }, ondata)
|
|
534
|
-
} else if (type === "pip") {
|
|
535
|
-
const message = (install ? install : `pip install ${name} ${args}`)
|
|
536
|
-
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
537
|
-
await this.exec({ message }, ondata)
|
|
538
|
-
} else if (type === "brew") {
|
|
539
|
-
const message = (install ? install : `brew install ${name} ${args}`)
|
|
540
|
-
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
541
|
-
await this.exec({ message }, ondata)
|
|
542
|
-
} else {
|
|
543
|
-
// find the mod
|
|
544
|
-
for(let m of this.mods) {
|
|
545
|
-
if (m.name === name) {
|
|
546
|
-
//await m.mod.install(this, ondata)
|
|
547
|
-
const message = `${m.mod.description ? '<br>' + m.mod.description : ''}`
|
|
548
|
-
ondata({ html: `<b>${progress} Installing ${name}</b>${message}` }, "notify")
|
|
549
|
-
console.log("## Before m.mod.install", requirement)
|
|
550
|
-
await m.mod.install(requirement, ondata, this.kernel)
|
|
551
|
-
|
|
552
|
-
// // 2 second delay to fix conda issue
|
|
553
|
-
// await new Promise((resolve, reject) => {
|
|
554
|
-
// setTimeout(() => {
|
|
555
|
-
// resolve()
|
|
556
|
-
// }, 2000)
|
|
557
|
-
// })
|
|
558
|
-
console.log("## After m.mod.install", requirement)
|
|
559
|
-
break
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
576
|
+
// Retry at least 5 times until it succeeds
|
|
577
|
+
for(let x=0; x<5; x++) {
|
|
578
|
+
console.log(`## Install Interation: ${x}`)
|
|
579
|
+
console.log("## Install Step 1: Try Install", requirement)
|
|
580
|
+
await this.tryInstall(requirement, i, requirements.length, ondata)
|
|
581
|
+
console.log("## Install Step 2: Refresh Installed")
|
|
582
|
+
await this.refreshInstalled()
|
|
583
|
+
console.log("## Install Step 3: Check Installed", requirement)
|
|
584
|
+
let installed = await this._installed(requirement.name, requirement.type)
|
|
585
|
+
if (installed) {
|
|
586
|
+
console.log("## Install Step 4: Installed Successful. Break")
|
|
587
|
+
break;
|
|
588
|
+
} else {
|
|
589
|
+
console.log("## Install Step 3: Install Unsuccessful. Retry")
|
|
563
590
|
}
|
|
564
591
|
}
|
|
565
592
|
}
|
|
566
593
|
await this.init()
|
|
567
594
|
}
|
|
595
|
+
async _installed(name, type) {
|
|
596
|
+
if (type === "conda") {
|
|
597
|
+
return this.kernel.bin.installed.conda.has(name)
|
|
598
|
+
} else if (type === "pip") {
|
|
599
|
+
return this.kernel.bin.installed.pip.has(name)
|
|
600
|
+
} else if (type === "brew") {
|
|
601
|
+
return this.kernel.bin.installed.brew.has(name)
|
|
602
|
+
} else {
|
|
603
|
+
// check kernel/bin/<module>.installed()
|
|
604
|
+
let filepath = path.resolve(__dirname, "..", "kernel", "bin", name + ".js")
|
|
605
|
+
let mod = this.kernel.bin.mod[name]
|
|
606
|
+
let installed = false
|
|
607
|
+
if (mod.installed) {
|
|
608
|
+
installed = await mod.installed()
|
|
609
|
+
}
|
|
610
|
+
return installed
|
|
611
|
+
}
|
|
612
|
+
}
|
|
568
613
|
async sh(params, ondata) {
|
|
569
614
|
let response = await this.kernel.shell.run(params, null, ondata)
|
|
570
615
|
return response
|
package/kernel/bin/node.js
CHANGED
|
@@ -8,7 +8,7 @@ class Node {
|
|
|
8
8
|
//message: "conda install -y nodejs=22.12.0 -c conda-forge"
|
|
9
9
|
message: [
|
|
10
10
|
"conda clean -y --all",
|
|
11
|
-
"conda install -y nodejs=20.17.0 -c conda-forge"
|
|
11
|
+
"conda install -y nodejs=20.17.0 pnpm -c conda-forge"
|
|
12
12
|
]
|
|
13
13
|
// conda: {
|
|
14
14
|
// name: "base",
|
|
@@ -17,11 +17,11 @@ class Node {
|
|
|
17
17
|
}, ondata)
|
|
18
18
|
}
|
|
19
19
|
async installed() {
|
|
20
|
-
return this.kernel.bin.installed.conda.has("nodejs")
|
|
20
|
+
return this.kernel.bin.installed.conda.has("nodejs") && this.kernel.bin.installed.conda.has("pnpm")
|
|
21
21
|
}
|
|
22
22
|
async uninstall(req, ondata) {
|
|
23
23
|
await this.kernel.bin.exec({
|
|
24
|
-
message: "conda remove nodejs",
|
|
24
|
+
message: "conda remove nodejs pnpm",
|
|
25
25
|
}, ondata)
|
|
26
26
|
}
|
|
27
27
|
}
|
package/kernel/index.js
CHANGED
|
@@ -340,6 +340,14 @@ class Kernel {
|
|
|
340
340
|
let ts = Date.now()
|
|
341
341
|
this.bin.init().then(() => {
|
|
342
342
|
console.log("bin init finished")
|
|
343
|
+
this.shell.init().then(() => {
|
|
344
|
+
if (this.envs) {
|
|
345
|
+
this.template.update({
|
|
346
|
+
env: this.envs,
|
|
347
|
+
envs: this.envs
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
})
|
|
343
351
|
})
|
|
344
352
|
let ts2 = Date.now()
|
|
345
353
|
await this.api.init()
|
|
@@ -401,16 +409,15 @@ class Kernel {
|
|
|
401
409
|
await this.update_sysinfo()
|
|
402
410
|
console.timeEnd("update_sysinfo")
|
|
403
411
|
*/
|
|
404
|
-
console.log("> 4")
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
})
|
|
412
|
+
// console.log("> 4")
|
|
413
|
+
// this.shell.init().then(() => {
|
|
414
|
+
// if (this.envs) {
|
|
415
|
+
// this.template.update({
|
|
416
|
+
// env: this.envs,
|
|
417
|
+
// envs: this.envs
|
|
418
|
+
// })
|
|
419
|
+
// }
|
|
420
|
+
// })
|
|
414
421
|
//await this.shell.init()
|
|
415
422
|
}
|
|
416
423
|
|
|
@@ -422,9 +429,6 @@ class Kernel {
|
|
|
422
429
|
// } else {
|
|
423
430
|
// pwpath = this.bin.path("miniconda/lib/node_modules/playwright")
|
|
424
431
|
// }
|
|
425
|
-
let pwpath = this.bin.path("playwright/browsers")
|
|
426
|
-
process.env.PLAYWRIGHT_BROWSERS_PATH = pwpath
|
|
427
|
-
await fs.promises.mkdir(pwpath, { recursive: true }).catch((e) => { })
|
|
428
432
|
|
|
429
433
|
// await this.template.init()
|
|
430
434
|
|