pinokiod 3.18.6 → 3.18.9

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.
Files changed (100) hide show
  1. package/kernel/api/index.js +13 -3
  2. package/kernel/bin/index.js +58 -1
  3. package/kernel/gitconfig_template +2 -0
  4. package/kernel/peer.js +0 -3
  5. package/kernel/proto/PINOKIO.md +6886 -0
  6. package/kernel/proto/cli/icon.png +0 -0
  7. package/kernel/proto/cli/installable/README.md +6 -0
  8. package/kernel/proto/cli/installable/index.js +54 -0
  9. package/kernel/proto/cli/installable/static/AGENTS.md +24 -0
  10. package/kernel/proto/cli/installable/static/gitignore +10 -0
  11. package/kernel/proto/cli/installable/static/pinokio.js +34 -0
  12. package/kernel/proto/cli/instant/README.md +5 -0
  13. package/kernel/proto/cli/instant/index.js +36 -0
  14. package/kernel/proto/cli/instant/static/AGENTS.md +24 -0
  15. package/kernel/proto/cli/instant/static/gitignore +10 -0
  16. package/kernel/proto/cli/instant/static/pinokio.js +11 -0
  17. package/kernel/proto/documentation/new/README.md +9 -0
  18. package/kernel/proto/documentation/new/icon.png +0 -0
  19. package/kernel/proto/documentation/new/index.js +39 -0
  20. package/kernel/proto/documentation/new/static/AGENTS.md +24 -0
  21. package/kernel/proto/documentation/new/static/docs/docsify.min.js +1 -0
  22. package/kernel/proto/documentation/new/static/docs/index.html +75 -0
  23. package/kernel/proto/documentation/new/static/docs/style.css +212 -0
  24. package/kernel/proto/documentation/new/static/docs/vue.css +1 -0
  25. package/kernel/proto/documentation/new/static/gitignore +10 -0
  26. package/kernel/proto/documentation/new/static/pinokio.js +28 -0
  27. package/kernel/proto/documentation/new/static/start.js +54 -0
  28. package/kernel/proto/empty/clone/README.md +14 -0
  29. package/kernel/proto/empty/clone/index.js +18 -0
  30. package/kernel/proto/empty/clone/static/AGENTS.md +28 -0
  31. package/kernel/proto/empty/clone/static/gitignore +11 -0
  32. package/kernel/proto/empty/clone/static/install.js +13 -0
  33. package/kernel/proto/empty/clone/static/pinokio.js +76 -0
  34. package/kernel/proto/empty/clone/static/pinokio.json +3 -0
  35. package/kernel/proto/empty/clone/static/reset.js +8 -0
  36. package/kernel/proto/empty/clone/static/start.js +35 -0
  37. package/kernel/proto/empty/clone/static/update.js +23 -0
  38. package/kernel/proto/empty/icon.png +0 -0
  39. package/kernel/proto/empty/new/README.md +14 -0
  40. package/kernel/proto/empty/new/index.js +18 -0
  41. package/kernel/proto/empty/new/static/AGENTS.md +28 -0
  42. package/kernel/proto/empty/new/static/app/.gitkeep +0 -0
  43. package/kernel/proto/empty/new/static/gitignore +10 -0
  44. package/kernel/proto/empty/new/static/install.js +13 -0
  45. package/kernel/proto/empty/new/static/pinokio.js +76 -0
  46. package/kernel/proto/empty/new/static/pinokio.json +3 -0
  47. package/kernel/proto/empty/new/static/reset.js +8 -0
  48. package/kernel/proto/empty/new/static/start.js +35 -0
  49. package/kernel/proto/empty/new/static/update.js +14 -0
  50. package/kernel/proto/nodejs/clone/README.md +16 -0
  51. package/kernel/proto/nodejs/clone/index.js +87 -0
  52. package/kernel/proto/nodejs/clone/static/AGENTS.md +27 -0
  53. package/kernel/proto/nodejs/clone/static/gitignore +11 -0
  54. package/kernel/proto/nodejs/clone/static/pinokio.js +77 -0
  55. package/kernel/proto/nodejs/clone/static/reset.js +8 -0
  56. package/kernel/proto/nodejs/clone/static/update.js +14 -0
  57. package/kernel/proto/nodejs/icon.png +0 -0
  58. package/kernel/proto/nodejs/new/README.md +15 -0
  59. package/kernel/proto/nodejs/new/index.js +82 -0
  60. package/kernel/proto/nodejs/new/static/AGENTS.md +27 -0
  61. package/kernel/proto/nodejs/new/static/app/index.js +10 -0
  62. package/kernel/proto/nodejs/new/static/app/package.json +16 -0
  63. package/kernel/proto/nodejs/new/static/gitignore +10 -0
  64. package/kernel/proto/nodejs/new/static/pinokio.js +84 -0
  65. package/kernel/proto/nodejs/new/static/reset.js +8 -0
  66. package/kernel/proto/nodejs/new/static/update.js +14 -0
  67. package/kernel/proto/pinokio.js +64 -0
  68. package/kernel/proto/python/clone/README.md +11 -0
  69. package/kernel/proto/python/clone/form.png +0 -0
  70. package/kernel/proto/python/clone/index.js +161 -0
  71. package/kernel/proto/python/clone/static/AGENTS.md +30 -0
  72. package/kernel/proto/python/clone/static/gitignore +11 -0
  73. package/kernel/proto/python/clone/static/link.js +10 -0
  74. package/kernel/proto/python/clone/static/pinokio.js +85 -0
  75. package/kernel/proto/python/clone/static/reset.js +8 -0
  76. package/kernel/proto/python/clone/static/torch.js +117 -0
  77. package/kernel/proto/python/clone/static/update.js +9 -0
  78. package/kernel/proto/python/icon.png +0 -0
  79. package/kernel/proto/python/new/README.md +18 -0
  80. package/kernel/proto/python/new/index.js +128 -0
  81. package/kernel/proto/python/new/install_with_torch.js +29 -0
  82. package/kernel/proto/python/new/static/AGENTS.md +27 -0
  83. package/kernel/proto/python/new/static/app/app.py +12 -0
  84. package/kernel/proto/python/new/static/app/requirements.txt +1 -0
  85. package/kernel/proto/python/new/static/gitignore +10 -0
  86. package/kernel/proto/python/new/static/link.js +10 -0
  87. package/kernel/proto/python/new/static/pinokio.js +84 -0
  88. package/kernel/proto/python/new/static/reset.js +8 -0
  89. package/kernel/proto/python/new/static/torch.js +117 -0
  90. package/kernel/proto/python/new/static/update.js +8 -0
  91. package/kernel/shell.js +31 -2
  92. package/kernel/shells.js +20 -11
  93. package/package.json +3 -2
  94. package/server/index.js +83 -24
  95. package/server/public/style.css +1 -2
  96. package/server/views/index.ejs +4 -1
  97. package/server/views/prototype/index.ejs +902 -533
  98. package/server/views/prototype/init.ejs +1785 -0
  99. package/server/views/prototype/old_index.ejs +0 -641
  100. package/server/views/prototype/show.ejs +0 -594
