@pipelab/plugin-filesystem 1.0.0-beta.23 → 1.0.0-beta.26

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/dist/index.mjs CHANGED
@@ -3,11 +3,11 @@ import { createRequire } from "node:module";
3
3
  import { hostname } from "os";
4
4
  import { normalize } from "path";
5
5
  import { formatWithOptions, types } from "util";
6
- import path, { basename, dirname, join } from "node:path";
6
+ import path, { basename, dirname, join, resolve } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
- import { constants, platform } from "node:os";
8
+ import { constants, homedir, platform } from "node:os";
9
9
  import { appendFileSync, createReadStream, createWriteStream, existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
10
- import { cp, mkdir, rm, stat } from "node:fs/promises";
10
+ import { cp, mkdir, readdir, rm, stat, writeFile } from "node:fs/promises";
11
11
  import http from "node:http";
12
12
  import { webcrypto } from "node:crypto";
13
13
  import { ChildProcess, exec, execFile, spawn, spawnSync } from "node:child_process";
@@ -45391,6 +45391,17 @@ const websocketPort = 33753;
45391
45391
  const metaUrl = typeof import.meta !== "undefined" ? import.meta.url : void 0;
45392
45392
  const _dirname = typeof __dirname !== "undefined" ? __dirname : metaUrl ? dirname(fileURLToPath(metaUrl)) : process.cwd();
45393
45393
  const isDev = process.env.NODE_ENV === "development";
45394
+ const getDefaultUserDataPath = (env) => {
45395
+ const base = (() => {
45396
+ switch (platform()) {
45397
+ case "win32": return process.env.APPDATA || join(homedir(), "AppData", "Roaming");
45398
+ case "darwin": return join(homedir(), "Library", "Application Support");
45399
+ default: return process.env.XDG_CONFIG_HOME || join(homedir(), ".config");
45400
+ }
45401
+ })();
45402
+ const mode = env ?? (isDev ? "dev" : "prod");
45403
+ return join(base, "@pipelab", mode === "dev" ? "app-dev" : mode === "beta" ? "app-beta" : "app");
45404
+ };
45394
45405
  /**
45395
45406
  * Finds the monorepo root by looking for pnpm-workspace.yaml.
45396
45407
  */
@@ -49152,6 +49163,121 @@ var WebSocketServer = class {
49152
49163
  };
49153
49164
  new WebSocketServer();
49154
49165
  //#endregion
49166
+ //#region ../../packages/core-node/src/fs-utils.ts
49167
+ var import_slash = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
49168
+ module.exports = (path) => {
49169
+ const isExtendedLengthPath = /^\\\\\?\\/.test(path);
49170
+ const hasNonAscii = /[^\u0000-\u0080]+/.test(path);
49171
+ if (isExtendedLengthPath || hasNonAscii) return path;
49172
+ return path.replace(/\\/g, "/");
49173
+ };
49174
+ })))(), 1);
49175
+ function removeTrailingSlash(path) {
49176
+ return path.replace(/[\\/]+$/, "");
49177
+ }
49178
+ function isWindowsDriveRoot(path) {
49179
+ return /^[a-z]:$/.test(path);
49180
+ }
49181
+ const windowsSystemFolders = [
49182
+ "windows",
49183
+ "program files",
49184
+ "program files (x86)",
49185
+ "users",
49186
+ "programdata",
49187
+ "perflogs"
49188
+ ];
49189
+ function isWindowsSystemDirectory(path) {
49190
+ if (!isWindowsDriveRoot(path.substring(0, 2)) || path.charAt(2) !== "/") return false;
49191
+ const folder = path.substring(3);
49192
+ return windowsSystemFolders.includes(folder);
49193
+ }
49194
+ const unixSystemDirectories = new Set([
49195
+ "",
49196
+ "/usr",
49197
+ "/var",
49198
+ "/opt",
49199
+ "/etc",
49200
+ "/bin",
49201
+ "/sbin",
49202
+ "/lib",
49203
+ "/lib64",
49204
+ "/boot",
49205
+ "/sys",
49206
+ "/proc",
49207
+ "/dev",
49208
+ "/run",
49209
+ "/home",
49210
+ "/root",
49211
+ "/mnt",
49212
+ "/media",
49213
+ "/srv",
49214
+ "/applications",
49215
+ "/library",
49216
+ "/system",
49217
+ "/volumes",
49218
+ "/snap"
49219
+ ]);
49220
+ const homeDirectory = removeTrailingSlash((0, import_slash.default)(resolve(homedir()))).toLowerCase();
49221
+ const additionalProtectedPaths = [
49222
+ getDefaultUserDataPath("dev"),
49223
+ getDefaultUserDataPath("beta"),
49224
+ getDefaultUserDataPath("prod"),
49225
+ projectRoot,
49226
+ process.cwd(),
49227
+ "/tmp",
49228
+ "/var/tmp",
49229
+ process.env.TEMP,
49230
+ process.env.TMP,
49231
+ join(homedir(), "AppData"),
49232
+ join(homedir(), "AppData", "Local"),
49233
+ join(homedir(), "AppData", "Roaming"),
49234
+ join(homedir(), "Library"),
49235
+ join(homedir(), "Library", "Application Support"),
49236
+ join(homedir(), ".config"),
49237
+ join(homedir(), ".local"),
49238
+ join(homedir(), ".local", "share"),
49239
+ join(homedir(), ".cache"),
49240
+ join(homedir(), "OneDrive"),
49241
+ join(homedir(), "Dropbox"),
49242
+ join(homedir(), ".ssh"),
49243
+ join(homedir(), ".gnupg"),
49244
+ join(homedir(), ".aws"),
49245
+ join(homedir(), ".docker"),
49246
+ join(homedir(), ".kube"),
49247
+ join(homedir(), ".vscode"),
49248
+ join(homedir(), ".vscode-insiders"),
49249
+ join(homedir(), ".cursor"),
49250
+ join(homedir(), ".npm"),
49251
+ join(homedir(), ".pnpm-state"),
49252
+ join(homedir(), ".yarn"),
49253
+ join(homedir(), ".cargo"),
49254
+ join(homedir(), ".rustup"),
49255
+ join(homedir(), ".m2"),
49256
+ join(homedir(), ".gradle")
49257
+ ].filter((p) => typeof p === "string" && p.length > 0);
49258
+ const userSubdirectories = new Set([
49259
+ join(homedir(), "Downloads"),
49260
+ join(homedir(), "Documents"),
49261
+ join(homedir(), "Desktop"),
49262
+ join(homedir(), "Pictures"),
49263
+ join(homedir(), "Music"),
49264
+ join(homedir(), "Videos"),
49265
+ join(homedir(), "Saved Games"),
49266
+ join(homedir(), "Contacts"),
49267
+ join(homedir(), "Searches"),
49268
+ join(homedir(), "Links"),
49269
+ join(homedir(), "3D Objects"),
49270
+ ...additionalProtectedPaths
49271
+ ].map((p) => removeTrailingSlash((0, import_slash.default)(resolve(p))).toLowerCase()));
49272
+ /**
49273
+ * Checks if a path matches a critical user or system directory.
49274
+ */
49275
+ function isPathBlacklisted(pathToCheck) {
49276
+ if (!pathToCheck) return false;
49277
+ const normalized = removeTrailingSlash((0, import_slash.default)(resolve(pathToCheck))).toLowerCase();
49278
+ return normalized === homeDirectory || unixSystemDirectories.has(normalized) || userSubdirectories.has(normalized) || isWindowsDriveRoot(normalized) || isWindowsSystemDirectory(normalized);
49279
+ }
49280
+ //#endregion
49155
49281
  //#region ../../node_modules/is-plain-obj/index.js
