pinokiod 3.2.137 → 3.2.140
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 +113 -71
- package/kernel/bin/node.js +3 -3
- package/kernel/index.js +17 -13
- package/package.json +1 -1
- package/server/views/download.ejs +2 -2
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) {
|
|
@@ -466,6 +471,82 @@ class Bin {
|
|
|
466
471
|
// await this.mod(name).rm({}, ondata)
|
|
467
472
|
// await this.mod(name).install(options, ondata)
|
|
468
473
|
//}
|
|
474
|
+
async tryInstall(requirement, i, total, ondata) {
|
|
475
|
+
let current_platform = os.platform()
|
|
476
|
+
let current_arch = os.arch()
|
|
477
|
+
let current_gpu = this.kernel.gpu
|
|
478
|
+
let type = requirement.type
|
|
479
|
+
let platform = requirement.platform
|
|
480
|
+
let arch = requirement.arch
|
|
481
|
+
let gpu = requirement.gpu
|
|
482
|
+
let name = requirement.name
|
|
483
|
+
|
|
484
|
+
// name := ["protobuf", "rust", "cmake"]
|
|
485
|
+
// => 'conda install protobuf rust cmake'
|
|
486
|
+
if (Array.isArray(name)) {
|
|
487
|
+
name = name.join(" ")
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
let install = requirement.install // custom install command
|
|
491
|
+
let args = requirement.args || ""
|
|
492
|
+
if (requirement.installed) {
|
|
493
|
+
console.log("Already installed", requirement)
|
|
494
|
+
} else {
|
|
495
|
+
console.log("Not yet installed", requirement)
|
|
496
|
+
/*
|
|
497
|
+
{
|
|
498
|
+
platform: win32|darwin|linux|<none>,
|
|
499
|
+
arch: x64|arm64,
|
|
500
|
+
gpu: nvidia|amd|null,
|
|
501
|
+
type: conda|pip|brew|npm,
|
|
502
|
+
name: <package name>,
|
|
503
|
+
install: <custom install command>, // example: "brew install hashicorp/tap/vault"
|
|
504
|
+
args: <install flags>
|
|
505
|
+
}
|
|
506
|
+
*/
|
|
507
|
+
console.log({ gpu, current_gpu })
|
|
508
|
+
//let percent = Math.floor(( i / requirements.length ) * 100)
|
|
509
|
+
let progress = `(${i}/${total})`
|
|
510
|
+
if ( (!platform ||platform === current_platform || (Array.isArray(platform) && platform.includes(current_platform))) &&
|
|
511
|
+
(!arch || arch === current_arch) &&
|
|
512
|
+
(!gpu || gpu === current_gpu) ) {
|
|
513
|
+
if (type === "conda") {
|
|
514
|
+
const message = (install ? install : `conda install ${name} -y ${args}`)
|
|
515
|
+
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
516
|
+
await this.exec({ message }, ondata)
|
|
517
|
+
} else if (type === "pip") {
|
|
518
|
+
const message = (install ? install : `pip install ${name} ${args}`)
|
|
519
|
+
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
520
|
+
await this.exec({ message }, ondata)
|
|
521
|
+
} else if (type === "brew") {
|
|
522
|
+
const message = (install ? install : `brew install ${name} ${args}`)
|
|
523
|
+
ondata({ html: `<b>${progress} Installing ${name}</b><br>${message}` }, "notify")
|
|
524
|
+
await this.exec({ message }, ondata)
|
|
525
|
+
} else {
|
|
526
|
+
// find the mod
|
|
527
|
+
for(let m of this.mods) {
|
|
528
|
+
if (m.name === name) {
|
|
529
|
+
//await m.mod.install(this, ondata)
|
|
530
|
+
const message = `${m.mod.description ? '<br>' + m.mod.description : ''}`
|
|
531
|
+
ondata({ html: `<b>${progress} Installing ${name}</b>${message}` }, "notify")
|
|
532
|
+
console.log("## Before m.mod.install", requirement)
|
|
533
|
+
await m.mod.install(requirement, ondata, this.kernel)
|
|
534
|
+
|
|
535
|
+
// // 2 second delay to fix conda issue
|
|
536
|
+
// await new Promise((resolve, reject) => {
|
|
537
|
+
// setTimeout(() => {
|
|
538
|
+
// resolve()
|
|
539
|
+
// }, 2000)
|
|
540
|
+
// })
|
|
541
|
+
console.log("## After m.mod.install", requirement)
|
|
542
|
+
break
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
469
550
|
async install(req, ondata) {
|
|
470
551
|
/*
|
|
471
552
|
req.params := {
|
|
@@ -486,85 +567,46 @@ class Bin {
|
|
|
486
567
|
}
|
|
487
568
|
|
|
488
569
|
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
570
|
let i = 0;
|
|
493
571
|
for(let requirement of requirements) {
|
|
494
572
|
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
|
-
}
|
|
573
|
+
// Retry at least 5 times until it succeeds
|
|
574
|
+
for(let x=0; x<5; x++) {
|
|
575
|
+
console.log(`## Install Interation: ${x}`)
|
|
576
|
+
console.log("## Install Step 1: Try Install", requirement)
|
|
577
|
+
await this.tryInstall(requirement, i, requirements.length, ondata)
|
|
578
|
+
console.log("## Install Step 2: Refresh Installed")
|
|
579
|
+
await this.refreshInstalled()
|
|
580
|
+
console.log("## Install Step 3: Check Installed", requirement)
|
|
581
|
+
let installed = await this._installed(requirement.name, requirement.type)
|
|
582
|
+
if (installed) {
|
|
583
|
+
console.log("## Install Step 4: Installed Successful. Break")
|
|
584
|
+
break;
|
|
585
|
+
} else {
|
|
586
|
+
console.log("## Install Step 3: Install Unsuccessful. Retry")
|
|
563
587
|
}
|
|
564
588
|
}
|
|
565
589
|
}
|
|
566
590
|
await this.init()
|
|
567
591
|
}
|
|
592
|
+
async _installed(name, type) {
|
|
593
|
+
if (type === "conda") {
|
|
594
|
+
return this.kernel.bin.installed.conda.has(name)
|
|
595
|
+
} else if (type === "pip") {
|
|
596
|
+
return this.kernel.bin.installed.pip.has(name)
|
|
597
|
+
} else if (type === "brew") {
|
|
598
|
+
return this.kernel.bin.installed.brew.has(name)
|
|
599
|
+
} else {
|
|
600
|
+
// check kernel/bin/<module>.installed()
|
|
601
|
+
let filepath = path.resolve(__dirname, "..", "kernel", "bin", name + ".js")
|
|
602
|
+
let mod = this.kernel.bin.mod[name]
|
|
603
|
+
let installed = false
|
|
604
|
+
if (mod.installed) {
|
|
605
|
+
installed = await mod.installed()
|
|
606
|
+
}
|
|
607
|
+
return installed
|
|
608
|
+
}
|
|
609
|
+
}
|
|
568
610
|
async sh(params, ondata) {
|
|
569
611
|
let response = await this.kernel.shell.run(params, null, ondata)
|
|
570
612
|
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
|
|
package/package.json
CHANGED
|
@@ -157,11 +157,11 @@ body {
|
|
|
157
157
|
<% requirements.map((r) => { %>
|
|
158
158
|
<div class='requirement-item'>
|
|
159
159
|
<% if (r.installed) { %>
|
|
160
|
-
<div class='name'><%=r.
|
|
160
|
+
<div class='name'><%=r.name%></div>
|
|
161
161
|
<div class='flexible'></div>
|
|
162
162
|
<div class='label'>Installed</div>
|
|
163
163
|
<% } else { %>
|
|
164
|
-
<div class='name highlighted'><%=r.
|
|
164
|
+
<div class='name highlighted'><%=r.name%></div>
|
|
165
165
|
<div class='flexible'></div>
|
|
166
166
|
<div class='label highlighted'>Not Installed</div>
|
|
167
167
|
<% } %>
|