@@ -50,9 +50,19 @@ class Api {
50
50
  p3 = this.kernel.path("api", name, "pinokio.json")
51
51
  }
52
52
  let pinokio = (await this.kernel.loader.load(p1)).resolved
53
+ if (pinokio && pinokio.menu && !(Array.isArray(pinokio.menu) || typeof pinokio.menu === "function")) {
54
+ delete pinokio.menu
55
+ }
53
56
  let pinokio2 = (await this.kernel.loader.load(p2)).resolved
57
+ if (pinokio2 && pinokio2.menu && !(Array.isArray(pinokio2.menu) || typeof pinokio2.menu === "function")) {
58
+ delete pinokio2.menu
59
+ }
54
60
  let pinokio3 = (await this.kernel.loader.load(p3)).resolved
61
+ if (pinokio3 && pinokio3.menu && !(Array.isArray(pinokio3.menu) || typeof pinokio3.menu === "function")) {
62
+ delete pinokio3.menu
63
+ }
55
64
  let meta = Object.assign({}, pinokio, pinokio2, pinokio3)
65
+ console.log("meta", meta)
56
66
 
57
67
  // create pinokio.json if it doesn't exist
58
68
  // if (!pinokio3) {
@@ -929,9 +939,9 @@ class Api {
929
939
  // write to current app folder's ENVIRONMENT
930
940
  let api_path = Util.api_path(request.path, this.kernel)
931
941
  let env_path = path.resolve(api_path, "ENVIRONMENT")
932
- await Util.update_env(env_path, {
933
- PINOKIO_SCRIPT_DEFAULT: "false"
934
- })
942
+ // await Util.update_env(env_path, {
943
+ // PINOKIO_SCRIPT_DEFAULT: "false"
944
+ // })
935
945
  return
936
946
  }
937
947
 
