pinokiod 2.1.10 → 2.1.11

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.
@@ -78,7 +78,7 @@ const ENVS = async () => {
78
78
  type: ["system"],
79
79
  key: "PS1",
80
80
  hidden: true,
81
- val: "<<PINOKIO SHELL>> "
81
+ val: "<<PINOKIO_SHELL>> "
82
82
  }, {
83
83
  type: ["system"],
84
84
  key: "GRADIO_ANALYTICS_ENABLED",
@@ -283,11 +283,23 @@ const ENVS = async () => {
283
283
  // type := system|app
284
284
  const ENV = async (type, homedir) => {
285
285
  const envs = await ENVS()
286
- let filtered_envs = envs.filter((e) => {
287
- return e.type.includes(type)
288
- })
286
+ let filtered_envs = []
287
+ let irrelevant_keys = []
288
+ for(let e of envs) {
289
+ if (e.type.includes(type)) {
290
+ filtered_envs.push(e)
291
+ } else {
292
+ irrelevant_keys.push(e.key)
293
+ }
294
+ }
295
+
296
+ // let filtered_envs = envs.filter((e) => {
297
+ // return e.type.includes(type)
298
+ // })
289
299
 
290
300
  let lines = []
301
+ let system_env
302
+ let keys = new Set()
291
303
  for(let e of filtered_envs) {
292
304
  let comment = ""
293
305
  if (e.comment && Array.isArray(e.comment)) {
@@ -305,17 +317,40 @@ const ENV = async (type, homedir) => {
305
317
  // if e.key exists on system env, use that
306
318
  // if e.key does NOT exist on system env,
307
319
  if (type === 'app') {
308
- let system_env = await get(homedir)
320
+ system_env = await get(homedir)
309
321
  if (e.key in system_env) {
310
322
  console.log(`original ${e.key}=${val}`)
311
323
  val = system_env[e.key]
312
324
  console.log(`inherited from system_env: ${e.key}=${val}`)
325
+ keys.add(e.key)
313
326
  }
314
327
  }
315
328
 
316
329
  let kv = `${e.key}=${val}`
330
+ console.log("kv", kv)
317
331
  lines.push(comment+kv)
318
332
  }
333
+
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
+ for(let key in system_env) {
338
+ if (!keys.has(key)) {
339
+ // the key has not been processed, need to add to the lines
340
+ if (irrelevant_keys.includes(key)) {
341
+ // if the key was explicitly stated to be not included, skip
342
+ console.log("irrelevant key", key)
343
+ } else {
344
+ console.log("relevant key", key)
345
+ let val = system_env[key]
346
+ let kv = `${key}=${val}`
347
+ lines.push(kv)
348
+ console.log(`inherited custom environment key from system_env: ${kv}`)
349
+ }
350
+ }
351
+ }
352
+ }
353
+
319
354
  return lines.join("\n")
320
355
  }
321
356
  const init_folders = async (homedir) => {
package/kernel/util.js CHANGED
@@ -95,10 +95,12 @@ const update_env = async (filepath, changes) => {
95
95
  .replace(returnPattern, returnReplacement)
96
96
  .trim();
97
97
  const safeName = escapeStringRegexp(varname);
98
- const varPattern = new RegExp(`^(${h}*${safeName}${h}*=${h}*)\\S*(${h}*)$`, "gm");
98
+ //const varPattern = new RegExp(`^(${h}*${safeName}${h}*=${h}*)\\S*(${h}*)$`, "gm");
99
+ const varPattern = new RegExp(`^(${h}*${safeName}${h}*=${h}*)(\\S(?:.*\\S)?)?(${h}*)$`, "gm");
99
100
  if (varPattern.test(result)) {
100
101
  const safeValue = value.replace(groupPattern, groupReplacement);
101
- return result.replace(varPattern, `$1${safeValue}$2`);
102
+ //return result.replace(varPattern, `$1${safeValue}$2`);
103
+ return result.replace(varPattern, `$1${safeValue}$3`);
102
104
  } else if (result === "") {
103
105
  append = true;
104
106
  return `${varname}=${value}${EOL}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "2.1.10",
3
+ "version": "2.1.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,7 +3,6 @@
3
3
  <style>
4
4
  body {
5
5
  width: 100%;
6
- height: 100%;
7
6
  margin: 0;
8
7
  background: royalblue;
9
8
  color: white;
@@ -41,9 +40,9 @@ footer a {
41
40
  <footer>
42
41
  <div>You may want to try:</div>
43
42
  <ol>
44
- <li>Update to the latest version of Pinokio: <a href="https://program.pinokio.computer/#/?id=install" target="_blank">https://program.pinokio.computer/#/?id=install</a></li>
43
+ <li>Update Pinokio: Simply install the latest version, it should only update the app binary while keeping all the data in tact. <a href="https://program.pinokio.computer/#/?id=install" target="_blank">Go to Download Page</a></li>
45
44
  <li>Try troubleshooting: <a href="/?mode=settings#troubleshoot">Troubleshoot</a></li>
46
- <li>Ask in community Discord: <a href="https://discord.gg/TQdNwadtE4" target="_blank">Discord</a></li>
45
+ <li>Ask in community Discord: <a href="http://localhost/?mode=help" target="_blank">Community</a></li>
47
46
  </ol>
48
47
  </footer>
49
48
  </body>