pinokiod 2.15.46 → 2.15.49

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.
@@ -10,6 +10,7 @@ const { glob, sync, hasMagic } = require('glob-gitignore')
10
10
  const fastq = require('fastq')
11
11
  const Loader = require("../loader")
12
12
  const Environment = require("../environment")
13
+ const Util = require('../util')
13
14
 
14
15
  class Api {
15
16
  constructor(kernel) {
@@ -739,6 +740,27 @@ class Api {
739
740
  rpc,
740
741
  rawrpc
741
742
  })
743
+
744
+ // if there's an error, set the PINOKIO_SCRIPT_DEFAULT to false
745
+
746
+ /*
747
+ req := {
748
+ "method": "env.set",
749
+ "params": {
750
+ <key>: <val>,
751
+ <key>: <val>,
752
+ }
753
+ }
754
+ */
755
+ // write to current app folder's ENVIRONMENT
756
+ console.log("request", request)
757
+ let api_path = Util.api_path(request.path, this.kernel)
758
+ console.log("api_path", api_path)
759
+ let env_path = path.resolve(api_path, "ENVIRONMENT")
760
+ console.log("env_path", env_path)
761
+ await Util.update_env(env_path, {
762
+ PINOKIO_SCRIPT_DEFAULT: "false"
763
+ })
742
764
  return
743
765
  }
744
766
 
package/kernel/shells.js CHANGED
@@ -63,18 +63,8 @@ class Shells {
63
63
  params_dup.message = message
64
64
  console.log("Launching Message", params_dup)
65
65
  res = await this._launch(params_dup, options, ondata)
66
- // if there's an error, trigger an error event
66
+ // if there's an error, immediately return with the error
67
67
  if (res.error) {
68
- console.log("Error exists. Trigger an error", { res })
69
- ondata({
70
- id: res.id,
71
- type: "error",
72
- data: res.response,
73
- event: res.error,
74
- // rpc,
75
- // rawrpc
76
- })
77
- // if there's an error, return immediately => so it will NOT go forward and stop the script
78
68
  return res
79
69
  }
80
70
  }
@@ -160,8 +150,6 @@ class Shells {
160
150
  ondata(stream)
161
151
  })
162
152
 
163
- console.log(">>>>>> RESPONSE", response)
164
-
165
153
  /*
166
154
  {
167
155
  method: "shell.run",
@@ -191,7 +179,6 @@ class Shells {
191
179
 
192
180
  // 2. first find the `break: false` handlers and replace the patterns with blank => so they won't be matched in the next step
193
181
  //let line = response.replaceAll(/[\r\n]/g, "")
194
- console.log("checking breakpoints", breakPoints)
195
182
  for(let handler of breakPoints) {
196
183
  if (handler.event) {
197
184
  let matches = /^\/(.+)\/([dgimsuy]*)$/gs.exec(handler.event)
@@ -206,9 +193,6 @@ class Shells {
206
193
  }
207
194
  }
208
195
  }
209
-
210
- console.log("Line before", line)
211
-
212
196
  // 3. Now with all the `break: false` (ignored patterns) gone, look for the `break: true` patterns
213
197
  for(let handler of breakPoints) {
214
198
  if (handler.event) {
@@ -218,16 +202,11 @@ class Shells {
218
202
  }
219
203
  let re = new RegExp(matches[1], matches[2])
220
204
 
221
- console.log("re", re)
222
-
223
205
  // only the "break: true" ones
224
206
  if (handler.break) {
225
- console.log("checking break handler", handler)
226
-
227
207
  let match;
228
208
  // Keep executing the regex on the text until no more matches are found
229
209
  while ((match = re.exec(line)) !== null) {
230
- console.log("match found", match)
231
210
  errors.add(match[0])
232
211
  // errors.add(match.slice(1));
233
212
  }
package/kernel/util.js CHANGED
@@ -140,6 +140,16 @@ const parse_env_detail = async (filename) => {
140
140
  */
141
141
  return items
142
142
  }
