pinokiod 3.6.33 → 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.
@@ -567,18 +567,10 @@ class Api {
567
567
 
568
568
  }
569
569
  async step (request, rawrpc, input, i, total, args) {
570
- console.log("####### step")
571
-
572
570
  console.time("STEP INIT")
573
571
  await Promise.all([this.init(), this.kernel.update_sysinfo()])
574
572
  console.timeEnd("STEP INIT")
575
573
 
576
- // await this.init()
577
- //
578
- // console.time("api.update_sysinfo")
579
- // await this.kernel.update_sysinfo()
580
- // console.timeEnd("api.update_sysinfo")
581
-
582
574
  // clear global regular expression object RegExp.lastMatch (memory leak prevention)
583
575
  let r = /\s*/g.exec("");
584
576
 
@@ -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
- if (String(version) === "3.47.2") {
143
- //let coerced = semver.coerce(version)
144
- //let sqlite_requirement = ">=3.47.2"
145
- //if (semver.satisfies(coerced, sqlite_requirement)) {
146
- console.log("sqlite version satisfied")
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("sqlite version NOT satisfied")
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",
@@ -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
- // let coerced = semver.coerce(version)
313
- // let sqlite_requirement = ">=3.47.2"
314
- // // console.log({ coerced, version, sqlite_requirement })
315
- // if (semver.satisfies(coerced, sqlite_requirement)) {
316
- if (String(version) === "3.47.2") {
317
- console.log("sqlite version satisfied")
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("sqlite version NOT satisfied")
352
+ console.log("semver NOT satisfied")
321
353
  }
322
354
  }
323
355
  }
@@ -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
- await this.update_sysinfo()
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,
@@ -599,68 +604,10 @@ class Kernel {
599
604
 
600
605
  await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
601
606
  await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify(this.i, null, 2))
602
-
603
- /*
604
- this.sys = new Sysinfo()
605
- await this.sys.init(this)
606
- let info = this.sys.info
607
- await fs.promises.mkdir(this.path("logs"), { recursive: true }).catch((e) => { })
608
- await fs.promises.writeFile(this.path("logs/system.json"), JSON.stringify({
609
- platform: this.platform,
610
- arch: this.arch,
611
- home: this.homedir,
612
- ...info
613
- }, null, 2))
614
- this.sysinfo = info
615
- console.time("template.init")
616
- await this.template.init({
617
- kernel: this,
618
- system,
619
- platform: this.platform,
620
- arch: this.arch,
621
- proxy: (port) => {
622
- return this.api.get_proxy_url("/proxy", port)
623
- },
624
- ...info
625
- })
626
- console.timeEnd("template.init")
627
- console.time("update_sysinfo")
628
- await this.update_sysinfo()
629
- console.timeEnd("update_sysinfo")
630
- */
631
- // console.log("> 4")
632
- // this.shell.init().then(() => {
633
- // if (this.envs) {
634
- // this.template.update({
635
- // env: this.envs,
636
- // envs: this.envs
637
- // })
638
- // }
639
- // })
640
- //await this.shell.init()
641
607
  }
642
608
 
643
- //let pwpath = this.bin.path("playwright/js/node_modules/playwright")
644
609
  let pwpath = this.bin.path("playwright/node_modules/playwright")
645
610
  this.playwright = (await this.loader.load(pwpath)).resolved
646
-
647
-
648
- // let pwpath
649
- // if (this.platform === "win32") {
650
- // pwpath = this.bin.path("miniconda/node_modules/playwright")
651
- // } else {
652
- // pwpath = this.bin.path("miniconda/lib/node_modules/playwright")
653
- // }
654
-
655
- // await this.template.init()
656
-
657
-
658
- // let PuppeteerPath = this.bin.path("puppet", "node_modules", "puppeteer")
659
- // this.puppet = (await this.loader.load(PuppeteerPath)).resolved
660
- // this.puppet.setGlobalOptions({
661
- // userDataDir: this.bin.path("puppet")
662
- // });
663
-
664
611
  } catch (e) {
665
612
  console.log("### ERROR", e)
666
613
  }
@@ -676,7 +623,6 @@ class Kernel {
676
623
  try {
677
624
  await this.sys.refresh()
678
625
  let info = this.sys.info
679
- console.log({ info })
680
626
  this.template.update(info)
681
627
  this.sysinfo = info
682
628
  this.gpu = info.gpu
package/kernel/sysinfo.js CHANGED
@@ -36,7 +36,6 @@ class Sysinfo {
36
36
  // await this.net()
37
37
  }
38
38
  async gpus() {
39
- console.log("SYSINFO GPUS")
40
39
  let g = await system.graphics()
41
40
  let gpus
42
41
  if (g && g.controllers && g.controllers.length > 0) {
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.33",
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,
@@ -2018,6 +2036,25 @@ class Server {
2018
2036
  home = this.kernel.store.get("home")
2019
2037
  theme = this.kernel.store.get("theme")
2020
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)
2021
2058
  }
2022
2059
  async startLogging(homedir) {
2023
2060
  console.log(">>>>>>> startLogging", homedir)
@@ -2329,6 +2366,7 @@ class Server {
2329
2366
  } else {
2330
2367
  _home = path.resolve(os.homedir(), "pinokio")
2331
2368
  }
2369
+ let system_env = await Environment.get(this.kernel.homedir)
2332
2370
  let configArray = [{
2333
2371
  key: "home",
2334
2372
  description: [
@@ -2346,6 +2384,21 @@ class Server {
2346
2384
  key: "theme",
2347
2385
  val: this.theme,
2348
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"
2349
2402
  }]
2350
2403
  let folders = {}
2351
2404
  if (this.kernel.homedir) {
@@ -3137,7 +3190,7 @@ class Server {
3137
3190
  res.json({ success: true })
3138
3191
  }))
3139
3192
  this.app.get("/pinokio/info", ex(async (req, res) => {
3140
- await this.kernel.getInfo()
3193
+ await this.kernel.getInfo(true)
3141
3194
  let info = Object.assign({}, this.kernel.i)
3142
3195
  info.launch_complete = this.kernel.launch_complete
3143
3196
  console.log("kernel.launch_complete", this.kernel.launch_complete)
@@ -3391,7 +3444,6 @@ class Server {
3391
3444
  this.start({ debug: this.debug, browser: this.browser })
3392
3445
  }))
3393
3446
  this.app.post("/config", ex(async (req, res) => {
3394
- console.log("/config", { body: req.body })
3395
3447
  try {
3396
3448
  await this.setConfig(req.body)
3397
3449
  res.json({ success: true })
package/server/socket.js CHANGED
@@ -16,7 +16,6 @@ class Socket {
16
16
  });
17
17
  });
18
18
  ws.on('message', async (message) => {
19
- console.log("MESSAGE", message)
20
19
  const req = JSON.parse(message);
21
20
  if (req.response) {
22
21
  this.parent.kernel.api.respond(req)
@@ -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
- home: (val && val.length > 0 ? val : null),
545
- // drive: (drive && drive.length > 0 ? drive : null),
546
- theme
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
  })