@runeya/runeya 1.33.19 → 1.33.22

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 (108) hide show
  1. package/node-red-contrib-runeya.tar +0 -0
  2. package/package.json +2 -3
  3. package/public/assets/{App-BVTb2f1U.css → App-BGPtogo-.css} +1 -1
  4. package/public/assets/App-Bj3c8ECd.js +101 -0
  5. package/public/assets/Bugs-B6LM8YSZ.js +1 -0
  6. package/public/assets/Bugs-DZVuTDKA.css +1 -0
  7. package/public/assets/Configs-CRGDsvnb.js +464 -0
  8. package/public/assets/Configs-DdBteQMK.css +1 -0
  9. package/public/assets/CurrentEditor-DI0XEvLu.js +1 -0
  10. package/public/assets/DynamicComponent-CmXZUvVU.js +1 -0
  11. package/public/assets/DynamicComponent-DgxRO4Pl.css +1 -0
  12. package/public/assets/{Editor-BGkwp83-.js → Editor-CBZeVePs.js} +7 -7
  13. package/public/assets/{Editor-BC23IeB6.css → Editor-CPPFMOjb.css} +1 -1
  14. package/public/assets/Git-Cf-zgTWr.js +11 -0
  15. package/public/assets/Git-UQIt5ANe.css +1 -0
  16. package/public/assets/ImportCreate-DZSPN5cY.js +1 -0
  17. package/public/assets/Index-BJieQWaU.js +1 -0
  18. package/public/assets/Index-BcFahN3S.css +1 -0
  19. package/public/assets/Index-BrbegLuT.js +1 -0
  20. package/public/assets/Index-C3gFkhHj.js +1 -0
  21. package/public/assets/Index-C66tLKvy.css +1 -0
  22. package/public/assets/Index-Cd-qd5VG.css +1 -0
  23. package/public/assets/Index-Cg-pTjT5.js +1 -0
  24. package/public/assets/Index-CvhWs0kp.css +1 -0
  25. package/public/assets/Index-D67OAIVa.js +314 -0
  26. package/public/assets/Index-DZ8CXixy.js +1 -0
  27. package/public/assets/{Init-C32Q3Vuy.js → Init-BILP6lrr.js} +1 -1
  28. package/public/assets/{LeftLogo-7mp987n7.js → LeftLogo-BCYb654E.js} +1 -1
  29. package/public/assets/Logs-BfqPcp-L.js +74 -0
  30. package/public/assets/Logs-BhdfGaw5.css +32 -0
  31. package/public/assets/{Markdown-CkEWgBbg.js → Markdown-CuewGlVj.js} +19 -103
  32. package/public/assets/Modal-CGUZawhK.css +1 -0
  33. package/public/assets/Modal-DmKdmCtc.js +1 -0
  34. package/public/assets/Modals-BHTrmB19.js +1 -0
  35. package/public/assets/NotUpToDate-CnmuPdX-.js +1 -0
  36. package/public/assets/NotUpToDate-Dh9RbAwK.css +1 -0
  37. package/public/assets/Npm-HBPCi13F.js +1 -0
  38. package/public/assets/Npm-KBzO1DYv.css +1 -0
  39. package/public/assets/Overview-CRtTdDEz.js +1 -0
  40. package/public/assets/Overview-DZIOmzKx.css +1 -0
  41. package/public/assets/{Section-DArSOaS2.js → Section-OccJuk7A.js} +1 -1
  42. package/public/assets/{Settings-CEcFg3LS.js → Settings-CgEyOTsE.js} +6 -6
  43. package/public/assets/{Settings-BBbk67zT.css → Settings-DUCkJDco.css} +1 -1
  44. package/public/assets/Spinner-BMGbc3X9.js +1 -0
  45. package/public/assets/Spinner-BZXOybIg.css +1 -0
  46. package/public/assets/StackChooser-DBof37zx.js +1 -0
  47. package/public/assets/{StackChooser-BsG17xPQ.js → StackChooser-PJ4_aCX-.js} +1 -1
  48. package/public/assets/StackMultiple-CiXqkibR.css +1 -0
  49. package/public/assets/{StackMultiple-CnhHiGG6.js → StackMultiple-D0bM6dXR.js} +17 -17
  50. package/public/assets/{StackSingle-DBZX9nN_.css → StackSingle-BVHxvisP.css} +1 -1
  51. package/public/assets/StackSingle-D1Yk8PXD.js +1 -0
  52. package/public/assets/{Tabs-fu2myJd9.css → Tabs-BGPqRkjE.css} +1 -1
  53. package/public/assets/Tabs-DQDvjS5y.js +1 -0
  54. package/public/assets/Theme-CzHFcMoz.js +1 -0
  55. package/public/assets/Toolbox-B5KXz4eX.css +1 -0
  56. package/public/assets/Toolbox-C5XEPDmg.js +1 -0
  57. package/public/assets/_baseFor-DiPelG4M.js +1 -0
  58. package/public/assets/_commonjsHelpers-D6-XlEtG.js +1 -0
  59. package/public/assets/{cssMode-CzzL7NLn.js → cssMode-CccHpseG.js} +1 -1
  60. package/public/assets/currentEditor-DKB6Zox9.js +1 -0
  61. package/public/assets/dayjs.min-CfWDS3UC.js +1 -0
  62. package/public/assets/{freemarker2-Dir7A35Q.js → freemarker2-DSPhVVzD.js} +1 -1
  63. package/public/assets/fs-CwxHstJI.js +1 -0
  64. package/public/assets/{handlebars-Bwt7SUKz.js → handlebars-1zANa-F3.js} +1 -1
  65. package/public/assets/{html-BVMS5MXg.js → html-fsS26eC3.js} +1 -1
  66. package/public/assets/{htmlMode-DtatUs1Z.js → htmlMode-DvnqyT9t.js} +1 -1
  67. package/public/assets/index-0X67tmWL.js +82 -0
  68. package/public/assets/index-B3Vh_zdc.js +1454 -0
  69. package/public/assets/index-B614CRIK.js +201 -0
  70. package/public/assets/index-BO82C_5u.js +720 -0
  71. package/public/assets/index-Brqxsm84.js +308 -0
  72. package/public/assets/index-CILDVkDy.js +310 -0
  73. package/public/assets/{index--FPUu8lq.css → index-D9v3u7Fv.css} +1 -1
  74. package/public/assets/index-DcbuCmxJ.js +84 -0
  75. package/public/assets/{index-BnoOVDVz.js → index-G_rNbFve.js} +2 -2
  76. package/public/assets/index-d75RPzOA.js +176 -0
  77. package/public/assets/index-uWoKtv9r.js +2 -0
  78. package/public/assets/{javascript-D-oImBdK.js → javascript-DRHvp6-v.js} +1 -1
  79. package/public/assets/json-tree-view-vue3.es-DVJTi2Rq.js +1 -0
  80. package/public/assets/{jsonMode-ChekEzF3.js → jsonMode-CJHmEzcn.js} +1 -1
  81. package/public/assets/{liquid-Cx00nEdK.js → liquid-V1Od9uns.js} +1 -1
  82. package/public/assets/lodash-D2RHCRSL.js +27 -0
  83. package/public/assets/{mdx-B_3CUkN7.js → mdx-DlWa4FFs.js} +1 -1
  84. package/public/assets/{python-PnVqLAvu.js → python-DawPqpxL.js} +1 -1
  85. package/public/assets/{razor-B-e3gtRB.js → razor-CrbHGO04.js} +1 -1
  86. package/public/assets/router-DPuc_QdV.css +1 -0
  87. package/public/assets/router-Dzu6a_zz.js +103 -0
  88. package/public/assets/sort-BibmqbFD.js +1 -0
  89. package/public/assets/{system-Bck6co6p.js → system-BqvwX5_3.js} +1 -1
  90. package/public/assets/{tsMode-aTnOdaF2.js → tsMode-Cb1yqXWI.js} +1 -1
  91. package/public/assets/{typescript-D4fq51ct.js → typescript-CnZCKV3a.js} +1 -1
  92. package/public/assets/{xml-aY-jq2ZR.js → xml-B90p6BQJ.js} +1 -1
  93. package/public/assets/{yaml-BH_SsNz5.js → yaml-Bkk9HYtt.js} +1 -1
  94. package/public/index.html +1 -1
  95. package/www.js +159 -259
  96. package/www.js.map +1 -1
  97. package/public/assets/App-Zd1wzq6w.js +0 -101
  98. package/public/assets/CurrentEditor-DLPmlCCH.js +0 -1
  99. package/public/assets/ImportCreate-Cb9Yo4_T.js +0 -1
  100. package/public/assets/Overview-BaSpvlXu.css +0 -1
  101. package/public/assets/Overview-Butnf29p.js +0 -1
  102. package/public/assets/StackChooser-CH4WGtD8.js +0 -1
  103. package/public/assets/StackMultiple-Dw-7UAYX.css +0 -1
  104. package/public/assets/StackSingle-DzMAOzU6.js +0 -1
  105. package/public/assets/Tabs-VGIyn9Mu.js +0 -1
  106. package/public/assets/router-59CbSGll.js +0 -4232
  107. package/public/assets/router-imsD-DjM.css +0 -32
  108. package/runeya.vsix +0 -0