143
+ const log_path = (fullpath, kernel) => {
144
+ let api_path = `${kernel.homedir}${path.sep}api`
145
+ let rel_path = path.relative(api_path, fullpath)
146
+ console.log({ rel_path })
147
+ let log_root = `${kernel.homedir}${path.sep}logs`
148
+ console.log({ log_root })
149
+ let current_log_path = path.resolve(log_root, "shell/cleaned/api", rel_path)
150
+ console.log({ current_log_path })
151
+ return current_log_path
152
+ }
143
153
  const api_path = (fullpath, kernel) => {
144
154
  let api_path = `${kernel.homedir}${path.sep}api`
145
155
  let rel_path = path.relative(api_path, fullpath)
@@ -196,5 +206,5 @@ const update_env = async (filepath, changes) => {
196
206
  await fs.promises.writeFile(filepath, newval)
197
207
  };
198
208
  module.exports = {
199
- parse_env, api_path, update_env, parse_env_detail, openfs, port_running, du
209
+ parse_env, log_path, api_path, update_env, parse_env_detail, openfs, port_running, du
200
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "2.15.46",
3
+ "version": "2.15.49",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/server/index.js CHANGED
@@ -931,6 +931,8 @@ class Server {
931
931
  items: pre_items
932
932
  })
933
933
  } else {
934
+ let logpath = encodeURIComponent(Util.log_path(filepath, this.kernel))
935
+ console.log({ logpath })
934
936
  const result = {
935
937
  prev,
936
938
  error,
@@ -949,6 +951,7 @@ class Server {
949
951
  gitRemote,
950
952
  filename,
951
953
  filepath,
954
+ logpath,
952
955
  encodedFilePath: encodeURIComponent(filepath),
953
956
  schemaPath,
954
957
  uri,
@@ -2363,6 +2366,11 @@ class Server {
2363
2366
  apps
2364
2367
  })
2365
2368
  }))
2369
+ this.app.get("/getlog", ex(async (req, res) => {
2370
+ console.log("query", req.query)
2371
+ let str = await fs.promises.readFile(req.query.logpath, "utf8")
2372
+ res.send(str)
2373
+ }))
2366
2374
  this.app.post("/proxy", ex(async (req, res) => {
2367
2375
  /*
2368
2376
  req.body := {
@@ -742,6 +742,14 @@ document.addEventListener("DOMContentLoaded", async () => {
742
742
  document.querySelector("#close-error-screen").addEventListener('click', (e) => {
743
743
  document.querySelector("#error-screen").classList.add("hidden")
744
744
  })
745
+ /*
746
+ document.querySelector("#open-log").addEventListener("click", async (e) => {
747
+ let logs = await fetch("/getlog?logpath=<%=logpath%>").then((res) => {
748
+ return res.text()
749
+ })
750
+ console.log(logs)
751
+ })
752
+ */
745
753
  })
746
754
  const reloadMemory = async () => {
747
755
  // let url = "/pinokio/memory?filepath=" + encodeURI("<%-filepath%>")
@@ -795,6 +803,9 @@ const reloadMemory = async () => {
795
803
  </div>
796
804
  <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> View File</button>
797
805
  <!--
806
+ <button class='btn' id='open-log' data-logpath="<%=logpath%>"><i class="fa-solid fa-align-left"></i> View Logs</button>
807
+ -->
808
+ <!--
798
809
  <button class='btn' id='source' data-editor-url="<%=editorUrl%>">Navigate</button>
799
810
  -->
800
811
  <div id='save' class='btn disabled'>
@@ -432,7 +432,8 @@ document.addEventListener("DOMContentLoaded", async () => {
432
432
 
433
433
 
434
434
 
435
- document.querySelector("footer .content").innerHTML = document.querySelector("footer .content").innerHTML + `<pre class='error'>${packet.data}</pre>`
435
+ //document.querySelector("footer .content").innerHTML = document.querySelector("footer .content").innerHTML + `<pre class='error'>${packet.data}</pre>`
436
+ document.querySelector("footer .content").innerHTML = document.querySelector("footer .content").innerHTML + `<pre class='error'>ERROR</pre>`
436
437
  // document.querySelector("footer .toggle-expand i").className = "fa-solid fa-circle-chevron-down"
437
438
  // document.querySelector("footer").classList.add("expanded")
438
439
  document.querySelector("footer i").className = "fa-solid fa-triangle-exclamation"
@@ -710,6 +711,12 @@ document.addEventListener("DOMContentLoaded", async () => {
710
711
  document.querySelector("#close-error-screen").addEventListener('click', (e) => {
711
712
  document.querySelector("#error-screen").classList.add("hidden")
712
713
  })
714
+ // document.querySelector("#open-log").addEventListener("click", async (e) => {
715
+ // let logs = await fetch("/getlog?logpath=<%=logpath%>").then((res) => {
716
+ // return res.text()
717
+ // })
718
+ // console.log(logs)
719
+ // })
713
720
  })
714
721
  const reloadMemory = async () => {
715
722
  // let url = "/pinokio/memory?filepath=<%=encodedFilePath%>"
@@ -753,6 +760,9 @@ const reloadMemory = async () => {
753
760
  <span class='stop hidden'><i class="fa-solid fa-stop"></i> Stop</span>
754
761
  </div>
755
762
  <button class='btn' id='open-fs' data-filepath="<%=filepath%>"><i class="fa-solid fa-eye"></i> View File</button>
763
+ <!--
764
+ <button class='btn' id='open-log' data-logpath="<%=logpath%>"><i class="fa-solid fa-align-left"></i> View Logs</button>
765
+ -->
756
766
  </div>
757
767
  <% } %>
758
768
  </header>