pinokiod 2.1.14 → 2.1.16
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/environment.js +36 -18
- package/package.json +1 -1
- package/server/index.js +1 -0
- package/server/views/editor.ejs +12 -11
package/kernel/environment.js
CHANGED
|
@@ -293,6 +293,8 @@ const ENV = async (type, homedir) => {
|
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
+
console.log({ filtered_envs, irrelevant_keys })
|
|
297
|
+
|
|
296
298
|
// let filtered_envs = envs.filter((e) => {
|
|
297
299
|
// return e.type.includes(type)
|
|
298
300
|
// })
|
|
@@ -315,9 +317,9 @@ const ENV = async (type, homedir) => {
|
|
|
315
317
|
|
|
316
318
|
// if app environment,
|
|
317
319
|
// if e.key exists on system env, use that
|
|
318
|
-
// if e.key does NOT exist on system env,
|
|
320
|
+
// if e.key does NOT exist on system env, use from the hardcoded default option
|
|
319
321
|
if (type === 'app') {
|
|
320
|
-
system_env = await
|
|
322
|
+
system_env = await get_raw(homedir)
|
|
321
323
|
if (e.key in system_env) {
|
|
322
324
|
console.log(`original ${e.key}=${val}`)
|
|
323
325
|
val = system_env[e.key]
|
|
@@ -331,25 +333,25 @@ const ENV = async (type, homedir) => {
|
|
|
331
333
|
lines.push(comment+kv)
|
|
332
334
|
}
|
|
333
335
|
|
|
334
|
-
// In case of type: app, inherit any other custom ENVIRONMENT variable not yet included
|
|
335
|
-
console.log({ irrelevant_keys })
|
|
336
|
-
if (type === "app" && system_env) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
336
|
+
// In case of type: app, inherit any other custom ENVIRONMENT variable not yet included
|
|
337
|
+
console.log({ irrelevant_keys })
|
|
338
|
+
if (type === "app" && system_env) {
|
|
339
|
+
for(let key in system_env) {
|
|
340
|
+
if (!keys.has(key)) {
|
|
341
|
+
// the key has not been processed, need to add to the lines
|
|
342
|
+
if (irrelevant_keys.includes(key)) {
|
|
343
|
+
// if the key was explicitly stated to be not included, skip
|
|
344
|
+
console.log("irrelevant key", key)
|
|
345
|
+
} else {
|
|
346
|
+
console.log("relevant key", key)
|
|
347
|
+
let val = system_env[key]
|
|
348
|
+
let kv = `${key}=${val}`
|
|
349
|
+
lines.push(kv)
|
|
350
|
+
console.log(`inherited custom environment key from system_env: ${kv}`)
|
|
351
|
+
}
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
354
|
}
|
|
352
|
-
}
|
|
353
355
|
|
|
354
356
|
return lines.join("\n")
|
|
355
357
|
}
|
|
@@ -381,6 +383,10 @@ const get2 = async (filepath, kernel) => {
|
|
|
381
383
|
let current_env = Object.assign({}, process.env, default_env, api_env)
|
|
382
384
|
return current_env
|
|
383
385
|
}
|
|
386
|
+
|
|
387
|
+
// return env object
|
|
388
|
+
// 1. if the value starts with ./ => convert to absolute path
|
|
389
|
+
// 2. if the value is empty => don't return the kv pair for that value
|
|
384
390
|
const get = async (homedir) => {
|
|
385
391
|
const env_path = path.resolve(homedir, "ENVIRONMENT")
|
|
386
392
|
const current_env = await Util.parse_env(env_path)
|
|
@@ -396,4 +402,16 @@ const get = async (homedir) => {
|
|
|
396
402
|
}
|
|
397
403
|
return current_env
|
|
398
404
|
}
|
|
405
|
+
|
|
406
|
+
const get_raw = async (homedir) => {
|
|
407
|
+
const env_path = path.resolve(homedir, "ENVIRONMENT")
|
|
408
|
+
const current_env = await Util.parse_env(env_path)
|
|
409
|
+
for(let key in current_env) {
|
|
410
|
+
let val = current_env[key]
|
|
411
|
+
if (val.trim() === "") {
|
|
412
|
+
delete current_env[key]
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return current_env
|
|
416
|
+
}
|
|
399
417
|
module.exports = { ENV, get, get2, init_folders }
|
package/package.json
CHANGED
package/server/index.js
CHANGED
package/server/views/editor.ejs
CHANGED
|
@@ -192,19 +192,20 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
192
192
|
document.querySelector(".run .starting").classList.add("hidden")
|
|
193
193
|
}
|
|
194
194
|
stop() {
|
|
195
|
+
debugger;
|
|
195
196
|
this.socket.run({
|
|
196
197
|
method: "kernel.api.stop",
|
|
197
198
|
params: {
|
|
198
|
-
|
|
199
|
-
uri: "~" + location.pathname
|
|
199
|
+
uri: "<%=execUrl%>",
|
|
200
|
+
//uri: "~" + location.pathname
|
|
200
201
|
}
|
|
201
202
|
}, (stream) => {
|
|
202
203
|
})
|
|
203
204
|
}
|
|
204
205
|
save() {
|
|
205
206
|
return new Promise((resolve, reject) => {
|
|
206
|
-
|
|
207
|
-
let cwd = "~" + location.pathname
|
|
207
|
+
let cwd = "<%=execUrl%>"
|
|
208
|
+
//let cwd = "~" + location.pathname
|
|
208
209
|
debugger
|
|
209
210
|
this.socket.close()
|
|
210
211
|
this.socket.run({
|
|
@@ -233,8 +234,8 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
233
234
|
this.socket.run({
|
|
234
235
|
//uri: location.pathname.slice(1).replace("api/", ""),
|
|
235
236
|
//uri: "~" + location.pathname,
|
|
236
|
-
|
|
237
|
-
uri: "~" + location.pathname,
|
|
237
|
+
uri: "<%=execUrl%>",
|
|
238
|
+
//uri: "~" + location.pathname,
|
|
238
239
|
mode,
|
|
239
240
|
input: query,
|
|
240
241
|
client: {
|
|
@@ -244,7 +245,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
244
245
|
}, async (packet) => {
|
|
245
246
|
console.log("packet", packet)
|
|
246
247
|
if (packet.type === 'start') {
|
|
247
|
-
refreshParent(packet)
|
|
248
|
+
// refreshParent(packet)
|
|
248
249
|
reloadMemory()
|
|
249
250
|
if (packet.data && packet.data.description) {
|
|
250
251
|
if ('current' in packet.data) {
|
|
@@ -289,7 +290,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
289
290
|
document.querySelector(".run .starting").classList.add("hidden")
|
|
290
291
|
document.querySelector(".run .stop").classList.remove("hidden")
|
|
291
292
|
} else if (packet.type === 'disconnect') {
|
|
292
|
-
refreshParent(packet)
|
|
293
|
+
// refreshParent(packet)
|
|
293
294
|
reloadMemory()
|
|
294
295
|
this.term.write("\r\nNot connected...\r\n")
|
|
295
296
|
document.querySelector("footer").innerHTML = "<b>Ready</b>"
|
|
@@ -357,7 +358,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
357
358
|
}
|
|
358
359
|
*/
|
|
359
360
|
} else if (packet.type === "tab.open") {
|
|
360
|
-
refreshParent(packet)
|
|
361
|
+
// refreshParent(packet)
|
|
361
362
|
} else if (packet.type === "browser.open") {
|
|
362
363
|
/*
|
|
363
364
|
{
|
|
@@ -443,7 +444,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
443
444
|
n.Noty(payload)
|
|
444
445
|
}
|
|
445
446
|
} else if (packet.type === "result") {
|
|
446
|
-
refreshParent(packet)
|
|
447
|
+
// refreshParent(packet)
|
|
447
448
|
reloadMemory()
|
|
448
449
|
if (packet.data) {
|
|
449
450
|
// document.querySelector("#response").innerHTML = he.escape(JSON.stringify(packet.data, null, 2))
|
|
@@ -458,7 +459,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|
|
458
459
|
// type: "error"
|
|
459
460
|
// })
|
|
460
461
|
this.socket.close()
|
|
461
|
-
refreshParent(packet)
|
|
462
|
+
// refreshParent(packet)
|
|
462
463
|
reloadMemory()
|
|
463
464
|
//document.querySelector("footer").innerHTML = `<b><i class="fa-solid fa-triangle-exclamation"></i> ERROR</b><pre>${packet.data}</pre>`
|
|
464
465
|
document.querySelector("footer .content").innerHTML = document.querySelector("footer .content").innerHTML + `<pre class='error'>${packet.data}</pre>`
|