@@ -4,6 +4,7 @@ const _ = require('lodash')
4
4
  const path = require('path')
5
5
  const { rimraf } = require('rimraf')
6
6
  const { DownloaderHelper } = require('node-downloader-helper');
7
+ const { spawn } = require('child_process')
7
8
  const { ProxyAgent } = require('proxy-agent');
8
9
 
9
10
  //const Cmake = require("./cmake")
@@ -77,7 +78,6 @@ class Bin {
77
78
  "User-Agent": userAgent
78
79
  }
79
80
  }
80
- console.log("Download", opts)
81
81
  if (process.env.HTTP_PROXY && process.env.HTTP_PROXY.length > 0) {
82
82
  opts.httpRequestOptions = { agent }
83
83
  opts.httpsRequestOptions = { agent }
@@ -628,6 +628,63 @@ class Bin {
628
628
  return res
629
629
  }
630
630
  }
631
+ async init_launcher(req, ondata) {
632
+ console.log("init_launcher", req)
633
+ try {
634
+ let projectType = req.params.projectType
635
+ let startType = req.params.cliType || req.params.startType
636
+ console.log({ projectType, startType })
637
+
638
+ let cwd = req.cwd
639
+ let name = req.name
640
+ let payload = {}
641
+ payload.cwd = path.resolve(cwd, name)
642
+ payload.input = req.params
643
+
644
+ let mod_path = path.resolve(__dirname, "../proto", projectType, startType)
645
+ let mod = await this.kernel.require(mod_path)
646
+
647
+ await mod(payload, ondata, this.kernel)
648
+
649
+ // copy readme
650
+ let readme_path = path.resolve(__dirname, "../proto/PINOKIO.md")
651
+ console.log("copy to", readme_path, path.resolve(cwd, name, "PINOKIO.md"))
652
+ await fs.promises.cp(readme_path, path.resolve(cwd, name, "PINOKIO.md"))
653
+
654
+ return { success: "/p/" + name }
655
+ } catch (e) {
656
+ console.log("ERROR", e)
657
+ return { error: e.stack }
658
+ }
659
+ }
660
+ async filepicker(req, ondata) {
661
+ /*
662
+ req.params := {
663
+ cwd: cwd
664
+ }
665
+ */
666
+ let response = await new Promise((resolve, reject) => {
667
+ let picker_path = this.kernel.path("bin/py/picker.py")
668
+ const proc = spawn("python", [picker_path])
669
+
670
+ let output = "";
671
+ proc.stdout.on("data", (chunk) => output += chunk);
672
+ proc.stderr.on("data", (err) => console.error("Python error:", err.toString()));
673
+ proc.on("close", () => {
674
+ try {
675
+ const result = JSON.parse(output);
676
+ if (result.error) return reject(result.error);
677
+ resolve(result.paths); // Always an array
678
+ } catch (e) {
679
+ reject("Failed to parse Python output: " + output);
680
+ }
681
+ });
682
+
683
+ proc.stdin.write(JSON.stringify(req.params));
684
+ proc.stdin.end();
685
+ });
686
+ return { paths: response }
687
+ }
631
688
  async install(req, ondata) {
632
689
  /*
633
690
  req.params := {
@@ -12,3 +12,5 @@
12
12
  [user]
13
13
  name = pinokio
14
14
  email = pinokio
15
+ [init]
16
+ defaultBranch = main
package/kernel/peer.js CHANGED
@@ -9,14 +9,12 @@ class PeerDiscovery {
9
9
  this.interval = interval;
10
10
  this.peers = new Set();
11
11
  this.host = this._getLocalIPAddress()
12
- console.log("THIS>HOST", this.host)
13
12
  this.default_port = 42000
14
13
  this.peers.add(this.host)
15
14
  // this.start();
16
15
  }
17
16
  stop() {
18
17
  if (this.socket) {
19
- console.log("peer stop")
20
18
  clearInterval(this.interval_handle)
21
19
  this.socket.close()
22
20
  }
@@ -60,7 +58,6 @@ class PeerDiscovery {
60
58
  // if PINOKIO_NETWORK_SHARE is 0 or false, turn it off
61
59
  // if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="0" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="false")) {
62
60
  await this.check(kernel)
63
- console.log({ active: this.active, name: this.name })
64
61
  // if (env && env.PINOKIO_NETWORK_ACTIVE && (env.PINOKIO_NETWORK_ACTIVE==="1" || env.PINOKIO_NETWORK_ACTIVE.toLowerCase()==="true")) {
65
62
  //// this.active = false
66
63
  // this.active = true