49156
49282
  function isPlainObject(value) {
49157
49283
  if (typeof value !== "object" || value === null) return false;
@@ -59542,13 +59668,13 @@ var require_opts_arg = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59542
59668
  //#region ../../node_modules/mkdirp/lib/path-arg.js
59543
59669
  var require_path_arg = /* @__PURE__ */ __commonJSMin(((exports, module) => {
59544
59670
  const platform = process.env.__TESTING_MKDIRP_PLATFORM__ || process.platform;
59545
- const { resolve: resolve$12, parse: parse$2 } = __require("path");
59671
+ const { resolve: resolve$13, parse: parse$2 } = __require("path");
59546
59672
  const pathArg = (path) => {
59547
59673
  if (/\0/.test(path)) throw Object.assign(/* @__PURE__ */ new TypeError("path must be a string without null bytes"), {
59548
59674
  path,
59549
59675
  code: "ERR_INVALID_ARG_VALUE"
59550
59676
  });
59551
- path = resolve$12(path);
59677
+ path = resolve$13(path);
59552
59678
  if (platform === "win32") {
59553
59679
  const badWinChars = /[*|"<>?:]/;
59554
59680
  const { root } = parse$2(path);
@@ -62498,7 +62624,7 @@ var require_readdir_glob = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62498
62624
  const fs$20 = __require("fs");
62499
62625
  const { EventEmitter: EventEmitter$1 } = __require("events");
62500
62626
  const { Minimatch } = require_minimatch$1();
62501
- const { resolve: resolve$11 } = __require("path");
62627
+ const { resolve: resolve$12 } = __require("path");
62502
62628
  function readdir(dir, strict) {
62503
62629
  return new Promise((resolve, reject) => {
62504
62630
  fs$20.readdir(dir, { withFileTypes: true }, (err, files) => {
@@ -62607,7 +62733,7 @@ var require_readdir_glob = /* @__PURE__ */ __commonJSMin(((exports, module) => {
62607
62733
  if (this.options.ignore) this.ignoreMatchers = (Array.isArray(this.options.ignore) ? this.options.ignore : [this.options.ignore]).map((ignore) => new Minimatch(ignore, { dot: true }));
62608
62734
  this.skipMatchers = [];
62609
62735
  if (this.options.skip) this.skipMatchers = (Array.isArray(this.options.skip) ? this.options.skip : [this.options.skip]).map((skip) => new Minimatch(skip, { dot: true }));
62610
- this.iterator = explore(resolve$11(cwd || "."), this.options.follow, this.options.stat, this._shouldSkipDirectory.bind(this));
62736
+ this.iterator = explore(resolve$12(cwd || "."), this.options.follow, this.options.stat, this._shouldSkipDirectory.bind(this));
62611
62737
  this.paused = false;
62612
62738
  this.inactive = false;
62613
62739
  this.aborted = false;
@@ -97890,7 +98016,7 @@ var require_npa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
97890
98016
  const isWindows = process.platform === "win32";
97891
98017
  const { URL: URL$6 } = __require("node:url");
97892
98018
  const path$18 = isWindows ? __require("node:path/win32") : __require("node:path");
97893
- const { homedir: homedir$1 } = __require("node:os");
98019
+ const { homedir: homedir$2 } = __require("node:os");
97894
98020
  const HostedGit = require_lib$28();
97895
98021
  const semver = require_semver$2();
97896
98022
  const validatePackageName = require_lib$23();
@@ -98095,7 +98221,7 @@ var require_npa = /* @__PURE__ */ __commonJSMin(((exports, module) => {
98095
98221
  }
98096
98222
  if (/^\/~(\/|$)/.test(specPath)) {
98097
98223
  res.saveSpec = `file:${specPath.substr(1)}`;
98098
- resolvedPath = path$18.resolve(homedir$1(), specPath.substr(3));
98224
+ resolvedPath = path$18.resolve(homedir$2(), specPath.substr(3));
98099
98225
  } else if (!path$18.isAbsolute(rawSpec.slice(5))) res.saveSpec = `file:${path$18.relative(where, resolvedPath)}`;
98100
98226
  else res.saveSpec = `file:${path$18.resolve(resolvedPath)}`;
98101
98227
  res.fetchSpec = path$18.resolve(where, resolvedPath);
@@ -99241,8 +99367,8 @@ var require_sort$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99241
99367
  //#endregion
99242
99368
  //#region ../../node_modules/@npmcli/package-json/lib/index.js
99243
99369
  var require_lib$18 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99244
- const { readFile: readFile$4, writeFile: writeFile$2 } = __require("node:fs/promises");
99245
- const { resolve: resolve$10 } = __require("node:path");
99370
+ const { readFile: readFile$4, writeFile: writeFile$3 } = __require("node:fs/promises");
99371
+ const { resolve: resolve$11 } = __require("node:path");
99246
99372
  const parseJSON = require_lib$30();
99247
99373
  const updateDeps = require_update_dependencies();
99248
99374
  const updateScripts = require_update_scripts();
@@ -99345,7 +99471,7 @@ var require_lib$18 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99345
99471
  parseErr = err;
99346
99472
  }
99347
99473
  if (parseErr) {
99348
- const indexFile = resolve$10(this.path, "index.js");
99474
+ const indexFile = resolve$11(this.path, "index.js");
99349
99475
  let indexFileContent;
99350
99476
  try {
99351
99477
  indexFileContent = await readFile$4(indexFile, "utf8");
@@ -99390,7 +99516,7 @@ var require_lib$18 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99390
99516
  return this.#path;
99391
99517
  }
99392
99518
  get filename() {
99393
- if (this.path) return resolve$10(this.path, "package.json");
99519
+ if (this.path) return resolve$11(this.path, "package.json");
99394
99520
  }
99395
99521
  create(path) {
99396
99522
  this.#path = path;
@@ -99414,7 +99540,7 @@ var require_lib$18 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
99414
99540
  const content = sort ? packageSort(rest) : rest;
99415
99541
  const fileContent = `${JSON.stringify(content, null, format)}\n`.replace(/\n/g, eol);
99416
99542
  if (fileContent.trim() !== this.#readFileContent.trim()) {
99417
- const written = await writeFile$2(this.filename, fileContent);
99543
+ const written = await writeFile$3(this.filename, fileContent);
99418
99544
  this.#readFileContent = fileContent;
99419
99545
  return written;
99420
99546
  }
@@ -100512,8 +100638,8 @@ var require_errors$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100512
100638
  var require_polyfill = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100513
100639
  const { ERR_FS_CP_DIR_TO_NON_DIR, ERR_FS_CP_EEXIST, ERR_FS_CP_EINVAL, ERR_FS_CP_FIFO_PIPE, ERR_FS_CP_NON_DIR_TO_DIR, ERR_FS_CP_SOCKET, ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY, ERR_FS_CP_UNKNOWN, ERR_FS_EISDIR, ERR_INVALID_ARG_TYPE } = require_errors$3();
100514
100640
  const { constants: { errno: { EEXIST, EISDIR, EINVAL, ENOTDIR } } } = __require("os");
100515
- const { chmod: chmod$1, copyFile, lstat: lstat$2, mkdir: mkdir$5, readdir: readdir$4, readlink, stat: stat$5, symlink, unlink, utimes } = __require("fs/promises");
100516
- const { dirname: dirname$6, isAbsolute: isAbsolute$1, join: join$6, parse, resolve: resolve$9, sep: sep$2, toNamespacedPath } = __require("path");
100641
+ const { chmod: chmod$1, copyFile, lstat: lstat$2, mkdir: mkdir$5, readdir: readdir$5, readlink, stat: stat$5, symlink, unlink, utimes } = __require("fs/promises");
100642
+ const { dirname: dirname$6, isAbsolute: isAbsolute$1, join: join$6, parse, resolve: resolve$10, sep: sep$2, toNamespacedPath } = __require("path");
100517
100643
  const { fileURLToPath: fileURLToPath$1 } = __require("url");
100518
100644
  const defaultOptions = {
100519
100645
  dereference: false,
@@ -100600,8 +100726,8 @@ var require_polyfill = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100600
100726
  );
100601
100727
  }
100602
100728
  async function checkParentPaths(src, srcStat, dest) {
100603
- const srcParent = resolve$9(dirname$6(src));
100604
- const destParent = resolve$9(dirname$6(dest));
100729
+ const srcParent = resolve$10(dirname$6(src));
100730
+ const destParent = resolve$10(dirname$6(dest));
100605
100731
  if (destParent === srcParent || destParent === parse(destParent).root) return;
100606
100732
  let destStat;
100607
100733
  try {
@@ -100620,7 +100746,7 @@ var require_polyfill = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100620
100746
  });
100621
100747
  return checkParentPaths(src, srcStat, destParent);
100622
100748
  }
100623
- const normalizePathToArray = (path) => resolve$9(path).split(sep$2).filter(Boolean);
100749
+ const normalizePathToArray = (path) => resolve$10(path).split(sep$2).filter(Boolean);
100624
100750
  function isSrcSubdir(src, dest) {
100625
100751
  const srcArr = normalizePathToArray(src);
100626
100752
  const destArr = normalizePathToArray(dest);
@@ -100719,7 +100845,7 @@ var require_polyfill = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100719
100845
  return setDestMode(dest, srcMode);
100720
100846
  }
100721
100847
  async function copyDir(src, dest, opts) {
100722
- const dir = await readdir$4(src);
100848
+ const dir = await readdir$5(src);
100723
100849
  for (let i = 0; i < dir.length; i++) {
100724
100850
  const item = dir[i];
100725
100851
  const srcItem = join$6(src, item);
@@ -100730,7 +100856,7 @@ var require_polyfill = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100730
100856
  }
100731
100857
  async function onLink(destStat, src, dest) {
100732
100858
  let resolvedSrc = await readlink(src);
100733
- if (!isAbsolute$1(resolvedSrc)) resolvedSrc = resolve$9(dirname$6(src), resolvedSrc);
100859
+ if (!isAbsolute$1(resolvedSrc)) resolvedSrc = resolve$10(dirname$6(src), resolvedSrc);
100734
100860
  if (!destStat) return symlink(resolvedSrc, dest);
100735
100861
  let resolvedDest;
100736
100862
  try {
@@ -100741,7 +100867,7 @@ var require_polyfill = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100741
100867
  // istanbul ignore next: should not be possible
100742
100868
  throw err;
100743
100869
  }
100744
- if (!isAbsolute$1(resolvedDest)) resolvedDest = resolve$9(dirname$6(dest), resolvedDest);
100870
+ if (!isAbsolute$1(resolvedDest)) resolvedDest = resolve$10(dirname$6(dest), resolvedDest);
100745
100871
  if (isSrcSubdir(resolvedSrc, resolvedDest)) throw new ERR_FS_CP_EINVAL({
100746
100872
  message: `cannot copy ${resolvedSrc} to a subdirectory of self ${resolvedDest}`,
100747
100873
  path: dest,
@@ -100815,11 +100941,11 @@ var require_with_temp_dir = /* @__PURE__ */ __commonJSMin(((exports, module) =>
100815
100941
  //#endregion
100816
100942
  //#region ../../node_modules/cacache/node_modules/@npmcli/fs/lib/readdir-scoped.js
100817
100943
  var require_readdir_scoped = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100818
- const { readdir: readdir$3 } = __require("fs/promises");
100944
+ const { readdir: readdir$4 } = __require("fs/promises");
100819
100945
  const { join: join$4 } = __require("path");
100820
100946
  const readdirScoped = async (dir) => {
100821
100947
  const results = [];
100822
- for (const item of await readdir$3(dir)) if (item.startsWith("@")) for (const scopedItem of await readdir$3(join$4(dir, item))) results.push(join$4(item, scopedItem));
100948
+ for (const item of await readdir$4(dir)) if (item.startsWith("@")) for (const scopedItem of await readdir$4(join$4(dir, item))) results.push(join$4(item, scopedItem));
100823
100949
  else results.push(item);
100824
100950
  return results;
100825
100951
  };
@@ -100828,7 +100954,7 @@ var require_readdir_scoped = /* @__PURE__ */ __commonJSMin(((exports, module) =>
100828
100954
  //#endregion
100829
100955
  //#region ../../node_modules/cacache/node_modules/@npmcli/fs/lib/move-file.js
100830
100956
  var require_move_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100831
- const { dirname: dirname$5, join: join$3, resolve: resolve$8, relative: relative$1, isAbsolute } = __require("path");
100957
+ const { dirname: dirname$5, join: join$3, resolve: resolve$9, relative: relative$1, isAbsolute } = __require("path");
100832
100958
  const fs$12 = __require("fs/promises");
100833
100959
  const pathExists = async (path) => {
100834
100960
  try {
@@ -100864,10 +100990,10 @@ var require_move_file = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100864
100990
  if (root) {
100865
100991
  await Promise.all(symlinks.map(async ({ source: symSource, destination: symDestination }) => {
100866
100992
  let target = await fs$12.readlink(symSource);
100867
- if (isAbsolute(target)) target = resolve$8(symDestination, relative$1(symSource, target));
100993
+ if (isAbsolute(target)) target = resolve$9(symDestination, relative$1(symSource, target));
100868
100994
  let targetStat = "file";
100869
100995
  try {
100870
- targetStat = await fs$12.stat(resolve$8(dirname$5(symSource), target));
100996
+ targetStat = await fs$12.stat(resolve$9(dirname$5(symSource), target));
100871
100997
  if (targetStat.isDirectory()) targetStat = "junction";
100872
100998
  } catch {}
100873
100999
  await fs$12.symlink(target, symDestination, targetStat);
@@ -101029,7 +101155,7 @@ var require_path = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101029
101155
  //#region ../../node_modules/cacache/lib/entry-index.js
101030
101156
  var require_entry_index = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101031
101157
  const crypto$1 = __require("crypto");
101032
- const { appendFile, mkdir: mkdir$3, readFile: readFile$3, readdir: readdir$2, rm: rm$4, writeFile: writeFile$1 } = __require("fs/promises");
101158
+ const { appendFile, mkdir: mkdir$3, readFile: readFile$3, readdir: readdir$3, rm: rm$4, writeFile: writeFile$2 } = __require("fs/promises");
101033
101159
  const { Minipass } = require_commonjs$10();
101034
101160
  const path$13 = __require("path");
101035
101161
  const ssri = require_lib$17();
@@ -101076,7 +101202,7 @@ var require_entry_index = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101076
101202
  });
101077
101203
  };
101078
101204
  const write = async (tmp) => {
101079
- await writeFile$1(tmp.target, newIndex, { flag: "wx" });
101205
+ await writeFile$2(tmp.target, newIndex, { flag: "wx" });
101080
101206
  await mkdir$3(path$13.dirname(bucket), { recursive: true });
101081
101207
  await moveFile(tmp.target, bucket);
101082
101208
  tmp.moved = true;
@@ -101222,7 +101348,7 @@ var require_entry_index = /* @__PURE__ */ __commonJSMin(((exports, module) => {
101222
101348
  };
101223
101349
  }
101224
101350
  function readdirOrEmpty(dir) {
101225
- return readdir$2(dir).catch((err) => {
101351
+ return readdir$3(dir).catch((err) => {
101226
101352
  if (err.code === "ENOENT" || err.code === "ENOTDIR") return [];
101227
101353
  throw err;
101228
101354
  });
@@ -105944,7 +106070,7 @@ var require_rm = /* @__PURE__ */ __commonJSMin(((exports, module) => {
105944
106070
  //#endregion
105945
106071
  //#region ../../node_modules/cacache/lib/verify.js
105946
106072
  var require_verify$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
105947
- const { mkdir: mkdir$2, readFile: readFile$2, rm: rm$2, stat: stat$4, truncate, writeFile } = __require("fs/promises");
106073
+ const { mkdir: mkdir$2, readFile: readFile$2, rm: rm$2, stat: stat$4, truncate, writeFile: writeFile$1 } = __require("fs/promises");
105948
106074
  const contentPath = require_path();
105949
106075
  const fsm = require_lib$15();
105950
106076
  const glob = require_glob();
@@ -106133,7 +106259,7 @@ var require_verify$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106133
106259
  async function writeVerifile(cache, opts) {
106134
106260
  const verifile = path$9.join(cache, "_lastverified");
106135
106261
  opts.log.silly("verify", "writing verifile to " + verifile);
106136
- return writeFile(verifile, `${Date.now()}`);
106262
+ return writeFile$1(verifile, `${Date.now()}`);
106137
106263
  }
106138
106264
  module.exports.lastRun = lastRun;
106139
106265
  async function lastRun(cache) {
@@ -106683,8 +106809,8 @@ var require_lib$12 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106683
106809
  //#region ../../node_modules/@npmcli/installed-package-contents/lib/index.js
106684
106810
  var require_lib$11 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106685
106811
  const bundled = require_lib$12();
106686
- const { readFile: readFile$1, readdir: readdir$1, stat: stat$3 } = __require("fs/promises");
106687
- const { resolve: resolve$7, basename: basename$4, dirname: dirname$4 } = __require("path");
106812
+ const { readFile: readFile$1, readdir: readdir$2, stat: stat$3 } = __require("fs/promises");
106813
+ const { resolve: resolve$8, basename: basename$4, dirname: dirname$4 } = __require("path");
106688
106814
  const normalizePackageBin = require_lib$21();
106689
106815
  const readPackage = ({ path, packageJsonCache }) => packageJsonCache.has(path) ? Promise.resolve(packageJsonCache.get(path)) : readFile$1(path).then((json) => {
106690
106816
  const pkg = normalizePackageBin(JSON.parse(json));
@@ -106728,7 +106854,7 @@ var require_lib$11 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106728
106854
  const nm = /^@.+/.test(scope) ? dirname$4(dir) : dir;
106729
106855
  const binFiles = [];
106730
106856
  Object.keys(pkg.bin).forEach((b) => {
106731
- const base = resolve$7(nm, ".bin", b);
106857
+ const base = resolve$8(nm, ".bin", b);
106732
106858
  binFiles.push(base, base + ".cmd", base + ".ps1");
106733
106859
  });
106734
106860
  (await Promise.all(binFiles.map((b) => stat$3(b).then(() => b).catch(() => null)))).filter((b) => b).forEach((b) => result.add(b));
@@ -106738,7 +106864,7 @@ var require_lib$11 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106738
106864
  result.add(path);
106739
106865
  return result;
106740
106866
  }
106741
- const [dirEntries, bundleDeps] = await Promise.all([readdir$1(path, { withFileTypes: true }), currentDepth === 0 && pkg && pkg.bundleDependencies ? bundled({
106867
+ const [dirEntries, bundleDeps] = await Promise.all([readdir$2(path, { withFileTypes: true }), currentDepth === 0 && pkg && pkg.bundleDependencies ? bundled({
106742
106868
  path,
106743
106869
  packageJsonCache
106744
106870
  }) : null]).catch(() => []);
@@ -106749,7 +106875,7 @@ var require_lib$11 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106749
106875
  }
106750
106876
  const recursePromises = [];
106751
106877
  for (const entry of dirEntries) {
106752
- const p = resolve$7(path, entry.name);
106878
+ const p = resolve$8(path, entry.name);
106753
106879
  if (entry.isDirectory() === false) {
106754
106880
  result.add(p);
106755
106881
  continue;
@@ -106768,7 +106894,7 @@ var require_lib$11 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106768
106894
  }
106769
106895
  if (bundleDeps) recursePromises.push(...bundleDeps.map((dep) => {
106770
106896
  return pkgContents({
106771
- path: resolve$7(path, "node_modules", dep),
106897
+ path: resolve$8(path, "node_modules", dep),
106772
106898
  packageJsonCache,
106773
106899
  pkg: true,
106774
106900
  depth,
@@ -106780,7 +106906,7 @@ var require_lib$11 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
106780
106906
  return result;
106781
106907
  };
106782
106908
  module.exports = ({ path, ...opts }) => pkgContents({
106783
- path: resolve$7(path),
106909
+ path: resolve$8(path),
106784
106910
  ...opts,
106785
106911
  pkg: true
106786
106912
  }).then((results) => [...results]);
@@ -110391,18 +110517,18 @@ var require_protected = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110391
110517
  //#endregion
110392
110518
  //#region ../../node_modules/pacote/lib/util/cache-dir.js
110393
110519
  var require_cache_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
110394
- const { resolve: resolve$6 } = __require("node:path");
110395
- const { tmpdir, homedir } = __require("node:os");
110520
+ const { resolve: resolve$7 } = __require("node:path");
110521
+ const { tmpdir, homedir: homedir$1 } = __require("node:os");
110396
110522
  module.exports = (fakePlatform = false) => {
110397
110523
  const temp = tmpdir();
110398
110524
  const uidOrPid = process.getuid ? process.getuid() : process.pid;
110399
- const home = homedir() || resolve$6(temp, "npm-" + uidOrPid);
110525
+ const home = homedir$1() || resolve$7(temp, "npm-" + uidOrPid);
110400
110526
  const platform = fakePlatform || process.platform;
110401
110527
  const cacheExtra = platform === "win32" ? "npm-cache" : ".npm";
110402
110528
  const cacheRoot = platform === "win32" && process.env.LOCALAPPDATA || home;
110403
110529
  return {
110404
- cacache: resolve$6(cacheRoot, cacheExtra, "_cacache"),
110405
- tufcache: resolve$6(cacheRoot, cacheExtra, "_tuf")
110530
+ cacache: resolve$7(cacheRoot, cacheExtra, "_cacache"),
110531
+ tufcache: resolve$7(cacheRoot, cacheExtra, "_tuf")
110406
110532
  };
110407
110533
  };
110408
110534
  }));
@@ -112216,7 +112342,7 @@ var require_lib$10 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112216
112342
  var require_lib$9 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112217
112343
  const { Walker: IgnoreWalker } = require_lib$10();
112218
112344
  const { lstatSync: lstat$1, readFileSync: readFile } = __require("fs");
112219
- const { basename: basename$3, dirname: dirname$3, extname: extname$1, join: join$2, relative, resolve: resolve$5, sep } = __require("path");
112345
+ const { basename: basename$3, dirname: dirname$3, extname: extname$1, join: join$2, relative, resolve: resolve$6, sep } = __require("path");
112220
112346
  const { log } = require_lib$29();
112221
112347
  const defaultRules = Symbol("npm-packlist.rules.default");
112222
112348
  const strictRules = Symbol("npm-packlist.rules.strict");
@@ -112267,7 +112393,7 @@ var require_lib$9 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112267
112393
  ...opts,
112268
112394
  includeEmpty: false,
112269
112395
  follow: false,
112270
- path: resolve$5(opts?.path || tree.path).replace(/\\/g, "/"),
112396
+ path: resolve$6(opts?.path || tree.path).replace(/\\/g, "/"),
112271
112397
  ignoreFiles: opts?.ignoreFiles || [
112272
112398
  defaultRules,
112273
112399
  "package.json",
@@ -112468,8 +112594,8 @@ var require_lib$9 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112468
112594
  var require_set_path = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112469
112595
  init_esm_shims();
112470
112596
  const { log } = require_lib$29();
112471
- const { resolve: resolve$4, dirname: dirname$2, delimiter } = __require("path");
112472
- const nodeGypPath = resolve$4(__dirname, "../lib/node-gyp-bin");
112597
+ const { resolve: resolve$5, dirname: dirname$2, delimiter } = __require("path");
112598
+ const nodeGypPath = resolve$5(__dirname, "../lib/node-gyp-bin");
112473
112599
  const setPATH = (projectPath, binPaths, env) => {
112474
112600
  const PATH = Object.keys(env).filter((p) => /^path$/i.test(p) && env[p]).map((p) => env[p].split(delimiter)).reduce((set, p) => set.concat(p.filter((concatted) => !set.includes(concatted))), []).join(delimiter);
112475
112601
  const pathArr = [];
@@ -112484,7 +112610,7 @@ var require_set_path = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112484
112610
  let p = projectPath;
112485
112611
  let pp;
112486
112612
  do {
112487
- pathArr.push(resolve$4(p, "node_modules", ".bin"));
112613
+ pathArr.push(resolve$5(p, "node_modules", ".bin"));
112488
112614
  pp = p;
112489
112615
  p = dirname$2(p);
112490
112616
  } while (p !== pp);
@@ -112499,7 +112625,7 @@ var require_set_path = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112499
112625
  //#region ../../node_modules/@npmcli/run-script/lib/make-spawn-args.js
112500
112626
  var require_make_spawn_args = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112501
112627
  const setPATH = require_set_path();
112502
- const { resolve: resolve$3 } = __require("path");
112628
+ const { resolve: resolve$4 } = __require("path");
112503
112629
  let npm_config_node_gyp;
112504
112630
  const makeSpawnArgs = (options) => {
112505
112631
  const { args, binPaths, cmd, env, event, nodeGyp, path, scriptShell = true, stdio, stdioString } = options;
@@ -112513,7 +112639,7 @@ var require_make_spawn_args = /* @__PURE__ */ __commonJSMin(((exports, module) =
112513
112639
  env: setPATH(path, binPaths, {
112514
112640
  ...process.env,
112515
112641
  ...env,
112516
- npm_package_json: resolve$3(path, "package.json"),
112642
+ npm_package_json: resolve$4(path, "package.json"),
112517
112643
  npm_lifecycle_event: event,
112518
112644
  npm_lifecycle_script: cmd,
112519
112645
  npm_config_node_gyp
@@ -112601,10 +112727,10 @@ var require_signal_manager = /* @__PURE__ */ __commonJSMin(((exports, module) =>
112601
112727
  //#region ../../node_modules/@npmcli/run-script/lib/is-server-package.js
112602
112728
  var require_is_server_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112603
112729
  const { stat: stat$2 } = __require("node:fs/promises");
112604
- const { resolve: resolve$2 } = __require("node:path");
112730
+ const { resolve: resolve$3 } = __require("node:path");
112605
112731
  module.exports = async (path) => {
112606
112732
  try {
112607
- return (await stat$2(resolve$2(path, "server.js"))).isFile();
112733
+ return (await stat$2(resolve$3(path, "server.js"))).isFile();
112608
112734
  } catch (er) {
112609
112735
  return false;
112610
112736
  }
@@ -112714,7 +112840,7 @@ var require_run_script = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112714
112840
  //#endregion
112715
112841
  //#region ../../node_modules/pacote/lib/file.js
112716
112842
  var require_file$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112717
- const { resolve: resolve$1 } = __require("node:path");
112843
+ const { resolve: resolve$2 } = __require("node:path");
112718
112844
  const { stat: stat$1, chmod } = __require("node:fs/promises");
112719
112845
  const cacache = require_lib$14();
112720
112846
  const fsm = require_lib$13();
@@ -112740,7 +112866,7 @@ var require_file$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112740
112866
  #exeBins(pkg, dest) {
112741
112867
  if (!pkg.bin) return Promise.resolve();
112742
112868
  return Promise.all(Object.keys(pkg.bin).map(async (k) => {
112743
- const script = resolve$1(dest, pkg.bin[k]);
112869
+ const script = resolve$2(dest, pkg.bin[k]);
112744
112870
  try {
112745
112871
  const st = await stat$1(script);
112746
112872
  const mode = st.mode | 73;
@@ -112791,7 +112917,7 @@ var require_tar_create_options = /* @__PURE__ */ __commonJSMin(((exports, module
112791
112917
  //#endregion
112792
112918
  //#region ../../node_modules/pacote/lib/dir.js
112793
112919
  var require_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112794
- const { resolve } = __require("node:path");
112920
+ const { resolve: resolve$1 } = __require("node:path");
112795
112921
  const packlist = require_lib$9();
112796
112922
  const runScript = require_run_script();
112797
112923
  const tar = require_index_min();
@@ -112827,7 +112953,7 @@ var require_dir = /* @__PURE__ */ __commonJSMin(((exports, module) => {
112827
112953
  env: {
112828
112954
  npm_package_resolved: this.resolved,
112829
112955
  npm_package_integrity: this.integrity,
112830
- npm_package_json: resolve(this.resolved, "package.json")
112956
+ npm_package_json: resolve$1(this.resolved, "package.json")
112831
112957
  }
112832
112958
  });
112833
112959
  });
@@ -150469,7 +150595,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150469
150595
  const { promisify: promisify$1 } = __require("util");
150470
150596
  const path$2 = __require("path");
150471
150597
  const { createHash } = __require("crypto");
150472
- const { realpath, lstat, createReadStream: createReadStream$1, readdir } = __require("fs");
150598
+ const { realpath, lstat, createReadStream: createReadStream$1, readdir: readdir$1 } = __require("fs");
150473
150599
  const url = __require("url");
150474
150600
  const slasher = require_glob_slash();
150475
150601
  const minimatch = require_minimatch();
@@ -150794,7 +150920,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
150794
150920
  lstat: promisify$1(lstat),
150795
150921
  realpath: promisify$1(realpath),
150796
150922
  createReadStream: createReadStream$1,
150797
- readdir: promisify$1(readdir),
150923
+ readdir: promisify$1(readdir$1),
150798
150924
  sendError
150799
150925
  }, methods);
150800
150926
  module.exports = async (request, response, config = {}, methods = {}) => {
@@ -150947,6 +151073,39 @@ if (isDev && projectRoot) {
150947
151073
  //#endregion
150948
151074
  //#region ../plugin-core/src/pipelab.ts
150949
151075
  const createActionRunner = (runner) => runner;
151076
+ //#endregion
151077
+ //#region ../plugin-core/src/fs-utils.ts
151078
+ /**
151079
+ * Asserts that a directory is safe to be deleted/cleaned up.
151080
+ * Throws an error if the directory is protected or is not empty and lacks the Pipelab folder marker.
151081
+ */
151082
+ async function assertSafeDirectoryCleanup(directoryPath) {
151083
+ if (!directoryPath) return;
151084
+ const resolvedPath = resolve(directoryPath);
151085
+ if (isPathBlacklisted(resolvedPath)) throw new Error(`Cannot cleanup/delete protected system or user directory: ${resolvedPath}`);
151086
+ try {
151087
+ if ((await stat(resolvedPath)).isDirectory()) {
151088
+ const files = await readdir(resolvedPath);
151089
+ if (files.length > 0) {
151090
+ if (!files.includes(".pipelab")) throw new Error(`Directory is not empty and was not created by Pipelab: ${resolvedPath}. Aborting to prevent data loss.`);
151091
+ }
151092
+ }
151093
+ } catch (e) {
151094
+ if (e.code !== "ENOENT") throw e;
151095
+ }
151096
+ }
151097
+ /**
151098
+ * Creates a hidden Pipelab marker directory with metadata.json at the specified destination path.
151099
+ */
151100
+ async function writePipelabFolderMarker(directoryPath, generator = "unknown") {
151101
+ if (!directoryPath) return;
151102
+ const markerDir = join(directoryPath, ".pipelab");
151103
+ await mkdir(markerDir, { recursive: true });
151104
+ await writeFile(join(markerDir, "metadata.json"), JSON.stringify({
151105
+ createdBy: generator,
151106
+ timestamp: Date.now()
151107
+ }, null, 2), "utf-8");
151108
+ }
150950
151109
  const zip = createAction({
150951
151110
  id: "zip-node",
150952
151111
  name: "Zip",
@@ -151972,6 +152131,7 @@ const copy = createAction({
151972
152131
  required: true,
151973
152132
  control: {
151974
152133
  type: "path",
152134
+ warnIfBlacklisted: true,
151975
152135
  options: { properties: [
151976
152136
  "openFile",
151977
152137
  "openDirectory",
@@ -151995,7 +152155,7 @@ const copy = createAction({
151995
152155
  cleanup: {
151996
152156
  label: "Cleanup",
151997
152157
  required: true,
151998
- description: "Whether to delete the original file/folder",
152158
+ description: "Delete existing files at destination before copying",
151999
152159
  value: true,
152000
152160
  control: { type: "boolean" }
152001
152161
  }
@@ -152046,6 +152206,7 @@ const copyRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152046
152206
  } catch (e) {}
152047
152207
  log("Copying", from, "to", to, "recursive", inputs.recursive, "overwrite", inputs.overwrite);
152048
152208
  if (inputs.cleanup) try {
152209
+ await assertSafeDirectoryCleanup(to);
152049
152210
  log("Cleaning up", to);
152050
152211
  process.noAsar = true;
152051
152212
  await rm(to, {
@@ -152065,6 +152226,7 @@ const copyRunner = createActionRunner(async ({ log, inputs, setOutput }) => {
152065
152226
  recursive: inputs.recursive && !fromIsAFile,
152066
152227
  force: inputs.overwrite
152067
152228
  });
152229
+ if (!fromIsAFile) await writePipelabFolderMarker(to, "fs:copy");
152068
152230
  process.noAsar = false;
152069
152231
  setOutput("output", to);
152070
152232
  setOutput("input", from);
@@ -152085,6 +152247,7 @@ const remove = createAction({
152085
152247
  required: true,
152086
152248
  control: {
152087
152249
  type: "path",
152250
+ warnIfBlacklisted: true,
152088
152251
  options: { properties: ["openFile"] }
152089
152252
  }
152090
152253
  }),
@@ -152109,6 +152272,7 @@ const removeRunner = createActionRunner(async ({ log, inputs }) => {
152109
152272
  throw new Error("Missing source");
152110
152273
  }
152111
152274
  try {
152275
+ await assertSafeDirectoryCleanup(from);
152112
152276
  process.noAsar = true;
152113
152277
  await rm(from, {
152114
152278
  recursive: true,