routesync 1.0.35 → 1.0.39

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 (3) hide show
  1. package/README.md +206 -28
  2. package/dist/cli.js +869 -564
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -983,8 +983,8 @@ var require_command = __commonJS({
983
983
  "use strict";
984
984
  var EventEmitter = require("events").EventEmitter;
985
985
  var childProcess = require("child_process");
986
- var path12 = require("path");
987
- var fs16 = require("fs");
986
+ var path13 = require("path");
987
+ var fs17 = require("fs");
988
988
  var process10 = require("process");
989
989
  var { Argument: Argument2, humanReadableArgName } = require_argument();
990
990
  var { CommanderError: CommanderError2 } = require_error();
@@ -1916,11 +1916,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1916
1916
  let launchWithNode = false;
1917
1917
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1918
1918
  function findFile(baseDir, baseName) {
1919
- const localBin = path12.resolve(baseDir, baseName);
1920
- if (fs16.existsSync(localBin)) return localBin;
1921
- if (sourceExt.includes(path12.extname(baseName))) return void 0;
1919
+ const localBin = path13.resolve(baseDir, baseName);
1920
+ if (fs17.existsSync(localBin)) return localBin;
1921
+ if (sourceExt.includes(path13.extname(baseName))) return void 0;
1922
1922
  const foundExt = sourceExt.find(
1923
- (ext) => fs16.existsSync(`${localBin}${ext}`)
1923
+ (ext) => fs17.existsSync(`${localBin}${ext}`)
1924
1924
  );
1925
1925
  if (foundExt) return `${localBin}${foundExt}`;
1926
1926
  return void 0;
@@ -1932,21 +1932,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1932
1932
  if (this._scriptPath) {
1933
1933
  let resolvedScriptPath;
1934
1934
  try {
1935
- resolvedScriptPath = fs16.realpathSync(this._scriptPath);
1935
+ resolvedScriptPath = fs17.realpathSync(this._scriptPath);
1936
1936
  } catch (err) {
1937
1937
  resolvedScriptPath = this._scriptPath;
1938
1938
  }
1939
- executableDir = path12.resolve(
1940
- path12.dirname(resolvedScriptPath),
1939
+ executableDir = path13.resolve(
1940
+ path13.dirname(resolvedScriptPath),
1941
1941
  executableDir
1942
1942
  );
1943
1943
  }
1944
1944
  if (executableDir) {
1945
1945
  let localFile = findFile(executableDir, executableFile);
1946
1946
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1947
- const legacyName = path12.basename(
1947
+ const legacyName = path13.basename(
1948
1948
  this._scriptPath,
1949
- path12.extname(this._scriptPath)
1949
+ path13.extname(this._scriptPath)
1950
1950
  );
1951
1951
  if (legacyName !== this._name) {
1952
1952
  localFile = findFile(
@@ -1957,7 +1957,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1957
1957
  }
1958
1958
  executableFile = localFile || executableFile;
1959
1959
  }
1960
- launchWithNode = sourceExt.includes(path12.extname(executableFile));
1960
+ launchWithNode = sourceExt.includes(path13.extname(executableFile));
1961
1961
  let proc;
1962
1962
  if (process10.platform !== "win32") {
1963
1963
  if (launchWithNode) {
@@ -2797,7 +2797,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2797
2797
  * @return {Command}
2798
2798
  */
2799
2799
  nameFromFilename(filename) {
2800
- this._name = path12.basename(filename, path12.extname(filename));
2800
+ this._name = path13.basename(filename, path13.extname(filename));
2801
2801
  return this;
2802
2802
  }
2803
2803
  /**
@@ -2811,9 +2811,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2811
2811
  * @param {string} [path]
2812
2812
  * @return {(string|null|Command)}
2813
2813
  */
2814
- executableDir(path13) {
2815
- if (path13 === void 0) return this._executableDir;
2816
- this._executableDir = path13;
2814
+ executableDir(path14) {
2815
+ if (path14 === void 0) return this._executableDir;
2816
+ this._executableDir = path14;
2817
2817
  return this;
2818
2818
  }
2819
2819
  /**
@@ -4744,54 +4744,54 @@ var require_polyfills = __commonJS({
4744
4744
  }
4745
4745
  var chdir;
4746
4746
  module2.exports = patch;
4747
- function patch(fs16) {
4747
+ function patch(fs17) {
4748
4748
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
4749
- patchLchmod(fs16);
4750
- }
4751
- if (!fs16.lutimes) {
4752
- patchLutimes(fs16);
4753
- }
4754
- fs16.chown = chownFix(fs16.chown);
4755
- fs16.fchown = chownFix(fs16.fchown);
4756
- fs16.lchown = chownFix(fs16.lchown);
4757
- fs16.chmod = chmodFix(fs16.chmod);
4758
- fs16.fchmod = chmodFix(fs16.fchmod);
4759
- fs16.lchmod = chmodFix(fs16.lchmod);
4760
- fs16.chownSync = chownFixSync(fs16.chownSync);
4761
- fs16.fchownSync = chownFixSync(fs16.fchownSync);
4762
- fs16.lchownSync = chownFixSync(fs16.lchownSync);
4763
- fs16.chmodSync = chmodFixSync(fs16.chmodSync);
4764
- fs16.fchmodSync = chmodFixSync(fs16.fchmodSync);
4765
- fs16.lchmodSync = chmodFixSync(fs16.lchmodSync);
4766
- fs16.stat = statFix(fs16.stat);
4767
- fs16.fstat = statFix(fs16.fstat);
4768
- fs16.lstat = statFix(fs16.lstat);
4769
- fs16.statSync = statFixSync(fs16.statSync);
4770
- fs16.fstatSync = statFixSync(fs16.fstatSync);
4771
- fs16.lstatSync = statFixSync(fs16.lstatSync);
4772
- if (fs16.chmod && !fs16.lchmod) {
4773
- fs16.lchmod = function(path12, mode, cb) {
4749
+ patchLchmod(fs17);
4750
+ }
4751
+ if (!fs17.lutimes) {
4752
+ patchLutimes(fs17);
4753
+ }
4754
+ fs17.chown = chownFix(fs17.chown);
4755
+ fs17.fchown = chownFix(fs17.fchown);
4756
+ fs17.lchown = chownFix(fs17.lchown);
4757
+ fs17.chmod = chmodFix(fs17.chmod);
4758
+ fs17.fchmod = chmodFix(fs17.fchmod);
4759
+ fs17.lchmod = chmodFix(fs17.lchmod);
4760
+ fs17.chownSync = chownFixSync(fs17.chownSync);
4761
+ fs17.fchownSync = chownFixSync(fs17.fchownSync);
4762
+ fs17.lchownSync = chownFixSync(fs17.lchownSync);
4763
+ fs17.chmodSync = chmodFixSync(fs17.chmodSync);
4764
+ fs17.fchmodSync = chmodFixSync(fs17.fchmodSync);
4765
+ fs17.lchmodSync = chmodFixSync(fs17.lchmodSync);
4766
+ fs17.stat = statFix(fs17.stat);
4767
+ fs17.fstat = statFix(fs17.fstat);
4768
+ fs17.lstat = statFix(fs17.lstat);
4769
+ fs17.statSync = statFixSync(fs17.statSync);
4770
+ fs17.fstatSync = statFixSync(fs17.fstatSync);
4771
+ fs17.lstatSync = statFixSync(fs17.lstatSync);
4772
+ if (fs17.chmod && !fs17.lchmod) {
4773
+ fs17.lchmod = function(path13, mode, cb) {
4774
4774
  if (cb) process.nextTick(cb);
4775
4775
  };
4776
- fs16.lchmodSync = function() {
4776
+ fs17.lchmodSync = function() {
4777
4777
  };
4778
4778
  }
4779
- if (fs16.chown && !fs16.lchown) {
4780
- fs16.lchown = function(path12, uid, gid, cb) {
4779
+ if (fs17.chown && !fs17.lchown) {
4780
+ fs17.lchown = function(path13, uid, gid, cb) {
4781
4781
  if (cb) process.nextTick(cb);
4782
4782
  };
4783
- fs16.lchownSync = function() {
4783
+ fs17.lchownSync = function() {
4784
4784
  };
4785
4785
  }
4786
4786
  if (platform === "win32") {
4787
- fs16.rename = typeof fs16.rename !== "function" ? fs16.rename : (function(fs$rename) {
4787
+ fs17.rename = typeof fs17.rename !== "function" ? fs17.rename : (function(fs$rename) {
4788
4788
  function rename(from, to, cb) {
4789
4789
  var start = Date.now();
4790
4790
  var backoff = 0;
4791
4791
  fs$rename(from, to, function CB(er) {
4792
4792
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
4793
4793
  setTimeout(function() {
4794
- fs16.stat(to, function(stater, st) {
4794
+ fs17.stat(to, function(stater, st) {
4795
4795
  if (stater && stater.code === "ENOENT")
4796
4796
  fs$rename(from, to, CB);
4797
4797
  else
@@ -4807,9 +4807,9 @@ var require_polyfills = __commonJS({
4807
4807
  }
4808
4808
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
4809
4809
  return rename;
4810
- })(fs16.rename);
4810
+ })(fs17.rename);
4811
4811
  }
4812
- fs16.read = typeof fs16.read !== "function" ? fs16.read : (function(fs$read) {
4812
+ fs17.read = typeof fs17.read !== "function" ? fs17.read : (function(fs$read) {
4813
4813
  function read(fd, buffer, offset, length, position, callback_) {
4814
4814
  var callback;
4815
4815
  if (callback_ && typeof callback_ === "function") {
@@ -4817,22 +4817,22 @@ var require_polyfills = __commonJS({
4817
4817
  callback = function(er, _, __) {
4818
4818
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
4819
4819
  eagCounter++;
4820
- return fs$read.call(fs16, fd, buffer, offset, length, position, callback);
4820
+ return fs$read.call(fs17, fd, buffer, offset, length, position, callback);
4821
4821
  }
4822
4822
  callback_.apply(this, arguments);
4823
4823
  };
4824
4824
  }
4825
- return fs$read.call(fs16, fd, buffer, offset, length, position, callback);
4825
+ return fs$read.call(fs17, fd, buffer, offset, length, position, callback);
4826
4826
  }
4827
4827
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
4828
4828
  return read;
4829
- })(fs16.read);
4830
- fs16.readSync = typeof fs16.readSync !== "function" ? fs16.readSync : /* @__PURE__ */ (function(fs$readSync) {
4829
+ })(fs17.read);
4830
+ fs17.readSync = typeof fs17.readSync !== "function" ? fs17.readSync : /* @__PURE__ */ (function(fs$readSync) {
4831
4831
  return function(fd, buffer, offset, length, position) {
4832
4832
  var eagCounter = 0;
4833
4833
  while (true) {
4834
4834
  try {
4835
- return fs$readSync.call(fs16, fd, buffer, offset, length, position);
4835
+ return fs$readSync.call(fs17, fd, buffer, offset, length, position);
4836
4836
  } catch (er) {
4837
4837
  if (er.code === "EAGAIN" && eagCounter < 10) {
4838
4838
  eagCounter++;
@@ -4842,11 +4842,11 @@ var require_polyfills = __commonJS({
4842
4842
  }
4843
4843
  }
4844
4844
  };
4845
- })(fs16.readSync);
4846
- function patchLchmod(fs17) {
4847
- fs17.lchmod = function(path12, mode, callback) {
4848
- fs17.open(
4849
- path12,
4845
+ })(fs17.readSync);
4846
+ function patchLchmod(fs18) {
4847
+ fs18.lchmod = function(path13, mode, callback) {
4848
+ fs18.open(
4849
+ path13,
4850
4850
  constants.O_WRONLY | constants.O_SYMLINK,
4851
4851
  mode,
4852
4852
  function(err, fd) {
@@ -4854,80 +4854,80 @@ var require_polyfills = __commonJS({
4854
4854
  if (callback) callback(err);
4855
4855
  return;
4856
4856
  }
4857
- fs17.fchmod(fd, mode, function(err2) {
4858
- fs17.close(fd, function(err22) {
4857
+ fs18.fchmod(fd, mode, function(err2) {
4858
+ fs18.close(fd, function(err22) {
4859
4859
  if (callback) callback(err2 || err22);
4860
4860
  });
4861
4861
  });
4862
4862
  }
4863
4863
  );
4864
4864
  };
4865
- fs17.lchmodSync = function(path12, mode) {
4866
- var fd = fs17.openSync(path12, constants.O_WRONLY | constants.O_SYMLINK, mode);
4865
+ fs18.lchmodSync = function(path13, mode) {
4866
+ var fd = fs18.openSync(path13, constants.O_WRONLY | constants.O_SYMLINK, mode);
4867
4867
  var threw = true;
4868
4868
  var ret;
4869
4869
  try {
4870
- ret = fs17.fchmodSync(fd, mode);
4870
+ ret = fs18.fchmodSync(fd, mode);
4871
4871
  threw = false;
4872
4872
  } finally {
4873
4873
  if (threw) {
4874
4874
  try {
4875
- fs17.closeSync(fd);
4875
+ fs18.closeSync(fd);
4876
4876
  } catch (er) {
4877
4877
  }
4878
4878
  } else {
4879
- fs17.closeSync(fd);
4879
+ fs18.closeSync(fd);
4880
4880
  }
4881
4881
  }
4882
4882
  return ret;
4883
4883
  };
4884
4884
  }
4885
- function patchLutimes(fs17) {
4886
- if (constants.hasOwnProperty("O_SYMLINK") && fs17.futimes) {
4887
- fs17.lutimes = function(path12, at, mt, cb) {
4888
- fs17.open(path12, constants.O_SYMLINK, function(er, fd) {
4885
+ function patchLutimes(fs18) {
4886
+ if (constants.hasOwnProperty("O_SYMLINK") && fs18.futimes) {
4887
+ fs18.lutimes = function(path13, at, mt, cb) {
4888
+ fs18.open(path13, constants.O_SYMLINK, function(er, fd) {
4889
4889
  if (er) {
4890
4890
  if (cb) cb(er);
4891
4891
  return;
4892
4892
  }
4893
- fs17.futimes(fd, at, mt, function(er2) {
4894
- fs17.close(fd, function(er22) {
4893
+ fs18.futimes(fd, at, mt, function(er2) {
4894
+ fs18.close(fd, function(er22) {
4895
4895
  if (cb) cb(er2 || er22);
4896
4896
  });
4897
4897
  });
4898
4898
  });
4899
4899
  };
4900
- fs17.lutimesSync = function(path12, at, mt) {
4901
- var fd = fs17.openSync(path12, constants.O_SYMLINK);
4900
+ fs18.lutimesSync = function(path13, at, mt) {
4901
+ var fd = fs18.openSync(path13, constants.O_SYMLINK);
4902
4902
  var ret;
4903
4903
  var threw = true;
4904
4904
  try {
4905
- ret = fs17.futimesSync(fd, at, mt);
4905
+ ret = fs18.futimesSync(fd, at, mt);
4906
4906
  threw = false;
4907
4907
  } finally {
4908
4908
  if (threw) {
4909
4909
  try {
4910
- fs17.closeSync(fd);
4910
+ fs18.closeSync(fd);
4911
4911
  } catch (er) {
4912
4912
  }
4913
4913
  } else {
4914
- fs17.closeSync(fd);
4914
+ fs18.closeSync(fd);
4915
4915
  }
4916
4916
  }
4917
4917
  return ret;
4918
4918
  };
4919
- } else if (fs17.futimes) {
4920
- fs17.lutimes = function(_a, _b, _c, cb) {
4919
+ } else if (fs18.futimes) {
4920
+ fs18.lutimes = function(_a, _b, _c, cb) {
4921
4921
  if (cb) process.nextTick(cb);
4922
4922
  };
4923
- fs17.lutimesSync = function() {
4923
+ fs18.lutimesSync = function() {
4924
4924
  };
4925
4925
  }
4926
4926
  }
4927
4927
  function chmodFix(orig) {
4928
4928
  if (!orig) return orig;
4929
4929
  return function(target, mode, cb) {
4930
- return orig.call(fs16, target, mode, function(er) {
4930
+ return orig.call(fs17, target, mode, function(er) {
4931
4931
  if (chownErOk(er)) er = null;
4932
4932
  if (cb) cb.apply(this, arguments);
4933
4933
  });
@@ -4937,7 +4937,7 @@ var require_polyfills = __commonJS({
4937
4937
  if (!orig) return orig;
4938
4938
  return function(target, mode) {
4939
4939
  try {
4940
- return orig.call(fs16, target, mode);
4940
+ return orig.call(fs17, target, mode);
4941
4941
  } catch (er) {
4942
4942
  if (!chownErOk(er)) throw er;
4943
4943
  }
@@ -4946,7 +4946,7 @@ var require_polyfills = __commonJS({
4946
4946
  function chownFix(orig) {
4947
4947
  if (!orig) return orig;
4948
4948
  return function(target, uid, gid, cb) {
4949
- return orig.call(fs16, target, uid, gid, function(er) {
4949
+ return orig.call(fs17, target, uid, gid, function(er) {
4950
4950
  if (chownErOk(er)) er = null;
4951
4951
  if (cb) cb.apply(this, arguments);
4952
4952
  });
@@ -4956,7 +4956,7 @@ var require_polyfills = __commonJS({
4956
4956
  if (!orig) return orig;
4957
4957
  return function(target, uid, gid) {
4958
4958
  try {
4959
- return orig.call(fs16, target, uid, gid);
4959
+ return orig.call(fs17, target, uid, gid);
4960
4960
  } catch (er) {
4961
4961
  if (!chownErOk(er)) throw er;
4962
4962
  }
@@ -4976,13 +4976,13 @@ var require_polyfills = __commonJS({
4976
4976
  }
4977
4977
  if (cb) cb.apply(this, arguments);
4978
4978
  }
4979
- return options ? orig.call(fs16, target, options, callback) : orig.call(fs16, target, callback);
4979
+ return options ? orig.call(fs17, target, options, callback) : orig.call(fs17, target, callback);
4980
4980
  };
4981
4981
  }
4982
4982
  function statFixSync(orig) {
4983
4983
  if (!orig) return orig;
4984
4984
  return function(target, options) {
4985
- var stats = options ? orig.call(fs16, target, options) : orig.call(fs16, target);
4985
+ var stats = options ? orig.call(fs17, target, options) : orig.call(fs17, target);
4986
4986
  if (stats) {
4987
4987
  if (stats.uid < 0) stats.uid += 4294967296;
4988
4988
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -5012,16 +5012,16 @@ var require_legacy_streams = __commonJS({
5012
5012
  "use strict";
5013
5013
  var Stream = require("stream").Stream;
5014
5014
  module2.exports = legacy;
5015
- function legacy(fs16) {
5015
+ function legacy(fs17) {
5016
5016
  return {
5017
5017
  ReadStream,
5018
5018
  WriteStream
5019
5019
  };
5020
- function ReadStream(path12, options) {
5021
- if (!(this instanceof ReadStream)) return new ReadStream(path12, options);
5020
+ function ReadStream(path13, options) {
5021
+ if (!(this instanceof ReadStream)) return new ReadStream(path13, options);
5022
5022
  Stream.call(this);
5023
5023
  var self = this;
5024
- this.path = path12;
5024
+ this.path = path13;
5025
5025
  this.fd = null;
5026
5026
  this.readable = true;
5027
5027
  this.paused = false;
@@ -5055,7 +5055,7 @@ var require_legacy_streams = __commonJS({
5055
5055
  });
5056
5056
  return;
5057
5057
  }
5058
- fs16.open(this.path, this.flags, this.mode, function(err, fd) {
5058
+ fs17.open(this.path, this.flags, this.mode, function(err, fd) {
5059
5059
  if (err) {
5060
5060
  self.emit("error", err);
5061
5061
  self.readable = false;
@@ -5066,10 +5066,10 @@ var require_legacy_streams = __commonJS({
5066
5066
  self._read();
5067
5067
  });
5068
5068
  }
5069
- function WriteStream(path12, options) {
5070
- if (!(this instanceof WriteStream)) return new WriteStream(path12, options);
5069
+ function WriteStream(path13, options) {
5070
+ if (!(this instanceof WriteStream)) return new WriteStream(path13, options);
5071
5071
  Stream.call(this);
5072
- this.path = path12;
5072
+ this.path = path13;
5073
5073
  this.fd = null;
5074
5074
  this.writable = true;
5075
5075
  this.flags = "w";
@@ -5094,7 +5094,7 @@ var require_legacy_streams = __commonJS({
5094
5094
  this.busy = false;
5095
5095
  this._queue = [];
5096
5096
  if (this.fd === null) {
5097
- this._open = fs16.open;
5097
+ this._open = fs17.open;
5098
5098
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
5099
5099
  this.flush();
5100
5100
  }
@@ -5130,7 +5130,7 @@ var require_clone = __commonJS({
5130
5130
  var require_graceful_fs = __commonJS({
5131
5131
  "node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
5132
5132
  "use strict";
5133
- var fs16 = require("fs");
5133
+ var fs17 = require("fs");
5134
5134
  var polyfills = require_polyfills();
5135
5135
  var legacy = require_legacy_streams();
5136
5136
  var clone = require_clone();
@@ -5162,12 +5162,12 @@ var require_graceful_fs = __commonJS({
5162
5162
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
5163
5163
  console.error(m);
5164
5164
  };
5165
- if (!fs16[gracefulQueue]) {
5165
+ if (!fs17[gracefulQueue]) {
5166
5166
  queue = global[gracefulQueue] || [];
5167
- publishQueue(fs16, queue);
5168
- fs16.close = (function(fs$close) {
5167
+ publishQueue(fs17, queue);
5168
+ fs17.close = (function(fs$close) {
5169
5169
  function close(fd, cb) {
5170
- return fs$close.call(fs16, fd, function(err) {
5170
+ return fs$close.call(fs17, fd, function(err) {
5171
5171
  if (!err) {
5172
5172
  resetQueue();
5173
5173
  }
@@ -5179,48 +5179,48 @@ var require_graceful_fs = __commonJS({
5179
5179
  value: fs$close
5180
5180
  });
5181
5181
  return close;
5182
- })(fs16.close);
5183
- fs16.closeSync = (function(fs$closeSync) {
5182
+ })(fs17.close);
5183
+ fs17.closeSync = (function(fs$closeSync) {
5184
5184
  function closeSync(fd) {
5185
- fs$closeSync.apply(fs16, arguments);
5185
+ fs$closeSync.apply(fs17, arguments);
5186
5186
  resetQueue();
5187
5187
  }
5188
5188
  Object.defineProperty(closeSync, previousSymbol, {
5189
5189
  value: fs$closeSync
5190
5190
  });
5191
5191
  return closeSync;
5192
- })(fs16.closeSync);
5192
+ })(fs17.closeSync);
5193
5193
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
5194
5194
  process.on("exit", function() {
5195
- debug(fs16[gracefulQueue]);
5196
- require("assert").equal(fs16[gracefulQueue].length, 0);
5195
+ debug(fs17[gracefulQueue]);
5196
+ require("assert").equal(fs17[gracefulQueue].length, 0);
5197
5197
  });
5198
5198
  }
5199
5199
  }
5200
5200
  var queue;
5201
5201
  if (!global[gracefulQueue]) {
5202
- publishQueue(global, fs16[gracefulQueue]);
5203
- }
5204
- module2.exports = patch(clone(fs16));
5205
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs16.__patched) {
5206
- module2.exports = patch(fs16);
5207
- fs16.__patched = true;
5208
- }
5209
- function patch(fs17) {
5210
- polyfills(fs17);
5211
- fs17.gracefulify = patch;
5212
- fs17.createReadStream = createReadStream;
5213
- fs17.createWriteStream = createWriteStream;
5214
- var fs$readFile = fs17.readFile;
5215
- fs17.readFile = readFile;
5216
- function readFile(path12, options, cb) {
5202
+ publishQueue(global, fs17[gracefulQueue]);
5203
+ }
5204
+ module2.exports = patch(clone(fs17));
5205
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs17.__patched) {
5206
+ module2.exports = patch(fs17);
5207
+ fs17.__patched = true;
5208
+ }
5209
+ function patch(fs18) {
5210
+ polyfills(fs18);
5211
+ fs18.gracefulify = patch;
5212
+ fs18.createReadStream = createReadStream;
5213
+ fs18.createWriteStream = createWriteStream;
5214
+ var fs$readFile = fs18.readFile;
5215
+ fs18.readFile = readFile;
5216
+ function readFile(path13, options, cb) {
5217
5217
  if (typeof options === "function")
5218
5218
  cb = options, options = null;
5219
- return go$readFile(path12, options, cb);
5220
- function go$readFile(path13, options2, cb2, startTime) {
5221
- return fs$readFile(path13, options2, function(err) {
5219
+ return go$readFile(path13, options, cb);
5220
+ function go$readFile(path14, options2, cb2, startTime) {
5221
+ return fs$readFile(path14, options2, function(err) {
5222
5222
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
5223
- enqueue([go$readFile, [path13, options2, cb2], err, startTime || Date.now(), Date.now()]);
5223
+ enqueue([go$readFile, [path14, options2, cb2], err, startTime || Date.now(), Date.now()]);
5224
5224
  else {
5225
5225
  if (typeof cb2 === "function")
5226
5226
  cb2.apply(this, arguments);
@@ -5228,16 +5228,16 @@ var require_graceful_fs = __commonJS({
5228
5228
  });
5229
5229
  }
5230
5230
  }
5231
- var fs$writeFile = fs17.writeFile;
5232
- fs17.writeFile = writeFile;
5233
- function writeFile(path12, data, options, cb) {
5231
+ var fs$writeFile = fs18.writeFile;
5232
+ fs18.writeFile = writeFile;
5233
+ function writeFile(path13, data, options, cb) {
5234
5234
  if (typeof options === "function")
5235
5235
  cb = options, options = null;
5236
- return go$writeFile(path12, data, options, cb);
5237
- function go$writeFile(path13, data2, options2, cb2, startTime) {
5238
- return fs$writeFile(path13, data2, options2, function(err) {
5236
+ return go$writeFile(path13, data, options, cb);
5237
+ function go$writeFile(path14, data2, options2, cb2, startTime) {
5238
+ return fs$writeFile(path14, data2, options2, function(err) {
5239
5239
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
5240
- enqueue([go$writeFile, [path13, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
5240
+ enqueue([go$writeFile, [path14, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
5241
5241
  else {
5242
5242
  if (typeof cb2 === "function")
5243
5243
  cb2.apply(this, arguments);
@@ -5245,17 +5245,17 @@ var require_graceful_fs = __commonJS({
5245
5245
  });
5246
5246
  }
5247
5247
  }
5248
- var fs$appendFile = fs17.appendFile;
5248
+ var fs$appendFile = fs18.appendFile;
5249
5249
  if (fs$appendFile)
5250
- fs17.appendFile = appendFile;
5251
- function appendFile(path12, data, options, cb) {
5250
+ fs18.appendFile = appendFile;
5251
+ function appendFile(path13, data, options, cb) {
5252
5252
  if (typeof options === "function")
5253
5253
  cb = options, options = null;
5254
- return go$appendFile(path12, data, options, cb);
5255
- function go$appendFile(path13, data2, options2, cb2, startTime) {
5256
- return fs$appendFile(path13, data2, options2, function(err) {
5254
+ return go$appendFile(path13, data, options, cb);
5255
+ function go$appendFile(path14, data2, options2, cb2, startTime) {
5256
+ return fs$appendFile(path14, data2, options2, function(err) {
5257
5257
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
5258
- enqueue([go$appendFile, [path13, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
5258
+ enqueue([go$appendFile, [path14, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
5259
5259
  else {
5260
5260
  if (typeof cb2 === "function")
5261
5261
  cb2.apply(this, arguments);
@@ -5263,9 +5263,9 @@ var require_graceful_fs = __commonJS({
5263
5263
  });
5264
5264
  }
5265
5265
  }
5266
- var fs$copyFile = fs17.copyFile;
5266
+ var fs$copyFile = fs18.copyFile;
5267
5267
  if (fs$copyFile)
5268
- fs17.copyFile = copyFile;
5268
+ fs18.copyFile = copyFile;
5269
5269
  function copyFile(src, dest, flags, cb) {
5270
5270
  if (typeof flags === "function") {
5271
5271
  cb = flags;
@@ -5283,34 +5283,34 @@ var require_graceful_fs = __commonJS({
5283
5283
  });
5284
5284
  }
5285
5285
  }
5286
- var fs$readdir = fs17.readdir;
5287
- fs17.readdir = readdir;
5286
+ var fs$readdir = fs18.readdir;
5287
+ fs18.readdir = readdir;
5288
5288
  var noReaddirOptionVersions = /^v[0-5]\./;
5289
- function readdir(path12, options, cb) {
5289
+ function readdir(path13, options, cb) {
5290
5290
  if (typeof options === "function")
5291
5291
  cb = options, options = null;
5292
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path13, options2, cb2, startTime) {
5293
- return fs$readdir(path13, fs$readdirCallback(
5294
- path13,
5292
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path14, options2, cb2, startTime) {
5293
+ return fs$readdir(path14, fs$readdirCallback(
5294
+ path14,
5295
5295
  options2,
5296
5296
  cb2,
5297
5297
  startTime
5298
5298
  ));
5299
- } : function go$readdir2(path13, options2, cb2, startTime) {
5300
- return fs$readdir(path13, options2, fs$readdirCallback(
5301
- path13,
5299
+ } : function go$readdir2(path14, options2, cb2, startTime) {
5300
+ return fs$readdir(path14, options2, fs$readdirCallback(
5301
+ path14,
5302
5302
  options2,
5303
5303
  cb2,
5304
5304
  startTime
5305
5305
  ));
5306
5306
  };
5307
- return go$readdir(path12, options, cb);
5308
- function fs$readdirCallback(path13, options2, cb2, startTime) {
5307
+ return go$readdir(path13, options, cb);
5308
+ function fs$readdirCallback(path14, options2, cb2, startTime) {
5309
5309
  return function(err, files) {
5310
5310
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
5311
5311
  enqueue([
5312
5312
  go$readdir,
5313
- [path13, options2, cb2],
5313
+ [path14, options2, cb2],
5314
5314
  err,
5315
5315
  startTime || Date.now(),
5316
5316
  Date.now()
@@ -5325,21 +5325,21 @@ var require_graceful_fs = __commonJS({
5325
5325
  }
5326
5326
  }
5327
5327
  if (process.version.substr(0, 4) === "v0.8") {
5328
- var legStreams = legacy(fs17);
5328
+ var legStreams = legacy(fs18);
5329
5329
  ReadStream = legStreams.ReadStream;
5330
5330
  WriteStream = legStreams.WriteStream;
5331
5331
  }
5332
- var fs$ReadStream = fs17.ReadStream;
5332
+ var fs$ReadStream = fs18.ReadStream;
5333
5333
  if (fs$ReadStream) {
5334
5334
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
5335
5335
  ReadStream.prototype.open = ReadStream$open;
5336
5336
  }
5337
- var fs$WriteStream = fs17.WriteStream;
5337
+ var fs$WriteStream = fs18.WriteStream;
5338
5338
  if (fs$WriteStream) {
5339
5339
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
5340
5340
  WriteStream.prototype.open = WriteStream$open;
5341
5341
  }
5342
- Object.defineProperty(fs17, "ReadStream", {
5342
+ Object.defineProperty(fs18, "ReadStream", {
5343
5343
  get: function() {
5344
5344
  return ReadStream;
5345
5345
  },
@@ -5349,7 +5349,7 @@ var require_graceful_fs = __commonJS({
5349
5349
  enumerable: true,
5350
5350
  configurable: true
5351
5351
  });
5352
- Object.defineProperty(fs17, "WriteStream", {
5352
+ Object.defineProperty(fs18, "WriteStream", {
5353
5353
  get: function() {
5354
5354
  return WriteStream;
5355
5355
  },
@@ -5360,7 +5360,7 @@ var require_graceful_fs = __commonJS({
5360
5360
  configurable: true
5361
5361
  });
5362
5362
  var FileReadStream = ReadStream;
5363
- Object.defineProperty(fs17, "FileReadStream", {
5363
+ Object.defineProperty(fs18, "FileReadStream", {
5364
5364
  get: function() {
5365
5365
  return FileReadStream;
5366
5366
  },
@@ -5371,7 +5371,7 @@ var require_graceful_fs = __commonJS({
5371
5371
  configurable: true
5372
5372
  });
5373
5373
  var FileWriteStream = WriteStream;
5374
- Object.defineProperty(fs17, "FileWriteStream", {
5374
+ Object.defineProperty(fs18, "FileWriteStream", {
5375
5375
  get: function() {
5376
5376
  return FileWriteStream;
5377
5377
  },
@@ -5381,7 +5381,7 @@ var require_graceful_fs = __commonJS({
5381
5381
  enumerable: true,
5382
5382
  configurable: true
5383
5383
  });
5384
- function ReadStream(path12, options) {
5384
+ function ReadStream(path13, options) {
5385
5385
  if (this instanceof ReadStream)
5386
5386
  return fs$ReadStream.apply(this, arguments), this;
5387
5387
  else
@@ -5401,7 +5401,7 @@ var require_graceful_fs = __commonJS({
5401
5401
  }
5402
5402
  });
5403
5403
  }
5404
- function WriteStream(path12, options) {
5404
+ function WriteStream(path13, options) {
5405
5405
  if (this instanceof WriteStream)
5406
5406
  return fs$WriteStream.apply(this, arguments), this;
5407
5407
  else
@@ -5419,22 +5419,22 @@ var require_graceful_fs = __commonJS({
5419
5419
  }
5420
5420
  });
5421
5421
  }
5422
- function createReadStream(path12, options) {
5423
- return new fs17.ReadStream(path12, options);
5422
+ function createReadStream(path13, options) {
5423
+ return new fs18.ReadStream(path13, options);
5424
5424
  }
5425
- function createWriteStream(path12, options) {
5426
- return new fs17.WriteStream(path12, options);
5425
+ function createWriteStream(path13, options) {
5426
+ return new fs18.WriteStream(path13, options);
5427
5427
  }
5428
- var fs$open = fs17.open;
5429
- fs17.open = open;
5430
- function open(path12, flags, mode, cb) {
5428
+ var fs$open = fs18.open;
5429
+ fs18.open = open;
5430
+ function open(path13, flags, mode, cb) {
5431
5431
  if (typeof mode === "function")
5432
5432
  cb = mode, mode = null;
5433
- return go$open(path12, flags, mode, cb);
5434
- function go$open(path13, flags2, mode2, cb2, startTime) {
5435
- return fs$open(path13, flags2, mode2, function(err, fd) {
5433
+ return go$open(path13, flags, mode, cb);
5434
+ function go$open(path14, flags2, mode2, cb2, startTime) {
5435
+ return fs$open(path14, flags2, mode2, function(err, fd) {
5436
5436
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
5437
- enqueue([go$open, [path13, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
5437
+ enqueue([go$open, [path14, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
5438
5438
  else {
5439
5439
  if (typeof cb2 === "function")
5440
5440
  cb2.apply(this, arguments);
@@ -5442,20 +5442,20 @@ var require_graceful_fs = __commonJS({
5442
5442
  });
5443
5443
  }
5444
5444
  }
5445
- return fs17;
5445
+ return fs18;
5446
5446
  }
5447
5447
  function enqueue(elem) {
5448
5448
  debug("ENQUEUE", elem[0].name, elem[1]);
5449
- fs16[gracefulQueue].push(elem);
5449
+ fs17[gracefulQueue].push(elem);
5450
5450
  retry();
5451
5451
  }
5452
5452
  var retryTimer;
5453
5453
  function resetQueue() {
5454
5454
  var now = Date.now();
5455
- for (var i = 0; i < fs16[gracefulQueue].length; ++i) {
5456
- if (fs16[gracefulQueue][i].length > 2) {
5457
- fs16[gracefulQueue][i][3] = now;
5458
- fs16[gracefulQueue][i][4] = now;
5455
+ for (var i = 0; i < fs17[gracefulQueue].length; ++i) {
5456
+ if (fs17[gracefulQueue][i].length > 2) {
5457
+ fs17[gracefulQueue][i][3] = now;
5458
+ fs17[gracefulQueue][i][4] = now;
5459
5459
  }
5460
5460
  }
5461
5461
  retry();
@@ -5463,9 +5463,9 @@ var require_graceful_fs = __commonJS({
5463
5463
  function retry() {
5464
5464
  clearTimeout(retryTimer);
5465
5465
  retryTimer = void 0;
5466
- if (fs16[gracefulQueue].length === 0)
5466
+ if (fs17[gracefulQueue].length === 0)
5467
5467
  return;
5468
- var elem = fs16[gracefulQueue].shift();
5468
+ var elem = fs17[gracefulQueue].shift();
5469
5469
  var fn = elem[0];
5470
5470
  var args = elem[1];
5471
5471
  var err = elem[2];
@@ -5487,7 +5487,7 @@ var require_graceful_fs = __commonJS({
5487
5487
  debug("RETRY", fn.name, args);
5488
5488
  fn.apply(null, args.concat([startTime]));
5489
5489
  } else {
5490
- fs16[gracefulQueue].push(elem);
5490
+ fs17[gracefulQueue].push(elem);
5491
5491
  }
5492
5492
  }
5493
5493
  if (retryTimer === void 0) {
@@ -5502,7 +5502,7 @@ var require_fs = __commonJS({
5502
5502
  "node_modules/fs-extra/lib/fs/index.js"(exports2) {
5503
5503
  "use strict";
5504
5504
  var u = require_universalify().fromCallback;
5505
- var fs16 = require_graceful_fs();
5505
+ var fs17 = require_graceful_fs();
5506
5506
  var api = [
5507
5507
  "access",
5508
5508
  "appendFile",
@@ -5543,26 +5543,26 @@ var require_fs = __commonJS({
5543
5543
  "utimes",
5544
5544
  "writeFile"
5545
5545
  ].filter((key) => {
5546
- return typeof fs16[key] === "function";
5546
+ return typeof fs17[key] === "function";
5547
5547
  });
5548
- Object.assign(exports2, fs16);
5548
+ Object.assign(exports2, fs17);
5549
5549
  api.forEach((method) => {
5550
- exports2[method] = u(fs16[method]);
5550
+ exports2[method] = u(fs17[method]);
5551
5551
  });
5552
5552
  exports2.exists = function(filename, callback) {
5553
5553
  if (typeof callback === "function") {
5554
- return fs16.exists(filename, callback);
5554
+ return fs17.exists(filename, callback);
5555
5555
  }
5556
5556
  return new Promise((resolve) => {
5557
- return fs16.exists(filename, resolve);
5557
+ return fs17.exists(filename, resolve);
5558
5558
  });
5559
5559
  };
5560
5560
  exports2.read = function(fd, buffer, offset, length, position, callback) {
5561
5561
  if (typeof callback === "function") {
5562
- return fs16.read(fd, buffer, offset, length, position, callback);
5562
+ return fs17.read(fd, buffer, offset, length, position, callback);
5563
5563
  }
5564
5564
  return new Promise((resolve, reject) => {
5565
- fs16.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
5565
+ fs17.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
5566
5566
  if (err) return reject(err);
5567
5567
  resolve({ bytesRead, buffer: buffer2 });
5568
5568
  });
@@ -5570,10 +5570,10 @@ var require_fs = __commonJS({
5570
5570
  };
5571
5571
  exports2.write = function(fd, buffer, ...args) {
5572
5572
  if (typeof args[args.length - 1] === "function") {
5573
- return fs16.write(fd, buffer, ...args);
5573
+ return fs17.write(fd, buffer, ...args);
5574
5574
  }
5575
5575
  return new Promise((resolve, reject) => {
5576
- fs16.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
5576
+ fs17.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
5577
5577
  if (err) return reject(err);
5578
5578
  resolve({ bytesWritten, buffer: buffer2 });
5579
5579
  });
@@ -5581,10 +5581,10 @@ var require_fs = __commonJS({
5581
5581
  };
5582
5582
  exports2.readv = function(fd, buffers, ...args) {
5583
5583
  if (typeof args[args.length - 1] === "function") {
5584
- return fs16.readv(fd, buffers, ...args);
5584
+ return fs17.readv(fd, buffers, ...args);
5585
5585
  }
5586
5586
  return new Promise((resolve, reject) => {
5587
- fs16.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
5587
+ fs17.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
5588
5588
  if (err) return reject(err);
5589
5589
  resolve({ bytesRead, buffers: buffers2 });
5590
5590
  });
@@ -5592,17 +5592,17 @@ var require_fs = __commonJS({
5592
5592
  };
5593
5593
  exports2.writev = function(fd, buffers, ...args) {
5594
5594
  if (typeof args[args.length - 1] === "function") {
5595
- return fs16.writev(fd, buffers, ...args);
5595
+ return fs17.writev(fd, buffers, ...args);
5596
5596
  }
5597
5597
  return new Promise((resolve, reject) => {
5598
- fs16.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
5598
+ fs17.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
5599
5599
  if (err) return reject(err);
5600
5600
  resolve({ bytesWritten, buffers: buffers2 });
5601
5601
  });
5602
5602
  });
5603
5603
  };
5604
- if (typeof fs16.realpath.native === "function") {
5605
- exports2.realpath.native = u(fs16.realpath.native);
5604
+ if (typeof fs17.realpath.native === "function") {
5605
+ exports2.realpath.native = u(fs17.realpath.native);
5606
5606
  } else {
5607
5607
  process.emitWarning(
5608
5608
  "fs.realpath.native is not a function. Is fs being monkey-patched?",
@@ -5617,10 +5617,10 @@ var require_fs = __commonJS({
5617
5617
  var require_utils = __commonJS({
5618
5618
  "node_modules/fs-extra/lib/mkdirs/utils.js"(exports2, module2) {
5619
5619
  "use strict";
5620
- var path12 = require("path");
5620
+ var path13 = require("path");
5621
5621
  module2.exports.checkPath = function checkPath(pth) {
5622
5622
  if (process.platform === "win32") {
5623
- const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path12.parse(pth).root, ""));
5623
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path13.parse(pth).root, ""));
5624
5624
  if (pathHasInvalidWinCharacters) {
5625
5625
  const error = new Error(`Path contains invalid characters: ${pth}`);
5626
5626
  error.code = "EINVAL";
@@ -5635,7 +5635,7 @@ var require_utils = __commonJS({
5635
5635
  var require_make_dir = __commonJS({
5636
5636
  "node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports2, module2) {
5637
5637
  "use strict";
5638
- var fs16 = require_fs();
5638
+ var fs17 = require_fs();
5639
5639
  var { checkPath } = require_utils();
5640
5640
  var getMode = (options) => {
5641
5641
  const defaults = { mode: 511 };
@@ -5644,14 +5644,14 @@ var require_make_dir = __commonJS({
5644
5644
  };
5645
5645
  module2.exports.makeDir = async (dir, options) => {
5646
5646
  checkPath(dir);
5647
- return fs16.mkdir(dir, {
5647
+ return fs17.mkdir(dir, {
5648
5648
  mode: getMode(options),
5649
5649
  recursive: true
5650
5650
  });
5651
5651
  };
5652
5652
  module2.exports.makeDirSync = (dir, options) => {
5653
5653
  checkPath(dir);
5654
- return fs16.mkdirSync(dir, {
5654
+ return fs17.mkdirSync(dir, {
5655
5655
  mode: getMode(options),
5656
5656
  recursive: true
5657
5657
  });
@@ -5683,13 +5683,13 @@ var require_path_exists = __commonJS({
5683
5683
  "node_modules/fs-extra/lib/path-exists/index.js"(exports2, module2) {
5684
5684
  "use strict";
5685
5685
  var u = require_universalify().fromPromise;
5686
- var fs16 = require_fs();
5687
- function pathExists(path12) {
5688
- return fs16.access(path12).then(() => true).catch(() => false);
5686
+ var fs17 = require_fs();
5687
+ function pathExists(path13) {
5688
+ return fs17.access(path13).then(() => true).catch(() => false);
5689
5689
  }
5690
5690
  module2.exports = {
5691
5691
  pathExists: u(pathExists),
5692
- pathExistsSync: fs16.existsSync
5692
+ pathExistsSync: fs17.existsSync
5693
5693
  };
5694
5694
  }
5695
5695
  });
@@ -5698,18 +5698,18 @@ var require_path_exists = __commonJS({
5698
5698
  var require_utimes = __commonJS({
5699
5699
  "node_modules/fs-extra/lib/util/utimes.js"(exports2, module2) {
5700
5700
  "use strict";
5701
- var fs16 = require_fs();
5701
+ var fs17 = require_fs();
5702
5702
  var u = require_universalify().fromPromise;
5703
- async function utimesMillis(path12, atime, mtime) {
5704
- const fd = await fs16.open(path12, "r+");
5703
+ async function utimesMillis(path13, atime, mtime) {
5704
+ const fd = await fs17.open(path13, "r+");
5705
5705
  let error = null;
5706
5706
  try {
5707
- await fs16.futimes(fd, atime, mtime);
5707
+ await fs17.futimes(fd, atime, mtime);
5708
5708
  } catch (futimesErr) {
5709
5709
  error = futimesErr;
5710
5710
  } finally {
5711
5711
  try {
5712
- await fs16.close(fd);
5712
+ await fs17.close(fd);
5713
5713
  } catch (closeErr) {
5714
5714
  if (!error) error = closeErr;
5715
5715
  }
@@ -5718,16 +5718,16 @@ var require_utimes = __commonJS({
5718
5718
  throw error;
5719
5719
  }
5720
5720
  }
5721
- function utimesMillisSync(path12, atime, mtime) {
5722
- const fd = fs16.openSync(path12, "r+");
5721
+ function utimesMillisSync(path13, atime, mtime) {
5722
+ const fd = fs17.openSync(path13, "r+");
5723
5723
  let error = null;
5724
5724
  try {
5725
- fs16.futimesSync(fd, atime, mtime);
5725
+ fs17.futimesSync(fd, atime, mtime);
5726
5726
  } catch (futimesErr) {
5727
5727
  error = futimesErr;
5728
5728
  } finally {
5729
5729
  try {
5730
- fs16.closeSync(fd);
5730
+ fs17.closeSync(fd);
5731
5731
  } catch (closeErr) {
5732
5732
  if (!error) error = closeErr;
5733
5733
  }
@@ -5747,11 +5747,11 @@ var require_utimes = __commonJS({
5747
5747
  var require_stat = __commonJS({
5748
5748
  "node_modules/fs-extra/lib/util/stat.js"(exports2, module2) {
5749
5749
  "use strict";
5750
- var fs16 = require_fs();
5751
- var path12 = require("path");
5750
+ var fs17 = require_fs();
5751
+ var path13 = require("path");
5752
5752
  var u = require_universalify().fromPromise;
5753
5753
  function getStats(src, dest, opts) {
5754
- const statFunc = opts.dereference ? (file) => fs16.stat(file, { bigint: true }) : (file) => fs16.lstat(file, { bigint: true });
5754
+ const statFunc = opts.dereference ? (file) => fs17.stat(file, { bigint: true }) : (file) => fs17.lstat(file, { bigint: true });
5755
5755
  return Promise.all([
5756
5756
  statFunc(src),
5757
5757
  statFunc(dest).catch((err) => {
@@ -5762,7 +5762,7 @@ var require_stat = __commonJS({
5762
5762
  }
5763
5763
  function getStatsSync(src, dest, opts) {
5764
5764
  let destStat;
5765
- const statFunc = opts.dereference ? (file) => fs16.statSync(file, { bigint: true }) : (file) => fs16.lstatSync(file, { bigint: true });
5765
+ const statFunc = opts.dereference ? (file) => fs17.statSync(file, { bigint: true }) : (file) => fs17.lstatSync(file, { bigint: true });
5766
5766
  const srcStat = statFunc(src);
5767
5767
  try {
5768
5768
  destStat = statFunc(dest);
@@ -5776,8 +5776,8 @@ var require_stat = __commonJS({
5776
5776
  const { srcStat, destStat } = await getStats(src, dest, opts);
5777
5777
  if (destStat) {
5778
5778
  if (areIdentical(srcStat, destStat)) {
5779
- const srcBaseName = path12.basename(src);
5780
- const destBaseName = path12.basename(dest);
5779
+ const srcBaseName = path13.basename(src);
5780
+ const destBaseName = path13.basename(dest);
5781
5781
  if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
5782
5782
  return { srcStat, destStat, isChangingCase: true };
5783
5783
  }
@@ -5799,8 +5799,8 @@ var require_stat = __commonJS({
5799
5799
  const { srcStat, destStat } = getStatsSync(src, dest, opts);
5800
5800
  if (destStat) {
5801
5801
  if (areIdentical(srcStat, destStat)) {
5802
- const srcBaseName = path12.basename(src);
5803
- const destBaseName = path12.basename(dest);
5802
+ const srcBaseName = path13.basename(src);
5803
+ const destBaseName = path13.basename(dest);
5804
5804
  if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
5805
5805
  return { srcStat, destStat, isChangingCase: true };
5806
5806
  }
@@ -5819,12 +5819,12 @@ var require_stat = __commonJS({
5819
5819
  return { srcStat, destStat };
5820
5820
  }
5821
5821
  async function checkParentPaths(src, srcStat, dest, funcName) {
5822
- const srcParent = path12.resolve(path12.dirname(src));
5823
- const destParent = path12.resolve(path12.dirname(dest));
5824
- if (destParent === srcParent || destParent === path12.parse(destParent).root) return;
5822
+ const srcParent = path13.resolve(path13.dirname(src));
5823
+ const destParent = path13.resolve(path13.dirname(dest));
5824
+ if (destParent === srcParent || destParent === path13.parse(destParent).root) return;
5825
5825
  let destStat;
5826
5826
  try {
5827
- destStat = await fs16.stat(destParent, { bigint: true });
5827
+ destStat = await fs17.stat(destParent, { bigint: true });
5828
5828
  } catch (err) {
5829
5829
  if (err.code === "ENOENT") return;
5830
5830
  throw err;
@@ -5835,12 +5835,12 @@ var require_stat = __commonJS({
5835
5835
  return checkParentPaths(src, srcStat, destParent, funcName);
5836
5836
  }
5837
5837
  function checkParentPathsSync(src, srcStat, dest, funcName) {
5838
- const srcParent = path12.resolve(path12.dirname(src));
5839
- const destParent = path12.resolve(path12.dirname(dest));
5840
- if (destParent === srcParent || destParent === path12.parse(destParent).root) return;
5838
+ const srcParent = path13.resolve(path13.dirname(src));
5839
+ const destParent = path13.resolve(path13.dirname(dest));
5840
+ if (destParent === srcParent || destParent === path13.parse(destParent).root) return;
5841
5841
  let destStat;
5842
5842
  try {
5843
- destStat = fs16.statSync(destParent, { bigint: true });
5843
+ destStat = fs17.statSync(destParent, { bigint: true });
5844
5844
  } catch (err) {
5845
5845
  if (err.code === "ENOENT") return;
5846
5846
  throw err;
@@ -5854,8 +5854,8 @@ var require_stat = __commonJS({
5854
5854
  return destStat.ino !== void 0 && destStat.dev !== void 0 && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
5855
5855
  }
5856
5856
  function isSrcSubdir(src, dest) {
5857
- const srcArr = path12.resolve(src).split(path12.sep).filter((i) => i);
5858
- const destArr = path12.resolve(dest).split(path12.sep).filter((i) => i);
5857
+ const srcArr = path13.resolve(src).split(path13.sep).filter((i) => i);
5858
+ const destArr = path13.resolve(dest).split(path13.sep).filter((i) => i);
5859
5859
  return srcArr.every((cur, i) => destArr[i] === cur);
5860
5860
  }
5861
5861
  function errMsg(src, dest, funcName) {
@@ -5907,8 +5907,8 @@ var require_async = __commonJS({
5907
5907
  var require_copy = __commonJS({
5908
5908
  "node_modules/fs-extra/lib/copy/copy.js"(exports2, module2) {
5909
5909
  "use strict";
5910
- var fs16 = require_fs();
5911
- var path12 = require("path");
5910
+ var fs17 = require_fs();
5911
+ var path13 = require("path");
5912
5912
  var { mkdirs } = require_mkdirs();
5913
5913
  var { pathExists } = require_path_exists();
5914
5914
  var { utimesMillis } = require_utimes();
@@ -5931,7 +5931,7 @@ var require_copy = __commonJS({
5931
5931
  await stat.checkParentPaths(src, srcStat, dest, "copy");
5932
5932
  const include = await runFilter(src, dest, opts);
5933
5933
  if (!include) return;
5934
- const destParent = path12.dirname(dest);
5934
+ const destParent = path13.dirname(dest);
5935
5935
  const dirExists = await pathExists(destParent);
5936
5936
  if (!dirExists) {
5937
5937
  await mkdirs(destParent);
@@ -5943,7 +5943,7 @@ var require_copy = __commonJS({
5943
5943
  return opts.filter(src, dest);
5944
5944
  }
5945
5945
  async function getStatsAndPerformCopy(destStat, src, dest, opts) {
5946
- const statFn = opts.dereference ? fs16.stat : fs16.lstat;
5946
+ const statFn = opts.dereference ? fs17.stat : fs17.lstat;
5947
5947
  const srcStat = await statFn(src);
5948
5948
  if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
5949
5949
  if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
@@ -5955,7 +5955,7 @@ var require_copy = __commonJS({
5955
5955
  async function onFile(srcStat, destStat, src, dest, opts) {
5956
5956
  if (!destStat) return copyFile(srcStat, src, dest, opts);
5957
5957
  if (opts.overwrite) {
5958
- await fs16.unlink(dest);
5958
+ await fs17.unlink(dest);
5959
5959
  return copyFile(srcStat, src, dest, opts);
5960
5960
  }
5961
5961
  if (opts.errorOnExist) {
@@ -5963,29 +5963,29 @@ var require_copy = __commonJS({
5963
5963
  }
5964
5964
  }
5965
5965
  async function copyFile(srcStat, src, dest, opts) {
5966
- await fs16.copyFile(src, dest);
5966
+ await fs17.copyFile(src, dest);
5967
5967
  if (opts.preserveTimestamps) {
5968
5968
  if (fileIsNotWritable(srcStat.mode)) {
5969
5969
  await makeFileWritable(dest, srcStat.mode);
5970
5970
  }
5971
- const updatedSrcStat = await fs16.stat(src);
5971
+ const updatedSrcStat = await fs17.stat(src);
5972
5972
  await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
5973
5973
  }
5974
- return fs16.chmod(dest, srcStat.mode);
5974
+ return fs17.chmod(dest, srcStat.mode);
5975
5975
  }
5976
5976
  function fileIsNotWritable(srcMode) {
5977
5977
  return (srcMode & 128) === 0;
5978
5978
  }
5979
5979
  function makeFileWritable(dest, srcMode) {
5980
- return fs16.chmod(dest, srcMode | 128);
5980
+ return fs17.chmod(dest, srcMode | 128);
5981
5981
  }
5982
5982
  async function onDir(srcStat, destStat, src, dest, opts) {
5983
5983
  if (!destStat) {
5984
- await fs16.mkdir(dest);
5984
+ await fs17.mkdir(dest);
5985
5985
  }
5986
- await asyncIteratorConcurrentProcess(await fs16.opendir(src), async (item) => {
5987
- const srcItem = path12.join(src, item.name);
5988
- const destItem = path12.join(dest, item.name);
5986
+ await asyncIteratorConcurrentProcess(await fs17.opendir(src), async (item) => {
5987
+ const srcItem = path13.join(src, item.name);
5988
+ const destItem = path13.join(dest, item.name);
5989
5989
  const include = await runFilter(srcItem, destItem, opts);
5990
5990
  if (include) {
5991
5991
  const { destStat: destStat2 } = await stat.checkPaths(srcItem, destItem, "copy", opts);
@@ -5993,26 +5993,26 @@ var require_copy = __commonJS({
5993
5993
  }
5994
5994
  });
5995
5995
  if (!destStat) {
5996
- await fs16.chmod(dest, srcStat.mode);
5996
+ await fs17.chmod(dest, srcStat.mode);
5997
5997
  }
5998
5998
  }
5999
5999
  async function onLink(destStat, src, dest, opts) {
6000
- let resolvedSrc = await fs16.readlink(src);
6000
+ let resolvedSrc = await fs17.readlink(src);
6001
6001
  if (opts.dereference) {
6002
- resolvedSrc = path12.resolve(process.cwd(), resolvedSrc);
6002
+ resolvedSrc = path13.resolve(process.cwd(), resolvedSrc);
6003
6003
  }
6004
6004
  if (!destStat) {
6005
- return fs16.symlink(resolvedSrc, dest);
6005
+ return fs17.symlink(resolvedSrc, dest);
6006
6006
  }
6007
6007
  let resolvedDest = null;
6008
6008
  try {
6009
- resolvedDest = await fs16.readlink(dest);
6009
+ resolvedDest = await fs17.readlink(dest);
6010
6010
  } catch (e) {
6011
- if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs16.symlink(resolvedSrc, dest);
6011
+ if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs17.symlink(resolvedSrc, dest);
6012
6012
  throw e;
6013
6013
  }
6014
6014
  if (opts.dereference) {
6015
- resolvedDest = path12.resolve(process.cwd(), resolvedDest);
6015
+ resolvedDest = path13.resolve(process.cwd(), resolvedDest);
6016
6016
  }
6017
6017
  if (resolvedSrc !== resolvedDest) {
6018
6018
  if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
@@ -6022,8 +6022,8 @@ var require_copy = __commonJS({
6022
6022
  throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
6023
6023
  }
6024
6024
  }
6025
- await fs16.unlink(dest);
6026
- return fs16.symlink(resolvedSrc, dest);
6025
+ await fs17.unlink(dest);
6026
+ return fs17.symlink(resolvedSrc, dest);
6027
6027
  }
6028
6028
  module2.exports = copy;
6029
6029
  }
@@ -6033,8 +6033,8 @@ var require_copy = __commonJS({
6033
6033
  var require_copy_sync = __commonJS({
6034
6034
  "node_modules/fs-extra/lib/copy/copy-sync.js"(exports2, module2) {
6035
6035
  "use strict";
6036
- var fs16 = require_graceful_fs();
6037
- var path12 = require("path");
6036
+ var fs17 = require_graceful_fs();
6037
+ var path13 = require("path");
6038
6038
  var mkdirsSync = require_mkdirs().mkdirsSync;
6039
6039
  var utimesMillisSync = require_utimes().utimesMillisSync;
6040
6040
  var stat = require_stat();
@@ -6055,12 +6055,12 @@ var require_copy_sync = __commonJS({
6055
6055
  const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
6056
6056
  stat.checkParentPathsSync(src, srcStat, dest, "copy");
6057
6057
  if (opts.filter && !opts.filter(src, dest)) return;
6058
- const destParent = path12.dirname(dest);
6059
- if (!fs16.existsSync(destParent)) mkdirsSync(destParent);
6058
+ const destParent = path13.dirname(dest);
6059
+ if (!fs17.existsSync(destParent)) mkdirsSync(destParent);
6060
6060
  return getStats(destStat, src, dest, opts);
6061
6061
  }
6062
6062
  function getStats(destStat, src, dest, opts) {
6063
- const statSync = opts.dereference ? fs16.statSync : fs16.lstatSync;
6063
+ const statSync = opts.dereference ? fs17.statSync : fs17.lstatSync;
6064
6064
  const srcStat = statSync(src);
6065
6065
  if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
6066
6066
  else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
@@ -6075,14 +6075,14 @@ var require_copy_sync = __commonJS({
6075
6075
  }
6076
6076
  function mayCopyFile(srcStat, src, dest, opts) {
6077
6077
  if (opts.overwrite) {
6078
- fs16.unlinkSync(dest);
6078
+ fs17.unlinkSync(dest);
6079
6079
  return copyFile(srcStat, src, dest, opts);
6080
6080
  } else if (opts.errorOnExist) {
6081
6081
  throw new Error(`'${dest}' already exists`);
6082
6082
  }
6083
6083
  }
6084
6084
  function copyFile(srcStat, src, dest, opts) {
6085
- fs16.copyFileSync(src, dest);
6085
+ fs17.copyFileSync(src, dest);
6086
6086
  if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
6087
6087
  return setDestMode(dest, srcStat.mode);
6088
6088
  }
@@ -6097,10 +6097,10 @@ var require_copy_sync = __commonJS({
6097
6097
  return setDestMode(dest, srcMode | 128);
6098
6098
  }
6099
6099
  function setDestMode(dest, srcMode) {
6100
- return fs16.chmodSync(dest, srcMode);
6100
+ return fs17.chmodSync(dest, srcMode);
6101
6101
  }
6102
6102
  function setDestTimestamps(src, dest) {
6103
- const updatedSrcStat = fs16.statSync(src);
6103
+ const updatedSrcStat = fs17.statSync(src);
6104
6104
  return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
6105
6105
  }
6106
6106
  function onDir(srcStat, destStat, src, dest, opts) {
@@ -6108,12 +6108,12 @@ var require_copy_sync = __commonJS({
6108
6108
  return copyDir(src, dest, opts);
6109
6109
  }
6110
6110
  function mkDirAndCopy(srcMode, src, dest, opts) {
6111
- fs16.mkdirSync(dest);
6111
+ fs17.mkdirSync(dest);
6112
6112
  copyDir(src, dest, opts);
6113
6113
  return setDestMode(dest, srcMode);
6114
6114
  }
6115
6115
  function copyDir(src, dest, opts) {
6116
- const dir = fs16.opendirSync(src);
6116
+ const dir = fs17.opendirSync(src);
6117
6117
  try {
6118
6118
  let dirent;
6119
6119
  while ((dirent = dir.readSync()) !== null) {
@@ -6124,29 +6124,29 @@ var require_copy_sync = __commonJS({
6124
6124
  }
6125
6125
  }
6126
6126
  function copyDirItem(item, src, dest, opts) {
6127
- const srcItem = path12.join(src, item);
6128
- const destItem = path12.join(dest, item);
6127
+ const srcItem = path13.join(src, item);
6128
+ const destItem = path13.join(dest, item);
6129
6129
  if (opts.filter && !opts.filter(srcItem, destItem)) return;
6130
6130
  const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
6131
6131
  return getStats(destStat, srcItem, destItem, opts);
6132
6132
  }
6133
6133
  function onLink(destStat, src, dest, opts) {
6134
- let resolvedSrc = fs16.readlinkSync(src);
6134
+ let resolvedSrc = fs17.readlinkSync(src);
6135
6135
  if (opts.dereference) {
6136
- resolvedSrc = path12.resolve(process.cwd(), resolvedSrc);
6136
+ resolvedSrc = path13.resolve(process.cwd(), resolvedSrc);
6137
6137
  }
6138
6138
  if (!destStat) {
6139
- return fs16.symlinkSync(resolvedSrc, dest);
6139
+ return fs17.symlinkSync(resolvedSrc, dest);
6140
6140
  } else {
6141
6141
  let resolvedDest;
6142
6142
  try {
6143
- resolvedDest = fs16.readlinkSync(dest);
6143
+ resolvedDest = fs17.readlinkSync(dest);
6144
6144
  } catch (err) {
6145
- if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs16.symlinkSync(resolvedSrc, dest);
6145
+ if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs17.symlinkSync(resolvedSrc, dest);
6146
6146
  throw err;
6147
6147
  }
6148
6148
  if (opts.dereference) {
6149
- resolvedDest = path12.resolve(process.cwd(), resolvedDest);
6149
+ resolvedDest = path13.resolve(process.cwd(), resolvedDest);
6150
6150
  }
6151
6151
  if (resolvedSrc !== resolvedDest) {
6152
6152
  if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
@@ -6160,8 +6160,8 @@ var require_copy_sync = __commonJS({
6160
6160
  }
6161
6161
  }
6162
6162
  function copyLink(resolvedSrc, dest) {
6163
- fs16.unlinkSync(dest);
6164
- return fs16.symlinkSync(resolvedSrc, dest);
6163
+ fs17.unlinkSync(dest);
6164
+ return fs17.symlinkSync(resolvedSrc, dest);
6165
6165
  }
6166
6166
  module2.exports = copySync;
6167
6167
  }
@@ -6183,13 +6183,13 @@ var require_copy2 = __commonJS({
6183
6183
  var require_remove = __commonJS({
6184
6184
  "node_modules/fs-extra/lib/remove/index.js"(exports2, module2) {
6185
6185
  "use strict";
6186
- var fs16 = require_graceful_fs();
6186
+ var fs17 = require_graceful_fs();
6187
6187
  var u = require_universalify().fromCallback;
6188
- function remove(path12, callback) {
6189
- fs16.rm(path12, { recursive: true, force: true }, callback);
6188
+ function remove(path13, callback) {
6189
+ fs17.rm(path13, { recursive: true, force: true }, callback);
6190
6190
  }
6191
- function removeSync(path12) {
6192
- fs16.rmSync(path12, { recursive: true, force: true });
6191
+ function removeSync(path13) {
6192
+ fs17.rmSync(path13, { recursive: true, force: true });
6193
6193
  }
6194
6194
  module2.exports = {
6195
6195
  remove: u(remove),
@@ -6203,28 +6203,28 @@ var require_empty = __commonJS({
6203
6203
  "node_modules/fs-extra/lib/empty/index.js"(exports2, module2) {
6204
6204
  "use strict";
6205
6205
  var u = require_universalify().fromPromise;
6206
- var fs16 = require_fs();
6207
- var path12 = require("path");
6206
+ var fs17 = require_fs();
6207
+ var path13 = require("path");
6208
6208
  var mkdir = require_mkdirs();
6209
6209
  var remove = require_remove();
6210
6210
  var emptyDir = u(async function emptyDir2(dir) {
6211
6211
  let items;
6212
6212
  try {
6213
- items = await fs16.readdir(dir);
6213
+ items = await fs17.readdir(dir);
6214
6214
  } catch {
6215
6215
  return mkdir.mkdirs(dir);
6216
6216
  }
6217
- return Promise.all(items.map((item) => remove.remove(path12.join(dir, item))));
6217
+ return Promise.all(items.map((item) => remove.remove(path13.join(dir, item))));
6218
6218
  });
6219
6219
  function emptyDirSync(dir) {
6220
6220
  let items;
6221
6221
  try {
6222
- items = fs16.readdirSync(dir);
6222
+ items = fs17.readdirSync(dir);
6223
6223
  } catch {
6224
6224
  return mkdir.mkdirsSync(dir);
6225
6225
  }
6226
6226
  items.forEach((item) => {
6227
- item = path12.join(dir, item);
6227
+ item = path13.join(dir, item);
6228
6228
  remove.removeSync(item);
6229
6229
  });
6230
6230
  }
@@ -6242,52 +6242,52 @@ var require_file = __commonJS({
6242
6242
  "node_modules/fs-extra/lib/ensure/file.js"(exports2, module2) {
6243
6243
  "use strict";
6244
6244
  var u = require_universalify().fromPromise;
6245
- var path12 = require("path");
6246
- var fs16 = require_fs();
6245
+ var path13 = require("path");
6246
+ var fs17 = require_fs();
6247
6247
  var mkdir = require_mkdirs();
6248
6248
  async function createFile(file) {
6249
6249
  let stats;
6250
6250
  try {
6251
- stats = await fs16.stat(file);
6251
+ stats = await fs17.stat(file);
6252
6252
  } catch {
6253
6253
  }
6254
6254
  if (stats && stats.isFile()) return;
6255
- const dir = path12.dirname(file);
6255
+ const dir = path13.dirname(file);
6256
6256
  let dirStats = null;
6257
6257
  try {
6258
- dirStats = await fs16.stat(dir);
6258
+ dirStats = await fs17.stat(dir);
6259
6259
  } catch (err) {
6260
6260
  if (err.code === "ENOENT") {
6261
6261
  await mkdir.mkdirs(dir);
6262
- await fs16.writeFile(file, "");
6262
+ await fs17.writeFile(file, "");
6263
6263
  return;
6264
6264
  } else {
6265
6265
  throw err;
6266
6266
  }
6267
6267
  }
6268
6268
  if (dirStats.isDirectory()) {
6269
- await fs16.writeFile(file, "");
6269
+ await fs17.writeFile(file, "");
6270
6270
  } else {
6271
- await fs16.readdir(dir);
6271
+ await fs17.readdir(dir);
6272
6272
  }
6273
6273
  }
6274
6274
  function createFileSync(file) {
6275
6275
  let stats;
6276
6276
  try {
6277
- stats = fs16.statSync(file);
6277
+ stats = fs17.statSync(file);
6278
6278
  } catch {
6279
6279
  }
6280
6280
  if (stats && stats.isFile()) return;
6281
- const dir = path12.dirname(file);
6281
+ const dir = path13.dirname(file);
6282
6282
  try {
6283
- if (!fs16.statSync(dir).isDirectory()) {
6284
- fs16.readdirSync(dir);
6283
+ if (!fs17.statSync(dir).isDirectory()) {
6284
+ fs17.readdirSync(dir);
6285
6285
  }
6286
6286
  } catch (err) {
6287
6287
  if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
6288
6288
  else throw err;
6289
6289
  }
6290
- fs16.writeFileSync(file, "");
6290
+ fs17.writeFileSync(file, "");
6291
6291
  }
6292
6292
  module2.exports = {
6293
6293
  createFile: u(createFile),
@@ -6301,50 +6301,50 @@ var require_link = __commonJS({
6301
6301
  "node_modules/fs-extra/lib/ensure/link.js"(exports2, module2) {
6302
6302
  "use strict";
6303
6303
  var u = require_universalify().fromPromise;
6304
- var path12 = require("path");
6305
- var fs16 = require_fs();
6304
+ var path13 = require("path");
6305
+ var fs17 = require_fs();
6306
6306
  var mkdir = require_mkdirs();
6307
6307
  var { pathExists } = require_path_exists();
6308
6308
  var { areIdentical } = require_stat();
6309
6309
  async function createLink(srcpath, dstpath) {
6310
6310
  let dstStat;
6311
6311
  try {
6312
- dstStat = await fs16.lstat(dstpath, { bigint: true });
6312
+ dstStat = await fs17.lstat(dstpath, { bigint: true });
6313
6313
  } catch {
6314
6314
  }
6315
6315
  let srcStat;
6316
6316
  try {
6317
- srcStat = await fs16.lstat(srcpath, { bigint: true });
6317
+ srcStat = await fs17.lstat(srcpath, { bigint: true });
6318
6318
  } catch (err) {
6319
6319
  err.message = err.message.replace("lstat", "ensureLink");
6320
6320
  throw err;
6321
6321
  }
6322
6322
  if (dstStat && areIdentical(srcStat, dstStat)) return;
6323
- const dir = path12.dirname(dstpath);
6323
+ const dir = path13.dirname(dstpath);
6324
6324
  const dirExists = await pathExists(dir);
6325
6325
  if (!dirExists) {
6326
6326
  await mkdir.mkdirs(dir);
6327
6327
  }
6328
- await fs16.link(srcpath, dstpath);
6328
+ await fs17.link(srcpath, dstpath);
6329
6329
  }
6330
6330
  function createLinkSync(srcpath, dstpath) {
6331
6331
  let dstStat;
6332
6332
  try {
6333
- dstStat = fs16.lstatSync(dstpath, { bigint: true });
6333
+ dstStat = fs17.lstatSync(dstpath, { bigint: true });
6334
6334
  } catch {
6335
6335
  }
6336
6336
  try {
6337
- const srcStat = fs16.lstatSync(srcpath, { bigint: true });
6337
+ const srcStat = fs17.lstatSync(srcpath, { bigint: true });
6338
6338
  if (dstStat && areIdentical(srcStat, dstStat)) return;
6339
6339
  } catch (err) {
6340
6340
  err.message = err.message.replace("lstat", "ensureLink");
6341
6341
  throw err;
6342
6342
  }
6343
- const dir = path12.dirname(dstpath);
6344
- const dirExists = fs16.existsSync(dir);
6345
- if (dirExists) return fs16.linkSync(srcpath, dstpath);
6343
+ const dir = path13.dirname(dstpath);
6344
+ const dirExists = fs17.existsSync(dir);
6345
+ if (dirExists) return fs17.linkSync(srcpath, dstpath);
6346
6346
  mkdir.mkdirsSync(dir);
6347
- return fs16.linkSync(srcpath, dstpath);
6347
+ return fs17.linkSync(srcpath, dstpath);
6348
6348
  }
6349
6349
  module2.exports = {
6350
6350
  createLink: u(createLink),
@@ -6357,14 +6357,14 @@ var require_link = __commonJS({
6357
6357
  var require_symlink_paths = __commonJS({
6358
6358
  "node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports2, module2) {
6359
6359
  "use strict";
6360
- var path12 = require("path");
6361
- var fs16 = require_fs();
6360
+ var path13 = require("path");
6361
+ var fs17 = require_fs();
6362
6362
  var { pathExists } = require_path_exists();
6363
6363
  var u = require_universalify().fromPromise;
6364
6364
  async function symlinkPaths(srcpath, dstpath) {
6365
- if (path12.isAbsolute(srcpath)) {
6365
+ if (path13.isAbsolute(srcpath)) {
6366
6366
  try {
6367
- await fs16.lstat(srcpath);
6367
+ await fs17.lstat(srcpath);
6368
6368
  } catch (err) {
6369
6369
  err.message = err.message.replace("lstat", "ensureSymlink");
6370
6370
  throw err;
@@ -6374,8 +6374,8 @@ var require_symlink_paths = __commonJS({
6374
6374
  toDst: srcpath
6375
6375
  };
6376
6376
  }
6377
- const dstdir = path12.dirname(dstpath);
6378
- const relativeToDst = path12.join(dstdir, srcpath);
6377
+ const dstdir = path13.dirname(dstpath);
6378
+ const relativeToDst = path13.join(dstdir, srcpath);
6379
6379
  const exists = await pathExists(relativeToDst);
6380
6380
  if (exists) {
6381
6381
  return {
@@ -6384,39 +6384,39 @@ var require_symlink_paths = __commonJS({
6384
6384
  };
6385
6385
  }
6386
6386
  try {
6387
- await fs16.lstat(srcpath);
6387
+ await fs17.lstat(srcpath);
6388
6388
  } catch (err) {
6389
6389
  err.message = err.message.replace("lstat", "ensureSymlink");
6390
6390
  throw err;
6391
6391
  }
6392
6392
  return {
6393
6393
  toCwd: srcpath,
6394
- toDst: path12.relative(dstdir, srcpath)
6394
+ toDst: path13.relative(dstdir, srcpath)
6395
6395
  };
6396
6396
  }
6397
6397
  function symlinkPathsSync(srcpath, dstpath) {
6398
- if (path12.isAbsolute(srcpath)) {
6399
- const exists2 = fs16.existsSync(srcpath);
6398
+ if (path13.isAbsolute(srcpath)) {
6399
+ const exists2 = fs17.existsSync(srcpath);
6400
6400
  if (!exists2) throw new Error("absolute srcpath does not exist");
6401
6401
  return {
6402
6402
  toCwd: srcpath,
6403
6403
  toDst: srcpath
6404
6404
  };
6405
6405
  }
6406
- const dstdir = path12.dirname(dstpath);
6407
- const relativeToDst = path12.join(dstdir, srcpath);
6408
- const exists = fs16.existsSync(relativeToDst);
6406
+ const dstdir = path13.dirname(dstpath);
6407
+ const relativeToDst = path13.join(dstdir, srcpath);
6408
+ const exists = fs17.existsSync(relativeToDst);
6409
6409
  if (exists) {
6410
6410
  return {
6411
6411
  toCwd: relativeToDst,
6412
6412
  toDst: srcpath
6413
6413
  };
6414
6414
  }
6415
- const srcExists = fs16.existsSync(srcpath);
6415
+ const srcExists = fs17.existsSync(srcpath);
6416
6416
  if (!srcExists) throw new Error("relative srcpath does not exist");
6417
6417
  return {
6418
6418
  toCwd: srcpath,
6419
- toDst: path12.relative(dstdir, srcpath)
6419
+ toDst: path13.relative(dstdir, srcpath)
6420
6420
  };
6421
6421
  }
6422
6422
  module2.exports = {
@@ -6430,13 +6430,13 @@ var require_symlink_paths = __commonJS({
6430
6430
  var require_symlink_type = __commonJS({
6431
6431
  "node_modules/fs-extra/lib/ensure/symlink-type.js"(exports2, module2) {
6432
6432
  "use strict";
6433
- var fs16 = require_fs();
6433
+ var fs17 = require_fs();
6434
6434
  var u = require_universalify().fromPromise;
6435
6435
  async function symlinkType(srcpath, type) {
6436
6436
  if (type) return type;
6437
6437
  let stats;
6438
6438
  try {
6439
- stats = await fs16.lstat(srcpath);
6439
+ stats = await fs17.lstat(srcpath);
6440
6440
  } catch {
6441
6441
  return "file";
6442
6442
  }
@@ -6446,7 +6446,7 @@ var require_symlink_type = __commonJS({
6446
6446
  if (type) return type;
6447
6447
  let stats;
6448
6448
  try {
6449
- stats = fs16.lstatSync(srcpath);
6449
+ stats = fs17.lstatSync(srcpath);
6450
6450
  } catch {
6451
6451
  return "file";
6452
6452
  }
@@ -6464,8 +6464,8 @@ var require_symlink = __commonJS({
6464
6464
  "node_modules/fs-extra/lib/ensure/symlink.js"(exports2, module2) {
6465
6465
  "use strict";
6466
6466
  var u = require_universalify().fromPromise;
6467
- var path12 = require("path");
6468
- var fs16 = require_fs();
6467
+ var path13 = require("path");
6468
+ var fs17 = require_fs();
6469
6469
  var { mkdirs, mkdirsSync } = require_mkdirs();
6470
6470
  var { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
6471
6471
  var { symlinkType, symlinkTypeSync } = require_symlink_type();
@@ -6474,64 +6474,64 @@ var require_symlink = __commonJS({
6474
6474
  async function createSymlink(srcpath, dstpath, type) {
6475
6475
  let stats;
6476
6476
  try {
6477
- stats = await fs16.lstat(dstpath);
6477
+ stats = await fs17.lstat(dstpath);
6478
6478
  } catch {
6479
6479
  }
6480
6480
  if (stats && stats.isSymbolicLink()) {
6481
6481
  let srcStat;
6482
- if (path12.isAbsolute(srcpath)) {
6483
- srcStat = await fs16.stat(srcpath, { bigint: true });
6482
+ if (path13.isAbsolute(srcpath)) {
6483
+ srcStat = await fs17.stat(srcpath, { bigint: true });
6484
6484
  } else {
6485
- const dstdir = path12.dirname(dstpath);
6486
- const relativeToDst = path12.join(dstdir, srcpath);
6485
+ const dstdir = path13.dirname(dstpath);
6486
+ const relativeToDst = path13.join(dstdir, srcpath);
6487
6487
  try {
6488
- srcStat = await fs16.stat(relativeToDst, { bigint: true });
6488
+ srcStat = await fs17.stat(relativeToDst, { bigint: true });
6489
6489
  } catch {
6490
- srcStat = await fs16.stat(srcpath, { bigint: true });
6490
+ srcStat = await fs17.stat(srcpath, { bigint: true });
6491
6491
  }
6492
6492
  }
6493
- const dstStat = await fs16.stat(dstpath, { bigint: true });
6493
+ const dstStat = await fs17.stat(dstpath, { bigint: true });
6494
6494
  if (areIdentical(srcStat, dstStat)) return;
6495
6495
  }
6496
6496
  const relative = await symlinkPaths(srcpath, dstpath);
6497
6497
  srcpath = relative.toDst;
6498
6498
  const toType = await symlinkType(relative.toCwd, type);
6499
- const dir = path12.dirname(dstpath);
6499
+ const dir = path13.dirname(dstpath);
6500
6500
  if (!await pathExists(dir)) {
6501
6501
  await mkdirs(dir);
6502
6502
  }
6503
- return fs16.symlink(srcpath, dstpath, toType);
6503
+ return fs17.symlink(srcpath, dstpath, toType);
6504
6504
  }
6505
6505
  function createSymlinkSync(srcpath, dstpath, type) {
6506
6506
  let stats;
6507
6507
  try {
6508
- stats = fs16.lstatSync(dstpath);
6508
+ stats = fs17.lstatSync(dstpath);
6509
6509
  } catch {
6510
6510
  }
6511
6511
  if (stats && stats.isSymbolicLink()) {
6512
6512
  let srcStat;
6513
- if (path12.isAbsolute(srcpath)) {
6514
- srcStat = fs16.statSync(srcpath, { bigint: true });
6513
+ if (path13.isAbsolute(srcpath)) {
6514
+ srcStat = fs17.statSync(srcpath, { bigint: true });
6515
6515
  } else {
6516
- const dstdir = path12.dirname(dstpath);
6517
- const relativeToDst = path12.join(dstdir, srcpath);
6516
+ const dstdir = path13.dirname(dstpath);
6517
+ const relativeToDst = path13.join(dstdir, srcpath);
6518
6518
  try {
6519
- srcStat = fs16.statSync(relativeToDst, { bigint: true });
6519
+ srcStat = fs17.statSync(relativeToDst, { bigint: true });
6520
6520
  } catch {
6521
- srcStat = fs16.statSync(srcpath, { bigint: true });
6521
+ srcStat = fs17.statSync(srcpath, { bigint: true });
6522
6522
  }
6523
6523
  }
6524
- const dstStat = fs16.statSync(dstpath, { bigint: true });
6524
+ const dstStat = fs17.statSync(dstpath, { bigint: true });
6525
6525
  if (areIdentical(srcStat, dstStat)) return;
6526
6526
  }
6527
6527
  const relative = symlinkPathsSync(srcpath, dstpath);
6528
6528
  srcpath = relative.toDst;
6529
6529
  type = symlinkTypeSync(relative.toCwd, type);
6530
- const dir = path12.dirname(dstpath);
6531
- const exists = fs16.existsSync(dir);
6532
- if (exists) return fs16.symlinkSync(srcpath, dstpath, type);
6530
+ const dir = path13.dirname(dstpath);
6531
+ const exists = fs17.existsSync(dir);
6532
+ if (exists) return fs17.symlinkSync(srcpath, dstpath, type);
6533
6533
  mkdirsSync(dir);
6534
- return fs16.symlinkSync(srcpath, dstpath, type);
6534
+ return fs17.symlinkSync(srcpath, dstpath, type);
6535
6535
  }
6536
6536
  module2.exports = {
6537
6537
  createSymlink: u(createSymlink),
@@ -6603,9 +6603,9 @@ var require_jsonfile = __commonJS({
6603
6603
  if (typeof options === "string") {
6604
6604
  options = { encoding: options };
6605
6605
  }
6606
- const fs16 = options.fs || _fs;
6606
+ const fs17 = options.fs || _fs;
6607
6607
  const shouldThrow = "throws" in options ? options.throws : true;
6608
- let data = await universalify.fromCallback(fs16.readFile)(file, options);
6608
+ let data = await universalify.fromCallback(fs17.readFile)(file, options);
6609
6609
  data = stripBom(data);
6610
6610
  let obj;
6611
6611
  try {
@@ -6625,10 +6625,10 @@ var require_jsonfile = __commonJS({
6625
6625
  if (typeof options === "string") {
6626
6626
  options = { encoding: options };
6627
6627
  }
6628
- const fs16 = options.fs || _fs;
6628
+ const fs17 = options.fs || _fs;
6629
6629
  const shouldThrow = "throws" in options ? options.throws : true;
6630
6630
  try {
6631
- let content = fs16.readFileSync(file, options);
6631
+ let content = fs17.readFileSync(file, options);
6632
6632
  content = stripBom(content);
6633
6633
  return JSON.parse(content, options.reviver);
6634
6634
  } catch (err) {
@@ -6641,15 +6641,15 @@ var require_jsonfile = __commonJS({
6641
6641
  }
6642
6642
  }
6643
6643
  async function _writeFile(file, obj, options = {}) {
6644
- const fs16 = options.fs || _fs;
6644
+ const fs17 = options.fs || _fs;
6645
6645
  const str = stringify(obj, options);
6646
- await universalify.fromCallback(fs16.writeFile)(file, str, options);
6646
+ await universalify.fromCallback(fs17.writeFile)(file, str, options);
6647
6647
  }
6648
6648
  var writeFile = universalify.fromPromise(_writeFile);
6649
6649
  function writeFileSync(file, obj, options = {}) {
6650
- const fs16 = options.fs || _fs;
6650
+ const fs17 = options.fs || _fs;
6651
6651
  const str = stringify(obj, options);
6652
- return fs16.writeFileSync(file, str, options);
6652
+ return fs17.writeFileSync(file, str, options);
6653
6653
  }
6654
6654
  module2.exports = {
6655
6655
  readFile,
@@ -6680,23 +6680,23 @@ var require_output_file = __commonJS({
6680
6680
  "node_modules/fs-extra/lib/output-file/index.js"(exports2, module2) {
6681
6681
  "use strict";
6682
6682
  var u = require_universalify().fromPromise;
6683
- var fs16 = require_fs();
6684
- var path12 = require("path");
6683
+ var fs17 = require_fs();
6684
+ var path13 = require("path");
6685
6685
  var mkdir = require_mkdirs();
6686
6686
  var pathExists = require_path_exists().pathExists;
6687
6687
  async function outputFile(file, data, encoding = "utf-8") {
6688
- const dir = path12.dirname(file);
6688
+ const dir = path13.dirname(file);
6689
6689
  if (!await pathExists(dir)) {
6690
6690
  await mkdir.mkdirs(dir);
6691
6691
  }
6692
- return fs16.writeFile(file, data, encoding);
6692
+ return fs17.writeFile(file, data, encoding);
6693
6693
  }
6694
6694
  function outputFileSync(file, ...args) {
6695
- const dir = path12.dirname(file);
6696
- if (!fs16.existsSync(dir)) {
6695
+ const dir = path13.dirname(file);
6696
+ if (!fs17.existsSync(dir)) {
6697
6697
  mkdir.mkdirsSync(dir);
6698
6698
  }
6699
- fs16.writeFileSync(file, ...args);
6699
+ fs17.writeFileSync(file, ...args);
6700
6700
  }
6701
6701
  module2.exports = {
6702
6702
  outputFile: u(outputFile),
@@ -6755,8 +6755,8 @@ var require_json = __commonJS({
6755
6755
  var require_move = __commonJS({
6756
6756
  "node_modules/fs-extra/lib/move/move.js"(exports2, module2) {
6757
6757
  "use strict";
6758
- var fs16 = require_fs();
6759
- var path12 = require("path");
6758
+ var fs17 = require_fs();
6759
+ var path13 = require("path");
6760
6760
  var { copy } = require_copy2();
6761
6761
  var { remove } = require_remove();
6762
6762
  var { mkdirp } = require_mkdirs();
@@ -6766,8 +6766,8 @@ var require_move = __commonJS({
6766
6766
  const overwrite = opts.overwrite || opts.clobber || false;
6767
6767
  const { srcStat, isChangingCase = false } = await stat.checkPaths(src, dest, "move", opts);
6768
6768
  await stat.checkParentPaths(src, srcStat, dest, "move");
6769
- const destParent = path12.dirname(dest);
6770
- const parsedParentPath = path12.parse(destParent);
6769
+ const destParent = path13.dirname(dest);
6770
+ const parsedParentPath = path13.parse(destParent);
6771
6771
  if (parsedParentPath.root !== destParent) {
6772
6772
  await mkdirp(destParent);
6773
6773
  }
@@ -6782,7 +6782,7 @@ var require_move = __commonJS({
6782
6782
  }
6783
6783
  }
6784
6784
  try {
6785
- await fs16.rename(src, dest);
6785
+ await fs17.rename(src, dest);
6786
6786
  } catch (err) {
6787
6787
  if (err.code !== "EXDEV") {
6788
6788
  throw err;
@@ -6807,8 +6807,8 @@ var require_move = __commonJS({
6807
6807
  var require_move_sync = __commonJS({
6808
6808
  "node_modules/fs-extra/lib/move/move-sync.js"(exports2, module2) {
6809
6809
  "use strict";
6810
- var fs16 = require_graceful_fs();
6811
- var path12 = require("path");
6810
+ var fs17 = require_graceful_fs();
6811
+ var path13 = require("path");
6812
6812
  var copySync = require_copy2().copySync;
6813
6813
  var removeSync = require_remove().removeSync;
6814
6814
  var mkdirpSync = require_mkdirs().mkdirpSync;
@@ -6818,12 +6818,12 @@ var require_move_sync = __commonJS({
6818
6818
  const overwrite = opts.overwrite || opts.clobber || false;
6819
6819
  const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
6820
6820
  stat.checkParentPathsSync(src, srcStat, dest, "move");
6821
- if (!isParentRoot(dest)) mkdirpSync(path12.dirname(dest));
6821
+ if (!isParentRoot(dest)) mkdirpSync(path13.dirname(dest));
6822
6822
  return doRename(src, dest, overwrite, isChangingCase);
6823
6823
  }
6824
6824
  function isParentRoot(dest) {
6825
- const parent = path12.dirname(dest);
6826
- const parsedPath = path12.parse(parent);
6825
+ const parent = path13.dirname(dest);
6826
+ const parsedPath = path13.parse(parent);
6827
6827
  return parsedPath.root === parent;
6828
6828
  }
6829
6829
  function doRename(src, dest, overwrite, isChangingCase) {
@@ -6832,12 +6832,12 @@ var require_move_sync = __commonJS({
6832
6832
  removeSync(dest);
6833
6833
  return rename(src, dest, overwrite);
6834
6834
  }
6835
- if (fs16.existsSync(dest)) throw new Error("dest already exists.");
6835
+ if (fs17.existsSync(dest)) throw new Error("dest already exists.");
6836
6836
  return rename(src, dest, overwrite);
6837
6837
  }
6838
6838
  function rename(src, dest, overwrite) {
6839
6839
  try {
6840
- fs16.renameSync(src, dest);
6840
+ fs17.renameSync(src, dest);
6841
6841
  } catch (err) {
6842
6842
  if (err.code !== "EXDEV") throw err;
6843
6843
  return moveAcrossDevice(src, dest, overwrite);
@@ -8361,25 +8361,189 @@ var import_path = __toESM(require("path"));
8361
8361
  var LaravelRouteParser = class {
8362
8362
  async parse(filePath, options = {}) {
8363
8363
  const projectRoot = import_path.default.resolve(import_path.default.dirname(filePath), "..");
8364
+ const extractModels = options.extractModels ? "true" : "false";
8364
8365
  const phpScript = `<?php
8365
8366
  require __DIR__.'/vendor/autoload.php';
8366
8367
  $app = require_once __DIR__.'/bootstrap/app.php';
8367
- $kernel = $app->make(Illuminate\\Contracts\\Console\\Kernel::class);
8368
+ $kernel = $app->make(IlluminateContractsConsoleKernel::class);
8368
8369
  $kernel->bootstrap();
8369
8370
 
8370
- $result = [
8371
- 'routes' => [],
8372
- 'models' => []
8373
- ];
8371
+ $result = ['routes' => [], 'models' => []];
8372
+
8373
+ // \u2500\u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
8374
+
8375
+ function rsync_get_source(ReflectionFunctionAbstract $ref): ?string {
8376
+ $file = $ref->getFileName();
8377
+ $start = $ref->getStartLine();
8378
+ $end = $ref->getEndLine();
8379
+ if (!$file || $start === false || $end === false) return null;
8380
+ return implode('', array_slice(file($file), $start - 1, $end - $start + 1));
8381
+ }
8382
+
8383
+ /**
8384
+ * Try to resolve responseMetadata from a Resource class.
8385
+ * Checks (in order):
8386
+ * 1. PHP 8 #[RouteSyncResponse] attribute on class
8387
+ * 2. @mixin docblock
8388
+ * 3. Constructor parameter type hint \u2190 NEW
8389
+ * 4. $this->resource @var docblock \u2190 NEW
8390
+ * 5. Strip Resource suffix \u2192 match AppModels*
8391
+ * 6. toArray() field vs DB column intersection
8392
+ */
8393
+ function rsync_infer_from_resource(string $resourceClass, bool $collection): ?array {
8394
+ if (!class_exists($resourceClass)) return null;
8395
+ $resRef = new ReflectionClass($resourceClass);
8396
+
8397
+ // 1. PHP 8 attribute
8398
+ foreach ($resRef->getAttributes() as $attr) {
8399
+ $short = class_basename($attr->getName());
8400
+ if (in_array($short, ['Response', 'RouteSyncResponse'])) {
8401
+ $args = $attr->getArguments();
8402
+ $type = $args[0] ?? $args['type'] ?? $args['model'] ?? $args['response'] ?? null;
8403
+ if ($type) return ['type' => class_basename($type), 'collection' => $collection];
8404
+ }
8405
+ }
8406
+
8407
+ // 2. @mixin docblock
8408
+ $doc = $resRef->getDocComment();
8409
+ if ($doc && preg_match('/@mixins+([\\\\w]+)/', $doc, $m)) {
8410
+ return ['type' => class_basename($m[1]), 'collection' => $collection];
8411
+ }
8412
+
8413
+ // 3. Constructor parameter type hint: __construct(User $user)
8414
+ if ($resRef->hasMethod('__construct')) {
8415
+ $ctor = $resRef->getMethod('__construct');
8416
+ foreach ($ctor->getParameters() as $param) {
8417
+ $ptype = $param->getType();
8418
+ if ($ptype && !$ptype->isBuiltin()) {
8419
+ $cn = $ptype->getName();
8420
+ if (is_subclass_of($cn, 'IlluminateDatabaseEloquentModel')) {
8421
+ return ['type' => class_basename($cn), 'collection' => $collection];
8422
+ }
8423
+ }
8424
+ }
8425
+ }
8426
+
8427
+ // 4. $this->resource @var docblock in class body or toArray()
8428
+ $classDoc = $resRef->getDocComment() ?: '';
8429
+ foreach (['toArray', 'toResponse'] as $mname) {
8430
+ if ($resRef->hasMethod($mname)) {
8431
+ $src = rsync_get_source($resRef->getMethod($mname)) ?? '';
8432
+ $classDoc .= $src;
8433
+ }
8434
+ }
8435
+ if (preg_match('/@vars+([\\\\w]+)s+$(?:resource|model)/', $classDoc, $m)) {
8436
+ $cn = ltrim($m[1], '\\');
8437
+ $fqcn = str_contains($cn, '\\') ? $cn : 'App\\Models\\' . $cn;
8438
+ if (class_exists($fqcn)) {
8439
+ return ['type' => class_basename($fqcn), 'collection' => $collection];
8440
+ }
8441
+ }
8442
+
8443
+ // 5. Strip Resource suffix \u2192 AppModels<Name>
8444
+ $inferredName = preg_replace('/Resource$/', '', class_basename($resourceClass));
8445
+ if ($inferredName) {
8446
+ $mc = 'App\\Models\\' . $inferredName;
8447
+ if (class_exists($mc)) {
8448
+ return ['type' => $inferredName, 'collection' => $collection];
8449
+ }
8450
+ }
8451
+
8452
+ // 6. toArray() field vs DB column intersection
8453
+ if ($resRef->hasMethod('toArray')) {
8454
+ $src = rsync_get_source($resRef->getMethod('toArray')) ?? '';
8455
+ preg_match_all('/['"]([a-zA-Z0-9_]+)['"]s*=>/', $src, $km);
8456
+ $resFields = array_unique($km[1] ?? []);
8457
+ if (!empty($resFields)) {
8458
+ $bestModel = null; $bestScore = 0;
8459
+ $modelsPath = app_path('Models');
8460
+ if (is_dir($modelsPath)) {
8461
+ foreach (IlluminateSupportFacadesFile::allFiles($modelsPath) as $mf) {
8462
+ $mn = preg_replace('/.php$/', '', $mf->getFilename());
8463
+ $mc = 'App\\Models\\' . $mn;
8464
+ if (!class_exists($mc)) continue;
8465
+ try {
8466
+ $mi = new $mc();
8467
+ $cols = array_column(IlluminateSupportFacadesSchema::getColumns($mi->getTable()), 'name');
8468
+ $score = count(array_intersect($resFields, $cols));
8469
+ if ($score > $bestScore) { $bestScore = $score; $bestModel = $mn; }
8470
+ } catch (Exception $e) {}
8471
+ }
8472
+ }
8473
+ if ($bestModel && $bestScore > 0) {
8474
+ return ['type' => $bestModel, 'collection' => $collection];
8475
+ }
8476
+ }
8477
+ }
8478
+
8479
+ return null;
8480
+ }
8481
+
8482
+ /**
8483
+ * Try to resolve responseMetadata directly from controller method source.
8484
+ * Handles cases where no Resource class is used at all.
8485
+ */
8486
+ function rsync_infer_from_source(?string $source): ?array {
8487
+ if (!$source) return null;
8488
+
8489
+ // return new SomeResource($x)
8490
+ if (preg_match('/returns+news+([a-zA-Z0-9_]+Resource)s*(/', $source, $m)) {
8491
+ $rc = 'App\\Http\\Resources\\' . $m[1];
8492
+ $result = rsync_infer_from_resource($rc, false);
8493
+ if ($result) return $result;
8494
+ }
8495
+
8496
+ // SomeResource::collection(...)
8497
+ if (preg_match('/([a-zA-Z0-9_]+Resource)::collections*(/', $source, $m)) {
8498
+ $rc = 'App\\Http\\Resources\\' . $m[1];
8499
+ $result = rsync_infer_from_resource($rc, true);
8500
+ if ($result) return $result;
8501
+ }
8502
+
8503
+ // ->paginate() or ->simplePaginate() with Resource
8504
+ if (preg_match('/([a-zA-Z0-9_]+Resource)::collection.*paginate/s', $source, $m)) {
8505
+ $rc = 'App\\Http\\Resources\\' . $m[1];
8506
+ $result = rsync_infer_from_resource($rc, true);
8507
+ if ($result) { $result['paginated'] = true; return $result; }
8508
+ }
8509
+
8510
+ // response()->json(['token' => ..., 'user' => ...]) \u2014 inline array
8511
+ // Extract top-level keys and try to match a model
8512
+ if (preg_match('/response()s*->s*jsons*(s*[([^]]{0,800})]/', $source, $jsonMatch)) {
8513
+ preg_match_all('/['"]([a-zA-Z0-9_]+)['"]s*=>/', $jsonMatch[1], $km);
8514
+ $keys = array_unique($km[1] ?? []);
8515
+ if (!empty($keys)) {
8516
+ $bestModel = null; $bestScore = 0;
8517
+ foreach (IlluminateSupportFacadesFile::allFiles(app_path('Models')) as $mf) {
8518
+ $mn = preg_replace('/.php$/', '', $mf->getFilename());
8519
+ $mc = 'App\\Models\\' . $mn;
8520
+ if (!class_exists($mc)) continue;
8521
+ try {
8522
+ $mi = new $mc();
8523
+ $cols = array_column(IlluminateSupportFacadesSchema::getColumns($mi->getTable()), 'name');
8524
+ $camelCols = array_map(fn($c) => lcfirst(str_replace('_', '', ucwords($c, '_'))), $cols);
8525
+ $score = count(array_intersect($keys, array_merge($cols, $camelCols)));
8526
+ if ($score > $bestScore) { $bestScore = $score; $bestModel = $mn; }
8527
+ } catch (Exception $e) {}
8528
+ }
8529
+ if ($bestModel && $bestScore >= 2) {
8530
+ return ['type' => $bestModel, 'collection' => false];
8531
+ }
8532
+ }
8533
+ }
8534
+
8535
+ return null;
8536
+ }
8537
+
8538
+ // \u2500\u2500\u2500 Main Route Loop \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
8374
8539
 
8375
- // Extract Routes
8376
8540
  $routes = app('router')->getRoutes();
8377
8541
  foreach ($routes as $route) {
8378
8542
  if (!str_starts_with($route->uri(), 'api/')) continue;
8379
-
8543
+
8380
8544
  $methods = array_diff($route->methods(), ['HEAD']);
8381
8545
  $middlewares = $route->gatherMiddleware();
8382
-
8546
+
8383
8547
  $auth = false;
8384
8548
  foreach ($middlewares as $mw) {
8385
8549
  if (is_string($mw) && (str_contains($mw, 'auth') || str_contains($mw, 'sanctum'))) {
@@ -8388,17 +8552,21 @@ foreach ($routes as $route) {
8388
8552
  }
8389
8553
 
8390
8554
  $schema = [];
8555
+ $responseMetadata = null;
8391
8556
  $action = $route->getAction();
8557
+
8392
8558
  if (isset($action['uses']) && is_string($action['uses']) && str_contains($action['uses'], '@')) {
8393
8559
  list($controller, $method) = explode('@', $action['uses']);
8394
8560
  if (class_exists($controller)) {
8395
8561
  try {
8396
8562
  $reflector = new ReflectionMethod($controller, $method);
8563
+
8564
+ // \u2500\u2500 Request schema from FormRequest \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
8397
8565
  foreach ($reflector->getParameters() as $param) {
8398
8566
  $type = $param->getType();
8399
8567
  if ($type && !$type->isBuiltin()) {
8400
8568
  $className = $type->getName();
8401
- if (is_subclass_of($className, 'Illuminate\\Foundation\\Http\\FormRequest')) {
8569
+ if (is_subclass_of($className, 'IlluminateFoundationHttpFormRequest')) {
8402
8570
  $request = new $className();
8403
8571
  if (method_exists($request, 'rules')) {
8404
8572
  $schema = $request->rules();
@@ -8406,174 +8574,97 @@ foreach ($routes as $route) {
8406
8574
  }
8407
8575
  }
8408
8576
  }
8409
-
8410
- // Parse PHP 8 Attributes for Response Metadata
8411
- $responseMetadata = null;
8412
- $attributes = $reflector->getAttributes();
8413
- foreach ($attributes as $attr) {
8414
- $attrName = $attr->getName();
8415
- $shortName = class_basename($attrName);
8416
-
8417
- if (in_array($shortName, ['Response', 'RouteSyncResponse'])) {
8577
+
8578
+ // \u2500\u2500 Stage 1: PHP 8 Attribute on controller method \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
8579
+ foreach ($reflector->getAttributes() as $attr) {
8580
+ $short = class_basename($attr->getName());
8581
+ if (in_array($short, ['Response', 'RouteSyncResponse'])) {
8418
8582
  $args = $attr->getArguments();
8419
-
8420
- $type = null;
8421
- if (isset($args[0])) {
8422
- $type = $args[0];
8423
- } elseif (isset($args['type'])) {
8424
- $type = $args['type'];
8425
- } elseif (isset($args['model'])) {
8426
- $type = $args['model'];
8427
- } elseif (isset($args['response'])) {
8428
- $type = $args['response'];
8429
- }
8430
-
8431
- $collection = false;
8432
- if (isset($args[1])) {
8433
- $collection = (bool) $args[1];
8434
- } elseif (isset($args['collection'])) {
8435
- $collection = (bool) $args['collection'];
8436
- }
8437
-
8583
+ $type = $args[0] ?? $args['type'] ?? $args['model'] ?? $args['response'] ?? null;
8438
8584
  if ($type) {
8439
- $responseMetadata = [
8440
- 'type' => class_basename($type),
8441
- 'collection' => $collection
8442
- ];
8585
+ $collection = (bool)($args[1] ?? $args['collection'] ?? false);
8586
+ $responseMetadata = ['type' => class_basename($type), 'collection' => $collection];
8443
8587
  break;
8444
8588
  }
8445
8589
  }
8446
8590
  }
8447
-
8448
-
8449
- $fileName = $reflector->getFileName();
8450
- $startLine = $reflector->getStartLine();
8451
- $endLine = $reflector->getEndLine();
8452
- $methodSource = null;
8453
-
8454
- if ($fileName && $startLine !== false && $endLine !== false) {
8455
- $lines = file($fileName);
8456
- $methodSource = implode("", array_slice($lines, $startLine - 1, $endLine - $startLine + 1));
8457
- }
8458
8591
 
8459
- // Resource Discovery
8460
- if (!$responseMetadata && $methodSource) {
8461
- $resourceName = null;
8462
- $collection = false;
8463
-
8464
- if (preg_match('/return\\s+new\\s+([a-zA-Z0-9_]+Resource)/', $methodSource, $matches)) {
8465
- $resourceName = $matches[1];
8466
- } elseif (preg_match('/return\\s+([a-zA-Z0-9_]+Resource)::collection/', $methodSource, $matches)) {
8467
- $resourceName = $matches[1];
8468
- $collection = true;
8469
- }
8470
-
8471
- if ($resourceName) {
8472
- $resourceClass = 'App\\\\Http\\\\Resources\\\\' . $resourceName;
8473
- if (class_exists($resourceClass)) {
8474
- $resReflector = new ReflectionClass($resourceClass);
8475
- $resAttrs = $resReflector->getAttributes();
8476
- foreach ($resAttrs as $attr) {
8477
- $shortName = class_basename($attr->getName());
8478
- if (in_array($shortName, ['Response', 'RouteSyncResponse'])) {
8479
- $args = $attr->getArguments();
8480
- $type = $args[0] ?? $args['type'] ?? $args['model'] ?? $args['response'] ?? null;
8481
- if ($type) {
8482
- $responseMetadata = [
8483
- 'type' => class_basename($type),
8484
- 'collection' => $collection
8485
- ];
8486
- }
8487
- }
8488
- }
8489
-
8490
- if (!$responseMetadata) {
8491
- $docComment = $resReflector->getDocComment();
8492
- if ($docComment && preg_match('/@mixin\\s+([\\\\\\\\a-zA-Z0-9_]+)/', $docComment, $mixinMatches)) {
8493
- $responseMetadata = [
8494
- 'type' => class_basename($mixinMatches[1]),
8495
- 'collection' => $collection
8496
- ];
8497
- }
8498
- }
8499
- }
8500
- }
8592
+ $methodSource = rsync_get_source($reflector);
8593
+
8594
+ // \u2500\u2500 Stage 2: Source-based inference \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
8595
+ if (!$responseMetadata) {
8596
+ $responseMetadata = rsync_infer_from_source($methodSource);
8501
8597
  }
8502
-
8503
- // Fallback: Try to parse $request->validate([...]) from source code
8598
+
8599
+ // \u2500\u2500 Stage 3: Fallback $request->validate([...]) for schema \u2500\u2500
8504
8600
  if (empty($schema) && $methodSource) {
8505
- // Look for $request->validate([ ... ])
8506
- if (preg_match('/\\\\$request->validate\\\\s*\\\\(\\\\s*\\\\[(.*?)\\\\]\\\\s*\\\\)/s', $methodSource, $matches)) {
8507
- $rulesString = $matches[1];
8508
- // Match 'field' => 'rules'
8509
- preg_match_all('~[\\'"]([a-zA-Z0-9_.*]+)[\\'"]\\\\s*=>\\\\s*[\\'"](.*?)[\\'"]~', $rulesString, $ruleMatches);
8510
- if (!empty($ruleMatches[1])) {
8511
- foreach ($ruleMatches[1] as $index => $field) {
8512
- $schema[$field] = $ruleMatches[2][$index];
8513
- }
8601
+ if (preg_match('/$request->validates*(s*[(.*?)]s*)/s', $methodSource, $vm)) {
8602
+ preg_match_all('/['"]([a-zA-Z0-9_.*]+)['"]s*=>s*['"]([^'"]*)['"]/', $vm[1], $rm);
8603
+ foreach ($rm[1] as $i => $field) {
8604
+ $schema[$field] = $rm[2][$i];
8514
8605
  }
8515
8606
  }
8516
8607
  }
8517
- } catch (\\Exception $e) {}
8608
+
8609
+ } catch (Exception $e) {}
8518
8610
  }
8519
8611
  }
8520
8612
 
8521
8613
  foreach ($methods as $method) {
8522
- $nameParts = explode('/', preg_replace('/^api\\//', '', $route->uri()));
8523
- $resource = preg_replace('/\\{.*\\}/', '', $nameParts[0]);
8614
+ $nameParts = explode('/', preg_replace('/^api//', '', $route->uri()));
8615
+ $resource = preg_replace('/{.*}/', '', $nameParts[0]);
8524
8616
  if (empty($resource)) $resource = 'api';
8525
-
8526
- $name = $resource . '.' . strtolower($method);
8527
-
8617
+
8528
8618
  $result['routes'][] = [
8529
- 'name' => $route->getName() ?: $name,
8530
- 'method' => $method,
8531
- 'path' => '/' . preg_replace('/^api\\//', '', $route->uri()),
8532
- 'auth' => $auth,
8619
+ 'name' => $route->getName() ?: ($resource . '.' . strtolower($method)),
8620
+ 'method' => $method,
8621
+ 'path' => '/' . preg_replace('/^api//', '', $route->uri()),
8622
+ 'auth' => $auth,
8533
8623
  'middleware' => $middlewares,
8534
- 'schema' => empty($schema) ? null : ['rules' => $schema],
8535
- 'response' => $responseMetadata
8624
+ 'schema' => empty($schema) ? null : ['rules' => $schema],
8625
+ 'response' => $responseMetadata,
8536
8626
  ];
8537
8627
  }
8538
8628
  }
8539
8629
 
8540
- // Extract Models if requested
8541
- $extractModels = ${options.extractModels ? "true" : "false"};
8630
+ // \u2500\u2500\u2500 Extract Models \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
8631
+
8632
+ $extractModels = ${extractModels};
8542
8633
  if ($extractModels) {
8543
8634
  $modelsPath = app_path('Models');
8544
8635
  if (is_dir($modelsPath)) {
8545
- $files = \\Illuminate\\Support\\Facades\\File::allFiles($modelsPath);
8636
+ $files = IlluminateSupportFacadesFile::allFiles($modelsPath);
8546
8637
  foreach ($files as $file) {
8547
- $class = 'App\\\\Models\\\\' . str_replace('/', '\\\\', $file->getRelativePathname());
8548
- $class = preg_replace('/\\.php$/', '', $class);
8549
-
8550
- if (class_exists($class) && is_subclass_of($class, 'Illuminate\\\\Database\\\\Eloquent\\\\Model')) {
8638
+ $class = 'App\\Models\\' . str_replace('/', '\\', $file->getRelativePathname());
8639
+ $class = preg_replace('/.php$/', '', $class);
8640
+
8641
+ if (class_exists($class) && is_subclass_of($class, 'Illuminate\\Database\\Eloquent\\Model')) {
8551
8642
  try {
8552
8643
  $reflection = new ReflectionClass($class);
8553
8644
  if ($reflection->isAbstract()) continue;
8554
-
8555
- $model = new $class();
8556
- $table = $model->getTable();
8557
- $columns = \\Illuminate\\Support\\Facades\\Schema::getColumns($table);
8558
-
8645
+
8646
+ $model = new $class();
8647
+ $table = $model->getTable();
8648
+ $columns = IlluminateSupportFacadesSchema::getColumns($table);
8649
+
8559
8650
  $parsedColumns = [];
8560
8651
  foreach ($columns as $col) {
8561
8652
  $parsedColumns[] = [
8562
- 'name' => $col['name'],
8563
- 'type' => $col['type'], // Use 'type' which contains the raw type like enum('a','b') instead of 'type_name'
8564
- 'nullable' => $col['nullable']
8653
+ 'name' => $col['name'],
8654
+ 'type' => $col['type'],
8655
+ 'nullable' => $col['nullable'],
8565
8656
  ];
8566
8657
  }
8567
-
8658
+
8568
8659
  $result['models'][] = [
8569
- 'name' => class_basename($class),
8570
- 'table' => $table,
8660
+ 'name' => class_basename($class),
8661
+ 'table' => $table,
8571
8662
  'columns' => $parsedColumns,
8572
- 'hidden' => $model->getHidden(),
8663
+ 'hidden' => $model->getHidden(),
8573
8664
  'appends' => $model->getAppends(),
8574
- 'casts' => $model->getCasts()
8665
+ 'casts' => $model->getCasts(),
8575
8666
  ];
8576
- } catch (\\Exception $e) {}
8667
+ } catch (Exception $e) {}
8577
8668
  }
8578
8669
  }
8579
8670
  }
@@ -8680,8 +8771,8 @@ function toIdentifier(value) {
8680
8771
  ].join("");
8681
8772
  return /^[A-Za-z_$]/.test(identifier) ? identifier : `route${toTypeName(identifier)}`;
8682
8773
  }
8683
- function toRuntimePath(path12) {
8684
- return path12.replace(/{([^}/]+)}/g, ":$1");
8774
+ function toRuntimePath(path13) {
8775
+ return path13.replace(/{([^}/]+)}/g, ":$1");
8685
8776
  }
8686
8777
  function toActionName(route, restSegments) {
8687
8778
  const method = route.method.toLowerCase();
@@ -8691,8 +8782,8 @@ function toActionName(route, restSegments) {
8691
8782
  function normalizeSegment(segment) {
8692
8783
  return segment.replace(/^{([^}/]+)}$/, "$1");
8693
8784
  }
8694
- function getPathSegments(path12) {
8695
- return path12.replace(/^\//, "").split("/").filter(Boolean);
8785
+ function getPathSegments(path13) {
8786
+ return path13.replace(/^\//, "").split("/").filter(Boolean);
8696
8787
  }
8697
8788
  function splitWords(value) {
8698
8789
  return value.replace(/^{([^}/]+)}$/, "$1").replace(/([a-z0-9])([A-Z])/g, "$1 $2").split(/[^A-Za-z0-9]+/).filter(Boolean).map((word) => word.toLowerCase());
@@ -8726,26 +8817,10 @@ var SDKGenerator = class {
8726
8817
  const lines = [];
8727
8818
  let usesZod = false;
8728
8819
  let usesTypes = false;
8729
- const zodRoutes = /* @__PURE__ */ new Set();
8730
- if (options.zod) {
8731
- for (const [group, routes] of Object.entries(grouped)) {
8732
- for (const route of routes) {
8733
- if (route.schema?.rules) {
8734
- usesZod = true;
8735
- zodRoutes.add(`${group}.${route.actionName}`);
8736
- }
8737
- if (route.response) {
8738
- usesTypes = true;
8739
- }
8740
- }
8741
- }
8742
- } else {
8743
- for (const [group, routes] of Object.entries(grouped)) {
8744
- for (const route of routes) {
8745
- if (route.response) {
8746
- usesTypes = true;
8747
- }
8748
- }
8820
+ for (const routes of Object.values(grouped)) {
8821
+ for (const route of routes) {
8822
+ if (options.zod && route.schema?.rules) usesZod = true;
8823
+ if (route.response) usesTypes = true;
8749
8824
  }
8750
8825
  }
8751
8826
  lines.push(`// Auto-generated by routesync. Do not edit manually.`);
@@ -8761,15 +8836,15 @@ var SDKGenerator = class {
8761
8836
  lines.push(`import * as Types from './types'`);
8762
8837
  }
8763
8838
  lines.push(``);
8764
- for (const [group, routes] of Object.entries(grouped)) {
8839
+ for (const [groupName, routes] of Object.entries(grouped)) {
8765
8840
  for (const route of routes) {
8766
- const TitleCaseGroup = group.charAt(0).toUpperCase() + group.slice(1);
8841
+ const TitleCaseGroup = groupName.charAt(0).toUpperCase() + groupName.slice(1);
8767
8842
  const TitleCaseAction = route.actionName.charAt(0).toUpperCase() + route.actionName.slice(1);
8768
8843
  const ContractName = `${TitleCaseGroup}${TitleCaseAction}Contract`;
8844
+ const SchemaName = `${TitleCaseGroup}${TitleCaseAction}Schema`;
8769
8845
  const pathParams = Array.from(route.runtimePath.matchAll(/:([a-zA-Z0-9_]+)/g)).map((m) => m[1]);
8770
8846
  const paramsType = pathParams.length > 0 ? `{ ${pathParams.map((p) => `${p}: string`).join(", ")} }` : `unknown`;
8771
- const methodActionName = TitleCaseGroup + TitleCaseAction;
8772
- const bodyType = route.schema?.rules && usesZod ? `z.infer<typeof Schemas.${methodActionName}Schema>` : `unknown`;
8847
+ const bodyType = route.schema?.rules && usesZod ? `z.infer<typeof Schemas.${SchemaName}>` : `unknown`;
8773
8848
  const responseType = route.response ? `Types.${route.response.type}${route.response.collection ? "[]" : ""}` : `unknown`;
8774
8849
  lines.push(`export type ${ContractName} = {`);
8775
8850
  lines.push(` request: {`);
@@ -8783,23 +8858,23 @@ var SDKGenerator = class {
8783
8858
  }
8784
8859
  lines.push(``);
8785
8860
  lines.push(`export const api = defineApi({`);
8786
- for (const [group, routes] of Object.entries(grouped)) {
8787
- lines.push(` ${group}: {`);
8861
+ for (const [groupName, routes] of Object.entries(grouped)) {
8862
+ lines.push(` ${groupName}: {`);
8788
8863
  for (const route of routes) {
8789
- const TitleCaseGroup = group.charAt(0).toUpperCase() + group.slice(1);
8864
+ const TitleCaseGroup = groupName.charAt(0).toUpperCase() + groupName.slice(1);
8790
8865
  const TitleCaseAction = route.actionName.charAt(0).toUpperCase() + route.actionName.slice(1);
8791
8866
  const ContractName = `${TitleCaseGroup}${TitleCaseAction}Contract`;
8867
+ const SchemaName = `${TitleCaseGroup}${TitleCaseAction}Schema`;
8792
8868
  lines.push(` ${route.actionName}: endpoint<${ContractName}['response'], ${ContractName}['request']['params'], ${ContractName}['request']['body']>({`);
8793
8869
  lines.push(` method: '${route.method}',`);
8794
8870
  lines.push(` path: '${route.runtimePath}',`);
8795
8871
  if (route.auth) lines.push(` auth: true,`);
8796
8872
  if (options.zod && route.schema?.rules) {
8797
- lines.push(` schema: {`);
8798
- lines.push(` body: Schemas.${ContractName.replace("Contract", "Schema")}`);
8799
- lines.push(` },`);
8873
+ lines.push(` schema: { body: Schemas.${SchemaName} },`);
8800
8874
  }
8801
- if (options.zod && route.response && options.models) {
8802
- lines.push(` responseSchema: Schemas.${route.response.type}Schema${route.response.collection ? ".array()" : ""},`);
8875
+ if (options.zod && options.models && route.response) {
8876
+ const responseSchema = `Schemas.${route.response.type}Schema${route.response.collection ? ".array()" : ""}`;
8877
+ lines.push(` responseSchema: ${responseSchema},`);
8803
8878
  }
8804
8879
  lines.push(` }),`);
8805
8880
  }
@@ -8857,7 +8932,6 @@ var import_fs_extra4 = __toESM(require_lib());
8857
8932
  var TypeGenerator = class {
8858
8933
  static async generate(manifest, outputDir) {
8859
8934
  const lines = [];
8860
- const hasSchemas = manifest.routes.some((r) => r.schema && Object.keys(r.schema).length > 0);
8861
8935
  lines.push(`// Auto-generated by routesync. Do not edit manually.`);
8862
8936
  lines.push(``);
8863
8937
  lines.push(`export interface ApiResponse<T = unknown> {`);
@@ -8885,15 +8959,17 @@ var TypeGenerator = class {
8885
8959
  for (const model of manifest.models) {
8886
8960
  lines.push(`export interface ${model.name} {`);
8887
8961
  for (const col of model.columns) {
8888
- if (model.hidden && model.hidden.includes(col.name)) continue;
8962
+ if (model.hidden?.includes(col.name)) continue;
8889
8963
  const tsType = this.mapSqlTypeToTs(col.type);
8890
8964
  const finalTsType = col.nullable ? `${tsType} | null` : tsType;
8891
- const safeName = camelCase(col.name).match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) ? camelCase(col.name) : `"${camelCase(col.name)}"`;
8965
+ const key = camelCase(col.name);
8966
+ const safeName = key.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) ? key : `"${key}"`;
8892
8967
  lines.push(` ${safeName}: ${finalTsType}`);
8893
8968
  }
8894
8969
  if (model.appends && model.appends.length > 0) {
8895
8970
  for (const append of model.appends) {
8896
- const safeAppend = camelCase(append).match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) ? camelCase(append) : `"${camelCase(append)}"`;
8971
+ const key = camelCase(append);
8972
+ const safeAppend = key.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) ? key : `"${key}"`;
8897
8973
  lines.push(` ${safeAppend}?: unknown`);
8898
8974
  }
8899
8975
  }
@@ -8908,7 +8984,7 @@ var TypeGenerator = class {
8908
8984
  const typeName = toTypeName(resource ?? "");
8909
8985
  lines.push(`export interface ${typeName} {`);
8910
8986
  lines.push(` id: number`);
8911
- lines.push(` // TODO: Add ${resource} fields`);
8987
+ lines.push(` // TODO: Add ${resource} fields \u2014 run scan with --models for real types`);
8912
8988
  lines.push(` createdAt?: string`);
8913
8989
  lines.push(` updatedAt?: string`);
8914
8990
  lines.push(`}`);
@@ -9485,8 +9561,8 @@ var watchCommand = new Command("watch").description("Watch routes file and re-sy
9485
9561
  debounceTimer = setTimeout(async () => {
9486
9562
  console.log(source_default.yellow(` [${(/* @__PURE__ */ new Date()).toLocaleTimeString()}] Routes changed, syncing...`));
9487
9563
  try {
9488
- const { execSync: execSync2 } = await import("child_process");
9489
- execSync2(
9564
+ const { execSync: execSync3 } = await import("child_process");
9565
+ execSync3(
9490
9566
  `routesync sync --input ${options.input} --output ${options.output} --baseURL ${options.baseURL}`,
9491
9567
  { stdio: "inherit" }
9492
9568
  );
@@ -9502,6 +9578,234 @@ var watchCommand = new Command("watch").description("Watch routes file and re-sy
9502
9578
  import_fs_extra15.default.watch(import_path11.default.resolve(options.input), onChange);
9503
9579
  });
9504
9580
 
9581
+ // packages/cli/src/commands/annotate.ts
9582
+ var import_child_process2 = require("child_process");
9583
+ var import_fs_extra16 = __toESM(require_lib());
9584
+ var import_path12 = __toESM(require("path"));
9585
+ var import_os = __toESM(require("os"));
9586
+ var annotateCommand = new Command("annotate").description("Auto-inject #[Response] PHP 8 attributes into controller methods based on Resource discovery").option("--input <file>", "Path to routes/api.php", "routes/api.php").option("--dry-run", "Preview changes without writing files").option("--force", "Re-annotate methods that already have #[Response]").action(async (options) => {
9587
+ const filePath = import_path12.default.resolve(options.input);
9588
+ if (!import_fs_extra16.default.existsSync(filePath)) {
9589
+ console.error(`\u274C Routes file not found: ${filePath}`);
9590
+ process.exit(1);
9591
+ }
9592
+ const projectRoot = import_path12.default.resolve(import_path12.default.dirname(filePath), "..");
9593
+ const forceFlag = options.force ? "true" : "false";
9594
+ const phpScript = `<?php
9595
+ require __DIR__.'/vendor/autoload.php';
9596
+ $app = require_once __DIR__.'/bootstrap/app.php';
9597
+ $kernel = $app->make(Illuminate\\Contracts\\Console\\Kernel::class);
9598
+ $kernel->bootstrap();
9599
+
9600
+ $result = [];
9601
+ $seen = []; // deduplicate by controllerClass + methodName
9602
+
9603
+ $routes = app('router')->getRoutes();
9604
+ foreach ($routes as $route) {
9605
+ if (!str_starts_with($route->uri(), 'api/')) continue;
9606
+
9607
+ $methods = array_diff($route->methods(), ['HEAD']);
9608
+ $action = $route->getAction();
9609
+ if (!isset($action['controller'])) continue;
9610
+
9611
+ [$controllerClass, $methodName] = array_pad(explode('@', $action['controller']), 2, null);
9612
+ if (!$methodName) continue;
9613
+
9614
+ $dedupKey = $controllerClass . '@' . $methodName;
9615
+ if (isset($seen[$dedupKey])) continue;
9616
+ $seen[$dedupKey] = true;
9617
+
9618
+ try {
9619
+ $reflector = new ReflectionMethod($controllerClass, $methodName);
9620
+
9621
+ // Check if already has #[Response] attribute
9622
+ $hasResponse = false;
9623
+ foreach ($reflector->getAttributes() as $attr) {
9624
+ if (str_contains($attr->getName(), 'Response')) {
9625
+ $hasResponse = true;
9626
+ break;
9627
+ }
9628
+ }
9629
+ if ($hasResponse && !${forceFlag}) continue;
9630
+
9631
+ // Get method source
9632
+ $fileName = $reflector->getFileName();
9633
+ $startLine = $reflector->getStartLine();
9634
+ $endLine = $reflector->getEndLine();
9635
+ if (!$fileName || $startLine === false) continue;
9636
+
9637
+ $fileLines = file($fileName);
9638
+ $methodSource = implode('', array_slice($fileLines, $startLine - 1, $endLine - $startLine + 1));
9639
+
9640
+ // Find the actual "public function" line (for correct injection point)
9641
+ // Walk backwards from startLine to find the real function declaration line
9642
+ $funcLine = $startLine;
9643
+ for ($i = $startLine - 1; $i >= max(0, $startLine - 10); $i--) {
9644
+ if (preg_match('/^\\s*(public|protected|private)?\\s*function\\s+' . preg_quote($methodName) . '\\s*\\(/', $fileLines[$i])) {
9645
+ $funcLine = $i + 1; // convert to 1-indexed
9646
+ break;
9647
+ }
9648
+ }
9649
+
9650
+ // Resource Discovery \u2014 support multiple return patterns
9651
+ $resourceName = null;
9652
+ $collection = false;
9653
+
9654
+ $patterns = [
9655
+ // XxxResource::collection(...)
9656
+ '/([a-zA-Z0-9_]+Resource)::collection/' => ['collection' => true],
9657
+ // new XxxResource(...)
9658
+ '/new\\s+([a-zA-Z0-9_]+Resource)\\s*\\(/' => ['collection' => false],
9659
+ // response()->json(new XxxResource(...))
9660
+ '/response\\(\\)->json\\(\\s*new\\s+([a-zA-Z0-9_]+Resource)/' => ['collection' => false],
9661
+ // response()->json(XxxResource::collection(...))
9662
+ '/response\\(\\)->json\\(\\s*([a-zA-Z0-9_]+Resource)::collection/' => ['collection' => true],
9663
+ // JsonResponse: return new JsonResponse(new XxxResource(...))
9664
+ '/JsonResponse\\(\\s*new\\s+([a-zA-Z0-9_]+Resource)/' => ['collection' => false],
9665
+ ];
9666
+
9667
+ foreach ($patterns as $pattern => $meta) {
9668
+ if (preg_match($pattern, $methodSource, $m)) {
9669
+ $resourceName = $m[1];
9670
+ $collection = $meta['collection'];
9671
+ break;
9672
+ }
9673
+ }
9674
+
9675
+ if (!$resourceName) continue;
9676
+
9677
+ // Resolve model from Resource @mixin docblock
9678
+ $resourceClass = 'App\\\\Http\\\\Resources\\\\' . $resourceName;
9679
+ if (!class_exists($resourceClass)) continue;
9680
+
9681
+ $resReflector = new ReflectionClass($resourceClass);
9682
+ $docComment = $resReflector->getDocComment();
9683
+ $modelClass = null;
9684
+
9685
+ if ($docComment && preg_match('/@mixin\\s+([\\\\a-zA-Z0-9_]+)/', $docComment, $mixinMatch)) {
9686
+ $modelClass = class_basename(trim($mixinMatch[1], '\\\\'));
9687
+ }
9688
+
9689
+ // Fallback: strip Resource suffix
9690
+ if (!$modelClass) {
9691
+ $modelClass = preg_replace('/Resource$/', '', $resourceName);
9692
+ }
9693
+
9694
+ $ctrlReflector = new ReflectionClass($controllerClass);
9695
+ $modelFull = 'App\\\\Models\\\\' . $modelClass;
9696
+
9697
+ $result[] = [
9698
+ 'method' => implode('|', $methods),
9699
+ 'uri' => '/' . preg_replace('/^api\\//', '', $route->uri()),
9700
+ 'controllerFile' => $fileName,
9701
+ 'controllerClass' => $controllerClass,
9702
+ 'controllerNamespace' => $ctrlReflector->getNamespaceName(),
9703
+ 'methodName' => $methodName,
9704
+ 'methodLine' => $funcLine,
9705
+ 'modelClass' => $modelClass,
9706
+ 'modelFull' => $modelFull,
9707
+ 'modelExists' => class_exists($modelFull),
9708
+ 'collection' => $collection,
9709
+ 'attrExists' => class_exists('App\\\\Attributes\\\\Response'),
9710
+ 'alreadyAnnotated' => $hasResponse,
9711
+ ];
9712
+
9713
+ } catch (\\Exception $e) {
9714
+ // skip unresolvable routes
9715
+ }
9716
+ }
9717
+
9718
+ echo json_encode($result);
9719
+ `;
9720
+ const tmpFile = import_path12.default.join(import_os.default.tmpdir(), `routesync-annotate-${Date.now()}.php`);
9721
+ import_fs_extra16.default.writeFileSync(tmpFile, phpScript);
9722
+ let annotations;
9723
+ try {
9724
+ const output = (0, import_child_process2.execSync)(`php ${tmpFile}`, { cwd: projectRoot, encoding: "utf-8" });
9725
+ annotations = JSON.parse(output);
9726
+ } catch (e) {
9727
+ console.error("\u274C PHP execution failed. Make sure PHP is available and database is accessible.");
9728
+ console.error(e instanceof Error ? e.message : String(e));
9729
+ import_fs_extra16.default.removeSync(tmpFile);
9730
+ process.exit(1);
9731
+ }
9732
+ import_fs_extra16.default.removeSync(tmpFile);
9733
+ if (annotations.length === 0) {
9734
+ console.log("\u2714 No methods to annotate \u2014 all routes already annotated or no Resources detected.");
9735
+ return;
9736
+ }
9737
+ const byFile = /* @__PURE__ */ new Map();
9738
+ for (const ann of annotations) {
9739
+ const existing = byFile.get(ann.controllerFile) ?? [];
9740
+ if (!existing.find((e) => e.methodName === ann.methodName)) {
9741
+ existing.push(ann);
9742
+ }
9743
+ byFile.set(ann.controllerFile, existing);
9744
+ }
9745
+ const attrPath = import_path12.default.join(projectRoot, "app", "Attributes", "Response.php");
9746
+ const attrExists = import_fs_extra16.default.existsSync(attrPath);
9747
+ if (!attrExists) {
9748
+ if (options.dryRun) {
9749
+ console.log(" [dry-run] Would create app/Attributes/Response.php");
9750
+ } else {
9751
+ import_fs_extra16.default.ensureDirSync(import_path12.default.dirname(attrPath));
9752
+ import_fs_extra16.default.writeFileSync(attrPath, `<?php
9753
+
9754
+ namespace App\\Attributes;
9755
+
9756
+ use Attribute;
9757
+
9758
+ #[Attribute(Attribute::TARGET_METHOD)]
9759
+ class Response
9760
+ {
9761
+ public function __construct(
9762
+ public string $type,
9763
+ public bool $collection = false,
9764
+ ) {}
9765
+ }
9766
+ `);
9767
+ console.log(" \u2714 Created app/Attributes/Response.php");
9768
+ }
9769
+ }
9770
+ let totalAnnotated = 0;
9771
+ for (const [ctrlFile, anns] of byFile) {
9772
+ const lines = import_fs_extra16.default.readFileSync(ctrlFile, "utf-8").split("\n");
9773
+ const needsImport = !lines.some((l) => l.includes("App\\Attributes\\Response"));
9774
+ const sorted = [...anns].sort((a, b) => b.methodLine - a.methodLine);
9775
+ for (const ann of sorted) {
9776
+ const collectionStr = ann.collection ? ", collection: true" : "";
9777
+ const attrLine = ` #[Response(${ann.modelClass}::class${collectionStr})]`;
9778
+ const insertAt = ann.methodLine - 1;
9779
+ lines.splice(insertAt, 0, attrLine);
9780
+ totalAnnotated++;
9781
+ if (options.dryRun) {
9782
+ const collDisplay = ann.collection ? "[]" : "";
9783
+ console.log(` [dry-run] ${ann.controllerClass}::${ann.methodName}`);
9784
+ console.log(` \u2192 #[Response(${ann.modelClass}::class${collectionStr})] (${ann.uri}${collDisplay})`);
9785
+ }
9786
+ }
9787
+ if (needsImport) {
9788
+ const lastUseIndex = lines.reduce((last, line, i) => line.trimStart().startsWith("use ") ? i : last, -1);
9789
+ const insertUseAt = lastUseIndex !== -1 ? lastUseIndex + 1 : 2;
9790
+ lines.splice(insertUseAt, 0, "use App\\Attributes\\Response;");
9791
+ }
9792
+ if (!options.dryRun) {
9793
+ import_fs_extra16.default.writeFileSync(ctrlFile, lines.join("\n"), "utf-8");
9794
+ }
9795
+ }
9796
+ if (options.dryRun) {
9797
+ console.log(`
9798
+ \u2714 [dry-run] Would annotate ${totalAnnotated} method(s) across ${byFile.size} controller file(s)`);
9799
+ console.log(" Run without --dry-run to apply.");
9800
+ } else {
9801
+ console.log(`\u2714 Annotated ${totalAnnotated} method(s) across ${byFile.size} controller file(s)`);
9802
+ console.log("\n Next steps:");
9803
+ console.log(" 1. npx routesync scan --input routes/api.php --models");
9804
+ console.log(" 2. Copy routesync.manifest.json to your frontend folder");
9805
+ console.log(" 3. npx routesync generate --manifest routesync.manifest.json --output src/api --next-actions --zod");
9806
+ }
9807
+ });
9808
+
9505
9809
  // packages/cli/src/index.ts
9506
9810
  var program2 = new Command();
9507
9811
  program2.name("routesync").description("Laravel routes to typed frontend SDKs").version("1.0.0");
@@ -9509,4 +9813,5 @@ program2.addCommand(scanCommand);
9509
9813
  program2.addCommand(generateCommand);
9510
9814
  program2.addCommand(syncCommand);
9511
9815
  program2.addCommand(watchCommand);
9816
+ program2.addCommand(annotateCommand);
9512
9817
  program2.parse(process.argv);