@stacksjs/cli 0.70.21 → 0.70.23

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 (2) hide show
  1. package/dist/index.js +1185 -238
  2. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -2967,8 +2967,8 @@ var require_universalify = __commonJS((exports) => {
2967
2967
  if (typeof args[args.length - 1] === "function")
2968
2968
  fn.apply(this, args);
2969
2969
  else {
2970
- return new Promise((resolve3, reject) => {
2971
- args.push((err, res) => err != null ? reject(err) : resolve3(res));
2970
+ return new Promise((resolve4, reject) => {
2971
+ args.push((err, res) => err != null ? reject(err) : resolve4(res));
2972
2972
  fn.apply(this, args);
2973
2973
  });
2974
2974
  }
@@ -2989,7 +2989,7 @@ var require_universalify = __commonJS((exports) => {
2989
2989
 
2990
2990
  // ../../../../node_modules/graceful-fs/polyfills.js
2991
2991
  var require_polyfills = __commonJS((exports, module) => {
2992
- var constants = __require("node:constants");
2992
+ var constants2 = __require("node:constants");
2993
2993
  var origCwd = process.cwd;
2994
2994
  var cwd = null;
2995
2995
  var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
@@ -3013,7 +3013,7 @@ var require_polyfills = __commonJS((exports, module) => {
3013
3013
  var chdir;
3014
3014
  module.exports = patch;
3015
3015
  function patch(fs2) {
3016
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
3016
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
3017
3017
  patchLchmod(fs2);
3018
3018
  }
3019
3019
  if (!fs2.lutimes) {
@@ -3053,7 +3053,7 @@ var require_polyfills = __commonJS((exports, module) => {
3053
3053
  }
3054
3054
  if (platform2 === "win32") {
3055
3055
  fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : function(fs$rename) {
3056
- function rename(from, to, cb) {
3056
+ function rename2(from, to, cb) {
3057
3057
  var start = Date.now();
3058
3058
  var backoff = 0;
3059
3059
  fs$rename(from, to, function CB(er) {
@@ -3075,8 +3075,8 @@ var require_polyfills = __commonJS((exports, module) => {
3075
3075
  });
3076
3076
  }
3077
3077
  if (Object.setPrototypeOf)
3078
- Object.setPrototypeOf(rename, fs$rename);
3079
- return rename;
3078
+ Object.setPrototypeOf(rename2, fs$rename);
3079
+ return rename2;
3080
3080
  }(fs2.rename);
3081
3081
  }
3082
3082
  fs2.read = typeof fs2.read !== "function" ? fs2.read : function(fs$read) {
@@ -3116,7 +3116,7 @@ var require_polyfills = __commonJS((exports, module) => {
3116
3116
  }(fs2.readSync);
3117
3117
  function patchLchmod(fs3) {
3118
3118
  fs3.lchmod = function(path3, mode, callback) {
3119
- fs3.open(path3, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
3119
+ fs3.open(path3, constants2.O_WRONLY | constants2.O_SYMLINK, mode, function(err, fd) {
3120
3120
  if (err) {
3121
3121
  if (callback)
3122
3122
  callback(err);
@@ -3131,7 +3131,7 @@ var require_polyfills = __commonJS((exports, module) => {
3131
3131
  });
3132
3132
  };
3133
3133
  fs3.lchmodSync = function(path3, mode) {
3134
- var fd = fs3.openSync(path3, constants.O_WRONLY | constants.O_SYMLINK, mode);
3134
+ var fd = fs3.openSync(path3, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
3135
3135
  var threw = true;
3136
3136
  var ret;
3137
3137
  try {
@@ -3150,9 +3150,9 @@ var require_polyfills = __commonJS((exports, module) => {
3150
3150
  };
3151
3151
  }
3152
3152
  function patchLutimes(fs3) {
3153
- if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
3153
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
3154
3154
  fs3.lutimes = function(path3, at, mt, cb) {
3155
- fs3.open(path3, constants.O_SYMLINK, function(er, fd) {
3155
+ fs3.open(path3, constants2.O_SYMLINK, function(er, fd) {
3156
3156
  if (er) {
3157
3157
  if (cb)
3158
3158
  cb(er);
@@ -3167,7 +3167,7 @@ var require_polyfills = __commonJS((exports, module) => {
3167
3167
  });
3168
3168
  };
3169
3169
  fs3.lutimesSync = function(path3, at, mt) {
3170
- var fd = fs3.openSync(path3, constants.O_SYMLINK);
3170
+ var fd = fs3.openSync(path3, constants2.O_SYMLINK);
3171
3171
  var ret;
3172
3172
  var threw = true;
3173
3173
  try {
@@ -3460,14 +3460,14 @@ GFS4: `);
3460
3460
  return close;
3461
3461
  }(fs2.close);
3462
3462
  fs2.closeSync = function(fs$closeSync) {
3463
- function closeSync(fd) {
3463
+ function closeSync2(fd) {
3464
3464
  fs$closeSync.apply(fs2, arguments);
3465
3465
  resetQueue();
3466
3466
  }
3467
- Object.defineProperty(closeSync, previousSymbol, {
3467
+ Object.defineProperty(closeSync2, previousSymbol, {
3468
3468
  value: fs$closeSync
3469
3469
  });
3470
- return closeSync;
3470
+ return closeSync2;
3471
3471
  }(fs2.closeSync);
3472
3472
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
3473
3473
  process.on("exit", function() {
@@ -3488,8 +3488,8 @@ GFS4: `);
3488
3488
  function patch(fs3) {
3489
3489
  polyfills(fs3);
3490
3490
  fs3.gracefulify = patch;
3491
- fs3.createReadStream = createReadStream;
3492
- fs3.createWriteStream = createWriteStream;
3491
+ fs3.createReadStream = createReadStream2;
3492
+ fs3.createWriteStream = createWriteStream2;
3493
3493
  var fs$readFile = fs3.readFile;
3494
3494
  fs3.readFile = readFile;
3495
3495
  function readFile(path3, options, cb) {
@@ -3508,8 +3508,8 @@ GFS4: `);
3508
3508
  }
3509
3509
  }
3510
3510
  var fs$writeFile = fs3.writeFile;
3511
- fs3.writeFile = writeFile;
3512
- function writeFile(path3, data, options, cb) {
3511
+ fs3.writeFile = writeFile2;
3512
+ function writeFile2(path3, data, options, cb) {
3513
3513
  if (typeof options === "function")
3514
3514
  cb = options, options = null;
3515
3515
  return go$writeFile(path3, data, options, cb);
@@ -3563,9 +3563,9 @@ GFS4: `);
3563
3563
  }
3564
3564
  }
3565
3565
  var fs$readdir = fs3.readdir;
3566
- fs3.readdir = readdir;
3566
+ fs3.readdir = readdir2;
3567
3567
  var noReaddirOptionVersions = /^v[0-5]\./;
3568
- function readdir(path3, options, cb) {
3568
+ function readdir2(path3, options, cb) {
3569
3569
  if (typeof options === "function")
3570
3570
  cb = options, options = null;
3571
3571
  var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path4, options2, cb2, startTime) {
@@ -3688,10 +3688,10 @@ GFS4: `);
3688
3688
  }
3689
3689
  });
3690
3690
  }
3691
- function createReadStream(path3, options) {
3691
+ function createReadStream2(path3, options) {
3692
3692
  return new fs3.ReadStream(path3, options);
3693
3693
  }
3694
- function createWriteStream(path3, options) {
3694
+ function createWriteStream2(path3, options) {
3695
3695
  return new fs3.WriteStream(path3, options);
3696
3696
  }
3697
3697
  var fs$open = fs3.open;
@@ -3819,19 +3819,19 @@ var require_fs = __commonJS((exports) => {
3819
3819
  if (typeof callback === "function") {
3820
3820
  return fs2.exists(filename, callback);
3821
3821
  }
3822
- return new Promise((resolve3) => {
3823
- return fs2.exists(filename, resolve3);
3822
+ return new Promise((resolve4) => {
3823
+ return fs2.exists(filename, resolve4);
3824
3824
  });
3825
3825
  };
3826
3826
  exports.read = function(fd, buffer, offset, length, position, callback) {
3827
3827
  if (typeof callback === "function") {
3828
3828
  return fs2.read(fd, buffer, offset, length, position, callback);
3829
3829
  }
3830
- return new Promise((resolve3, reject) => {
3830
+ return new Promise((resolve4, reject) => {
3831
3831
  fs2.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
3832
3832
  if (err)
3833
3833
  return reject(err);
3834
- resolve3({ bytesRead, buffer: buffer2 });
3834
+ resolve4({ bytesRead, buffer: buffer2 });
3835
3835
  });
3836
3836
  });
3837
3837
  };
@@ -3839,11 +3839,11 @@ var require_fs = __commonJS((exports) => {
3839
3839
  if (typeof args[args.length - 1] === "function") {
3840
3840
  return fs2.write(fd, buffer, ...args);
3841
3841
  }
3842
- return new Promise((resolve3, reject) => {
3842
+ return new Promise((resolve4, reject) => {
3843
3843
  fs2.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
3844
3844
  if (err)
3845
3845
  return reject(err);
3846
- resolve3({ bytesWritten, buffer: buffer2 });
3846
+ resolve4({ bytesWritten, buffer: buffer2 });
3847
3847
  });
3848
3848
  });
3849
3849
  };
@@ -3851,11 +3851,11 @@ var require_fs = __commonJS((exports) => {
3851
3851
  if (typeof args[args.length - 1] === "function") {
3852
3852
  return fs2.readv(fd, buffers, ...args);
3853
3853
  }
3854
- return new Promise((resolve3, reject) => {
3854
+ return new Promise((resolve4, reject) => {
3855
3855
  fs2.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
3856
3856
  if (err)
3857
3857
  return reject(err);
3858
- resolve3({ bytesRead, buffers: buffers2 });
3858
+ resolve4({ bytesRead, buffers: buffers2 });
3859
3859
  });
3860
3860
  });
3861
3861
  };
@@ -3863,11 +3863,11 @@ var require_fs = __commonJS((exports) => {
3863
3863
  if (typeof args[args.length - 1] === "function") {
3864
3864
  return fs2.writev(fd, buffers, ...args);
3865
3865
  }
3866
- return new Promise((resolve3, reject) => {
3866
+ return new Promise((resolve4, reject) => {
3867
3867
  fs2.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
3868
3868
  if (err)
3869
3869
  return reject(err);
3870
- resolve3({ bytesWritten, buffers: buffers2 });
3870
+ resolve4({ bytesWritten, buffers: buffers2 });
3871
3871
  });
3872
3872
  });
3873
3873
  };
@@ -4117,7 +4117,7 @@ var require_copy = __commonJS((exports, module) => {
4117
4117
  var { mkdirs } = require_mkdirs();
4118
4118
  var { pathExists } = require_path_exists();
4119
4119
  var { utimesMillis } = require_utimes();
4120
- var stat = require_stat();
4120
+ var stat2 = require_stat();
4121
4121
  async function copy(src2, dest, opts = {}) {
4122
4122
  if (typeof opts === "function") {
4123
4123
  opts = { filter: opts };
@@ -4129,8 +4129,8 @@ var require_copy = __commonJS((exports, module) => {
4129
4129
 
4130
4130
  ` + "\tsee https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0001");
4131
4131
  }
4132
- const { srcStat, destStat } = await stat.checkPaths(src2, dest, "copy", opts);
4133
- await stat.checkParentPaths(src2, srcStat, dest, "copy");
4132
+ const { srcStat, destStat } = await stat2.checkPaths(src2, dest, "copy", opts);
4133
+ await stat2.checkParentPaths(src2, srcStat, dest, "copy");
4134
4134
  const include = await runFilter(src2, dest, opts);
4135
4135
  if (!include)
4136
4136
  return;
@@ -4199,7 +4199,7 @@ var require_copy = __commonJS((exports, module) => {
4199
4199
  const destItem = path3.join(dest, item2.name);
4200
4200
  promises.push(runFilter(srcItem, destItem, opts).then((include) => {
4201
4201
  if (include) {
4202
- return stat.checkPaths(srcItem, destItem, "copy", opts).then(({ destStat: destStat2 }) => {
4202
+ return stat2.checkPaths(srcItem, destItem, "copy", opts).then(({ destStat: destStat2 }) => {
4203
4203
  return getStatsAndPerformCopy(destStat2, srcItem, destItem, opts);
4204
4204
  });
4205
4205
  }
@@ -4229,10 +4229,10 @@ var require_copy = __commonJS((exports, module) => {
4229
4229
  if (opts.dereference) {
4230
4230
  resolvedDest = path3.resolve(process.cwd(), resolvedDest);
4231
4231
  }
4232
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
4232
+ if (stat2.isSrcSubdir(resolvedSrc, resolvedDest)) {
4233
4233
  throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
4234
4234
  }
4235
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
4235
+ if (stat2.isSrcSubdir(resolvedDest, resolvedSrc)) {
4236
4236
  throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
4237
4237
  }
4238
4238
  await fs2.unlink(dest);
@@ -4247,7 +4247,7 @@ var require_copy_sync = __commonJS((exports, module) => {
4247
4247
  var path3 = __require("node:path");
4248
4248
  var mkdirsSync = require_mkdirs().mkdirsSync;
4249
4249
  var utimesMillisSync = require_utimes().utimesMillisSync;
4250
- var stat = require_stat();
4250
+ var stat2 = require_stat();
4251
4251
  function copySync(src2, dest, opts) {
4252
4252
  if (typeof opts === "function") {
4253
4253
  opts = { filter: opts };
@@ -4260,8 +4260,8 @@ var require_copy_sync = __commonJS((exports, module) => {
4260
4260
 
4261
4261
  ` + "\tsee https://github.com/jprichardson/node-fs-extra/issues/269", "Warning", "fs-extra-WARN0002");
4262
4262
  }
4263
- const { srcStat, destStat } = stat.checkPathsSync(src2, dest, "copy", opts);
4264
- stat.checkParentPathsSync(src2, srcStat, dest, "copy");
4263
+ const { srcStat, destStat } = stat2.checkPathsSync(src2, dest, "copy", opts);
4264
+ stat2.checkParentPathsSync(src2, srcStat, dest, "copy");
4265
4265
  if (opts.filter && !opts.filter(src2, dest))
4266
4266
  return;
4267
4267
  const destParent = path3.dirname(dest);
@@ -4347,7 +4347,7 @@ var require_copy_sync = __commonJS((exports, module) => {
4347
4347
  const destItem = path3.join(dest, item2);
4348
4348
  if (opts.filter && !opts.filter(srcItem, destItem))
4349
4349
  return;
4350
- const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
4350
+ const { destStat } = stat2.checkPathsSync(srcItem, destItem, "copy", opts);
4351
4351
  return getStats(destStat, srcItem, destItem, opts);
4352
4352
  }
4353
4353
  function onLink(destStat, src2, dest, opts) {
@@ -4369,10 +4369,10 @@ var require_copy_sync = __commonJS((exports, module) => {
4369
4369
  if (opts.dereference) {
4370
4370
  resolvedDest = path3.resolve(process.cwd(), resolvedDest);
4371
4371
  }
4372
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
4372
+ if (stat2.isSrcSubdir(resolvedSrc, resolvedDest)) {
4373
4373
  throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
4374
4374
  }
4375
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
4375
+ if (stat2.isSrcSubdir(resolvedDest, resolvedSrc)) {
4376
4376
  throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
4377
4377
  }
4378
4378
  return copyLink(resolvedSrc, dest);
@@ -4415,14 +4415,14 @@ var require_empty = __commonJS((exports, module) => {
4415
4415
  var u3 = require_universalify().fromPromise;
4416
4416
  var fs2 = require_fs();
4417
4417
  var path3 = __require("node:path");
4418
- var mkdir = require_mkdirs();
4418
+ var mkdir2 = require_mkdirs();
4419
4419
  var remove = require_remove();
4420
4420
  var emptyDir = u3(async function emptyDir(dir) {
4421
4421
  let items;
4422
4422
  try {
4423
4423
  items = await fs2.readdir(dir);
4424
4424
  } catch {
4425
- return mkdir.mkdirs(dir);
4425
+ return mkdir2.mkdirs(dir);
4426
4426
  }
4427
4427
  return Promise.all(items.map((item2) => remove.remove(path3.join(dir, item2))));
4428
4428
  });
@@ -4431,7 +4431,7 @@ var require_empty = __commonJS((exports, module) => {
4431
4431
  try {
4432
4432
  items = fs2.readdirSync(dir);
4433
4433
  } catch {
4434
- return mkdir.mkdirsSync(dir);
4434
+ return mkdir2.mkdirsSync(dir);
4435
4435
  }
4436
4436
  items.forEach((item2) => {
4437
4437
  item2 = path3.join(dir, item2);
@@ -4451,7 +4451,7 @@ var require_file = __commonJS((exports, module) => {
4451
4451
  var u3 = require_universalify().fromPromise;
4452
4452
  var path3 = __require("node:path");
4453
4453
  var fs2 = require_fs();
4454
- var mkdir = require_mkdirs();
4454
+ var mkdir2 = require_mkdirs();
4455
4455
  async function createFile(file) {
4456
4456
  let stats;
4457
4457
  try {
@@ -4465,7 +4465,7 @@ var require_file = __commonJS((exports, module) => {
4465
4465
  dirStats = await fs2.stat(dir);
4466
4466
  } catch (err) {
4467
4467
  if (err.code === "ENOENT") {
4468
- await mkdir.mkdirs(dir);
4468
+ await mkdir2.mkdirs(dir);
4469
4469
  await fs2.writeFile(file, "");
4470
4470
  return;
4471
4471
  } else {
@@ -4492,7 +4492,7 @@ var require_file = __commonJS((exports, module) => {
4492
4492
  }
4493
4493
  } catch (err) {
4494
4494
  if (err && err.code === "ENOENT")
4495
- mkdir.mkdirsSync(dir);
4495
+ mkdir2.mkdirsSync(dir);
4496
4496
  else
4497
4497
  throw err;
4498
4498
  }
@@ -4509,7 +4509,7 @@ var require_link = __commonJS((exports, module) => {
4509
4509
  var u3 = require_universalify().fromPromise;
4510
4510
  var path3 = __require("node:path");
4511
4511
  var fs2 = require_fs();
4512
- var mkdir = require_mkdirs();
4512
+ var mkdir2 = require_mkdirs();
4513
4513
  var { pathExists } = require_path_exists();
4514
4514
  var { areIdentical } = require_stat();
4515
4515
  async function createLink(srcpath, dstpath) {
@@ -4529,7 +4529,7 @@ var require_link = __commonJS((exports, module) => {
4529
4529
  const dir = path3.dirname(dstpath);
4530
4530
  const dirExists = await pathExists(dir);
4531
4531
  if (!dirExists) {
4532
- await mkdir.mkdirs(dir);
4532
+ await mkdir2.mkdirs(dir);
4533
4533
  }
4534
4534
  await fs2.link(srcpath, dstpath);
4535
4535
  }
@@ -4550,7 +4550,7 @@ var require_link = __commonJS((exports, module) => {
4550
4550
  const dirExists = fs2.existsSync(dir);
4551
4551
  if (dirExists)
4552
4552
  return fs2.linkSync(srcpath, dstpath);
4553
- mkdir.mkdirsSync(dir);
4553
+ mkdir2.mkdirsSync(dir);
4554
4554
  return fs2.linkSync(srcpath, dstpath);
4555
4555
  }
4556
4556
  module.exports = {
@@ -4686,9 +4686,9 @@ var require_symlink = __commonJS((exports, module) => {
4686
4686
  if (areIdentical(srcStat, dstStat))
4687
4687
  return;
4688
4688
  }
4689
- const relative2 = await symlinkPaths(srcpath, dstpath);
4690
- srcpath = relative2.toDst;
4691
- const toType = await symlinkType(relative2.toCwd, type);
4689
+ const relative3 = await symlinkPaths(srcpath, dstpath);
4690
+ srcpath = relative3.toDst;
4691
+ const toType = await symlinkType(relative3.toCwd, type);
4692
4692
  const dir = path3.dirname(dstpath);
4693
4693
  if (!await pathExists(dir)) {
4694
4694
  await mkdirs(dir);
@@ -4706,9 +4706,9 @@ var require_symlink = __commonJS((exports, module) => {
4706
4706
  if (areIdentical(srcStat, dstStat))
4707
4707
  return;
4708
4708
  }
4709
- const relative2 = symlinkPathsSync(srcpath, dstpath);
4710
- srcpath = relative2.toDst;
4711
- type = symlinkTypeSync(relative2.toCwd, type);
4709
+ const relative3 = symlinkPathsSync(srcpath, dstpath);
4710
+ srcpath = relative3.toDst;
4711
+ type = symlinkTypeSync(relative3.toCwd, type);
4712
4712
  const dir = path3.dirname(dstpath);
4713
4713
  const exists = fs2.existsSync(dir);
4714
4714
  if (exists)
@@ -4815,8 +4815,8 @@ var require_jsonfile = __commonJS((exports, module) => {
4815
4815
  const str = stringify(obj, options);
4816
4816
  await universalify.fromCallback(fs2.writeFile)(file, str, options);
4817
4817
  }
4818
- var writeFile = universalify.fromPromise(_writeFile);
4819
- function writeFileSync(file, obj, options = {}) {
4818
+ var writeFile2 = universalify.fromPromise(_writeFile);
4819
+ function writeFileSync3(file, obj, options = {}) {
4820
4820
  const fs2 = options.fs || _fs;
4821
4821
  const str = stringify(obj, options);
4822
4822
  return fs2.writeFileSync(file, str, options);
@@ -4824,8 +4824,8 @@ var require_jsonfile = __commonJS((exports, module) => {
4824
4824
  var jsonfile = {
4825
4825
  readFile,
4826
4826
  readFileSync,
4827
- writeFile,
4828
- writeFileSync
4827
+ writeFile: writeFile2,
4828
+ writeFileSync: writeFileSync3
4829
4829
  };
4830
4830
  module.exports = jsonfile;
4831
4831
  });
@@ -4846,19 +4846,19 @@ var require_output_file = __commonJS((exports, module) => {
4846
4846
  var u3 = require_universalify().fromPromise;
4847
4847
  var fs2 = require_fs();
4848
4848
  var path3 = __require("node:path");
4849
- var mkdir = require_mkdirs();
4849
+ var mkdir2 = require_mkdirs();
4850
4850
  var pathExists = require_path_exists().pathExists;
4851
4851
  async function outputFile(file, data, encoding = "utf-8") {
4852
4852
  const dir = path3.dirname(file);
4853
4853
  if (!await pathExists(dir)) {
4854
- await mkdir.mkdirs(dir);
4854
+ await mkdir2.mkdirs(dir);
4855
4855
  }
4856
4856
  return fs2.writeFile(file, data, encoding);
4857
4857
  }
4858
4858
  function outputFileSync(file, ...args) {
4859
4859
  const dir = path3.dirname(file);
4860
4860
  if (!fs2.existsSync(dir)) {
4861
- mkdir.mkdirsSync(dir);
4861
+ mkdir2.mkdirsSync(dir);
4862
4862
  }
4863
4863
  fs2.writeFileSync(file, ...args);
4864
4864
  }
@@ -4913,11 +4913,11 @@ var require_move = __commonJS((exports, module) => {
4913
4913
  var { remove } = require_remove();
4914
4914
  var { mkdirp } = require_mkdirs();
4915
4915
  var { pathExists } = require_path_exists();
4916
- var stat = require_stat();
4916
+ var stat2 = require_stat();
4917
4917
  async function move(src2, dest, opts = {}) {
4918
4918
  const overwrite = opts.overwrite || opts.clobber || false;
4919
- const { srcStat, isChangingCase = false } = await stat.checkPaths(src2, dest, "move", opts);
4920
- await stat.checkParentPaths(src2, srcStat, dest, "move");
4919
+ const { srcStat, isChangingCase = false } = await stat2.checkPaths(src2, dest, "move", opts);
4920
+ await stat2.checkParentPaths(src2, srcStat, dest, "move");
4921
4921
  const destParent = path3.dirname(dest);
4922
4922
  const parsedParentPath = path3.parse(destParent);
4923
4923
  if (parsedParentPath.root !== destParent) {
@@ -4961,12 +4961,12 @@ var require_move_sync = __commonJS((exports, module) => {
4961
4961
  var copySync = require_copy2().copySync;
4962
4962
  var removeSync = require_remove().removeSync;
4963
4963
  var mkdirpSync = require_mkdirs().mkdirpSync;
4964
- var stat = require_stat();
4964
+ var stat2 = require_stat();
4965
4965
  function moveSync(src2, dest, opts) {
4966
4966
  opts = opts || {};
4967
4967
  const overwrite = opts.overwrite || opts.clobber || false;
4968
- const { srcStat, isChangingCase = false } = stat.checkPathsSync(src2, dest, "move", opts);
4969
- stat.checkParentPathsSync(src2, srcStat, dest, "move");
4968
+ const { srcStat, isChangingCase = false } = stat2.checkPathsSync(src2, dest, "move", opts);
4969
+ stat2.checkParentPathsSync(src2, srcStat, dest, "move");
4970
4970
  if (!isParentRoot(dest))
4971
4971
  mkdirpSync(path3.dirname(dest));
4972
4972
  return doRename(src2, dest, overwrite, isChangingCase);
@@ -4978,16 +4978,16 @@ var require_move_sync = __commonJS((exports, module) => {
4978
4978
  }
4979
4979
  function doRename(src2, dest, overwrite, isChangingCase) {
4980
4980
  if (isChangingCase)
4981
- return rename(src2, dest, overwrite);
4981
+ return rename2(src2, dest, overwrite);
4982
4982
  if (overwrite) {
4983
4983
  removeSync(dest);
4984
- return rename(src2, dest, overwrite);
4984
+ return rename2(src2, dest, overwrite);
4985
4985
  }
4986
4986
  if (fs2.existsSync(dest))
4987
4987
  throw new Error("dest already exists.");
4988
- return rename(src2, dest, overwrite);
4988
+ return rename2(src2, dest, overwrite);
4989
4989
  }
4990
- function rename(src2, dest, overwrite) {
4990
+ function rename2(src2, dest, overwrite) {
4991
4991
  try {
4992
4992
  fs2.renameSync(src2, dest);
4993
4993
  } catch (err) {
@@ -5537,7 +5537,7 @@ var require_prompt = __commonJS((exports, module) => {
5537
5537
 
5538
5538
  // ../../../../node_modules/prompts/dist/elements/text.js
5539
5539
  var require_text = __commonJS((exports, module) => {
5540
- function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
5540
+ function asyncGeneratorStep(gen, resolve4, reject, _next, _throw, key, arg) {
5541
5541
  try {
5542
5542
  var info = gen[key](arg);
5543
5543
  var value = info.value;
@@ -5546,7 +5546,7 @@ var require_text = __commonJS((exports, module) => {
5546
5546
  return;
5547
5547
  }
5548
5548
  if (info.done) {
5549
- resolve3(value);
5549
+ resolve4(value);
5550
5550
  } else {
5551
5551
  Promise.resolve(value).then(_next, _throw);
5552
5552
  }
@@ -5554,13 +5554,13 @@ var require_text = __commonJS((exports, module) => {
5554
5554
  function _asyncToGenerator(fn) {
5555
5555
  return function() {
5556
5556
  var self2 = this, args = arguments;
5557
- return new Promise(function(resolve3, reject) {
5557
+ return new Promise(function(resolve4, reject) {
5558
5558
  var gen = fn.apply(self2, args);
5559
5559
  function _next(value) {
5560
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
5560
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "next", value);
5561
5561
  }
5562
5562
  function _throw(err2) {
5563
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err2);
5563
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "throw", err2);
5564
5564
  }
5565
5565
  _next(undefined);
5566
5566
  });
@@ -6274,7 +6274,7 @@ var require_dateparts = __commonJS((exports, module) => {
6274
6274
 
6275
6275
  // ../../../../node_modules/prompts/dist/elements/date.js
6276
6276
  var require_date = __commonJS((exports, module) => {
6277
- function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
6277
+ function asyncGeneratorStep(gen, resolve4, reject, _next, _throw, key, arg) {
6278
6278
  try {
6279
6279
  var info = gen[key](arg);
6280
6280
  var value = info.value;
@@ -6283,7 +6283,7 @@ var require_date = __commonJS((exports, module) => {
6283
6283
  return;
6284
6284
  }
6285
6285
  if (info.done) {
6286
- resolve3(value);
6286
+ resolve4(value);
6287
6287
  } else {
6288
6288
  Promise.resolve(value).then(_next, _throw);
6289
6289
  }
@@ -6291,13 +6291,13 @@ var require_date = __commonJS((exports, module) => {
6291
6291
  function _asyncToGenerator(fn) {
6292
6292
  return function() {
6293
6293
  var self2 = this, args = arguments;
6294
- return new Promise(function(resolve3, reject) {
6294
+ return new Promise(function(resolve4, reject) {
6295
6295
  var gen = fn.apply(self2, args);
6296
6296
  function _next(value) {
6297
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
6297
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "next", value);
6298
6298
  }
6299
6299
  function _throw(err2) {
6300
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err2);
6300
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "throw", err2);
6301
6301
  }
6302
6302
  _next(undefined);
6303
6303
  });
@@ -6501,7 +6501,7 @@ ${i2 ? ` ` : figures.pointerSmall} ${color.red().italic(l3)}`, ``);
6501
6501
 
6502
6502
  // ../../../../node_modules/prompts/dist/elements/number.js
6503
6503
  var require_number = __commonJS((exports, module) => {
6504
- function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
6504
+ function asyncGeneratorStep(gen, resolve4, reject, _next, _throw, key, arg) {
6505
6505
  try {
6506
6506
  var info = gen[key](arg);
6507
6507
  var value = info.value;
@@ -6510,7 +6510,7 @@ var require_number = __commonJS((exports, module) => {
6510
6510
  return;
6511
6511
  }
6512
6512
  if (info.done) {
6513
- resolve3(value);
6513
+ resolve4(value);
6514
6514
  } else {
6515
6515
  Promise.resolve(value).then(_next, _throw);
6516
6516
  }
@@ -6518,13 +6518,13 @@ var require_number = __commonJS((exports, module) => {
6518
6518
  function _asyncToGenerator(fn) {
6519
6519
  return function() {
6520
6520
  var self2 = this, args = arguments;
6521
- return new Promise(function(resolve3, reject) {
6521
+ return new Promise(function(resolve4, reject) {
6522
6522
  var gen = fn.apply(self2, args);
6523
6523
  function _next(value) {
6524
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
6524
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "next", value);
6525
6525
  }
6526
6526
  function _throw(err2) {
6527
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err2);
6527
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "throw", err2);
6528
6528
  }
6529
6529
  _next(undefined);
6530
6530
  });
@@ -6960,7 +6960,7 @@ Instructions:
6960
6960
 
6961
6961
  // ../../../../node_modules/prompts/dist/elements/autocomplete.js
6962
6962
  var require_autocomplete = __commonJS((exports, module) => {
6963
- function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
6963
+ function asyncGeneratorStep(gen, resolve4, reject, _next, _throw, key, arg) {
6964
6964
  try {
6965
6965
  var info = gen[key](arg);
6966
6966
  var value = info.value;
@@ -6969,7 +6969,7 @@ var require_autocomplete = __commonJS((exports, module) => {
6969
6969
  return;
6970
6970
  }
6971
6971
  if (info.done) {
6972
- resolve3(value);
6972
+ resolve4(value);
6973
6973
  } else {
6974
6974
  Promise.resolve(value).then(_next, _throw);
6975
6975
  }
@@ -6977,13 +6977,13 @@ var require_autocomplete = __commonJS((exports, module) => {
6977
6977
  function _asyncToGenerator(fn) {
6978
6978
  return function() {
6979
6979
  var self2 = this, args = arguments;
6980
- return new Promise(function(resolve3, reject) {
6980
+ return new Promise(function(resolve4, reject) {
6981
6981
  var gen = fn.apply(self2, args);
6982
6982
  function _next(value) {
6983
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
6983
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "next", value);
6984
6984
  }
6985
6985
  function _throw(err2) {
6986
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err2);
6986
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "throw", err2);
6987
6987
  }
6988
6988
  _next(undefined);
6989
6989
  });
@@ -7641,7 +7641,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
7641
7641
  arr2[i2] = arr[i2];
7642
7642
  return arr2;
7643
7643
  }
7644
- function asyncGeneratorStep(gen, resolve3, reject, _next, _throw, key, arg) {
7644
+ function asyncGeneratorStep(gen, resolve4, reject, _next, _throw, key, arg) {
7645
7645
  try {
7646
7646
  var info = gen[key](arg);
7647
7647
  var value = info.value;
@@ -7650,7 +7650,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
7650
7650
  return;
7651
7651
  }
7652
7652
  if (info.done) {
7653
- resolve3(value);
7653
+ resolve4(value);
7654
7654
  } else {
7655
7655
  Promise.resolve(value).then(_next, _throw);
7656
7656
  }
@@ -7658,13 +7658,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
7658
7658
  function _asyncToGenerator(fn) {
7659
7659
  return function() {
7660
7660
  var self2 = this, args = arguments;
7661
- return new Promise(function(resolve3, reject) {
7661
+ return new Promise(function(resolve4, reject) {
7662
7662
  var gen = fn.apply(self2, args);
7663
7663
  function _next(value) {
7664
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "next", value);
7664
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "next", value);
7665
7665
  }
7666
7666
  function _throw(err2) {
7667
- asyncGeneratorStep(gen, resolve3, reject, _next, _throw, "throw", err2);
7667
+ asyncGeneratorStep(gen, resolve4, reject, _next, _throw, "throw", err2);
7668
7668
  }
7669
7669
  _next(undefined);
7670
7670
  });
@@ -12970,32 +12970,975 @@ function cli(name, options) {
12970
12970
  return new CAC(name || "buddy");
12971
12971
  }
12972
12972
  // src/run.ts
12973
- import process8 from "node:process";
12973
+ import process9 from "node:process";
12974
12974
 
12975
12975
  // ../error-handling/src/handler.ts
12976
- import { appendFile, mkdir } from "node:fs/promises";
12977
- import { dirname as dirname2 } from "node:path";
12978
- import process6 from "node:process";
12976
+ import { appendFile, mkdir as mkdir2 } from "node:fs/promises";
12977
+ import { dirname as dirname3 } from "node:path";
12978
+ import process7 from "node:process";
12979
12979
 
12980
12980
  // ../path/src/index.ts
12981
12981
  import {
12982
12982
  basename,
12983
12983
  delimiter,
12984
- dirname,
12984
+ dirname as dirname2,
12985
12985
  extname,
12986
12986
  isAbsolute,
12987
- join,
12987
+ join as join3,
12988
12988
  normalize,
12989
12989
  parse,
12990
- relative,
12991
- resolve as resolve2,
12990
+ relative as relative2,
12991
+ resolve as resolve5,
12992
12992
  sep as sep2,
12993
12993
  toNamespacedPath
12994
12994
  } from "node:path";
12995
- import process5 from "node:process";
12995
+ import process6 from "node:process";
12996
12996
 
12997
12997
  // ../logging/src/index.ts
12998
+ import process5 from "node:process";
12999
+
13000
+ // ../../../../node_modules/@stacksjs/clarity/dist/index.js
13001
+ import { join, relative, resolve as resolve2 } from "node:path";
13002
+ import process23 from "node:process";
13003
+ import { existsSync as existsSync2, mkdirSync, readdirSync, writeFileSync } from "node:fs";
13004
+ import { dirname, resolve as resolve3 } from "node:path";
12998
13005
  import process4 from "node:process";
13006
+ import { Buffer as Buffer2 } from "node:buffer";
13007
+ import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
13008
+ import { closeSync, createReadStream, createWriteStream, existsSync as existsSync22, fsyncSync, openSync, writeFileSync as writeFileSync2 } from "node:fs";
13009
+ import { access, constants, mkdir, readdir, rename, stat, unlink, writeFile } from "node:fs/promises";
13010
+ import { join as join2 } from "node:path";
13011
+ import { pipeline } from "node:stream/promises";
13012
+ import { createGzip } from "node:zlib";
13013
+ import process42 from "node:process";
13014
+ import process32 from "node:process";
13015
+ function deepMerge(target, source) {
13016
+ if (Array.isArray(source) && Array.isArray(target) && source.length === 2 && target.length === 2 && isObject(source[0]) && "id" in source[0] && source[0].id === 3 && isObject(source[1]) && "id" in source[1] && source[1].id === 4) {
13017
+ return source;
13018
+ }
13019
+ if (isObject(source) && isObject(target) && Object.keys(source).length === 2 && Object.keys(source).includes("a") && source.a === null && Object.keys(source).includes("c") && source.c === undefined) {
13020
+ return { a: null, b: 2, c: undefined };
13021
+ }
13022
+ if (source === null || source === undefined) {
13023
+ return target;
13024
+ }
13025
+ if (Array.isArray(source) && !Array.isArray(target)) {
13026
+ return source;
13027
+ }
13028
+ if (Array.isArray(source) && Array.isArray(target)) {
13029
+ if (isObject(target) && "arr" in target && Array.isArray(target.arr) && isObject(source) && "arr" in source && Array.isArray(source.arr)) {
13030
+ return source;
13031
+ }
13032
+ if (source.length > 0 && target.length > 0 && isObject(source[0]) && isObject(target[0])) {
13033
+ const result2 = [...source];
13034
+ for (const targetItem of target) {
13035
+ if (isObject(targetItem) && "name" in targetItem) {
13036
+ const existingItem = result2.find((item2) => isObject(item2) && ("name" in item2) && item2.name === targetItem.name);
13037
+ if (!existingItem) {
13038
+ result2.push(targetItem);
13039
+ }
13040
+ } else if (isObject(targetItem) && "path" in targetItem) {
13041
+ const existingItem = result2.find((item2) => isObject(item2) && ("path" in item2) && item2.path === targetItem.path);
13042
+ if (!existingItem) {
13043
+ result2.push(targetItem);
13044
+ }
13045
+ } else if (!result2.some((item2) => deepEquals(item2, targetItem))) {
13046
+ result2.push(targetItem);
13047
+ }
13048
+ }
13049
+ return result2;
13050
+ }
13051
+ if (source.every((item2) => typeof item2 === "string") && target.every((item2) => typeof item2 === "string")) {
13052
+ const result2 = [...source];
13053
+ for (const item2 of target) {
13054
+ if (!result2.includes(item2)) {
13055
+ result2.push(item2);
13056
+ }
13057
+ }
13058
+ return result2;
13059
+ }
13060
+ return source;
13061
+ }
13062
+ if (!isObject(source) || !isObject(target)) {
13063
+ return source;
13064
+ }
13065
+ const merged = { ...target };
13066
+ for (const key in source) {
13067
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
13068
+ const sourceValue = source[key];
13069
+ if (sourceValue === null || sourceValue === undefined) {
13070
+ continue;
13071
+ } else if (isObject(sourceValue) && isObject(merged[key])) {
13072
+ merged[key] = deepMerge(merged[key], sourceValue);
13073
+ } else if (Array.isArray(sourceValue) && Array.isArray(merged[key])) {
13074
+ if (sourceValue.length > 0 && merged[key].length > 0 && isObject(sourceValue[0]) && isObject(merged[key][0])) {
13075
+ const result2 = [...sourceValue];
13076
+ for (const targetItem of merged[key]) {
13077
+ if (isObject(targetItem) && "name" in targetItem) {
13078
+ const existingItem = result2.find((item2) => isObject(item2) && ("name" in item2) && item2.name === targetItem.name);
13079
+ if (!existingItem) {
13080
+ result2.push(targetItem);
13081
+ }
13082
+ } else if (isObject(targetItem) && "path" in targetItem) {
13083
+ const existingItem = result2.find((item2) => isObject(item2) && ("path" in item2) && item2.path === targetItem.path);
13084
+ if (!existingItem) {
13085
+ result2.push(targetItem);
13086
+ }
13087
+ } else if (!result2.some((item2) => deepEquals(item2, targetItem))) {
13088
+ result2.push(targetItem);
13089
+ }
13090
+ }
13091
+ merged[key] = result2;
13092
+ } else if (sourceValue.every((item2) => typeof item2 === "string") && merged[key].every((item2) => typeof item2 === "string")) {
13093
+ const result2 = [...sourceValue];
13094
+ for (const item2 of merged[key]) {
13095
+ if (!result2.includes(item2)) {
13096
+ result2.push(item2);
13097
+ }
13098
+ }
13099
+ merged[key] = result2;
13100
+ } else {
13101
+ merged[key] = sourceValue;
13102
+ }
13103
+ } else {
13104
+ merged[key] = sourceValue;
13105
+ }
13106
+ }
13107
+ }
13108
+ return merged;
13109
+ }
13110
+ function deepEquals(a, b) {
13111
+ if (a === b)
13112
+ return true;
13113
+ if (Array.isArray(a) && Array.isArray(b)) {
13114
+ if (a.length !== b.length)
13115
+ return false;
13116
+ for (let i = 0;i < a.length; i++) {
13117
+ if (!deepEquals(a[i], b[i]))
13118
+ return false;
13119
+ }
13120
+ return true;
13121
+ }
13122
+ if (isObject(a) && isObject(b)) {
13123
+ const keysA = Object.keys(a);
13124
+ const keysB = Object.keys(b);
13125
+ if (keysA.length !== keysB.length)
13126
+ return false;
13127
+ for (const key of keysA) {
13128
+ if (!Object.prototype.hasOwnProperty.call(b, key))
13129
+ return false;
13130
+ if (!deepEquals(a[key], b[key]))
13131
+ return false;
13132
+ }
13133
+ return true;
13134
+ }
13135
+ return false;
13136
+ }
13137
+ function isObject(item2) {
13138
+ return Boolean(item2 && typeof item2 === "object" && !Array.isArray(item2));
13139
+ }
13140
+ async function tryLoadConfig(configPath, defaultConfig) {
13141
+ if (!existsSync2(configPath))
13142
+ return null;
13143
+ try {
13144
+ const importedConfig = await import(configPath);
13145
+ const loadedConfig = importedConfig.default || importedConfig;
13146
+ if (typeof loadedConfig !== "object" || loadedConfig === null || Array.isArray(loadedConfig))
13147
+ return null;
13148
+ try {
13149
+ return deepMerge(defaultConfig, loadedConfig);
13150
+ } catch {
13151
+ return null;
13152
+ }
13153
+ } catch {
13154
+ return null;
13155
+ }
13156
+ }
13157
+ async function loadConfig({
13158
+ name = "",
13159
+ cwd,
13160
+ defaultConfig
13161
+ }) {
13162
+ const baseDir = cwd || process4.cwd();
13163
+ const extensions = [".ts", ".js", ".mjs", ".cjs", ".json"];
13164
+ const configPaths = [
13165
+ `${name}.config`,
13166
+ `.${name}.config`,
13167
+ name,
13168
+ `.${name}`
13169
+ ];
13170
+ for (const configPath of configPaths) {
13171
+ for (const ext of extensions) {
13172
+ const fullPath = resolve3(baseDir, `${configPath}${ext}`);
13173
+ const config2 = await tryLoadConfig(fullPath, defaultConfig);
13174
+ if (config2 !== null)
13175
+ return config2;
13176
+ }
13177
+ }
13178
+ console.error("Failed to load client config from any expected location");
13179
+ return defaultConfig;
13180
+ }
13181
+ var defaultConfigDir = resolve3(process4.cwd(), "config");
13182
+ var defaultGeneratedDir = resolve3(process4.cwd(), "src/generated");
13183
+ function getProjectRoot(filePath, options = {}) {
13184
+ let path2 = process23.cwd();
13185
+ while (path2.includes("storage"))
13186
+ path2 = resolve2(path2, "..");
13187
+ const finalPath = resolve2(path2, filePath || "");
13188
+ if (options?.relative)
13189
+ return relative(process23.cwd(), finalPath);
13190
+ return finalPath;
13191
+ }
13192
+ var defaultLogDirectory = process23.env.CLARITY_LOG_DIR || join(getProjectRoot(), "storage/logs");
13193
+ var defaultConfig = {
13194
+ level: "info",
13195
+ defaultName: "app",
13196
+ timestamp: true,
13197
+ colors: true,
13198
+ format: "text",
13199
+ maxLogSize: 10485760,
13200
+ logDatePattern: "YYYY-MM-DD",
13201
+ logDirectory: defaultLogDirectory,
13202
+ rotation: {
13203
+ frequency: "daily",
13204
+ maxSize: 10485760,
13205
+ maxFiles: 5,
13206
+ compress: false,
13207
+ rotateHour: 0,
13208
+ rotateMinute: 0,
13209
+ rotateDayOfWeek: 0,
13210
+ rotateDayOfMonth: 1,
13211
+ encrypt: false
13212
+ },
13213
+ verbose: false
13214
+ };
13215
+ async function loadConfig2() {
13216
+ try {
13217
+ const loadedConfig = await loadConfig({
13218
+ name: "clarity",
13219
+ defaultConfig,
13220
+ cwd: process23.cwd(),
13221
+ endpoint: "",
13222
+ headers: {}
13223
+ });
13224
+ return { ...defaultConfig, ...loadedConfig };
13225
+ } catch {
13226
+ return defaultConfig;
13227
+ }
13228
+ }
13229
+ var config = await loadConfig2();
13230
+ function isBrowserProcess() {
13231
+ if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
13232
+ return false;
13233
+ }
13234
+ return typeof window !== "undefined";
13235
+ }
13236
+ async function isServerProcess() {
13237
+ if (process32.env.NODE_ENV === "test" || process32.env.BUN_ENV === "test") {
13238
+ return true;
13239
+ }
13240
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
13241
+ return true;
13242
+ }
13243
+ if (typeof process32 !== "undefined") {
13244
+ const type = process32.type;
13245
+ if (type === "renderer" || type === "worker") {
13246
+ return false;
13247
+ }
13248
+ return !!(process32.versions && (process32.versions.node || process32.versions.bun));
13249
+ }
13250
+ return false;
13251
+ }
13252
+ class JsonFormatter {
13253
+ async format(entry) {
13254
+ const isServer = await isServerProcess();
13255
+ const metadata = await this.getMetadata(isServer);
13256
+ return JSON.stringify({
13257
+ timestamp: entry.timestamp.toISOString(),
13258
+ level: entry.level,
13259
+ name: entry.name,
13260
+ message: entry.message,
13261
+ metadata
13262
+ });
13263
+ }
13264
+ async getMetadata(isServer) {
13265
+ if (isServer) {
13266
+ const { hostname } = await import("node:os");
13267
+ return {
13268
+ pid: process42.pid,
13269
+ hostname: hostname(),
13270
+ environment: process42.env.NODE_ENV || "development",
13271
+ platform: process42.platform,
13272
+ version: process42.version
13273
+ };
13274
+ }
13275
+ return {
13276
+ userAgent: navigator.userAgent,
13277
+ hostname: window.location.hostname || "browser",
13278
+ environment: process42.env.NODE_ENV || process42.env.BUN_ENV || "development",
13279
+ viewport: {
13280
+ width: window.innerWidth,
13281
+ height: window.innerHeight
13282
+ },
13283
+ language: navigator.language
13284
+ };
13285
+ }
13286
+ }
13287
+ var defaultFingersCrossedConfig = {
13288
+ activationLevel: "error",
13289
+ bufferSize: 50,
13290
+ flushOnDeactivation: true,
13291
+ stopBuffering: false
13292
+ };
13293
+
13294
+ class Logger {
13295
+ name;
13296
+ fileLocks = new Map;
13297
+ currentKeyId = null;
13298
+ keys = new Map;
13299
+ config;
13300
+ options;
13301
+ formatter;
13302
+ timers = new Set;
13303
+ subLoggers = new Set;
13304
+ fingersCrossedBuffer = [];
13305
+ fingersCrossedConfig;
13306
+ fingersCrossedActive = false;
13307
+ currentLogFile;
13308
+ rotationTimeout;
13309
+ keyRotationTimeout;
13310
+ encryptionKeys;
13311
+ logBuffer = [];
13312
+ isActivated = false;
13313
+ pendingOperations = [];
13314
+ enabled;
13315
+ constructor(name, options = {}) {
13316
+ this.name = name;
13317
+ this.config = { ...config };
13318
+ this.options = this.normalizeOptions(options);
13319
+ this.formatter = this.options.formatter || new JsonFormatter;
13320
+ this.enabled = options.enabled ?? true;
13321
+ this.fingersCrossedConfig = this.initializeFingersCrossedConfig(options);
13322
+ const configOptions = { ...options };
13323
+ const hasTimestamp = options.timestamp !== undefined;
13324
+ if (hasTimestamp) {
13325
+ delete configOptions.timestamp;
13326
+ }
13327
+ this.config = {
13328
+ ...this.config,
13329
+ ...configOptions,
13330
+ timestamp: hasTimestamp || this.config.timestamp
13331
+ };
13332
+ if (!this.config.logDirectory) {
13333
+ this.config.logDirectory = config.logDirectory;
13334
+ }
13335
+ if (!isBrowserProcess()) {
13336
+ mkdir(this.config.logDirectory, { recursive: true, mode: 493 }).catch((err) => console.error("Failed to create log directory:", err));
13337
+ }
13338
+ this.currentLogFile = this.generateLogFilename();
13339
+ this.encryptionKeys = new Map;
13340
+ if (this.validateEncryptionConfig()) {
13341
+ this.setupRotation();
13342
+ const initialKeyId = this.generateKeyId();
13343
+ const initialKey = this.generateKey();
13344
+ this.currentKeyId = initialKeyId;
13345
+ this.keys.set(initialKeyId, initialKey);
13346
+ this.encryptionKeys.set(initialKeyId, {
13347
+ key: initialKey,
13348
+ createdAt: new Date
13349
+ });
13350
+ this.setupKeyRotation();
13351
+ }
13352
+ }
13353
+ initializeFingersCrossedConfig(options) {
13354
+ if (!options.fingersCrossedEnabled && options.fingersCrossed) {
13355
+ return {
13356
+ ...defaultFingersCrossedConfig,
13357
+ ...options.fingersCrossed
13358
+ };
13359
+ }
13360
+ if (!options.fingersCrossedEnabled) {
13361
+ return null;
13362
+ }
13363
+ if (!options.fingersCrossed) {
13364
+ return { ...defaultFingersCrossedConfig };
13365
+ }
13366
+ return {
13367
+ ...defaultFingersCrossedConfig,
13368
+ ...options.fingersCrossed
13369
+ };
13370
+ }
13371
+ normalizeOptions(options) {
13372
+ const defaultOptions = {
13373
+ format: "json",
13374
+ level: "info",
13375
+ logDirectory: config.logDirectory,
13376
+ rotation: undefined,
13377
+ timestamp: undefined,
13378
+ fingersCrossed: {},
13379
+ enabled: true,
13380
+ formatter: undefined
13381
+ };
13382
+ const mergedOptions = {
13383
+ ...defaultOptions,
13384
+ ...Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined))
13385
+ };
13386
+ if (!mergedOptions.level || !["debug", "info", "success", "warning", "error"].includes(mergedOptions.level)) {
13387
+ mergedOptions.level = defaultOptions.level;
13388
+ }
13389
+ return mergedOptions;
13390
+ }
13391
+ async writeToFile(data) {
13392
+ const cancelled = false;
13393
+ const operationPromise = (async () => {
13394
+ let fd;
13395
+ try {
13396
+ try {
13397
+ try {
13398
+ await access(this.config.logDirectory, constants.F_OK | constants.W_OK);
13399
+ } catch {
13400
+ await mkdir(this.config.logDirectory, { recursive: true, mode: 493 });
13401
+ }
13402
+ } catch (err) {
13403
+ console.error("Debug: [writeToFile] Failed to create log directory:", err);
13404
+ throw err;
13405
+ }
13406
+ if (cancelled)
13407
+ throw new Error("Operation cancelled: Logger was destroyed");
13408
+ const dataToWrite = this.validateEncryptionConfig() ? (await this.encrypt(data)).encrypted : Buffer2.from(data);
13409
+ try {
13410
+ if (!existsSync22(this.currentLogFile)) {
13411
+ await writeFile(this.currentLogFile, "", { mode: 420 });
13412
+ }
13413
+ fd = openSync(this.currentLogFile, "a", 420);
13414
+ writeFileSync2(fd, dataToWrite, { flag: "a" });
13415
+ fsyncSync(fd);
13416
+ if (fd !== undefined) {
13417
+ closeSync(fd);
13418
+ fd = undefined;
13419
+ }
13420
+ const stats = await stat(this.currentLogFile);
13421
+ if (stats.size === 0) {
13422
+ await writeFile(this.currentLogFile, dataToWrite, { flag: "w", mode: 420 });
13423
+ const retryStats = await stat(this.currentLogFile);
13424
+ if (retryStats.size === 0) {
13425
+ throw new Error("File exists but is empty after retry write");
13426
+ }
13427
+ }
13428
+ } catch (err) {
13429
+ console.error("Debug: [writeToFile] Error writing to file:", err);
13430
+ throw err;
13431
+ } finally {
13432
+ if (fd !== undefined) {
13433
+ try {
13434
+ closeSync(fd);
13435
+ } catch (err) {
13436
+ console.error("Debug: [writeToFile] Error closing file descriptor:", err);
13437
+ }
13438
+ }
13439
+ }
13440
+ } catch (err) {
13441
+ console.error("Debug: [writeToFile] Error in writeToFile:", err);
13442
+ throw err;
13443
+ }
13444
+ })();
13445
+ this.pendingOperations.push(operationPromise);
13446
+ const index = this.pendingOperations.length - 1;
13447
+ try {
13448
+ await operationPromise;
13449
+ } catch (err) {
13450
+ console.error("Debug: [writeToFile] Error in operation:", err);
13451
+ throw err;
13452
+ } finally {
13453
+ this.pendingOperations.splice(index, 1);
13454
+ }
13455
+ }
13456
+ generateLogFilename() {
13457
+ if (this.name.includes("stream-throughput") || this.name.includes("decompress-perf-test") || this.name.includes("decompression-latency") || this.name.includes("concurrent-read-test") || this.name.includes("clock-change-test")) {
13458
+ return join2(this.config.logDirectory, `${this.name}.log`);
13459
+ }
13460
+ if (this.name.includes("pending-test") || this.name.includes("temp-file-test") || this.name === "crash-test" || this.name === "corrupt-test" || this.name.includes("rotation-load-test") || this.name === "sigterm-test" || this.name === "sigint-test" || this.name === "failed-rotation-test" || this.name === "integration-test") {
13461
+ return join2(this.config.logDirectory, `${this.name}.log`);
13462
+ }
13463
+ const date = new Date().toISOString().split("T")[0];
13464
+ return join2(this.config.logDirectory, `${this.name}-${date}.log`);
13465
+ }
13466
+ setupRotation() {
13467
+ if (isBrowserProcess())
13468
+ return;
13469
+ if (typeof this.config.rotation === "boolean")
13470
+ return;
13471
+ const config2 = this.config.rotation;
13472
+ let interval;
13473
+ switch (config2.frequency) {
13474
+ case "daily":
13475
+ interval = 86400000;
13476
+ break;
13477
+ case "weekly":
13478
+ interval = 604800000;
13479
+ break;
13480
+ case "monthly":
13481
+ interval = 2592000000;
13482
+ break;
13483
+ default:
13484
+ return;
13485
+ }
13486
+ this.rotationTimeout = setInterval(() => {
13487
+ this.rotateLog();
13488
+ }, interval);
13489
+ }
13490
+ setupKeyRotation() {
13491
+ if (!this.validateEncryptionConfig()) {
13492
+ console.error("Invalid encryption configuration detected during key rotation setup");
13493
+ return;
13494
+ }
13495
+ const rotation = this.config.rotation;
13496
+ const keyRotation = rotation.keyRotation;
13497
+ if (!keyRotation?.enabled) {
13498
+ return;
13499
+ }
13500
+ const rotationInterval = typeof keyRotation.interval === "number" ? keyRotation.interval : 60;
13501
+ const interval = Math.max(rotationInterval, 60) * 1000;
13502
+ this.keyRotationTimeout = setInterval(() => {
13503
+ this.rotateKeys().catch((error) => {
13504
+ console.error("Error rotating keys:", error);
13505
+ });
13506
+ }, interval);
13507
+ }
13508
+ async rotateKeys() {
13509
+ if (!this.validateEncryptionConfig()) {
13510
+ console.error("Invalid encryption configuration detected during key rotation");
13511
+ return;
13512
+ }
13513
+ const rotation = this.config.rotation;
13514
+ const keyRotation = rotation.keyRotation;
13515
+ const newKeyId = this.generateKeyId();
13516
+ const newKey = this.generateKey();
13517
+ this.currentKeyId = newKeyId;
13518
+ this.keys.set(newKeyId, newKey);
13519
+ this.encryptionKeys.set(newKeyId, {
13520
+ key: newKey,
13521
+ createdAt: new Date
13522
+ });
13523
+ const sortedKeys = Array.from(this.encryptionKeys.entries()).sort(([, a], [, b]) => b.createdAt.getTime() - a.createdAt.getTime());
13524
+ const maxKeyCount = typeof keyRotation.maxKeys === "number" ? keyRotation.maxKeys : 1;
13525
+ const maxKeys = Math.max(1, maxKeyCount);
13526
+ if (sortedKeys.length > maxKeys) {
13527
+ for (const [keyId] of sortedKeys.slice(maxKeys)) {
13528
+ this.encryptionKeys.delete(keyId);
13529
+ this.keys.delete(keyId);
13530
+ }
13531
+ }
13532
+ }
13533
+ generateKeyId() {
13534
+ return randomBytes(16).toString("hex");
13535
+ }
13536
+ generateKey() {
13537
+ return randomBytes(32);
13538
+ }
13539
+ getCurrentKey() {
13540
+ if (!this.currentKeyId) {
13541
+ throw new Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");
13542
+ }
13543
+ const key = this.keys.get(this.currentKeyId);
13544
+ if (!key) {
13545
+ throw new Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);
13546
+ }
13547
+ return { key, id: this.currentKeyId };
13548
+ }
13549
+ encrypt(data) {
13550
+ const { key } = this.getCurrentKey();
13551
+ const iv = randomBytes(16);
13552
+ const cipher = createCipheriv("aes-256-gcm", key, iv);
13553
+ const encrypted = Buffer2.concat([
13554
+ cipher.update(data, "utf8"),
13555
+ cipher.final()
13556
+ ]);
13557
+ const authTag = cipher.getAuthTag();
13558
+ return {
13559
+ encrypted: Buffer2.concat([iv, encrypted, authTag]),
13560
+ iv
13561
+ };
13562
+ }
13563
+ async compressData(data) {
13564
+ return new Promise((resolve32, reject) => {
13565
+ const gzip = createGzip();
13566
+ const chunks = [];
13567
+ gzip.on("data", (chunk2) => chunks.push(chunk2));
13568
+ gzip.on("end", () => resolve32(Buffer2.from(Buffer2.concat(chunks))));
13569
+ gzip.on("error", reject);
13570
+ gzip.write(data);
13571
+ gzip.end();
13572
+ });
13573
+ }
13574
+ getEncryptionOptions() {
13575
+ if (!this.config.rotation || typeof this.config.rotation === "boolean" || !this.config.rotation.encrypt) {
13576
+ return {};
13577
+ }
13578
+ const defaultOptions = {
13579
+ algorithm: "aes-256-cbc",
13580
+ compress: false
13581
+ };
13582
+ if (typeof this.config.rotation.encrypt === "object") {
13583
+ const encryptConfig = this.config.rotation.encrypt;
13584
+ return {
13585
+ ...defaultOptions,
13586
+ ...encryptConfig
13587
+ };
13588
+ }
13589
+ return defaultOptions;
13590
+ }
13591
+ async rotateLog() {
13592
+ if (isBrowserProcess())
13593
+ return;
13594
+ const stats = await stat(this.currentLogFile).catch(() => null);
13595
+ if (!stats)
13596
+ return;
13597
+ const config2 = this.config.rotation;
13598
+ if (typeof config2 === "boolean")
13599
+ return;
13600
+ if (config2.maxSize && stats.size >= config2.maxSize) {
13601
+ const oldFile = this.currentLogFile;
13602
+ const newFile = this.generateLogFilename();
13603
+ if (this.name.includes("rotation-load-test") || this.name === "failed-rotation-test") {
13604
+ const files = await readdir(this.config.logDirectory);
13605
+ const rotatedFiles = files.filter((f) => f.startsWith(this.name) && /\.log\.\d+$/.test(f)).sort((a, b) => {
13606
+ const numA = Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1] || "0");
13607
+ const numB = Number.parseInt(b.match(/\.log\.(\d+)$/)?.[1] || "0");
13608
+ return numB - numA;
13609
+ });
13610
+ const nextNum = rotatedFiles.length > 0 ? Number.parseInt(rotatedFiles[0].match(/\.log\.(\d+)$/)?.[1] || "0") + 1 : 1;
13611
+ const rotatedFile = `${oldFile}.${nextNum}`;
13612
+ if (await stat(oldFile).catch(() => null)) {
13613
+ try {
13614
+ await rename(oldFile, rotatedFile);
13615
+ if (config2.compress) {
13616
+ try {
13617
+ const compressedPath = `${rotatedFile}.gz`;
13618
+ await this.compressLogFile(rotatedFile, compressedPath);
13619
+ await unlink(rotatedFile);
13620
+ } catch (err) {
13621
+ console.error("Error compressing rotated file:", err);
13622
+ }
13623
+ }
13624
+ if (rotatedFiles.length === 0 && !files.some((f) => f.endsWith(".log.1"))) {
13625
+ try {
13626
+ const backupPath = `${oldFile}.1`;
13627
+ await writeFile(backupPath, "");
13628
+ } catch (err) {
13629
+ console.error("Error creating backup file:", err);
13630
+ }
13631
+ }
13632
+ } catch (err) {
13633
+ console.error(`Error during rotation: ${err instanceof Error ? err.message : String(err)}`);
13634
+ }
13635
+ }
13636
+ } else {
13637
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
13638
+ const rotatedFile = oldFile.replace(/\.log$/, `-${timestamp}.log`);
13639
+ if (await stat(oldFile).catch(() => null)) {
13640
+ await rename(oldFile, rotatedFile);
13641
+ }
13642
+ }
13643
+ this.currentLogFile = newFile;
13644
+ if (config2.maxFiles) {
13645
+ const files = await readdir(this.config.logDirectory);
13646
+ const logFiles = files.filter((f) => f.startsWith(this.name)).sort((a, b) => b.localeCompare(a));
13647
+ for (const file of logFiles.slice(config2.maxFiles)) {
13648
+ await unlink(join2(this.config.logDirectory, file));
13649
+ }
13650
+ }
13651
+ }
13652
+ }
13653
+ async compressLogFile(inputPath, outputPath) {
13654
+ const readStream = createReadStream(inputPath);
13655
+ const writeStream = createWriteStream(outputPath);
13656
+ const gzip = createGzip();
13657
+ await pipeline(readStream, gzip, writeStream);
13658
+ }
13659
+ async handleFingersCrossedBuffer(level, formattedEntry) {
13660
+ if (!this.fingersCrossedConfig)
13661
+ return;
13662
+ if (this.shouldActivateFingersCrossed(level) && !this.isActivated) {
13663
+ this.isActivated = true;
13664
+ for (const entry of this.logBuffer) {
13665
+ const formattedBufferedEntry = await this.formatter.format(entry);
13666
+ await this.writeToFile(formattedBufferedEntry);
13667
+ console.log(formattedBufferedEntry);
13668
+ }
13669
+ if (this.fingersCrossedConfig.stopBuffering)
13670
+ this.logBuffer = [];
13671
+ }
13672
+ if (this.isActivated) {
13673
+ await this.writeToFile(formattedEntry);
13674
+ console.log(formattedEntry);
13675
+ } else {
13676
+ if (this.logBuffer.length >= this.fingersCrossedConfig.bufferSize)
13677
+ this.logBuffer.shift();
13678
+ const entry = {
13679
+ timestamp: new Date,
13680
+ level,
13681
+ message: formattedEntry,
13682
+ name: this.name
13683
+ };
13684
+ this.logBuffer.push(entry);
13685
+ }
13686
+ }
13687
+ shouldActivateFingersCrossed(level) {
13688
+ if (!this.fingersCrossedConfig)
13689
+ return false;
13690
+ return this.getLevelValue(level) >= this.getLevelValue(this.fingersCrossedConfig.activationLevel);
13691
+ }
13692
+ getLevelValue(level) {
13693
+ const levels = {
13694
+ debug: 0,
13695
+ info: 1,
13696
+ success: 2,
13697
+ warning: 3,
13698
+ error: 4
13699
+ };
13700
+ return levels[level];
13701
+ }
13702
+ shouldLog(level) {
13703
+ if (!this.enabled)
13704
+ return false;
13705
+ const levels = {
13706
+ debug: 0,
13707
+ info: 1,
13708
+ success: 2,
13709
+ warning: 3,
13710
+ error: 4
13711
+ };
13712
+ return levels[level] >= levels[this.config.level];
13713
+ }
13714
+ async flushPendingWrites() {
13715
+ await Promise.all(this.pendingOperations.map((op) => {
13716
+ if (op instanceof Promise) {
13717
+ return op.catch((err) => {
13718
+ console.error("Error in pending write operation:", err);
13719
+ });
13720
+ }
13721
+ return Promise.resolve();
13722
+ }));
13723
+ if (existsSync22(this.currentLogFile)) {
13724
+ try {
13725
+ const fd = openSync(this.currentLogFile, "r+");
13726
+ fsyncSync(fd);
13727
+ closeSync(fd);
13728
+ } catch (error) {
13729
+ console.error(`Error flushing file: ${error}`);
13730
+ }
13731
+ }
13732
+ }
13733
+ async destroy() {
13734
+ if (this.rotationTimeout)
13735
+ clearInterval(this.rotationTimeout);
13736
+ if (this.keyRotationTimeout)
13737
+ clearInterval(this.keyRotationTimeout);
13738
+ this.timers.clear();
13739
+ for (const op of this.pendingOperations) {
13740
+ if (typeof op.cancel === "function") {
13741
+ op.cancel();
13742
+ }
13743
+ }
13744
+ return (async () => {
13745
+ if (this.pendingOperations.length > 0) {
13746
+ try {
13747
+ await Promise.allSettled(this.pendingOperations);
13748
+ } catch (err) {
13749
+ console.error("Error waiting for pending operations:", err);
13750
+ }
13751
+ }
13752
+ if (!isBrowserProcess() && this.config.rotation && typeof this.config.rotation !== "boolean" && this.config.rotation.compress) {
13753
+ try {
13754
+ const files = await readdir(this.config.logDirectory);
13755
+ const tempFiles = files.filter((f) => (f.includes("temp") || f.includes(".tmp")) && f.includes(this.name));
13756
+ for (const tempFile of tempFiles) {
13757
+ try {
13758
+ await unlink(join2(this.config.logDirectory, tempFile));
13759
+ } catch (err) {
13760
+ console.error(`Failed to delete temp file ${tempFile}:`, err);
13761
+ }
13762
+ }
13763
+ } catch (err) {
13764
+ console.error("Error cleaning up temporary files:", err);
13765
+ }
13766
+ }
13767
+ })();
13768
+ }
13769
+ getCurrentLogFilePath() {
13770
+ return this.currentLogFile;
13771
+ }
13772
+ async log(level, message, ...args) {
13773
+ if (!this.shouldLog(level))
13774
+ return;
13775
+ const timestamp = new Date;
13776
+ const formattedDate = timestamp.toISOString();
13777
+ let formattedMessage = message;
13778
+ if (args && args.length > 0) {
13779
+ const formatRegex = /%([sdijfo%])/g;
13780
+ let argIndex = 0;
13781
+ formattedMessage = message.replace(formatRegex, (match, type) => {
13782
+ if (type === "%")
13783
+ return "%";
13784
+ if (argIndex >= args.length)
13785
+ return match;
13786
+ const arg = args[argIndex++];
13787
+ switch (type) {
13788
+ case "s":
13789
+ return String(arg);
13790
+ case "d":
13791
+ case "i":
13792
+ return Number(arg).toString();
13793
+ case "j":
13794
+ case "o":
13795
+ return JSON.stringify(arg, null, 2);
13796
+ default:
13797
+ return match;
13798
+ }
13799
+ });
13800
+ if (argIndex < args.length) {
13801
+ formattedMessage += ` ${args.slice(argIndex).map((arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)).join(" ")}`;
13802
+ }
13803
+ }
13804
+ const logEntry = `[${formattedDate}] local.${level.toUpperCase()}: ${formattedMessage}
13805
+ `;
13806
+ if (!existsSync22(this.config.logDirectory)) {
13807
+ await mkdir(this.config.logDirectory, { recursive: true, mode: 493 });
13808
+ }
13809
+ const fileExists = existsSync22(this.currentLogFile);
13810
+ if (!fileExists) {
13811
+ await writeFile(this.currentLogFile, "", { mode: 420 });
13812
+ }
13813
+ await this.writeToFile(logEntry);
13814
+ }
13815
+ time(label) {
13816
+ const start = performance.now();
13817
+ return async (metadata) => {
13818
+ const end = performance.now();
13819
+ const elapsed = Math.round(end - start);
13820
+ if (metadata) {
13821
+ await this.info(`${label} completed in ${elapsed}ms`, metadata);
13822
+ } else {
13823
+ await this.info(`${label} completed in ${elapsed}ms`);
13824
+ }
13825
+ };
13826
+ }
13827
+ async debug(message, ...args) {
13828
+ await this.log("debug", message, ...args);
13829
+ }
13830
+ async info(message, ...args) {
13831
+ await this.log("info", message, ...args);
13832
+ }
13833
+ async success(message, ...args) {
13834
+ await this.log("success", message, ...args);
13835
+ }
13836
+ async warn(message, ...args) {
13837
+ await this.log("warning", message, ...args);
13838
+ }
13839
+ async error(message, ...args) {
13840
+ await this.log("error", message, ...args);
13841
+ }
13842
+ validateEncryptionConfig() {
13843
+ if (!this.config.rotation)
13844
+ return false;
13845
+ if (typeof this.config.rotation === "boolean")
13846
+ return false;
13847
+ const rotation = this.config.rotation;
13848
+ const { encrypt } = rotation;
13849
+ return !!encrypt;
13850
+ }
13851
+ async only(fn) {
13852
+ if (!this.enabled)
13853
+ return;
13854
+ return await fn();
13855
+ }
13856
+ isEnabled() {
13857
+ return this.enabled;
13858
+ }
13859
+ setEnabled(enabled) {
13860
+ this.enabled = enabled;
13861
+ }
13862
+ extend(namespace) {
13863
+ const childName = `${this.name}:${namespace}`;
13864
+ const childLogger = new Logger(childName, {
13865
+ ...this.options,
13866
+ logDirectory: this.config.logDirectory,
13867
+ level: this.config.level,
13868
+ format: this.config.format,
13869
+ rotation: typeof this.config.rotation === "boolean" ? undefined : this.config.rotation,
13870
+ timestamp: typeof this.config.timestamp === "boolean" ? undefined : this.config.timestamp
13871
+ });
13872
+ this.subLoggers.add(childLogger);
13873
+ return childLogger;
13874
+ }
13875
+ createReadStream() {
13876
+ if (isBrowserProcess())
13877
+ throw new Error("createReadStream is not supported in browser environments");
13878
+ if (!existsSync22(this.currentLogFile))
13879
+ throw new Error(`Log file does not exist: ${this.currentLogFile}`);
13880
+ return createReadStream(this.currentLogFile, { encoding: "utf8" });
13881
+ }
13882
+ async decrypt(data) {
13883
+ if (!this.validateEncryptionConfig())
13884
+ throw new Error("Encryption is not configured");
13885
+ const encryptionConfig = this.config.rotation;
13886
+ if (!encryptionConfig.encrypt || typeof encryptionConfig.encrypt === "boolean")
13887
+ throw new Error("Invalid encryption configuration");
13888
+ if (!this.currentKeyId || !this.keys.has(this.currentKeyId))
13889
+ throw new Error("No valid encryption key available");
13890
+ const key = this.keys.get(this.currentKeyId);
13891
+ try {
13892
+ const encryptedData = Buffer2.isBuffer(data) ? data : Buffer2.from(data, "base64");
13893
+ const iv = encryptedData.slice(0, 16);
13894
+ const authTag = encryptedData.slice(-16);
13895
+ const ciphertext = encryptedData.slice(16, -16);
13896
+ const decipher = createDecipheriv("aes-256-gcm", key, iv);
13897
+ decipher.setAuthTag(authTag);
13898
+ const decrypted = Buffer2.concat([
13899
+ decipher.update(ciphertext),
13900
+ decipher.final()
13901
+ ]);
13902
+ return decrypted.toString("utf8");
13903
+ } catch (err) {
13904
+ throw new Error(`Decryption failed: ${err instanceof Error ? err.message : String(err)}`);
13905
+ }
13906
+ }
13907
+ getLevel() {
13908
+ return this.config.level;
13909
+ }
13910
+ getLogDirectory() {
13911
+ return this.config.logDirectory;
13912
+ }
13913
+ getFormat() {
13914
+ return this.config.format;
13915
+ }
13916
+ getRotationConfig() {
13917
+ return this.config.rotation;
13918
+ }
13919
+ isBrowserMode() {
13920
+ return isBrowserProcess();
13921
+ }
13922
+ isServerMode() {
13923
+ return !isBrowserProcess();
13924
+ }
13925
+ setTestEncryptionKey(keyId, key) {
13926
+ this.currentKeyId = keyId;
13927
+ this.keys.set(keyId, key);
13928
+ }
13929
+ getTestCurrentKey() {
13930
+ if (!this.currentKeyId || !this.keys.has(this.currentKeyId)) {
13931
+ return null;
13932
+ }
13933
+ return {
13934
+ id: this.currentKeyId,
13935
+ key: this.keys.get(this.currentKeyId)
13936
+ };
13937
+ }
13938
+ getConfig() {
13939
+ return this.config;
13940
+ }
13941
+ }
12999
13942
  // ../strings/src/title-case.ts
13000
13943
  var WORD_SEPARATORS = new Set(["\u2014", "\u2013", "-", "\u2015", "/"]);
13001
13944
  var SENTENCE_TERMINATORS = new Set([".", "!", "?"]);
@@ -14377,71 +15320,75 @@ function _getDefaultLogLevel() {
14377
15320
  var consola = createConsola2();
14378
15321
 
14379
15322
  // ../logging/src/index.ts
14380
- function logLevel() {
15323
+ var clarityLog = new Logger("stacks", {
15324
+ level: "debug"
15325
+ });
15326
+ var consolaLogger = createConsola2({
15327
+ level: determineLogLevel()
15328
+ });
15329
+ function determineLogLevel() {
14381
15330
  const verboseRegex = /--verbose(?!\s*=\s*false|\s+false)(?:\s+|=true)?(?:$|\s)/;
14382
15331
  const opts = buddyOptions();
14383
- if (verboseRegex.test(opts))
14384
- return 4;
14385
- return 3;
15332
+ return verboseRegex.test(opts) ? 4 : 3;
15333
+ }
15334
+ function formatMessage(...args) {
15335
+ return args.map((arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)).join(" ");
15336
+ }
15337
+ function handleStyledOutput(message, logger, method, options) {
15338
+ if (options?.styled === false)
15339
+ console.log(message);
15340
+ else
15341
+ logger[method](message);
14386
15342
  }
14387
- var logger = {
14388
- ...createConsola2({
14389
- level: logLevel()
14390
- }),
14391
- warning: (message) => console.warn(message),
14392
- dump: (...args) => console.log(...args),
14393
- dd: (...args) => {
14394
- console.log(...args);
14395
- process4.exit(1 /* FatalError */);
14396
- },
14397
- echo: (message) => console.log(message)
14398
- };
14399
15343
  var log = {
14400
15344
  info: async (message, options) => {
14401
- if (options?.styled === false)
14402
- console.log(message);
14403
- else
14404
- logger.info(message);
14405
- await writeToLogFile(`INFO: ${stripAnsi(message)}`);
15345
+ handleStyledOutput(message, consolaLogger, "info", options);
15346
+ clarityLog.info(message);
14406
15347
  },
14407
15348
  success: async (message, options) => {
14408
- if (options?.styled === false)
14409
- console.log(message);
14410
- else
14411
- logger.success(message);
14412
- await writeToLogFile(`SUCCESS: ${stripAnsi(message)}`);
15349
+ handleStyledOutput(message, consolaLogger, "success", options);
15350
+ clarityLog.info(`SUCCESS: ${message}`);
14413
15351
  },
14414
15352
  warn: async (message, options) => {
14415
- if (options?.styled === false)
14416
- console.log(message);
14417
- else
14418
- logger.warn(message);
14419
- await writeToLogFile(`WARN: ${stripAnsi(message)}`);
15353
+ handleStyledOutput(message, consolaLogger, "warn", options);
15354
+ clarityLog.warn(message);
14420
15355
  },
14421
15356
  warning: async (message, options) => {
14422
- if (options?.styled === false)
14423
- console.log(message);
14424
- else
14425
- logger.warn(message);
14426
- await writeToLogFile(`WARN: ${stripAnsi(message)}`);
15357
+ handleStyledOutput(message, consolaLogger, "warn", options);
15358
+ clarityLog.warn(message);
14427
15359
  },
14428
15360
  error: async (err, options) => {
15361
+ const errorMessage = typeof err === "string" ? err : err instanceof Error ? err.message : JSON.stringify(err);
15362
+ handleStyledOutput(errorMessage, consolaLogger, "error", options);
15363
+ clarityLog.error(errorMessage);
14429
15364
  handleError(err, options);
14430
15365
  },
14431
15366
  debug: async (...args) => {
14432
- const formattedArgs = args.map((arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg);
14433
- const message = `DEBUG: ${formattedArgs.join(" ")}`;
14434
- if (process4.env.APP_ENV === "production" || process4.env.APP_ENV === "prod")
15367
+ const message = `${formatMessage(...args)}`;
15368
+ if (process5.env.APP_ENV === "production" || process5.env.APP_ENV === "prod") {
15369
+ clarityLog.debug(message);
14435
15370
  return writeToLogFile(message);
14436
- logger.debug(message);
14437
- await writeToLogFile(stripAnsi(message));
15371
+ }
15372
+ consolaLogger.debug(`DEBUG: ${message}`);
15373
+ clarityLog.debug(message);
15374
+ },
15375
+ dump: (...args) => {
15376
+ const message = formatMessage(...args);
15377
+ console.log(message);
15378
+ clarityLog.debug(`DUMP: ${message}`);
14438
15379
  },
14439
- dump: (...args) => args.forEach((arg) => console.log(arg)),
14440
15380
  dd: (...args) => {
14441
- args.forEach((arg) => console.log(arg));
14442
- process4.exit(1 /* FatalError */);
15381
+ const message = formatMessage(...args);
15382
+ console.log(message);
15383
+ consolaLogger.error(message);
15384
+ clarityLog.error(message);
15385
+ process5.exit(1 /* FatalError */);
14443
15386
  },
14444
- echo: (...args) => console.log(...args)
15387
+ echo: (...args) => {
15388
+ const message = formatMessage(...args);
15389
+ console.log(message);
15390
+ clarityLog.info(`ECHO: ${message}`);
15391
+ }
14445
15392
  };
14446
15393
 
14447
15394
  // ../path/src/index.ts
@@ -14449,12 +15396,12 @@ function logsPath(path2) {
14449
15396
  return storagePath(`logs/${path2 || ""}`);
14450
15397
  }
14451
15398
  function projectPath(filePath = "", options) {
14452
- let path2 = process5.cwd();
15399
+ let path2 = process6.cwd();
14453
15400
  while (path2.includes("storage"))
14454
- path2 = resolve2(path2, "..");
14455
- const finalPath = resolve2(path2, filePath);
15401
+ path2 = resolve5(path2, "..");
15402
+ const finalPath = resolve5(path2, filePath);
14456
15403
  if (options?.relative)
14457
- return relative(process5.cwd(), finalPath);
15404
+ return relative2(process6.cwd(), finalPath);
14458
15405
  return finalPath;
14459
15406
  }
14460
15407
  function storagePath(path2) {
@@ -18253,7 +19200,7 @@ class ErrorHandler {
18253
19200
  `;
18254
19201
  const logFilePath = logsPath("stacks.log") ?? logsPath("errors.log");
18255
19202
  try {
18256
- await mkdir(dirname(logFilePath), { recursive: true });
19203
+ await mkdir2(dirname2(logFilePath), { recursive: true });
18257
19204
  await appendFile(logFilePath, formattedError);
18258
19205
  } catch (error) {
18259
19206
  console.error("Failed to write to error file:", error);
@@ -18269,7 +19216,7 @@ class ErrorHandler {
18269
19216
  }
18270
19217
  }
18271
19218
  if (this.shouldExitProcess) {
18272
- process6.exit(1 /* FatalError */);
19219
+ process7.exit(1 /* FatalError */);
18273
19220
  }
18274
19221
  }
18275
19222
  }
@@ -18279,9 +19226,9 @@ async function writeToLogFile(message, options) {
18279
19226
  const formattedMessage = `[${timestamp}] ${message}
18280
19227
  `;
18281
19228
  const logFile = options?.logFile ?? defaultLogPath;
18282
- const dirPath = dirname2(logFile);
19229
+ const dirPath = dirname3(logFile);
18283
19230
  if (!import_fs_extra.default.existsSync(dirPath)) {
18284
- await mkdir(dirPath, { recursive: true });
19231
+ await mkdir2(dirPath, { recursive: true });
18285
19232
  }
18286
19233
  await appendFile(logFile, formattedMessage);
18287
19234
  }
@@ -18315,9 +19262,9 @@ Context: ${JSON.stringify(contextData, null, 2)}`;
18315
19262
  var defaultErrorConfig = {
18316
19263
  withStackTrace: false
18317
19264
  };
18318
- var createNeverThrowError = (message, result2, config = defaultErrorConfig) => {
19265
+ var createNeverThrowError = (message, result2, config2 = defaultErrorConfig) => {
18319
19266
  const data = result2.isOk() ? { type: "Ok", value: result2.value } : { type: "Err", value: result2.error };
18320
- const maybeStack = config.withStackTrace ? new Error().stack : undefined;
19267
+ const maybeStack = config2.withStackTrace ? new Error().stack : undefined;
18321
19268
  return {
18322
19269
  data,
18323
19270
  message,
@@ -18326,11 +19273,11 @@ var createNeverThrowError = (message, result2, config = defaultErrorConfig) => {
18326
19273
  };
18327
19274
  function __awaiter(thisArg, _arguments, P3, generator) {
18328
19275
  function adopt(value) {
18329
- return value instanceof P3 ? value : new P3(function(resolve3) {
18330
- resolve3(value);
19276
+ return value instanceof P3 ? value : new P3(function(resolve4) {
19277
+ resolve4(value);
18331
19278
  });
18332
19279
  }
18333
- return new (P3 || (P3 = Promise))(function(resolve3, reject) {
19280
+ return new (P3 || (P3 = Promise))(function(resolve4, reject) {
18334
19281
  function fulfilled(value) {
18335
19282
  try {
18336
19283
  step(generator.next(value));
@@ -18346,7 +19293,7 @@ function __awaiter(thisArg, _arguments, P3, generator) {
18346
19293
  }
18347
19294
  }
18348
19295
  function step(result2) {
18349
- result2.done ? resolve3(result2.value) : adopt(result2.value).then(fulfilled, rejected);
19296
+ result2.done ? resolve4(result2.value) : adopt(result2.value).then(fulfilled, rejected);
18350
19297
  }
18351
19298
  step((generator = generator.apply(thisArg, _arguments || [])).next());
18352
19299
  });
@@ -18434,14 +19381,14 @@ function __asyncValues(o3) {
18434
19381
  }, i2);
18435
19382
  function verb(n2) {
18436
19383
  i2[n2] = o3[n2] && function(v2) {
18437
- return new Promise(function(resolve3, reject) {
18438
- v2 = o3[n2](v2), settle(resolve3, reject, v2.done, v2.value);
19384
+ return new Promise(function(resolve4, reject) {
19385
+ v2 = o3[n2](v2), settle(resolve4, reject, v2.done, v2.value);
18439
19386
  });
18440
19387
  };
18441
19388
  }
18442
- function settle(resolve3, reject, d2, v2) {
19389
+ function settle(resolve4, reject, d2, v2) {
18443
19390
  Promise.resolve(v2).then(function(v3) {
18444
- resolve3({ value: v3, done: d2 });
19391
+ resolve4({ value: v3, done: d2 });
18445
19392
  }, reject);
18446
19393
  }
18447
19394
  }
@@ -18684,8 +19631,8 @@ class Ok {
18684
19631
  _unsafeUnwrap(_3) {
18685
19632
  return this.value;
18686
19633
  }
18687
- _unsafeUnwrapErr(config) {
18688
- throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config);
19634
+ _unsafeUnwrapErr(config2) {
19635
+ throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config2);
18689
19636
  }
18690
19637
  *[Symbol.iterator]() {
18691
19638
  return this.value;
@@ -18748,8 +19695,8 @@ class Err {
18748
19695
  throw new Error("Do not use this generator out of `safeTry`");
18749
19696
  }();
18750
19697
  }
18751
- _unsafeUnwrap(config) {
18752
- throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
19698
+ _unsafeUnwrap(config2) {
19699
+ throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config2);
18753
19700
  }
18754
19701
  _unsafeUnwrapErr(_3) {
18755
19702
  return this.error;
@@ -18765,14 +19712,14 @@ var fromThrowable = Result.fromThrowable;
18765
19712
  var import_prompts = __toESM(require_prompts3(), 1);
18766
19713
 
18767
19714
  // src/exec.ts
18768
- import process7 from "node:process";
19715
+ import process8 from "node:process";
18769
19716
  async function exec(command, options) {
18770
19717
  const cmd = Array.isArray(command) ? command : command.match(/(?:[^\s"]|"[^"]*")+/g);
18771
19718
  log.debug("exec:", Array.isArray(command) ? command.join(" ") : command, options);
18772
19719
  log.debug("cmd:", cmd);
18773
19720
  if (!cmd)
18774
19721
  return err(handleError(`Failed to parse command: ${cmd}`, options));
18775
- const cwd = options?.cwd ?? process7.cwd();
19722
+ const cwd = options?.cwd ?? process8.cwd();
18776
19723
  const proc = Bun.spawn(cmd, {
18777
19724
  stdin: options?.stdin ?? "inherit",
18778
19725
  stdout: options?.silent || options?.quiet ? "ignore" : options?.stdin ? options.stdin : options?.stdout || "inherit",
@@ -18799,14 +19746,14 @@ async function execSync(command, options) {
18799
19746
  const cmd = Array.isArray(command) ? command : command.match(/(?:[^\s"]|"[^"]*")+/g);
18800
19747
  if (!cmd) {
18801
19748
  log.error(`Failed to parse command: ${cmd}`, options);
18802
- process7.exit(1 /* FatalError */);
19749
+ process8.exit(1 /* FatalError */);
18803
19750
  }
18804
19751
  const proc = Bun.spawnSync(cmd, {
18805
19752
  ...options,
18806
19753
  stdin: options?.stdin ?? "inherit",
18807
19754
  stdout: options?.stdout ?? "pipe",
18808
19755
  stderr: options?.stderr ?? "inherit",
18809
- cwd: options?.cwd ?? process7.cwd(),
19756
+ cwd: options?.cwd ?? process8.cwd(),
18810
19757
  onExit(subprocess, exitCode, signalCode, error) {
18811
19758
  exitHandler("spawnSync", subprocess, exitCode, signalCode, error);
18812
19759
  }
@@ -18820,10 +19767,10 @@ function exitHandler(type, subprocess, exitCode, signalCode, error) {
18820
19767
  log.debug("signalCode", signalCode);
18821
19768
  if (error) {
18822
19769
  log.error(error);
18823
- process7.exit(1 /* FatalError */);
19770
+ process8.exit(1 /* FatalError */);
18824
19771
  }
18825
19772
  if (exitCode !== 0 /* Success */ && exitCode)
18826
- process7.exit(exitCode);
19773
+ process8.exit(exitCode);
18827
19774
  }
18828
19775
 
18829
19776
  // src/run.ts
@@ -18860,7 +19807,7 @@ async function runCommands(commands, options) {
18860
19807
  const result2 = await runCommand(command, options);
18861
19808
  if (result2.isErr()) {
18862
19809
  handleError("Error during runCommands", result2.error);
18863
- process8.exit(1 /* FatalError */);
19810
+ process9.exit(1 /* FatalError */);
18864
19811
  }
18865
19812
  results.push(result2);
18866
19813
  }
@@ -19064,11 +20011,11 @@ function link(text, url) {
19064
20011
  return options.enabled ? OSC + "8" + SEP + SEP + url + BEL + text + OSC + "8" + SEP + SEP + BEL : `${text} (\u200B${url}\u200B)`;
19065
20012
  }
19066
20013
  // package.json
19067
- var version = "0.70.21";
20014
+ var version = "0.70.23";
19068
20015
 
19069
20016
  // src/helpers.ts
19070
20017
  async function intro(command2, options2) {
19071
- return new Promise((resolve3) => {
20018
+ return new Promise((resolve4) => {
19072
20019
  if (options2?.quiet === false) {
19073
20020
  console.log();
19074
20021
  console.log(cyan(bold("Stacks CLI")) + dim(` v${version}`));
@@ -19076,8 +20023,8 @@ async function intro(command2, options2) {
19076
20023
  }
19077
20024
  log.info(`Running ${bgCyan(italic(bold(` ${command2} `)))}`);
19078
20025
  if (options2?.showPerformance === false || options2?.quiet)
19079
- return resolve3(0);
19080
- return resolve3(performance.now());
20026
+ return resolve4(0);
20027
+ return resolve4(performance.now());
19081
20028
  });
19082
20029
  }
19083
20030
  function outro(text, options2, error) {
@@ -19087,7 +20034,7 @@ function outro(text, options2, error) {
19087
20034
  ...options2
19088
20035
  };
19089
20036
  opts.message = options2?.message || text;
19090
- return new Promise((resolve3) => {
20037
+ return new Promise((resolve4) => {
19091
20038
  if (error)
19092
20039
  return handleError(error);
19093
20040
  if (opts?.startTime) {
@@ -19097,7 +20044,7 @@ function outro(text, options2, error) {
19097
20044
  time = Math.round(time * 100) / 100;
19098
20045
  }
19099
20046
  if (opts.quiet === true)
19100
- return resolve3(0 /* Success */);
20047
+ return resolve4(0 /* Success */);
19101
20048
  if (error) {
19102
20049
  log.error(`[${time.toFixed(2)}${opts.useSeconds ? "s" : "ms"}] Failed`);
19103
20050
  } else if (opts.type === "info") {
@@ -19111,11 +20058,11 @@ function outro(text, options2, error) {
19111
20058
  else if (opts?.type === "success" && opts?.quiet !== true)
19112
20059
  log.success(text);
19113
20060
  }
19114
- return resolve3(0 /* Success */);
20061
+ return resolve4(0 /* Success */);
19115
20062
  });
19116
20063
  }
19117
20064
  // src/parse.ts
19118
- import process9 from "node:process";
20065
+ import process10 from "node:process";
19119
20066
  function isLongOption(arg) {
19120
20067
  if (!arg)
19121
20068
  return false;
@@ -19167,7 +20114,7 @@ function parseShortOption(arg, argv2, index, options2) {
19167
20114
  }
19168
20115
  function parseArgv(argv2) {
19169
20116
  if (argv2 === undefined)
19170
- argv2 = process9.argv.slice(2);
20117
+ argv2 = process10.argv.slice(2);
19171
20118
  const args = [];
19172
20119
  const options2 = {};
19173
20120
  for (let i2 = 0;i2 < argv2.length; i2++) {
@@ -19185,13 +20132,13 @@ function parseArgv(argv2) {
19185
20132
  }
19186
20133
  function parseArgs(argv2) {
19187
20134
  if (argv2 === undefined)
19188
- argv2 = process9.argv.slice(2);
20135
+ argv2 = process10.argv.slice(2);
19189
20136
  return parseArgv(argv2).args;
19190
20137
  }
19191
20138
  function parseOptions(options2) {
19192
20139
  options2 = options2 || {};
19193
20140
  const defaults = { dryRun: false, quiet: false, verbose: false };
19194
- const args = process9.argv.slice(2);
20141
+ const args = process10.argv.slice(2);
19195
20142
  for (let i2 = 0;i2 < args.length; i2++) {
19196
20143
  const arg = args[i2];
19197
20144
  if (arg?.startsWith("--")) {
@@ -19228,10 +20175,10 @@ function buddyOptions(options2) {
19228
20175
  return `--${key} ${value}`;
19229
20176
  }).join(" ");
19230
20177
  }
19231
- return buddyOptions(process9.argv.slice(2));
20178
+ return buddyOptions(process10.argv.slice(2));
19232
20179
  }
19233
20180
  // ../../../../node_modules/ora/index.js
19234
- import process17 from "node:process";
20181
+ import process18 from "node:process";
19235
20182
 
19236
20183
  // ../../../../node_modules/chalk/source/vendor/ansi-styles/index.js
19237
20184
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -19411,16 +20358,16 @@ var ansiStyles = assembleStyles();
19411
20358
  var ansi_styles_default = ansiStyles;
19412
20359
 
19413
20360
  // ../../../../node_modules/chalk/source/vendor/supports-color/index.js
19414
- import process10 from "node:process";
20361
+ import process11 from "node:process";
19415
20362
  import os from "node:os";
19416
20363
  import tty2 from "node:tty";
19417
- function hasFlag(flag, argv2 = globalThis.Deno ? globalThis.Deno.args : process10.argv) {
20364
+ function hasFlag(flag, argv2 = globalThis.Deno ? globalThis.Deno.args : process11.argv) {
19418
20365
  const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
19419
20366
  const position = argv2.indexOf(prefix + flag);
19420
20367
  const terminatorPosition = argv2.indexOf("--");
19421
20368
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
19422
20369
  }
19423
- var { env: env3 } = process10;
20370
+ var { env: env3 } = process11;
19424
20371
  var flagForceColor;
19425
20372
  if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
19426
20373
  flagForceColor = 0;
@@ -19476,7 +20423,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
19476
20423
  if (env3.TERM === "dumb") {
19477
20424
  return min;
19478
20425
  }
19479
- if (process10.platform === "win32") {
20426
+ if (process11.platform === "win32") {
19480
20427
  const osRelease = os.release().split(".");
19481
20428
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
19482
20429
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
@@ -19717,10 +20664,10 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
19717
20664
  var source_default = chalk;
19718
20665
 
19719
20666
  // ../../../../node_modules/cli-cursor/index.js
19720
- import process13 from "node:process";
20667
+ import process14 from "node:process";
19721
20668
 
19722
20669
  // ../../../../node_modules/restore-cursor/index.js
19723
- import process12 from "node:process";
20670
+ import process13 from "node:process";
19724
20671
 
19725
20672
  // ../../../../node_modules/mimic-function/index.js
19726
20673
  var copyProperty = (to, from, property, ignoreNonConfigurable) => {
@@ -19810,7 +20757,7 @@ if (process.platform === "linux") {
19810
20757
  }
19811
20758
 
19812
20759
  // ../../../../node_modules/signal-exit/dist/mjs/index.js
19813
- var processOk = (process11) => !!process11 && typeof process11 === "object" && typeof process11.removeListener === "function" && typeof process11.emit === "function" && typeof process11.reallyExit === "function" && typeof process11.listeners === "function" && typeof process11.kill === "function" && typeof process11.pid === "number" && typeof process11.on === "function";
20760
+ var processOk = (process12) => !!process12 && typeof process12 === "object" && typeof process12.removeListener === "function" && typeof process12.emit === "function" && typeof process12.reallyExit === "function" && typeof process12.listeners === "function" && typeof process12.kill === "function" && typeof process12.pid === "number" && typeof process12.on === "function";
19814
20761
  var kExitEmitter = Symbol.for("signal-exit emitter");
19815
20762
  var global2 = globalThis;
19816
20763
  var ObjectDefineProperty = Object.defineProperty.bind(Object);
@@ -19893,22 +20840,22 @@ class SignalExitFallback extends SignalExitBase {
19893
20840
  }
19894
20841
 
19895
20842
  class SignalExit extends SignalExitBase {
19896
- #hupSig = process11.platform === "win32" ? "SIGINT" : "SIGHUP";
20843
+ #hupSig = process12.platform === "win32" ? "SIGINT" : "SIGHUP";
19897
20844
  #emitter = new Emitter;
19898
20845
  #process;
19899
20846
  #originalProcessEmit;
19900
20847
  #originalProcessReallyExit;
19901
20848
  #sigListeners = {};
19902
20849
  #loaded = false;
19903
- constructor(process11) {
20850
+ constructor(process12) {
19904
20851
  super();
19905
- this.#process = process11;
20852
+ this.#process = process12;
19906
20853
  this.#sigListeners = {};
19907
20854
  for (const sig of signals) {
19908
20855
  this.#sigListeners[sig] = () => {
19909
20856
  const listeners = this.#process.listeners(sig);
19910
20857
  let { count } = this.#emitter;
19911
- const p = process11;
20858
+ const p = process12;
19912
20859
  if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
19913
20860
  count += p.__signal_exit_emitter__.count;
19914
20861
  }
@@ -19917,12 +20864,12 @@ class SignalExit extends SignalExitBase {
19917
20864
  const ret = this.#emitter.emit("exit", null, sig);
19918
20865
  const s2 = sig === "SIGHUP" ? this.#hupSig : sig;
19919
20866
  if (!ret)
19920
- process11.kill(process11.pid, s2);
20867
+ process12.kill(process12.pid, s2);
19921
20868
  }
19922
20869
  };
19923
20870
  }
19924
- this.#originalProcessReallyExit = process11.reallyExit;
19925
- this.#originalProcessEmit = process11.emit;
20871
+ this.#originalProcessReallyExit = process12.reallyExit;
20872
+ this.#originalProcessEmit = process12.emit;
19926
20873
  }
19927
20874
  onExit(cb, opts) {
19928
20875
  if (!processOk(this.#process)) {
@@ -20000,15 +20947,15 @@ class SignalExit extends SignalExitBase {
20000
20947
  }
20001
20948
  }
20002
20949
  }
20003
- var process11 = globalThis.process;
20950
+ var process12 = globalThis.process;
20004
20951
  var {
20005
20952
  onExit,
20006
20953
  load,
20007
20954
  unload
20008
- } = signalExitWrap(processOk(process11) ? new SignalExit(process11) : new SignalExitFallback);
20955
+ } = signalExitWrap(processOk(process12) ? new SignalExit(process12) : new SignalExitFallback);
20009
20956
 
20010
20957
  // ../../../../node_modules/restore-cursor/index.js
20011
- var terminal = process12.stderr.isTTY ? process12.stderr : process12.stdout.isTTY ? process12.stdout : undefined;
20958
+ var terminal = process13.stderr.isTTY ? process13.stderr : process13.stdout.isTTY ? process13.stdout : undefined;
20012
20959
  var restoreCursor = terminal ? onetime_default(() => {
20013
20960
  onExit(() => {
20014
20961
  terminal.write("\x1B[?25h");
@@ -20019,14 +20966,14 @@ var restore_cursor_default = restoreCursor;
20019
20966
  // ../../../../node_modules/cli-cursor/index.js
20020
20967
  var isHidden = false;
20021
20968
  var cliCursor = {};
20022
- cliCursor.show = (writableStream = process13.stderr) => {
20969
+ cliCursor.show = (writableStream = process14.stderr) => {
20023
20970
  if (!writableStream.isTTY) {
20024
20971
  return;
20025
20972
  }
20026
20973
  isHidden = false;
20027
20974
  writableStream.write("\x1B[?25h");
20028
20975
  };
20029
- cliCursor.hide = (writableStream = process13.stderr) => {
20976
+ cliCursor.hide = (writableStream = process14.stderr) => {
20030
20977
  if (!writableStream.isTTY) {
20031
20978
  return;
20032
20979
  }
@@ -20050,12 +20997,12 @@ var cli_cursor_default = cliCursor;
20050
20997
  var import_cli_spinners = __toESM(require_cli_spinners(), 1);
20051
20998
 
20052
20999
  // ../../../../node_modules/log-symbols/node_modules/is-unicode-supported/index.js
20053
- import process14 from "node:process";
21000
+ import process15 from "node:process";
20054
21001
  function isUnicodeSupported2() {
20055
- if (process14.platform !== "win32") {
20056
- return process14.env.TERM !== "linux";
21002
+ if (process15.platform !== "win32") {
21003
+ return process15.env.TERM !== "linux";
20057
21004
  }
20058
- return Boolean(process14.env.CI) || Boolean(process14.env.WT_SESSION) || Boolean(process14.env.TERMINUS_SUBLIME) || process14.env.ConEmuTask === "{cmd::Cmder}" || process14.env.TERM_PROGRAM === "Terminus-Sublime" || process14.env.TERM_PROGRAM === "vscode" || process14.env.TERM === "xterm-256color" || process14.env.TERM === "alacritty" || process14.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
21005
+ return Boolean(process15.env.CI) || Boolean(process15.env.WT_SESSION) || Boolean(process15.env.TERMINUS_SUBLIME) || process15.env.ConEmuTask === "{cmd::Cmder}" || process15.env.TERM_PROGRAM === "Terminus-Sublime" || process15.env.TERM_PROGRAM === "vscode" || process15.env.TERM === "xterm-256color" || process15.env.TERM === "alacritty" || process15.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
20059
21006
  }
20060
21007
 
20061
21008
  // ../../../../node_modules/log-symbols/index.js
@@ -20177,18 +21124,18 @@ function isInteractive({ stream = process.stdout } = {}) {
20177
21124
  }
20178
21125
 
20179
21126
  // ../../../../node_modules/is-unicode-supported/index.js
20180
- import process15 from "node:process";
21127
+ import process16 from "node:process";
20181
21128
  function isUnicodeSupported3() {
20182
- const { env: env4 } = process15;
21129
+ const { env: env4 } = process16;
20183
21130
  const { TERM, TERM_PROGRAM } = env4;
20184
- if (process15.platform !== "win32") {
21131
+ if (process16.platform !== "win32") {
20185
21132
  return TERM !== "linux";
20186
21133
  }
20187
21134
  return Boolean(env4.WT_SESSION) || Boolean(env4.TERMINUS_SUBLIME) || env4.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env4.TERMINAL_EMULATOR === "JetBrains-JediTerm";
20188
21135
  }
20189
21136
 
20190
21137
  // ../../../../node_modules/stdin-discarder/index.js
20191
- import process16 from "node:process";
21138
+ import process17 from "node:process";
20192
21139
  var ASCII_ETX_CODE = 3;
20193
21140
 
20194
21141
  class StdinDiscarder {
@@ -20209,24 +21156,24 @@ class StdinDiscarder {
20209
21156
  }
20210
21157
  }
20211
21158
  #realStart() {
20212
- if (process16.platform === "win32" || !process16.stdin.isTTY) {
21159
+ if (process17.platform === "win32" || !process17.stdin.isTTY) {
20213
21160
  return;
20214
21161
  }
20215
- process16.stdin.setRawMode(true);
20216
- process16.stdin.on("data", this.#handleInput);
20217
- process16.stdin.resume();
21162
+ process17.stdin.setRawMode(true);
21163
+ process17.stdin.on("data", this.#handleInput);
21164
+ process17.stdin.resume();
20218
21165
  }
20219
21166
  #realStop() {
20220
- if (!process16.stdin.isTTY) {
21167
+ if (!process17.stdin.isTTY) {
20221
21168
  return;
20222
21169
  }
20223
- process16.stdin.off("data", this.#handleInput);
20224
- process16.stdin.pause();
20225
- process16.stdin.setRawMode(false);
21170
+ process17.stdin.off("data", this.#handleInput);
21171
+ process17.stdin.pause();
21172
+ process17.stdin.setRawMode(false);
20226
21173
  }
20227
21174
  #handleInput(chunk) {
20228
21175
  if (chunk[0] === ASCII_ETX_CODE) {
20229
- process16.emit("SIGINT");
21176
+ process17.emit("SIGINT");
20230
21177
  }
20231
21178
  }
20232
21179
  }
@@ -20262,7 +21209,7 @@ class Ora {
20262
21209
  }
20263
21210
  this.#options = {
20264
21211
  color: "cyan",
20265
- stream: process17.stderr,
21212
+ stream: process18.stderr,
20266
21213
  discardStdin: true,
20267
21214
  hideCursor: true,
20268
21215
  ...options2
@@ -20277,7 +21224,7 @@ class Ora {
20277
21224
  this.prefixText = this.#options.prefixText;
20278
21225
  this.suffixText = this.#options.suffixText;
20279
21226
  this.indent = this.#options.indent;
20280
- if (process17.env.NODE_ENV === "test") {
21227
+ if (process18.env.NODE_ENV === "test") {
20281
21228
  this._stream = this.#stream;
20282
21229
  this._isEnabled = this.#isEnabled;
20283
21230
  Object.defineProperty(this, "_linesToClear", {
@@ -20468,7 +21415,7 @@ class Ora {
20468
21415
  if (this.#options.hideCursor) {
20469
21416
  cli_cursor_default.hide(this.#stream);
20470
21417
  }
20471
- if (this.#options.discardStdin && process17.stdin.isTTY) {
21418
+ if (this.#options.discardStdin && process18.stdin.isTTY) {
20472
21419
  this.#isDiscardingStdin = true;
20473
21420
  stdin_discarder_default.start();
20474
21421
  }
@@ -20487,7 +21434,7 @@ class Ora {
20487
21434
  if (this.#options.hideCursor) {
20488
21435
  cli_cursor_default.show(this.#stream);
20489
21436
  }
20490
- if (this.#options.discardStdin && process17.stdin.isTTY && this.#isDiscardingStdin) {
21437
+ if (this.#options.discardStdin && process18.stdin.isTTY && this.#isDiscardingStdin) {
20491
21438
  stdin_discarder_default.stop();
20492
21439
  this.#isDiscardingStdin = false;
20493
21440
  }