package/www.js CHANGED
@@ -102,13 +102,16 @@ var require_args = __commonJS({
102
102
  var path = require("path");
103
103
  var yargs = require("yargs/yargs");
104
104
  var { hideBin } = require("yargs/helpers");
105
- var { existsSync } = require("fs");
105
+ var { existsSync: existsSync2 } = require("fs");
106
106
  var yarg = yargs(hideBin(process.argv)).usage("Usage: <path-to-your-stack> [options]").alias("pe", "pull-env").describe("pe", "Pull env from a service (need --environment and --service)").default("pe", false).alias("e", "environment").describe("e", "Choose your environment").default("e", void 0).alias("s", "service").describe("s", "Service").default("s", void 0).alias("ss", "services").describe("ss", "Services").default("ss", []).boolean(["pe"]).string(["e", "s"]).array(["ss"]).help("h").alias("h", "help").parse();
107
+ var rootPath = path.resolve(yarg["_"]?.[0] || ".");
107
108
  var args2 = Object.assign({
108
- rootPath: path.resolve(yarg["_"]?.[0] || "."),
109
- initialCwd: ""
109
+ rootPath,
110
+ initialCwd: "",
111
+ runeyaConfigPath: path.resolve(rootPath, ".runeya"),
112
+ runeyaGlobalConfigPath: path.resolve(require("os").homedir(), ".runeya-global")
110
113
  }, yarg);
111
- if (!existsSync(args2.rootPath)) {
114
+ if (!existsSync2(args2.rootPath)) {
112
115
  console.error("Error: Runeya was launched with an invalid root path that does not exist. Please check your launch command. \nPath: ", args2.rootPath);
113
116
  process.exit(1);
114
117
  }
@@ -134,13 +137,13 @@ var require_routes = __commonJS({
134
137
  "use strict";
135
138
  var express = require("express");
136
139
  var router = express.Router();
137
- var pathfs = require("path");
140
+ var pathfs2 = require("path");
138
141
  var { fork } = require("child_process");
139
142
  module2.exports = (runeya) => {
140
143
  router.get("/bugs/:service", async (req, res) => {
141
144
  const service = runeya.findService(req.params.service);
142
145
  if (!service) return res.status(404).send("SERVICE_NOT_FOUND");
143
- const ts = fork(pathfs.resolve(__dirname, "checkJsFork"));
146
+ const ts = fork(pathfs2.resolve(__dirname, "checkJsFork"));
144
147
  ts.on("message", (results) => {
145
148
  res.json(results);
146
149
  ts.kill("SIGKILL");
@@ -157,8 +160,8 @@ var require_routes = __commonJS({
157
160
  var require_backend = __commonJS({
158
161
  "../../modules/bugs/backend/index.js"(exports2, module2) {
159
162
  "use strict";
160
- var { existsSync } = require("fs");
161
- var pathfs = require("path");
163
+ var { existsSync: existsSync2 } = require("fs");
164
+ var pathfs2 = require("path");
162
165
  var plugin = {
163
166
  enabled: true,
164
167
  name: "Bugs",
@@ -262,14 +265,14 @@ var require_reencrypt_nodered = __commonJS({
262
265
  var require_EncryptionKey = __commonJS({
263
266
  "models/EncryptionKey.js"(exports2, module2) {
264
267
  "use strict";
265
- var { existsSync } = require("fs");
268
+ var { existsSync: existsSync2 } = require("fs");
266
269
  var path = require("path");
267
270
  var { writeFile, readFile, appendFile } = require("fs/promises");
268
271
  var { randomUUID: randomUUID2 } = require("crypto");
269
272
  var dbs2 = require_dbs();
270
273
  var { generateKey, encrypt, decrypt } = require_crypto();
271
274
  var reencryptNodered = require_reencrypt_nodered();
272
- var pathfs = require("path");
275
+ var pathfs2 = require("path");
273
276
  var args2 = require_args();
274
277
  var _EncryptionKey_instances, getDb_fn;
275
278
  var EncryptionKey = class {
@@ -281,7 +284,7 @@ var require_EncryptionKey = __commonJS({
281
284
  this.encryptionKey = (await __privateMethod(this, _EncryptionKey_instances, getDb_fn).call(this).read()).encryptionKey;
282
285
  const dirname = path.dirname(await dbs2.getDb("encryption-key", { encrypted: false }).getPath());
283
286
  const gitignorePath = path.resolve(dirname, ".gitignore");
284
- if (!existsSync(gitignorePath)) {
287
+ if (!existsSync2(gitignorePath)) {
285
288
  writeFile(gitignorePath, "encryption-key.json");
286
289
  } else {
287
290
  const gitignoreFile = (await readFile(gitignorePath, "utf-8")).split("\n");
@@ -319,7 +322,7 @@ var require_EncryptionKey = __commonJS({
319
322
  const envSample = (await dbs2.getDbs("envs"))[0];
320
323
  if (envSample) await dbs2.getDb(`envs/${envSample}`).read();
321
324
  if (this.encryptionKey) {
322
- await reencryptNodered(this.encryptionKey, key, pathfs.resolve(require_stack().getRootPath(), "nodered/flow_cred.json"));
325
+ await reencryptNodered(this.encryptionKey, key, pathfs2.resolve(require_stack().getRootPath(), "nodered/flow_cred.json"));
323
326
  await dbs2.reencrypt(this.encryptionKey, key);
324
327
  }
325
328
  ;
@@ -473,16 +476,16 @@ var require_dbs = __commonJS({
473
476
  "helpers/dbs.js"(exports2, module2) {
474
477
  "use strict";
475
478
  var {
476
- existsSync,
479
+ existsSync: existsSync2,
477
480
  mkdirSync,
478
481
  writeFileSync,
479
482
  readFileSync,
480
483
  unlinkSync
481
484
  } = require("fs");
482
- var pathfs = require("path");
485
+ var pathfs2 = require("path");
483
486
  var {
484
487
  readdir,
485
- mkdir,
488
+ mkdir: mkdir2,
486
489
  writeFile,
487
490
  readFile,
488
491
  unlink
@@ -498,14 +501,14 @@ var require_dbs = __commonJS({
498
501
  __publicField(this, "cache", {});
499
502
  }
500
503
  getRootPath() {
501
- const rootPath = pathfs.resolve(args2.rootPath, ".runeya/dbs");
502
- if (!existsSync(rootPath)) mkdirSync(rootPath, { recursive: true });
504
+ const rootPath = pathfs2.resolve(args2.rootPath, ".runeya/dbs");
505
+ if (!existsSync2(rootPath)) mkdirSync(rootPath, { recursive: true });
503
506
  return rootPath;
504
507
  }
505
508
  async getDbs(namespace = "") {
506
- const pathToDbs = pathfs.resolve(this.getRootPath(), namespace);
507
- if (!existsSync(pathToDbs)) await mkdir(pathToDbs, { recursive: true });
508
- return (await readdir(pathToDbs)).map((id) => id.replace(pathfs.extname(id), "").replace(".encrypted", ""));
509
+ const pathToDbs = pathfs2.resolve(this.getRootPath(), namespace);
510
+ if (!existsSync2(pathToDbs)) await mkdir2(pathToDbs, { recursive: true });
511
+ return (await readdir(pathToDbs)).map((id) => id.replace(pathfs2.extname(id), "").replace(".encrypted", ""));
509
512
  }
510
513
  async reencrypt(oldKey, newKey) {
511
514
  const api = new fdir().withFullPaths().filter((path) => path.endsWith("encrypted.json")).crawl(this.getRootPath());
@@ -519,9 +522,9 @@ var require_dbs = __commonJS({
519
522
  }
520
523
  getDb(id, { encrypted, defaultData } = { encrypted: true, defaultData: {} }) {
521
524
  const getPath = async () => {
522
- const persistencePath = pathfs.resolve(`${this.getRootPath()}/${id}${encrypted ? ".encrypted" : ""}.json`);
523
- if (!existsSync(pathfs.dirname(persistencePath))) await mkdirSync(pathfs.dirname(persistencePath), { recursive: true });
524
- if (!existsSync(persistencePath)) {
525
+ const persistencePath = pathfs2.resolve(`${this.getRootPath()}/${id}${encrypted ? ".encrypted" : ""}.json`);
526
+ if (!existsSync2(pathfs2.dirname(persistencePath))) await mkdirSync(pathfs2.dirname(persistencePath), { recursive: true });
527
+ if (!existsSync2(persistencePath)) {
525
528
  let defaultDB = JSON.stringify(defaultData || [], null, 2);
526
529
  if (encrypted) defaultDB = await encrypt(defaultDB, { additionnalNonce: persistencePath.split(".runeya").pop() });
527
530
  await writeFile(persistencePath, defaultDB, "utf-8");
@@ -803,7 +806,7 @@ var require_backend3 = __commonJS({
803
806
  "use strict";
804
807
  var { readFile } = require("fs/promises");
805
808
  var PromiseB2 = require("bluebird");
806
- var pathfs = require("path");
809
+ var pathfs2 = require("path");
807
810
  var Documentation = require_Documentation();
808
811
  var plugin = {
809
812
  enabled: true,
@@ -1001,16 +1004,16 @@ var require_src2 = __commonJS({
1001
1004
  var require_Git = __commonJS({
1002
1005
  "../../modules/git/backend/Git.js"(exports2, module2) {
1003
1006
  "use strict";
1004
- var { existsSync } = require("fs");
1005
- var pathfs = require("path");
1007
+ var { existsSync: existsSync2 } = require("fs");
1008
+ var pathfs2 = require("path");
1006
1009
  var { execAsync, execAsyncWithoutErr } = require_exec();
1007
1010
  var HTTPError = require_src2();
1008
1011
  var Git = (runeya) => {
1009
1012
  const { findService } = runeya;
1010
1013
  const searchGit = (path) => {
1011
- if (existsSync(pathfs.resolve(path, ".git"))) return path;
1012
- const parentPath = pathfs.resolve(path, "..");
1013
- if (parentPath === pathfs.resolve("/")) return null;
1014
+ if (existsSync2(pathfs2.resolve(path, ".git"))) return path;
1015
+ const parentPath = pathfs2.resolve(path, "..");
1016
+ if (parentPath === pathfs2.resolve("/")) return null;
1014
1017
  return searchGit(parentPath);
1015
1018
  };
1016
1019
  const getGitRootPath = (service) => searchGit(service.getRootPath());
@@ -1019,7 +1022,7 @@ var require_Git = __commonJS({
1019
1022
  if (!service.git) throw new Error(`Git Error - ${service?.label}: Git option not set`);
1020
1023
  const path = getGitRootPath(service);
1021
1024
  if (!path) return false;
1022
- if (!existsSync(path)) return false;
1025
+ if (!existsSync2(path)) return false;
1023
1026
  return true;
1024
1027
  }
1025
1028
  return {
@@ -1647,11 +1650,11 @@ var require_stringTransformer_helper = __commonJS({
1647
1650
  var require_Npm = __commonJS({
1648
1651
  "../../modules/npm/backend/Npm.js"(exports2, module2) {
1649
1652
  "use strict";
1650
- var pathfs = require("path");
1653
+ var pathfs2 = require("path");
1651
1654
  var { execAsync } = require_exec();
1652
1655
  var { readFile } = require("fs/promises");
1653
1656
  var { replaceEnvs } = require_stringTransformer_helper();
1654
- var { existsSync } = require("fs");
1657
+ var { existsSync: existsSync2 } = require("fs");
1655
1658
  var Npm = class {
1656
1659
  /** @param {import('@runeya/servers-server/models/Service')} service */
1657
1660
  constructor(service) {
@@ -1659,7 +1662,7 @@ var require_Npm = __commonJS({
1659
1662
  }
1660
1663
  async isNpm(path) {
1661
1664
  if (path) {
1662
- return existsSync(pathfs.resolve(path?.toString(), "package.json"));
1665
+ return existsSync2(pathfs2.resolve(path?.toString(), "package.json"));
1663
1666
  }
1664
1667
  return null;
1665
1668
  }
@@ -1671,13 +1674,13 @@ var require_Npm = __commonJS({
1671
1674
  }
1672
1675
  async packageJSON(path) {
1673
1676
  if (path) {
1674
- return JSON.parse(await readFile(pathfs.resolve(path?.toString(), "package.json"), "utf-8"));
1677
+ return JSON.parse(await readFile(pathfs2.resolve(path?.toString(), "package.json"), "utf-8"));
1675
1678
  }
1676
1679
  return {};
1677
1680
  }
1678
1681
  async packageLock(path) {
1679
1682
  if (path) {
1680
- return JSON.parse(await readFile(pathfs.resolve(path?.toString(), "package-lock.json"), "utf-8")).catch((err) => {
1683
+ return JSON.parse(await readFile(pathfs2.resolve(path?.toString(), "package-lock.json"), "utf-8")).catch((err) => {
1681
1684
  console.error(err);
1682
1685
  return {};
1683
1686
  });
@@ -1853,124 +1856,8 @@ var require_backend11 = __commonJS({
1853
1856
  }
1854
1857
  });
1855
1858
 
1856
- // ../../modules/vscode/backend/routes.js
1857
- var require_routes9 = __commonJS({
1858
- "../../modules/vscode/backend/routes.js"(exports2, module2) {
1859
- "use strict";
1860
- var express = require("express");
1861
- var open = require("open");
1862
- var pathfs = require("path");
1863
- var ws = require("workspace-tools");
1864
- var { readFile } = require("fs/promises");
1865
- var { readFileSync, existsSync } = require("fs");
1866
- var { execAsync } = require_exec();
1867
- var router = express.Router();
1868
- var routes = (runeya) => {
1869
- router.post("/vscode/install", async (req, res) => {
1870
- await execAsync("code --install-extension ./runeya.vsix", { cwd: __dirname });
1871
- res.send("ok");
1872
- });
1873
- router.delete("/vscode/uninstall", async (req, res) => {
1874
- await execAsync("code --uninstall-extension runeya.runeya", { cwd: __dirname });
1875
- res.send("ok");
1876
- });
1877
- router.get("/vscode/open-url", async (req, res) => {
1878
- const url = req.query.url?.toString();
1879
- if (url) open(url);
1880
- res.send("ok");
1881
- });
1882
- router.get("/vscode/get-services-from-file", async (req, res) => {
1883
- try {
1884
- if (!req.query.file) return res.status(400).send("file params is required");
1885
- const packageRoot = ws.findPackageRoot(req.query.file?.toString());
1886
- let projectRoot;
1887
- try {
1888
- projectRoot = ws.findProjectRoot(req.query.file?.toString());
1889
- } catch (error) {
1890
- projectRoot = packageRoot;
1891
- }
1892
- if (!packageRoot) return res.status(400).send("no package found");
1893
- if (!projectRoot) return res.status(400).send("no package found");
1894
- const monorepo = packageRoot !== projectRoot;
1895
- if (monorepo) {
1896
- const packageInfos = await ws.getPackageInfosAsync(projectRoot);
1897
- const { dependents: dependentsMap } = ws.createDependencyMap(packageInfos);
1898
- const packageJSON = JSON.parse(await readFile(pathfs.resolve(packageRoot, "./package.json"), "utf-8"));
1899
- const dependents = [
1900
- ...dependentsMap.get(packageJSON.name) || []
1901
- ];
1902
- const services = runeya.getServices().filter((service) => {
1903
- const servicePackageNames = [
1904
- service.getRootPath(),
1905
- ...service.commands.map((cmd) => cmd.spawnOptions?.env)
1906
- ].flat(100).filter((a, i, arr) => a && !arr.slice(0, i).includes(a) && a.toString() !== projectRoot && existsSync(pathfs.resolve(a.toString(), "./package.json"))).map((path) => JSON.parse(readFileSync(pathfs.resolve(path?.toString() || "", "./package.json"), "utf-8")).name);
1907
- return dependents.some((packageName) => servicePackageNames.includes(packageName)) || servicePackageNames.includes(packageJSON.name);
1908
- });
1909
- res.json(services);
1910
- } else {
1911
- const packageRoot2 = ws.findPackageRoot(req.query.file?.toString());
1912
- let projectRoot2;
1913
- try {
1914
- projectRoot2 = ws.findProjectRoot(req.query.file?.toString());
1915
- } catch (error) {
1916
- projectRoot2 = packageRoot2;
1917
- }
1918
- if (!packageRoot2) return res.status(400).send("no package found");
1919
- if (!projectRoot2) return res.status(400).send("no package found");
1920
- const services = runeya.getServices().filter((service) => {
1921
- const servicePaths = [
1922
- service.getRootPath(),
1923
- ...service.commands.map((cmd) => cmd.spawnOptions?.env)
1924
- ].flat(100).filter((a, i, arr) => a && !arr.slice(0, i).includes(a) && existsSync(pathfs.resolve(a.toString(), "./package.json")));
1925
- return servicePaths.includes(projectRoot2);
1926
- });
1927
- res.json(services);
1928
- }
1929
- } catch (error) {
1930
- console.error(error);
1931
- res.json([]);
1932
- }
1933
- return null;
1934
- });
1935
- router.get("/vscode/download", (req, res) => {
1936
- const vsixPath = pathfs.resolve(__dirname, "./runeya.vsix");
1937
- res.download(vsixPath, "runeya.vsix");
1938
- });
1939
- return router;
1940
- };
1941
- module2.exports = routes;
1942
- }
1943
- });
1944
-
1945
- // ../../modules/vscode/backend/index.js
1946
- var require_backend12 = __commonJS({
1947
- "../../modules/vscode/backend/index.js"(exports2, module2) {
1948
- "use strict";
1949
- var commandExists = require("command-exists");
1950
- var plugin = {
1951
- enabled: true,
1952
- name: "Vscode",
1953
- displayName: "Vscode",
1954
- description: "interact with vscode extension",
1955
- icon: "fab fa-git-alt",
1956
- export: null,
1957
- order: Infinity,
1958
- placements: [{
1959
- position: "sidebar",
1960
- label: "VScode extension",
1961
- img: "https://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Visual_Studio_Code_1.35_icon.svg/512px-Visual_Studio_Code_1.35_icon.svg.png",
1962
- goTo: { path: "/Vscode" },
1963
- active: "Vscode"
1964
- }],
1965
- hidden: () => commandExists("code").then(() => false).catch(() => true),
1966
- routes: require_routes9()
1967
- };
1968
- module2.exports = plugin;
1969
- }
1970
- });
1971
-
1972
1859
  // ../../modules/docker/backend/routes.js
1973
- var require_routes10 = __commonJS({
1860
+ var require_routes9 = __commonJS({
1974
1861
  "../../modules/docker/backend/routes.js"(exports2, module2) {
1975
1862
  "use strict";
1976
1863
  var express = require("express");
@@ -2018,7 +1905,7 @@ var require_routes10 = __commonJS({
2018
1905
  });
2019
1906
 
2020
1907
  // ../../modules/docker/backend/index.js
2021
- var require_backend13 = __commonJS({
1908
+ var require_backend12 = __commonJS({
2022
1909
  "../../modules/docker/backend/index.js"(exports2, module2) {
2023
1910
  "use strict";
2024
1911
  var plugin = {
@@ -2035,7 +1922,7 @@ var require_backend13 = __commonJS({
2035
1922
  if (!service?.container) return true;
2036
1923
  return !service.container.enabled;
2037
1924
  },
2038
- routes: require_routes10()
1925
+ routes: require_routes9()
2039
1926
  };
2040
1927
  module2.exports = plugin;
2041
1928
  }
@@ -2222,7 +2109,7 @@ var require_src6 = __commonJS({
2222
2109
  require("express-async-errors");
2223
2110
  var express = require("express");
2224
2111
  var cors = require("cors");
2225
- var pathfs = require("path");
2112
+ var pathfs2 = require("path");
2226
2113
  var fs = require("fs");
2227
2114
  var healthCheck = require_src3();
2228
2115
  var helmet = require("helmet").default;
@@ -2292,7 +2179,7 @@ var require_src6 = __commonJS({
2292
2179
  authApi = (app) => {
2293
2180
  }
2294
2181
  }) {
2295
- const pkgJSONPath = pathfs.resolve(baseUrl, "package.json");
2182
+ const pkgJSONPath = pathfs2.resolve(baseUrl, "package.json");
2296
2183
  const isPkgJSONExists = fs.existsSync(pkgJSONPath);
2297
2184
  const pkgJSON = isPkgJSONExists ? require(pkgJSONPath) : { name: "unknown", version: "unknown" };
2298
2185
  const appVersion = pkgJSON.version;
@@ -2377,7 +2264,7 @@ var require_ports = __commonJS({
2377
2264
  });
2378
2265
 
2379
2266
  // ../../modules/workflows/backend/routes.js
2380
- var require_routes11 = __commonJS({
2267
+ var require_routes10 = __commonJS({
2381
2268
  "../../modules/workflows/backend/routes.js"(exports2, module2) {
2382
2269
  "use strict";
2383
2270
  var { express, getServer } = require_src6();
@@ -2385,9 +2272,9 @@ var require_routes11 = __commonJS({
2385
2272
  var RED = require("node-red");
2386
2273
  var compressing = require("compressing");
2387
2274
  var router = express.Router();
2388
- var pathfs = require("path");
2389
- var { existsSync } = require("fs");
2390
- var { rm, readFile, writeFile, mkdir, readdir } = require("fs/promises");
2275
+ var pathfs2 = require("path");
2276
+ var { existsSync: existsSync2 } = require("fs");
2277
+ var { rm: rm2, readFile, writeFile, mkdir: mkdir2, readdir } = require("fs/promises");
2391
2278
  var ports = require_ports();
2392
2279
  var { execAsync } = require_exec();
2393
2280
  var EncryptionKey = require_EncryptionKey();
@@ -2395,8 +2282,8 @@ var require_routes11 = __commonJS({
2395
2282
  var { v4 } = require("uuid");
2396
2283
  module2.exports = (Stack) => {
2397
2284
  getServer().then(async (server) => {
2398
- const userDir = pathfs.resolve(Stack.getRootPath(), "nodered");
2399
- if (!existsSync(userDir)) await mkdir(userDir, { recursive: true });
2285
+ const userDir = pathfs2.resolve(Stack.getRootPath(), "nodered");
2286
+ if (!existsSync2(userDir)) await mkdir2(userDir, { recursive: true });
2400
2287
  const settings = {
2401
2288
  httpAdminRoot: "/red",
2402
2289
  httpNodeRoot: "/node-red",
@@ -2418,25 +2305,25 @@ var require_routes11 = __commonJS({
2418
2305
  router.use(settings.httpNodeRoot, RED.httpNode);
2419
2306
  const moduleName = "node-red-contrib-runeya";
2420
2307
  const moduleNameLegacy = "node-red-contrib-stack-monitor";
2421
- const modulePath = pathfs.resolve(userDir, "node_modules", moduleName);
2422
- const localNodeModuleTarPath = pathfs.resolve(__dirname, `${moduleName}.tar`);
2423
- const packageJSONPath = pathfs.resolve(userDir, "package.json");
2424
- if (existsSync(pathfs.resolve(userDir, "node_modules", moduleNameLegacy))) {
2425
- await rm(pathfs.resolve(userDir, "node_modules", moduleNameLegacy), { recursive: true, force: true });
2308
+ const modulePath = pathfs2.resolve(userDir, "node_modules", moduleName);
2309
+ const localNodeModuleTarPath = pathfs2.resolve(__dirname, `${moduleName}.tar`);
2310
+ const packageJSONPath = pathfs2.resolve(userDir, "package.json");
2311
+ if (existsSync2(pathfs2.resolve(userDir, "node_modules", moduleNameLegacy))) {
2312
+ await rm2(pathfs2.resolve(userDir, "node_modules", moduleNameLegacy), { recursive: true, force: true });
2426
2313
  await execAsync("npm uninstall node-red-contrib-stack-monitor", { cwd: userDir });
2427
2314
  }
2428
- if (existsSync(modulePath)) {
2315
+ if (existsSync2(modulePath)) {
2429
2316
  console.log(moduleName, "found, delete it before start nodered");
2430
- await rm(modulePath, { recursive: true, force: true });
2317
+ await rm2(modulePath, { recursive: true, force: true });
2431
2318
  await execAsync("npm uninstall node-red-contrib-runeya", { cwd: userDir });
2432
2319
  }
2433
2320
  await PromiseB2.map(await readdir(userDir), async (file) => {
2434
2321
  if (file.startsWith(`node-red-contrib-runeya-`) && file.endsWith(".tgz")) {
2435
- await rm(pathfs.resolve(userDir, file));
2322
+ await rm2(pathfs2.resolve(userDir, file));
2436
2323
  }
2437
2324
  });
2438
2325
  let buffer;
2439
- if (existsSync(localNodeModuleTarPath)) {
2326
+ if (existsSync2(localNodeModuleTarPath)) {
2440
2327
  console.log(`Read ${moduleName} from local tar`);
2441
2328
  buffer = await readFile(localNodeModuleTarPath);
2442
2329
  } else {
@@ -2451,7 +2338,7 @@ var require_routes11 = __commonJS({
2451
2338
  var stream2buffer = stream2buffer2;
2452
2339
  console.log(`Build ${moduleName} from dir`);
2453
2340
  const stream = new compressing.tar.Stream();
2454
- stream.addEntry(pathfs.resolve(__dirname, "./nodes"), { ignoreBase: true, relativePath: "package" });
2341
+ stream.addEntry(pathfs2.resolve(__dirname, "./nodes"), { ignoreBase: true, relativePath: "package" });
2455
2342
  buffer = await stream2buffer2(stream);
2456
2343
  }
2457
2344
  let packageJSON = {
@@ -2461,16 +2348,16 @@ var require_routes11 = __commonJS({
2461
2348
  "private": true,
2462
2349
  "dependencies": {}
2463
2350
  };
2464
- if (existsSync(packageJSONPath)) {
2351
+ if (existsSync2(packageJSONPath)) {
2465
2352
  Object.assign(packageJSON, JSON.parse(await readFile(packageJSONPath, "utf-8")));
2466
2353
  }
2467
2354
  const tgzFileName = `${moduleName}.tgz`;
2468
2355
  packageJSON.dependencies[moduleName] = `file:${tgzFileName}`;
2469
- const pathToTgz = pathfs.resolve(userDir, `${tgzFileName}`);
2356
+ const pathToTgz = pathfs2.resolve(userDir, `${tgzFileName}`);
2470
2357
  await writeFile(pathToTgz, buffer);
2471
2358
  await writeFile(packageJSONPath, JSON.stringify(packageJSON, null, 2), "utf-8");
2472
2359
  await execAsync("npm i", { cwd: userDir });
2473
- await writeFile(pathfs.resolve(userDir, ".gitignore"), `*
2360
+ await writeFile(pathfs2.resolve(userDir, ".gitignore"), `*
2474
2361
  !flow.json
2475
2362
  !flow_cred.json
2476
2363
  !package.json
@@ -2484,7 +2371,7 @@ var require_routes11 = __commonJS({
2484
2371
  });
2485
2372
 
2486
2373
  // ../../modules/workflows/backend/index.js
2487
- var require_backend14 = __commonJS({
2374
+ var require_backend13 = __commonJS({
2488
2375
  "../../modules/workflows/backend/index.js"(exports2, module2) {
2489
2376
  "use strict";
2490
2377
  var Workflows = require_Workflows();
@@ -2508,7 +2395,7 @@ var require_backend14 = __commonJS({
2508
2395
  finder: (search, runeya) => {
2509
2396
  return [];
2510
2397
  },
2511
- routes: require_routes11()
2398
+ routes: require_routes10()
2512
2399
  };
2513
2400
  module2.exports = plugin;
2514
2401
  }
@@ -2530,9 +2417,8 @@ var require_plugins = __commonJS({
2530
2417
  toolbox: require_backend9(),
2531
2418
  help: require_backend10(),
2532
2419
  openapi: require_backend11(),
2533
- vscode: require_backend12(),
2534
- docker: require_backend13(),
2535
- nodered: require_backend14()
2420
+ docker: require_backend12(),
2421
+ nodered: require_backend13()
2536
2422
  };
2537
2423
  module2.exports = Object.keys(plugins).reduce((acc, key) => {
2538
2424
  if (plugins[key].enabled) acc[key] = plugins[key];
@@ -2627,7 +2513,7 @@ var require_Environment = __commonJS({
2627
2513
  var PromiseB2 = require("bluebird");
2628
2514
  var { cloneDeep, merge, over } = require("lodash");
2629
2515
  var dbs2 = require_dbs();
2630
- var { existsSync } = require("fs");
2516
+ var { existsSync: existsSync2 } = require("fs");
2631
2517
  var Environment = class _Environment {
2632
2518
  /**
2633
2519
  * @param {import('@runeya/common-typings').NonFunctionProperties<Environment>} environment
@@ -2644,7 +2530,7 @@ var require_Environment = __commonJS({
2644
2530
  static async load(label, Stack) {
2645
2531
  const environmentDB = await dbs2.getDb(`envs/${label}`).read();
2646
2532
  const overridesDB = dbs2.getDb(`overrides/${label}-environment`);
2647
- if (!existsSync(await overridesDB.getPath())) await new _Environment(environmentDB).save();
2533
+ if (!existsSync2(await overridesDB.getPath())) await new _Environment(environmentDB).save();
2648
2534
  const overrides = await dbs2.getDb(`overrides/${label}-environment`).read();
2649
2535
  merge(environmentDB?.envs || {}, overrides?.envs || {});
2650
2536
  return new _Environment(environmentDB, Stack);
@@ -2872,13 +2758,13 @@ var require_Service = __commonJS({
2872
2758
  var PromiseB2 = require("bluebird");
2873
2759
  var dayjs = require("dayjs");
2874
2760
  var { v4 } = require("uuid");
2875
- var { existsSync, readFileSync } = require("fs");
2761
+ var { existsSync: existsSync2, readFileSync } = require("fs");
2876
2762
  var kill = require("tree-kill");
2877
2763
  var axios = require("axios").default;
2878
- var pathfs = require("path");
2764
+ var pathfs2 = require("path");
2879
2765
  var net = require("net");
2880
2766
  var { sockets: sockets2 } = require_src();
2881
- var { mkdir, writeFile } = require("fs/promises");
2767
+ var { mkdir: mkdir2, writeFile } = require("fs/promises");
2882
2768
  var { cloneDeep, over } = require("lodash");
2883
2769
  var CreateInterface = require_readline();
2884
2770
  var { stripAnsi, ansiconvert, unescapeAnsi } = require_ansiconvert();
@@ -3010,8 +2896,8 @@ var require_Service = __commonJS({
3010
2896
  return new Service(await dbs2.getDb(`services/${label}`).read(), Stack);
3011
2897
  };
3012
2898
  Service.prototype.loadCustomEnv = function(path2) {
3013
- const dotEnvPath = pathfs.resolve(path2, ".env");
3014
- if (existsSync(dotEnvPath) && readFileSync(dotEnvPath, { encoding: "utf-8" }).trim()) {
2899
+ const dotEnvPath = pathfs2.resolve(path2, ".env");
2900
+ if (existsSync2(dotEnvPath) && readFileSync(dotEnvPath, { encoding: "utf-8" }).trim()) {
3015
2901
  console.log(`! A .env will override your ${this.label} service !`);
3016
2902
  return require("dotenv").parse(readFileSync(dotEnvPath, "utf-8"));
3017
2903
  }
@@ -3165,7 +3051,7 @@ var require_Service = __commonJS({
3165
3051
  this.crashed = false;
3166
3052
  this.exited = false;
3167
3053
  let { cmd, args: args2, options } = this.container.enabled ? await this.parseIncomingCommandDocker(command) : await this.parseIncomingCommand(command);
3168
- if (!existsSync(options.cwd)) {
3054
+ if (!existsSync2(options.cwd)) {
3169
3055
  this.crashed = true;
3170
3056
  this.exited = true;
3171
3057
  const launchMessage2 = {
@@ -3429,7 +3315,7 @@ var require_Service = __commonJS({
3429
3315
  "sh",
3430
3316
  `-c '${spawnCmd} ${spawnArgs.join(" ")}'`
3431
3317
  ];
3432
- const cwd = pathfs.resolve(replaceEnvs(spawnOptions.cwd || this.getRootPath() || "."));
3318
+ const cwd = pathfs2.resolve(replaceEnvs(spawnOptions.cwd || this.getRootPath() || "."));
3433
3319
  const options = {
3434
3320
  cwd,
3435
3321
  shell: isWindows ? process.env.ComSpec : "/bin/sh"
@@ -3446,7 +3332,7 @@ var require_Service = __commonJS({
3446
3332
  cmd = currentAlias?.cmd || cmd;
3447
3333
  args2 = [...currentAlias?.args || [], ...args2];
3448
3334
  }
3449
- const cwd = pathfs.resolve(replaceEnvs(spawnOptions.cwd || this.getRootPath() || "."));
3335
+ const cwd = pathfs2.resolve(replaceEnvs(spawnOptions.cwd || this.getRootPath() || "."));
3450
3336
  const options = {
3451
3337
  ...spawnOptions,
3452
3338
  cwd,
@@ -3463,19 +3349,19 @@ var require_Service = __commonJS({
3463
3349
  return { cmd, args: args2, options };
3464
3350
  };
3465
3351
  function replaceHome(str) {
3466
- return str.startsWith("~") ? pathfs.resolve(os.homedir(), str.replace("~/", "")) : pathfs.resolve(str);
3352
+ return str.startsWith("~") ? pathfs2.resolve(os.homedir(), str.replace("~/", "")) : pathfs2.resolve(str);
3467
3353
  }
3468
3354
  Service.prototype.getDockerVolumesArgs = async function() {
3469
3355
  const internalVolumeRootPath = replaceHome(this.container.sharedVolume);
3470
3356
  const volumesCmd = this.container.volumes.map((v) => {
3471
3357
  let [external, internal] = v.split(":");
3472
- if (external) external = pathfs.resolve(replaceHome(replaceEnvs(external)));
3473
- if (internal) internal = pathfs.resolve(replaceHome(replaceEnvs(internal)));
3358
+ if (external) external = pathfs2.resolve(replaceHome(replaceEnvs(external)));
3359
+ if (internal) internal = pathfs2.resolve(replaceHome(replaceEnvs(internal)));
3474
3360
  return ["-v", `"${external}:${internal || external}"`];
3475
3361
  });
3476
3362
  volumesCmd.push(...await PromiseB2.map(this.container.ignoreVolumes, async (ignoredVolume) => {
3477
- const volumePath = pathfs.join(internalVolumeRootPath, `ignored-volume-${humanStringToKey(this.label)}`, ignoredVolume);
3478
- if (!existsSync(volumePath)) await mkdir(volumePath, { recursive: true });
3363
+ const volumePath = pathfs2.join(internalVolumeRootPath, `ignored-volume-${humanStringToKey(this.label)}`, ignoredVolume);
3364
+ if (!existsSync2(volumePath)) await mkdir2(volumePath, { recursive: true });
3479
3365
  return ["-v", `"${volumePath}:${ignoredVolume}"`];
3480
3366
  }).filter((f) => !!f?.length));
3481
3367
  return volumesCmd.flat(1);
@@ -3497,8 +3383,8 @@ var require_Service = __commonJS({
3497
3383
  };
3498
3384
  Service.prototype.launchDockerBuild = async function({ isMainProcess }) {
3499
3385
  const internalVolumeRootPath = replaceHome(this.container.sharedVolume);
3500
- const dockerFilePath = pathfs.resolve(internalVolumeRootPath, `Dockerfile.${this.container.name}`);
3501
- const dockerContextPath = pathfs.resolve(internalVolumeRootPath, ".empty-context");
3386
+ const dockerFilePath = pathfs2.resolve(internalVolumeRootPath, `Dockerfile.${this.container.name}`);
3387
+ const dockerContextPath = pathfs2.resolve(internalVolumeRootPath, ".empty-context");
3502
3388
  const command = {
3503
3389
  spwanCmd: "docker",
3504
3390
  spawnArgs: ["build", "-f", dockerFilePath, "-t", this.container?.name || "", dockerContextPath],
@@ -3581,11 +3467,11 @@ var require_Service = __commonJS({
3581
3467
  isMainProcess
3582
3468
  }) {
3583
3469
  const internalVolumeRootPath = replaceHome(this.container.sharedVolume);
3584
- const dockerFilePath = pathfs.resolve(internalVolumeRootPath, `Dockerfile.${this.container.name}`);
3585
- const dockerIgnoreFilePath = pathfs.resolve(internalVolumeRootPath, ".dockerignore");
3586
- const dockerContextPath = pathfs.resolve(internalVolumeRootPath, ".empty-context");
3587
- if (!existsSync(internalVolumeRootPath)) await mkdir(internalVolumeRootPath, { recursive: true });
3588
- if (!existsSync(dockerContextPath)) await mkdir(dockerContextPath, { recursive: true });
3470
+ const dockerFilePath = pathfs2.resolve(internalVolumeRootPath, `Dockerfile.${this.container.name}`);
3471
+ const dockerIgnoreFilePath = pathfs2.resolve(internalVolumeRootPath, ".dockerignore");
3472
+ const dockerContextPath = pathfs2.resolve(internalVolumeRootPath, ".empty-context");
3473
+ if (!existsSync2(internalVolumeRootPath)) await mkdir2(internalVolumeRootPath, { recursive: true });
3474
+ if (!existsSync2(dockerContextPath)) await mkdir2(dockerContextPath, { recursive: true });
3589
3475
  await writeFile(dockerFilePath, `${this.container.build || ""}`);
3590
3476
  await writeFile(dockerIgnoreFilePath, "Dockerfile.*".trim(), "utf-8");
3591
3477
  await this.launchDockerBuild({ isMainProcess });
@@ -3653,16 +3539,16 @@ var require_exportedHelpers = __commonJS({
3653
3539
  var require_version = __commonJS({
3654
3540
  "helpers/version.js"(exports2, module2) {
3655
3541
  "use strict";
3656
- var { existsSync, readFileSync } = require("fs");
3542
+ var { existsSync: existsSync2, readFileSync } = require("fs");
3657
3543
  var path = require("path");
3658
3544
  var file = {
3659
3545
  version: "0.0.0"
3660
3546
  };
3661
- if (existsSync(path.resolve(__dirname, "./package.json"))) {
3547
+ if (existsSync2(path.resolve(__dirname, "./package.json"))) {
3662
3548
  file.version = JSON.parse(readFileSync(path.resolve(__dirname, "./package.json"), { encoding: "utf-8" })).version;
3663
- } else if (existsSync(path.resolve(__dirname, "../package.json"))) {
3549
+ } else if (existsSync2(path.resolve(__dirname, "../package.json"))) {
3664
3550
  file.version = JSON.parse(readFileSync(path.resolve(__dirname, "../package.json"), { encoding: "utf-8" })).version;
3665
- } else if (existsSync(path.resolve(__dirname, "../../../lerna.json"))) {
3551
+ } else if (existsSync2(path.resolve(__dirname, "../../../lerna.json"))) {
3666
3552
  file.version = JSON.parse(readFileSync(path.resolve(__dirname, "../../../lerna.json"), { encoding: "utf-8" })).version;
3667
3553
  }
3668
3554
  module2.exports = {
@@ -3675,19 +3561,19 @@ var require_version = __commonJS({
3675
3561
  var require_saves = __commonJS({
3676
3562
  "models/saves.js"(exports2, module2) {
3677
3563
  "use strict";
3678
- var pathfs = require("path");
3564
+ var pathfs2 = require("path");
3679
3565
  var homedir = require("os").homedir();
3680
3566
  var {
3681
- existsSync,
3567
+ existsSync: existsSync2,
3682
3568
  mkdirSync,
3683
3569
  writeFileSync,
3684
3570
  readFileSync
3685
3571
  } = require("fs");
3686
- var confDir = pathfs.resolve(homedir, ".runeya");
3572
+ var confDir = pathfs2.resolve(homedir, ".runeya");
3687
3573
  function getSave(file, initialData, options = {}) {
3688
- if (!existsSync(confDir)) mkdirSync(confDir);
3689
- const dataConfPath = pathfs.resolve(confDir, file);
3690
- if (!existsSync(dataConfPath)) writeFileSync(dataConfPath, JSON.stringify(initialData), "utf-8");
3574
+ if (!existsSync2(confDir)) mkdirSync(confDir);
3575
+ const dataConfPath = pathfs2.resolve(confDir, file);
3576
+ if (!existsSync2(dataConfPath)) writeFileSync(dataConfPath, JSON.stringify(initialData), "utf-8");
3691
3577
  const data = JSON.parse(readFileSync(dataConfPath, "utf-8"));
3692
3578
  options?.afterGet?.(data);
3693
3579
  return {
@@ -3717,9 +3603,9 @@ var require_stack = __commonJS({
3717
3603
  var EncryptionKey = require_EncryptionKey();
3718
3604
  var CustomObservable = require_CustomObservable();
3719
3605
  var args2 = require_args();
3720
- var { existsSync, mkdirSync } = require("fs");
3721
- var { rename } = require("fs/promises");
3722
- var pathfs = require("path");
3606
+ var { existsSync: existsSync2, mkdirSync } = require("fs");
3607
+ var { rename, cp: cp2, rmdir, rm: rm2 } = require("fs/promises");
3608
+ var pathfs2 = require("path");
3723
3609
  var { default: axios } = require("axios");
3724
3610
  function Stack(stack) {
3725
3611
  this.onServerLauch = new CustomObservable();
@@ -3788,8 +3674,7 @@ var require_stack = __commonJS({
3788
3674
  };
3789
3675
  };
3790
3676
  Stack.getRootPath = () => {
3791
- const rootPath = pathfs.resolve(args2.rootPath, ".runeya");
3792
- if (!existsSync(rootPath)) mkdirSync(rootPath, { recursive: true });
3677
+ const rootPath = pathfs2.resolve(args2.rootPath, ".runeya");
3793
3678
  return rootPath;
3794
3679
  };
3795
3680
  Stack.parse = async function() {
@@ -3852,18 +3737,6 @@ var require_stack = __commonJS({
3852
3737
  return Stack.findService(serviceLabel);
3853
3738
  };
3854
3739
  Stack.selectConf = async function() {
3855
- const localLegacyPath = pathfs.resolve(require_stack().getRootPath(), "../.stackmonitor");
3856
- const localNewPath = pathfs.resolve(require_stack().getRootPath(), ".runeya");
3857
- if (existsSync(localLegacyPath) && !existsSync(localNewPath)) {
3858
- console.log("Legacy path found, move to new path");
3859
- await rename(localLegacyPath, localNewPath);
3860
- }
3861
- const globalLegacyPath = pathfs.resolve(require("os").homedir(), ".stackmonitor");
3862
- const globalNewPath = pathfs.resolve(require("os").homedir(), ".runeya-global");
3863
- if (existsSync(globalLegacyPath) && !existsSync(globalNewPath)) {
3864
- console.log("Legacy path found, move to new path");
3865
- await rename(globalLegacyPath, globalNewPath);
3866
- }
3867
3740
  await EncryptionKey.init();
3868
3741
  if (!EncryptionKey.encryptionKey) {
3869
3742
  await EncryptionKey.saveKey(await EncryptionKey.generateKey());
@@ -3961,8 +3834,8 @@ var require_plugins2 = __commonJS({
3961
3834
  var { default: axios } = require("axios");
3962
3835
  var { tmpdir } = require("os");
3963
3836
  var path = require("path");
3964
- var { existsSync } = require("fs");
3965
- var { writeFile, mkdir, readFile, cp, rm, readdir } = require("fs/promises");
3837
+ var { existsSync: existsSync2 } = require("fs");
3838
+ var { writeFile, mkdir: mkdir2, readFile, cp: cp2, rm: rm2, readdir } = require("fs/promises");
3966
3839
  var { spawn } = require("child_process");
3967
3840
  var dbs2 = require_dbs();
3968
3841
  var HTTPError = require_src2();
@@ -4007,13 +3880,13 @@ var require_plugins2 = __commonJS({
4007
3880
  });
4008
3881
  async function install(remotePath, force = false) {
4009
3882
  const rootPath = args2.rootPath;
4010
- if (!existsSync(rootPath)) await mkdir(rootPath, { recursive: true });
3883
+ if (!existsSync2(rootPath)) await mkdir2(rootPath, { recursive: true });
4011
3884
  const runeyaPath = path.resolve(rootPath, ".runeya");
4012
- if (!existsSync(runeyaPath)) await mkdir(runeyaPath, { recursive: true });
3885
+ if (!existsSync2(runeyaPath)) await mkdir2(runeyaPath, { recursive: true });
4013
3886
  const pluginsPath = path.resolve(runeyaPath, "plugins");
4014
- if (!existsSync(pluginsPath)) await mkdir(pluginsPath, { recursive: true });
3887
+ if (!existsSync2(pluginsPath)) await mkdir2(pluginsPath, { recursive: true });
4015
3888
  const packageTmpPath = path.resolve(tmpdir(), `runeya-plugin-${Date.now()}`);
4016
- if (!existsSync(packageTmpPath)) await mkdir(packageTmpPath, { recursive: true });
3889
+ if (!existsSync2(packageTmpPath)) await mkdir2(packageTmpPath, { recursive: true });
4017
3890
  const packageTmpFilePath = `${packageTmpPath}.tar.gz`;
4018
3891
  const { data } = await axios.get(remotePath, { responseType: "arraybuffer" });
4019
3892
  await writeFile(packageTmpFilePath, data);
@@ -4026,8 +3899,8 @@ var require_plugins2 = __commonJS({
4026
3899
  }
4027
3900
  await dbConfig.alasql.delete(`name='${config.name}'`);
4028
3901
  const diskPath = path.resolve(pluginsPath, config.name);
4029
- if (existsSync(diskPath)) await rm(diskPath, { recursive: true, force: true });
4030
- await cp(path.resolve(packageTmpPath), diskPath, { recursive: true });
3902
+ if (existsSync2(diskPath)) await rm2(diskPath, { recursive: true, force: true });
3903
+ await cp2(path.resolve(packageTmpPath), diskPath, { recursive: true });
4031
3904
  await dbConfig.alasql.insertOne({
4032
3905
  name: config.name,
4033
3906
  version: config.version,
@@ -4118,8 +3991,8 @@ var require_plugins2 = __commonJS({
4118
3991
  if (!plugin) {
4119
3992
  throw new HTTPError("Plugin not found", "404.plugin.not.found");
4120
3993
  }
4121
- if (plugin.diskPath && existsSync(plugin.diskPath)) {
4122
- await rm(plugin.diskPath, { recursive: true, force: true });
3994
+ if (plugin.diskPath && existsSync2(plugin.diskPath)) {
3995
+ await rm2(plugin.diskPath, { recursive: true, force: true });
4123
3996
  }
4124
3997
  await dbConfig.alasql.delete(`name='${name}'`);
4125
3998
  sockets2.emit("plugins:uninstalled", {
@@ -4168,7 +4041,7 @@ var require_plugins2 = __commonJS({
4168
4041
  backendPath = path.resolve(pluginPath, "backend/index.js");
4169
4042
  themePath = path.resolve(pluginPath, "theme/index.js");
4170
4043
  let frontWatcher;
4171
- if (existsSync(frontPath) && existsSync(frontPathDist) && existsSync(backendPath)) {
4044
+ if (existsSync2(frontPath) && existsSync2(frontPathDist) && existsSync2(backendPath)) {
4172
4045
  const debouncedFrontWatcher = debounce(async () => {
4173
4046
  sockets2.emit("plugins:front:building", pluginName);
4174
4047
  console.log("Front changed", pluginName);
@@ -4176,7 +4049,7 @@ var require_plugins2 = __commonJS({
4176
4049
  frontWatcher = chokidar.watch(frontPath, { ignored: frontPathDist, ignoreInitial: true }).on("all", debouncedFrontWatcher);
4177
4050
  }
4178
4051
  let frontDistWatcher;
4179
- if (existsSync(frontPathDist)) {
4052
+ if (existsSync2(frontPathDist)) {
4180
4053
  const debouncedFrontDistWatcher = debounce(async (a, b, c) => {
4181
4054
  sockets2.emit("plugins:front:changed", pluginName);
4182
4055
  console.log("Front dist changed", pluginName);
@@ -4184,7 +4057,7 @@ var require_plugins2 = __commonJS({
4184
4057
  frontDistWatcher = chokidar.watch(frontPathDist, { ignoreInitial: true }).on("all", debouncedFrontDistWatcher);
4185
4058
  }
4186
4059
  let backendWatcher;
4187
- if (existsSync(backendPath)) {
4060
+ if (existsSync2(backendPath)) {
4188
4061
  const debouncedBackendWatcher = debounce(async () => {
4189
4062
  await frontWatcher.close();
4190
4063
  await frontDistWatcher.close();
@@ -4197,7 +4070,7 @@ var require_plugins2 = __commonJS({
4197
4070
  backendPath = null;
4198
4071
  }
4199
4072
  let themeWatcher;
4200
- if (existsSync(themePath)) {
4073
+ if (existsSync2(themePath)) {
4201
4074
  const debouncedThemeWatcher = debounce(async () => {
4202
4075
  if (frontWatcher) await frontWatcher.close();
4203
4076
  if (frontDistWatcher) await frontDistWatcher.close();
@@ -4358,7 +4231,11 @@ var require_plugins3 = __commonJS({
4358
4231
  });
4359
4232
  router.post("/:plugin/call/:method", async (req, res) => {
4360
4233
  const result = await plugins.call(req.params.plugin, req.params.method, req.body?.args || []);
4361
- res.json(result);
4234
+ if (typeof result === "function") {
4235
+ await result(req, res);
4236
+ } else {
4237
+ res.json(result);
4238
+ }
4362
4239
  });
4363
4240
  module2.exports = router;
4364
4241
  }
@@ -4468,18 +4345,18 @@ var require_system = __commonJS({
4468
4345
  var require_myConfs = __commonJS({
4469
4346
  "models/myConfs.js"(exports2, module2) {
4470
4347
  "use strict";
4471
- var pathfs = require("path");
4348
+ var pathfs2 = require("path");
4472
4349
  var os = require("os");
4473
4350
  var {
4474
- existsSync,
4351
+ existsSync: existsSync2,
4475
4352
  mkdirSync,
4476
4353
  writeFileSync,
4477
4354
  readFileSync
4478
4355
  } = require("fs");
4479
- var persistencePath = pathfs.resolve(os.homedir(), ".runeya");
4480
- if (!existsSync(persistencePath)) mkdirSync(persistencePath, { recursive: true });
4481
- var confsPath = pathfs.resolve(persistencePath, "confs");
4482
- if (!existsSync(confsPath)) writeFileSync(confsPath, JSON.stringify([]), "utf-8");
4356
+ var persistencePath = pathfs2.resolve(os.homedir(), ".runeya");
4357
+ if (!existsSync2(persistencePath)) mkdirSync(persistencePath, { recursive: true });
4358
+ var confsPath = pathfs2.resolve(persistencePath, "confs");
4359
+ if (!existsSync2(confsPath)) writeFileSync(confsPath, JSON.stringify([]), "utf-8");
4483
4360
  var store = JSON.parse(readFileSync(confsPath, "utf-8"));
4484
4361
  module2.exports = {
4485
4362
  /** @type {string[]} */
@@ -4691,7 +4568,7 @@ var require_fs = __commonJS({
4691
4568
  "use strict";
4692
4569
  var { express } = require_src6();
4693
4570
  var router = express.Router();
4694
- var pathfs = require("path");
4571
+ var pathfs2 = require("path");
4695
4572
  var PromiseB2 = require("bluebird");
4696
4573
  var os = require("os");
4697
4574
  var { sort } = require("fast-sort");
@@ -4703,7 +4580,7 @@ var require_fs = __commonJS({
4703
4580
  const path = req.query.path?.toString() || __dirname;
4704
4581
  const dir = await readdir(path);
4705
4582
  const parentDirectory = {
4706
- absolutePath: pathfs.resolve(path, ".."),
4583
+ absolutePath: pathfs2.resolve(path, ".."),
4707
4584
  name: "..",
4708
4585
  isDirectory: true
4709
4586
  };
@@ -4711,7 +4588,7 @@ var require_fs = __commonJS({
4711
4588
  await PromiseB2.map(dir, async (entry) => {
4712
4589
  try {
4713
4590
  if (entry.charAt(0) === ".") return null;
4714
- const absolutePath = pathfs.resolve(path, entry);
4591
+ const absolutePath = pathfs2.resolve(path, entry);
4715
4592
  const entryStat = await stat(absolutePath);
4716
4593
  const entryInfos = {
4717
4594
  absolutePath,
@@ -4722,7 +4599,7 @@ var require_fs = __commonJS({
4722
4599
  };
4723
4600
  if (entryInfos.isDirectory) {
4724
4601
  entryInfos.npmInfos = await getNpmInfos(entryInfos.absolutePath);
4725
- } else if (pathfs.extname(absolutePath) === ".js") {
4602
+ } else if (pathfs2.extname(absolutePath) === ".js") {
4726
4603
  try {
4727
4604
  const stack = require(absolutePath);
4728
4605
  if (Array.isArray(stack) && stack.length && stack[0].label && stack[0].spawnCmd) {
@@ -4745,7 +4622,7 @@ var require_fs = __commonJS({
4745
4622
  async function getNpmInfos(path) {
4746
4623
  const dir = await readdir(path);
4747
4624
  if (dir.includes("package.json")) {
4748
- const packageJSON = JSON.parse(await readFile(pathfs.resolve(path, "package.json"), "utf-8"));
4625
+ const packageJSON = JSON.parse(await readFile(pathfs2.resolve(path, "package.json"), "utf-8"));
4749
4626
  return {
4750
4627
  path,
4751
4628
  packageJSON,
@@ -4995,7 +4872,7 @@ var require_config = __commonJS({
4995
4872
  });
4996
4873
 
4997
4874
  // routes/index.js
4998
- var require_routes12 = __commonJS({
4875
+ var require_routes11 = __commonJS({
4999
4876
  "routes/index.js"(exports2, module2) {
5000
4877
  "use strict";
5001
4878
  var { express } = require_src6();
@@ -5055,7 +4932,7 @@ var require_app = __commonJS({
5055
4932
  "use strict";
5056
4933
  require("express-async-errors");
5057
4934
  var { express } = require_src6();
5058
- var indexRouter = require_routes12();
4935
+ var indexRouter = require_routes11();
5059
4936
  var { stopCpu } = require_cpu();
5060
4937
  var { stopWatchers } = require_stack();
5061
4938
  var app = express();
@@ -5073,7 +4950,7 @@ var require_server = __commonJS({
5073
4950
  "bin/server.js"(exports2, module2) {
5074
4951
  "use strict";
5075
4952
  var { launch } = require_src6();
5076
- var pathfs = require("path");
4953
+ var pathfs2 = require("path");
5077
4954
  var ports = require_ports();
5078
4955
  var table = require_console_table();
5079
4956
  var args2 = require_args();
@@ -5086,7 +4963,7 @@ var require_server = __commonJS({
5086
4963
  apiPrefix: "/",
5087
4964
  bodyLimit: "100mb",
5088
4965
  noGreetings: true,
5089
- staticController: process.env.NODE_ENV !== "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ" ? pathfs.resolve(__dirname, "public") : void 0,
4966
+ staticController: process.env.NODE_ENV !== "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ" ? pathfs2.resolve(__dirname, "public") : void 0,
5090
4967
  helmetConf: process.env.NODE_ENV !== "HFBXdZMJxLyJoua28asEaxRixJ6LriR7FnRzX6pwA7pFjZ" ? {
5091
4968
  crossOriginEmbedderPolicy: false,
5092
4969
  crossOriginResourcePolicy: false,
@@ -5141,10 +5018,33 @@ var require_server = __commonJS({
5141
5018
 
5142
5019
  // bin/www
5143
5020
  var { sockets } = require_src();
5021
+ var pathfs = require("path");
5022
+ var { mkdir, rm, cp } = require("fs/promises");
5023
+ var { existsSync } = require("fs");
5144
5024
  process.title = "runeya";
5145
5025
  var args = require_args();
5146
5026
  require("dotenv").config();
5147
5027
  (async () => {
5028
+ const localLegacyPath = pathfs.resolve(args.runeyaConfigPath, "../.stackmonitor");
5029
+ const localNewPath = args.runeyaConfigPath;
5030
+ if (existsSync(localLegacyPath) && !existsSync(localNewPath)) {
5031
+ console.log("Legacy path found, copy to new path");
5032
+ await cp(localLegacyPath, localNewPath, { recursive: true, force: true });
5033
+ }
5034
+ const globalLegacyPath = pathfs.resolve(args.runeyaGlobalConfigPath, "../.stackmonitor");
5035
+ const globalNewPath = args.runeyaGlobalConfigPath;
5036
+ if (existsSync(globalLegacyPath) && !existsSync(globalNewPath)) {
5037
+ console.log("Legacy path found, copy to new path");
5038
+ await cp(globalLegacyPath, globalNewPath, { recursive: true, force: true });
5039
+ }
5040
+ if (existsSync(localLegacyPath) && !existsSync(pathfs.resolve(args.runeyaConfigPath, "dbs/overrides"))) {
5041
+ console.log("Legacy path found, copy to new path");
5042
+ await cp(pathfs.resolve(localLegacyPath, "dbs/overrides"), pathfs.resolve(args.runeyaConfigPath, "dbs/overrides"), { recursive: true, force: true });
5043
+ }
5044
+ if (existsSync(localLegacyPath) && !existsSync(pathfs.resolve(args.runeyaConfigPath, "dbs/encryption-key.json"))) {
5045
+ console.log("Legacy path found, copy to new path");
5046
+ await cp(pathfs.resolve(localLegacyPath, "dbs/encryption-key.json"), pathfs.resolve(args.runeyaConfigPath, "dbs/encryption-key.json"), { recursive: true, force: true });
5047
+ }
5148
5048
  if (args["pull-env"]) {
5149
5049
  await require_stack().selectConf();
5150
5050
  const service = require_stack().findService(args.s);