@atlashub/smartstack-cli 1.34.0 → 1.35.0

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 (56) hide show
  1. package/.documentation/installation.html +56 -31
  2. package/dist/index.js +1098 -582
  3. package/dist/index.js.map +1 -1
  4. package/package.json +1 -1
  5. package/templates/agents/docs-context-reader.md +125 -0
  6. package/templates/agents/docs-sync-checker.md +122 -0
  7. package/templates/hooks/docs-drift-check.md +97 -0
  8. package/templates/skills/_resources/context-digest-template.md +53 -0
  9. package/templates/skills/_resources/doc-context-cache.md +62 -0
  10. package/templates/skills/_resources/docs-manifest-schema.md +157 -0
  11. package/templates/skills/_resources/mcp-validate-documentation-spec.md +183 -0
  12. package/templates/skills/_shared.md +8 -0
  13. package/templates/skills/apex/SKILL.md +6 -0
  14. package/templates/skills/apex/steps/step-00-init.md +9 -0
  15. package/templates/skills/apex/steps/step-01-analyze.md +36 -0
  16. package/templates/skills/apex/steps/step-02-plan.md +38 -0
  17. package/templates/skills/apex/steps/step-03-execute.md +39 -0
  18. package/templates/skills/apex/steps/step-04-validate.md +31 -1
  19. package/templates/skills/apex/steps/step-04b-doc-sync.md +162 -0
  20. package/templates/skills/apex/steps/step-05-examine.md +7 -0
  21. package/templates/skills/apex/templates/04b-doc-sync.md +31 -0
  22. package/templates/skills/apex/templates/context-digest.md +35 -0
  23. package/templates/skills/business-analyse/SKILL.md +18 -5
  24. package/templates/skills/business-analyse/_shared.md +306 -4
  25. package/templates/skills/business-analyse/questionnaire/01-context.md +21 -6
  26. package/templates/skills/business-analyse/questionnaire/02-stakeholders.md +34 -0
  27. package/templates/skills/business-analyse/questionnaire/03-scope.md +23 -0
  28. package/templates/skills/business-analyse/questionnaire/04-data.md +44 -0
  29. package/templates/skills/business-analyse/questionnaire/05-integrations.md +29 -7
  30. package/templates/skills/business-analyse/questionnaire/06-security.md +28 -0
  31. package/templates/skills/business-analyse/questionnaire/07-ui.md +32 -7
  32. package/templates/skills/business-analyse/questionnaire/08-performance.md +21 -0
  33. package/templates/skills/business-analyse/questionnaire/09-constraints.md +29 -6
  34. package/templates/skills/business-analyse/questionnaire/10-documentation.md +27 -6
  35. package/templates/skills/business-analyse/questionnaire/11-data-lifecycle.md +59 -0
  36. package/templates/skills/business-analyse/questionnaire/12-migration.md +58 -0
  37. package/templates/skills/business-analyse/questionnaire/13-cross-module.md +69 -0
  38. package/templates/skills/business-analyse/steps/step-00-init.md +110 -16
  39. package/templates/skills/business-analyse/steps/step-01-discover.md +530 -85
  40. package/templates/skills/business-analyse/steps/step-02-analyse.md +81 -25
  41. package/templates/skills/business-analyse/steps/step-03-specify.md +116 -24
  42. package/templates/skills/business-analyse/steps/step-04-validate.md +107 -33
  43. package/templates/skills/business-analyse/steps/step-05-handoff.md +256 -33
  44. package/templates/skills/business-analyse/steps/step-06-doc-html.md +84 -25
  45. package/templates/skills/business-analyse/templates/{frd-handoff.md → tpl-handoff.md} +18 -4
  46. package/templates/skills/business-analyse/templates-frd.md +19 -5
  47. package/templates/skills/business-analyse/tracking/change-template.md +30 -0
  48. package/templates/skills/documentation/SKILL.md +68 -31
  49. package/templates/skills/documentation/data-schema.md +198 -0
  50. package/templates/skills/documentation/templates.md +30 -1
  51. package/templates/skills/gitflow/steps/step-init.md +128 -1
  52. package/templates/skills/gitflow/templates/config.json +7 -0
  53. package/templates/skills/ralph-loop/SKILL.md +3 -0
  54. /package/templates/skills/business-analyse/templates/{frd-brd.md → tpl-brd.md} +0 -0
  55. /package/templates/skills/business-analyse/templates/{frd-discovery.md → tpl-discovery.md} +0 -0
  56. /package/templates/skills/business-analyse/templates/{frd-spec.md → tpl-frd.md} +0 -0
package/dist/index.js CHANGED
@@ -974,7 +974,7 @@ var require_command = __commonJS({
974
974
  var EventEmitter2 = require("events").EventEmitter;
975
975
  var childProcess2 = require("child_process");
976
976
  var path5 = require("path");
977
- var fs13 = require("fs");
977
+ var fs14 = require("fs");
978
978
  var process17 = require("process");
979
979
  var { Argument: Argument2, humanReadableArgName } = require_argument();
980
980
  var { CommanderError: CommanderError2 } = require_error();
@@ -1907,10 +1907,10 @@ Expecting one of '${allowedValues.join("', '")}'`);
1907
1907
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1908
1908
  function findFile(baseDir, baseName) {
1909
1909
  const localBin = path5.resolve(baseDir, baseName);
1910
- if (fs13.existsSync(localBin)) return localBin;
1910
+ if (fs14.existsSync(localBin)) return localBin;
1911
1911
  if (sourceExt.includes(path5.extname(baseName))) return void 0;
1912
1912
  const foundExt = sourceExt.find(
1913
- (ext2) => fs13.existsSync(`${localBin}${ext2}`)
1913
+ (ext2) => fs14.existsSync(`${localBin}${ext2}`)
1914
1914
  );
1915
1915
  if (foundExt) return `${localBin}${foundExt}`;
1916
1916
  return void 0;
@@ -1922,7 +1922,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1922
1922
  if (this._scriptPath) {
1923
1923
  let resolvedScriptPath;
1924
1924
  try {
1925
- resolvedScriptPath = fs13.realpathSync(this._scriptPath);
1925
+ resolvedScriptPath = fs14.realpathSync(this._scriptPath);
1926
1926
  } catch (err) {
1927
1927
  resolvedScriptPath = this._scriptPath;
1928
1928
  }
@@ -4734,54 +4734,54 @@ var require_polyfills = __commonJS({
4734
4734
  }
4735
4735
  var chdir;
4736
4736
  module2.exports = patch;
4737
- function patch(fs13) {
4737
+ function patch(fs14) {
4738
4738
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
4739
- patchLchmod(fs13);
4740
- }
4741
- if (!fs13.lutimes) {
4742
- patchLutimes(fs13);
4743
- }
4744
- fs13.chown = chownFix(fs13.chown);
4745
- fs13.fchown = chownFix(fs13.fchown);
4746
- fs13.lchown = chownFix(fs13.lchown);
4747
- fs13.chmod = chmodFix(fs13.chmod);
4748
- fs13.fchmod = chmodFix(fs13.fchmod);
4749
- fs13.lchmod = chmodFix(fs13.lchmod);
4750
- fs13.chownSync = chownFixSync(fs13.chownSync);
4751
- fs13.fchownSync = chownFixSync(fs13.fchownSync);
4752
- fs13.lchownSync = chownFixSync(fs13.lchownSync);
4753
- fs13.chmodSync = chmodFixSync(fs13.chmodSync);
4754
- fs13.fchmodSync = chmodFixSync(fs13.fchmodSync);
4755
- fs13.lchmodSync = chmodFixSync(fs13.lchmodSync);
4756
- fs13.stat = statFix(fs13.stat);
4757
- fs13.fstat = statFix(fs13.fstat);
4758
- fs13.lstat = statFix(fs13.lstat);
4759
- fs13.statSync = statFixSync(fs13.statSync);
4760
- fs13.fstatSync = statFixSync(fs13.fstatSync);
4761
- fs13.lstatSync = statFixSync(fs13.lstatSync);
4762
- if (fs13.chmod && !fs13.lchmod) {
4763
- fs13.lchmod = function(path5, mode, cb) {
4739
+ patchLchmod(fs14);
4740
+ }
4741
+ if (!fs14.lutimes) {
4742
+ patchLutimes(fs14);
4743
+ }
4744
+ fs14.chown = chownFix(fs14.chown);
4745
+ fs14.fchown = chownFix(fs14.fchown);
4746
+ fs14.lchown = chownFix(fs14.lchown);
4747
+ fs14.chmod = chmodFix(fs14.chmod);
4748
+ fs14.fchmod = chmodFix(fs14.fchmod);
4749
+ fs14.lchmod = chmodFix(fs14.lchmod);
4750
+ fs14.chownSync = chownFixSync(fs14.chownSync);
4751
+ fs14.fchownSync = chownFixSync(fs14.fchownSync);
4752
+ fs14.lchownSync = chownFixSync(fs14.lchownSync);
4753
+ fs14.chmodSync = chmodFixSync(fs14.chmodSync);
4754
+ fs14.fchmodSync = chmodFixSync(fs14.fchmodSync);
4755
+ fs14.lchmodSync = chmodFixSync(fs14.lchmodSync);
4756
+ fs14.stat = statFix(fs14.stat);
4757
+ fs14.fstat = statFix(fs14.fstat);
4758
+ fs14.lstat = statFix(fs14.lstat);
4759
+ fs14.statSync = statFixSync(fs14.statSync);
4760
+ fs14.fstatSync = statFixSync(fs14.fstatSync);
4761
+ fs14.lstatSync = statFixSync(fs14.lstatSync);
4762
+ if (fs14.chmod && !fs14.lchmod) {
4763
+ fs14.lchmod = function(path5, mode, cb) {
4764
4764
  if (cb) process.nextTick(cb);
4765
4765
  };
4766
- fs13.lchmodSync = function() {
4766
+ fs14.lchmodSync = function() {
4767
4767
  };
4768
4768
  }
4769
- if (fs13.chown && !fs13.lchown) {
4770
- fs13.lchown = function(path5, uid, gid, cb) {
4769
+ if (fs14.chown && !fs14.lchown) {
4770
+ fs14.lchown = function(path5, uid, gid, cb) {
4771
4771
  if (cb) process.nextTick(cb);
4772
4772
  };
4773
- fs13.lchownSync = function() {
4773
+ fs14.lchownSync = function() {
4774
4774
  };
4775
4775
  }
4776
4776
  if (platform2 === "win32") {
4777
- fs13.rename = typeof fs13.rename !== "function" ? fs13.rename : (function(fs$rename) {
4777
+ fs14.rename = typeof fs14.rename !== "function" ? fs14.rename : (function(fs$rename) {
4778
4778
  function rename(from3, to, cb) {
4779
4779
  var start = Date.now();
4780
4780
  var backoff = 0;
4781
4781
  fs$rename(from3, to, function CB(er) {
4782
4782
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
4783
4783
  setTimeout(function() {
4784
- fs13.stat(to, function(stater, st) {
4784
+ fs14.stat(to, function(stater, st) {
4785
4785
  if (stater && stater.code === "ENOENT")
4786
4786
  fs$rename(from3, to, CB);
4787
4787
  else
@@ -4797,9 +4797,9 @@ var require_polyfills = __commonJS({
4797
4797
  }
4798
4798
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
4799
4799
  return rename;
4800
- })(fs13.rename);
4800
+ })(fs14.rename);
4801
4801
  }
4802
- fs13.read = typeof fs13.read !== "function" ? fs13.read : (function(fs$read) {
4802
+ fs14.read = typeof fs14.read !== "function" ? fs14.read : (function(fs$read) {
4803
4803
  function read(fd, buffer, offset, length, position, callback_) {
4804
4804
  var callback;
4805
4805
  if (callback_ && typeof callback_ === "function") {
@@ -4807,22 +4807,22 @@ var require_polyfills = __commonJS({
4807
4807
  callback = function(er, _3, __) {
4808
4808
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
4809
4809
  eagCounter++;
4810
- return fs$read.call(fs13, fd, buffer, offset, length, position, callback);
4810
+ return fs$read.call(fs14, fd, buffer, offset, length, position, callback);
4811
4811
  }
4812
4812
  callback_.apply(this, arguments);
4813
4813
  };
4814
4814
  }
4815
- return fs$read.call(fs13, fd, buffer, offset, length, position, callback);
4815
+ return fs$read.call(fs14, fd, buffer, offset, length, position, callback);
4816
4816
  }
4817
4817
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
4818
4818
  return read;
4819
- })(fs13.read);
4820
- fs13.readSync = typeof fs13.readSync !== "function" ? fs13.readSync : /* @__PURE__ */ (function(fs$readSync) {
4819
+ })(fs14.read);
4820
+ fs14.readSync = typeof fs14.readSync !== "function" ? fs14.readSync : /* @__PURE__ */ (function(fs$readSync) {
4821
4821
  return function(fd, buffer, offset, length, position) {
4822
4822
  var eagCounter = 0;
4823
4823
  while (true) {
4824
4824
  try {
4825
- return fs$readSync.call(fs13, fd, buffer, offset, length, position);
4825
+ return fs$readSync.call(fs14, fd, buffer, offset, length, position);
4826
4826
  } catch (er) {
4827
4827
  if (er.code === "EAGAIN" && eagCounter < 10) {
4828
4828
  eagCounter++;
@@ -4832,10 +4832,10 @@ var require_polyfills = __commonJS({
4832
4832
  }
4833
4833
  }
4834
4834
  };
4835
- })(fs13.readSync);
4836
- function patchLchmod(fs14) {
4837
- fs14.lchmod = function(path5, mode, callback) {
4838
- fs14.open(
4835
+ })(fs14.readSync);
4836
+ function patchLchmod(fs15) {
4837
+ fs15.lchmod = function(path5, mode, callback) {
4838
+ fs15.open(
4839
4839
  path5,
4840
4840
  constants.O_WRONLY | constants.O_SYMLINK,
4841
4841
  mode,
@@ -4844,80 +4844,80 @@ var require_polyfills = __commonJS({
4844
4844
  if (callback) callback(err);
4845
4845
  return;
4846
4846
  }
4847
- fs14.fchmod(fd, mode, function(err2) {
4848
- fs14.close(fd, function(err22) {
4847
+ fs15.fchmod(fd, mode, function(err2) {
4848
+ fs15.close(fd, function(err22) {
4849
4849
  if (callback) callback(err2 || err22);
4850
4850
  });
4851
4851
  });
4852
4852
  }
4853
4853
  );
4854
4854
  };
4855
- fs14.lchmodSync = function(path5, mode) {
4856
- var fd = fs14.openSync(path5, constants.O_WRONLY | constants.O_SYMLINK, mode);
4855
+ fs15.lchmodSync = function(path5, mode) {
4856
+ var fd = fs15.openSync(path5, constants.O_WRONLY | constants.O_SYMLINK, mode);
4857
4857
  var threw = true;
4858
4858
  var ret;
4859
4859
  try {
4860
- ret = fs14.fchmodSync(fd, mode);
4860
+ ret = fs15.fchmodSync(fd, mode);
4861
4861
  threw = false;
4862
4862
  } finally {
4863
4863
  if (threw) {
4864
4864
  try {
4865
- fs14.closeSync(fd);
4865
+ fs15.closeSync(fd);
4866
4866
  } catch (er) {
4867
4867
  }
4868
4868
  } else {
4869
- fs14.closeSync(fd);
4869
+ fs15.closeSync(fd);
4870
4870
  }
4871
4871
  }
4872
4872
  return ret;
4873
4873
  };
4874
4874
  }
4875
- function patchLutimes(fs14) {
4876
- if (constants.hasOwnProperty("O_SYMLINK") && fs14.futimes) {
4877
- fs14.lutimes = function(path5, at, mt, cb) {
4878
- fs14.open(path5, constants.O_SYMLINK, function(er, fd) {
4875
+ function patchLutimes(fs15) {
4876
+ if (constants.hasOwnProperty("O_SYMLINK") && fs15.futimes) {
4877
+ fs15.lutimes = function(path5, at, mt, cb) {
4878
+ fs15.open(path5, constants.O_SYMLINK, function(er, fd) {
4879
4879
  if (er) {
4880
4880
  if (cb) cb(er);
4881
4881
  return;
4882
4882
  }
4883
- fs14.futimes(fd, at, mt, function(er2) {
4884
- fs14.close(fd, function(er22) {
4883
+ fs15.futimes(fd, at, mt, function(er2) {
4884
+ fs15.close(fd, function(er22) {
4885
4885
  if (cb) cb(er2 || er22);
4886
4886
  });
4887
4887
  });
4888
4888
  });
4889
4889
  };
4890
- fs14.lutimesSync = function(path5, at, mt) {
4891
- var fd = fs14.openSync(path5, constants.O_SYMLINK);
4890
+ fs15.lutimesSync = function(path5, at, mt) {
4891
+ var fd = fs15.openSync(path5, constants.O_SYMLINK);
4892
4892
  var ret;
4893
4893
  var threw = true;
4894
4894
  try {
4895
- ret = fs14.futimesSync(fd, at, mt);
4895
+ ret = fs15.futimesSync(fd, at, mt);
4896
4896
  threw = false;
4897
4897
  } finally {
4898
4898
  if (threw) {
4899
4899
  try {
4900
- fs14.closeSync(fd);
4900
+ fs15.closeSync(fd);
4901
4901
  } catch (er) {
4902
4902
  }
4903
4903
  } else {
4904
- fs14.closeSync(fd);
4904
+ fs15.closeSync(fd);
4905
4905
  }
4906
4906
  }
4907
4907
  return ret;
4908
4908
  };
4909
- } else if (fs14.futimes) {
4910
- fs14.lutimes = function(_a, _b, _c, cb) {
4909
+ } else if (fs15.futimes) {
4910
+ fs15.lutimes = function(_a, _b, _c, cb) {
4911
4911
  if (cb) process.nextTick(cb);
4912
4912
  };
4913
- fs14.lutimesSync = function() {
4913
+ fs15.lutimesSync = function() {
4914
4914
  };
4915
4915
  }
4916
4916
  }
4917
4917
  function chmodFix(orig) {
4918
4918
  if (!orig) return orig;
4919
4919
  return function(target, mode, cb) {
4920
- return orig.call(fs13, target, mode, function(er) {
4920
+ return orig.call(fs14, target, mode, function(er) {
4921
4921
  if (chownErOk(er)) er = null;
4922
4922
  if (cb) cb.apply(this, arguments);
4923
4923
  });
@@ -4927,7 +4927,7 @@ var require_polyfills = __commonJS({
4927
4927
  if (!orig) return orig;
4928
4928
  return function(target, mode) {
4929
4929
  try {
4930
- return orig.call(fs13, target, mode);
4930
+ return orig.call(fs14, target, mode);
4931
4931
  } catch (er) {
4932
4932
  if (!chownErOk(er)) throw er;
4933
4933
  }
@@ -4936,7 +4936,7 @@ var require_polyfills = __commonJS({
4936
4936
  function chownFix(orig) {
4937
4937
  if (!orig) return orig;
4938
4938
  return function(target, uid, gid, cb) {
4939
- return orig.call(fs13, target, uid, gid, function(er) {
4939
+ return orig.call(fs14, target, uid, gid, function(er) {
4940
4940
  if (chownErOk(er)) er = null;
4941
4941
  if (cb) cb.apply(this, arguments);
4942
4942
  });
@@ -4946,7 +4946,7 @@ var require_polyfills = __commonJS({
4946
4946
  if (!orig) return orig;
4947
4947
  return function(target, uid, gid) {
4948
4948
  try {
4949
- return orig.call(fs13, target, uid, gid);
4949
+ return orig.call(fs14, target, uid, gid);
4950
4950
  } catch (er) {
4951
4951
  if (!chownErOk(er)) throw er;
4952
4952
  }
@@ -4966,13 +4966,13 @@ var require_polyfills = __commonJS({
4966
4966
  }
4967
4967
  if (cb) cb.apply(this, arguments);
4968
4968
  }
4969
- return options ? orig.call(fs13, target, options, callback) : orig.call(fs13, target, callback);
4969
+ return options ? orig.call(fs14, target, options, callback) : orig.call(fs14, target, callback);
4970
4970
  };
4971
4971
  }
4972
4972
  function statFixSync(orig) {
4973
4973
  if (!orig) return orig;
4974
4974
  return function(target, options) {
4975
- var stats = options ? orig.call(fs13, target, options) : orig.call(fs13, target);
4975
+ var stats = options ? orig.call(fs14, target, options) : orig.call(fs14, target);
4976
4976
  if (stats) {
4977
4977
  if (stats.uid < 0) stats.uid += 4294967296;
4978
4978
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -5002,7 +5002,7 @@ var require_legacy_streams = __commonJS({
5002
5002
  "use strict";
5003
5003
  var Stream2 = require("stream").Stream;
5004
5004
  module2.exports = legacy;
5005
- function legacy(fs13) {
5005
+ function legacy(fs14) {
5006
5006
  return {
5007
5007
  ReadStream,
5008
5008
  WriteStream
@@ -5045,7 +5045,7 @@ var require_legacy_streams = __commonJS({
5045
5045
  });
5046
5046
  return;
5047
5047
  }
5048
- fs13.open(this.path, this.flags, this.mode, function(err, fd) {
5048
+ fs14.open(this.path, this.flags, this.mode, function(err, fd) {
5049
5049
  if (err) {
5050
5050
  self2.emit("error", err);
5051
5051
  self2.readable = false;
@@ -5084,7 +5084,7 @@ var require_legacy_streams = __commonJS({
5084
5084
  this.busy = false;
5085
5085
  this._queue = [];
5086
5086
  if (this.fd === null) {
5087
- this._open = fs13.open;
5087
+ this._open = fs14.open;
5088
5088
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
5089
5089
  this.flush();
5090
5090
  }
@@ -5120,7 +5120,7 @@ var require_clone = __commonJS({
5120
5120
  var require_graceful_fs = __commonJS({
5121
5121
  "node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
5122
5122
  "use strict";
5123
- var fs13 = require("fs");
5123
+ var fs14 = require("fs");
5124
5124
  var polyfills = require_polyfills();
5125
5125
  var legacy = require_legacy_streams();
5126
5126
  var clone = require_clone();
@@ -5152,12 +5152,12 @@ var require_graceful_fs = __commonJS({
5152
5152
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
5153
5153
  console.error(m);
5154
5154
  };
5155
- if (!fs13[gracefulQueue]) {
5155
+ if (!fs14[gracefulQueue]) {
5156
5156
  queue = global[gracefulQueue] || [];
5157
- publishQueue(fs13, queue);
5158
- fs13.close = (function(fs$close) {
5157
+ publishQueue(fs14, queue);
5158
+ fs14.close = (function(fs$close) {
5159
5159
  function close(fd, cb) {
5160
- return fs$close.call(fs13, fd, function(err) {
5160
+ return fs$close.call(fs14, fd, function(err) {
5161
5161
  if (!err) {
5162
5162
  resetQueue();
5163
5163
  }
@@ -5169,40 +5169,40 @@ var require_graceful_fs = __commonJS({
5169
5169
  value: fs$close
5170
5170
  });
5171
5171
  return close;
5172
- })(fs13.close);
5173
- fs13.closeSync = (function(fs$closeSync) {
5172
+ })(fs14.close);
5173
+ fs14.closeSync = (function(fs$closeSync) {
5174
5174
  function closeSync(fd) {
5175
- fs$closeSync.apply(fs13, arguments);
5175
+ fs$closeSync.apply(fs14, arguments);
5176
5176
  resetQueue();
5177
5177
  }
5178
5178
  Object.defineProperty(closeSync, previousSymbol, {
5179
5179
  value: fs$closeSync
5180
5180
  });
5181
5181
  return closeSync;
5182
- })(fs13.closeSync);
5182
+ })(fs14.closeSync);
5183
5183
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
5184
5184
  process.on("exit", function() {
5185
- debug(fs13[gracefulQueue]);
5186
- require("assert").equal(fs13[gracefulQueue].length, 0);
5185
+ debug(fs14[gracefulQueue]);
5186
+ require("assert").equal(fs14[gracefulQueue].length, 0);
5187
5187
  });
5188
5188
  }
5189
5189
  }
5190
5190
  var queue;
5191
5191
  if (!global[gracefulQueue]) {
5192
- publishQueue(global, fs13[gracefulQueue]);
5193
- }
5194
- module2.exports = patch(clone(fs13));
5195
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs13.__patched) {
5196
- module2.exports = patch(fs13);
5197
- fs13.__patched = true;
5198
- }
5199
- function patch(fs14) {
5200
- polyfills(fs14);
5201
- fs14.gracefulify = patch;
5202
- fs14.createReadStream = createReadStream;
5203
- fs14.createWriteStream = createWriteStream;
5204
- var fs$readFile = fs14.readFile;
5205
- fs14.readFile = readFile2;
5192
+ publishQueue(global, fs14[gracefulQueue]);
5193
+ }
5194
+ module2.exports = patch(clone(fs14));
5195
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs14.__patched) {
5196
+ module2.exports = patch(fs14);
5197
+ fs14.__patched = true;
5198
+ }
5199
+ function patch(fs15) {
5200
+ polyfills(fs15);
5201
+ fs15.gracefulify = patch;
5202
+ fs15.createReadStream = createReadStream;
5203
+ fs15.createWriteStream = createWriteStream;
5204
+ var fs$readFile = fs15.readFile;
5205
+ fs15.readFile = readFile2;
5206
5206
  function readFile2(path5, options, cb) {
5207
5207
  if (typeof options === "function")
5208
5208
  cb = options, options = null;
@@ -5218,8 +5218,8 @@ var require_graceful_fs = __commonJS({
5218
5218
  });
5219
5219
  }
5220
5220
  }
5221
- var fs$writeFile = fs14.writeFile;
5222
- fs14.writeFile = writeFile2;
5221
+ var fs$writeFile = fs15.writeFile;
5222
+ fs15.writeFile = writeFile2;
5223
5223
  function writeFile2(path5, data, options, cb) {
5224
5224
  if (typeof options === "function")
5225
5225
  cb = options, options = null;
@@ -5235,9 +5235,9 @@ var require_graceful_fs = __commonJS({
5235
5235
  });
5236
5236
  }
5237
5237
  }
5238
- var fs$appendFile = fs14.appendFile;
5238
+ var fs$appendFile = fs15.appendFile;
5239
5239
  if (fs$appendFile)
5240
- fs14.appendFile = appendFile;
5240
+ fs15.appendFile = appendFile;
5241
5241
  function appendFile(path5, data, options, cb) {
5242
5242
  if (typeof options === "function")
5243
5243
  cb = options, options = null;
@@ -5253,9 +5253,9 @@ var require_graceful_fs = __commonJS({
5253
5253
  });
5254
5254
  }
5255
5255
  }
5256
- var fs$copyFile = fs14.copyFile;
5256
+ var fs$copyFile = fs15.copyFile;
5257
5257
  if (fs$copyFile)
5258
- fs14.copyFile = copyFile;
5258
+ fs15.copyFile = copyFile;
5259
5259
  function copyFile(src, dest, flags, cb) {
5260
5260
  if (typeof flags === "function") {
5261
5261
  cb = flags;
@@ -5273,8 +5273,8 @@ var require_graceful_fs = __commonJS({
5273
5273
  });
5274
5274
  }
5275
5275
  }
5276
- var fs$readdir = fs14.readdir;
5277
- fs14.readdir = readdir2;
5276
+ var fs$readdir = fs15.readdir;
5277
+ fs15.readdir = readdir2;
5278
5278
  var noReaddirOptionVersions = /^v[0-5]\./;
5279
5279
  function readdir2(path5, options, cb) {
5280
5280
  if (typeof options === "function")
@@ -5315,21 +5315,21 @@ var require_graceful_fs = __commonJS({
5315
5315
  }
5316
5316
  }
5317
5317
  if (process.version.substr(0, 4) === "v0.8") {
5318
- var legStreams = legacy(fs14);
5318
+ var legStreams = legacy(fs15);
5319
5319
  ReadStream = legStreams.ReadStream;
5320
5320
  WriteStream = legStreams.WriteStream;
5321
5321
  }
5322
- var fs$ReadStream = fs14.ReadStream;
5322
+ var fs$ReadStream = fs15.ReadStream;
5323
5323
  if (fs$ReadStream) {
5324
5324
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
5325
5325
  ReadStream.prototype.open = ReadStream$open;
5326
5326
  }
5327
- var fs$WriteStream = fs14.WriteStream;
5327
+ var fs$WriteStream = fs15.WriteStream;
5328
5328
  if (fs$WriteStream) {
5329
5329
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
5330
5330
  WriteStream.prototype.open = WriteStream$open;
5331
5331
  }
5332
- Object.defineProperty(fs14, "ReadStream", {
5332
+ Object.defineProperty(fs15, "ReadStream", {
5333
5333
  get: function() {
5334
5334
  return ReadStream;
5335
5335
  },
@@ -5339,7 +5339,7 @@ var require_graceful_fs = __commonJS({
5339
5339
  enumerable: true,
5340
5340
  configurable: true
5341
5341
  });
5342
- Object.defineProperty(fs14, "WriteStream", {
5342
+ Object.defineProperty(fs15, "WriteStream", {
5343
5343
  get: function() {
5344
5344
  return WriteStream;
5345
5345
  },
@@ -5350,7 +5350,7 @@ var require_graceful_fs = __commonJS({
5350
5350
  configurable: true
5351
5351
  });
5352
5352
  var FileReadStream = ReadStream;
5353
- Object.defineProperty(fs14, "FileReadStream", {
5353
+ Object.defineProperty(fs15, "FileReadStream", {
5354
5354
  get: function() {
5355
5355
  return FileReadStream;
5356
5356
  },
@@ -5361,7 +5361,7 @@ var require_graceful_fs = __commonJS({
5361
5361
  configurable: true
5362
5362
  });
5363
5363
  var FileWriteStream = WriteStream;
5364
- Object.defineProperty(fs14, "FileWriteStream", {
5364
+ Object.defineProperty(fs15, "FileWriteStream", {
5365
5365
  get: function() {
5366
5366
  return FileWriteStream;
5367
5367
  },
@@ -5410,13 +5410,13 @@ var require_graceful_fs = __commonJS({
5410
5410
  });
5411
5411
  }
5412
5412
  function createReadStream(path5, options) {
5413
- return new fs14.ReadStream(path5, options);
5413
+ return new fs15.ReadStream(path5, options);
5414
5414
  }
5415
5415
  function createWriteStream(path5, options) {
5416
- return new fs14.WriteStream(path5, options);
5416
+ return new fs15.WriteStream(path5, options);
5417
5417
  }
5418
- var fs$open = fs14.open;
5419
- fs14.open = open2;
5418
+ var fs$open = fs15.open;
5419
+ fs15.open = open2;
5420
5420
  function open2(path5, flags, mode, cb) {
5421
5421
  if (typeof mode === "function")
5422
5422
  cb = mode, mode = null;
@@ -5432,20 +5432,20 @@ var require_graceful_fs = __commonJS({
5432
5432
  });
5433
5433
  }
5434
5434
  }
5435
- return fs14;
5435
+ return fs15;
5436
5436
  }
5437
5437
  function enqueue(elem) {
5438
5438
  debug("ENQUEUE", elem[0].name, elem[1]);
5439
- fs13[gracefulQueue].push(elem);
5439
+ fs14[gracefulQueue].push(elem);
5440
5440
  retry();
5441
5441
  }
5442
5442
  var retryTimer;
5443
5443
  function resetQueue() {
5444
5444
  var now = Date.now();
5445
- for (var i = 0; i < fs13[gracefulQueue].length; ++i) {
5446
- if (fs13[gracefulQueue][i].length > 2) {
5447
- fs13[gracefulQueue][i][3] = now;
5448
- fs13[gracefulQueue][i][4] = now;
5445
+ for (var i = 0; i < fs14[gracefulQueue].length; ++i) {
5446
+ if (fs14[gracefulQueue][i].length > 2) {
5447
+ fs14[gracefulQueue][i][3] = now;
5448
+ fs14[gracefulQueue][i][4] = now;
5449
5449
  }
5450
5450
  }
5451
5451
  retry();
@@ -5453,9 +5453,9 @@ var require_graceful_fs = __commonJS({
5453
5453
  function retry() {
5454
5454
  clearTimeout(retryTimer);
5455
5455
  retryTimer = void 0;
5456
- if (fs13[gracefulQueue].length === 0)
5456
+ if (fs14[gracefulQueue].length === 0)
5457
5457
  return;
5458
- var elem = fs13[gracefulQueue].shift();
5458
+ var elem = fs14[gracefulQueue].shift();
5459
5459
  var fn = elem[0];
5460
5460
  var args = elem[1];
5461
5461
  var err = elem[2];
@@ -5477,7 +5477,7 @@ var require_graceful_fs = __commonJS({
5477
5477
  debug("RETRY", fn.name, args);
5478
5478
  fn.apply(null, args.concat([startTime]));
5479
5479
  } else {
5480
- fs13[gracefulQueue].push(elem);
5480
+ fs14[gracefulQueue].push(elem);
5481
5481
  }
5482
5482
  }
5483
5483
  if (retryTimer === void 0) {
@@ -5492,7 +5492,7 @@ var require_fs = __commonJS({
5492
5492
  "node_modules/fs-extra/lib/fs/index.js"(exports2) {
5493
5493
  "use strict";
5494
5494
  var u = require_universalify().fromCallback;
5495
- var fs13 = require_graceful_fs();
5495
+ var fs14 = require_graceful_fs();
5496
5496
  var api = [
5497
5497
  "access",
5498
5498
  "appendFile",
@@ -5533,26 +5533,26 @@ var require_fs = __commonJS({
5533
5533
  "utimes",
5534
5534
  "writeFile"
5535
5535
  ].filter((key) => {
5536
- return typeof fs13[key] === "function";
5536
+ return typeof fs14[key] === "function";
5537
5537
  });
5538
- Object.assign(exports2, fs13);
5538
+ Object.assign(exports2, fs14);
5539
5539
  api.forEach((method) => {
5540
- exports2[method] = u(fs13[method]);
5540
+ exports2[method] = u(fs14[method]);
5541
5541
  });
5542
5542
  exports2.exists = function(filename, callback) {
5543
5543
  if (typeof callback === "function") {
5544
- return fs13.exists(filename, callback);
5544
+ return fs14.exists(filename, callback);
5545
5545
  }
5546
5546
  return new Promise((resolve) => {
5547
- return fs13.exists(filename, resolve);
5547
+ return fs14.exists(filename, resolve);
5548
5548
  });
5549
5549
  };
5550
5550
  exports2.read = function(fd, buffer, offset, length, position, callback) {
5551
5551
  if (typeof callback === "function") {
5552
- return fs13.read(fd, buffer, offset, length, position, callback);
5552
+ return fs14.read(fd, buffer, offset, length, position, callback);
5553
5553
  }
5554
5554
  return new Promise((resolve, reject) => {
5555
- fs13.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
5555
+ fs14.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
5556
5556
  if (err) return reject(err);
5557
5557
  resolve({ bytesRead, buffer: buffer2 });
5558
5558
  });
@@ -5560,10 +5560,10 @@ var require_fs = __commonJS({
5560
5560
  };
5561
5561
  exports2.write = function(fd, buffer, ...args) {
5562
5562
  if (typeof args[args.length - 1] === "function") {
5563
- return fs13.write(fd, buffer, ...args);
5563
+ return fs14.write(fd, buffer, ...args);
5564
5564
  }
5565
5565
  return new Promise((resolve, reject) => {
5566
- fs13.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
5566
+ fs14.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
5567
5567
  if (err) return reject(err);
5568
5568
  resolve({ bytesWritten, buffer: buffer2 });
5569
5569
  });
@@ -5571,10 +5571,10 @@ var require_fs = __commonJS({
5571
5571
  };
5572
5572
  exports2.readv = function(fd, buffers, ...args) {
5573
5573
  if (typeof args[args.length - 1] === "function") {
5574
- return fs13.readv(fd, buffers, ...args);
5574
+ return fs14.readv(fd, buffers, ...args);
5575
5575
  }
5576
5576
  return new Promise((resolve, reject) => {
5577
- fs13.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
5577
+ fs14.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
5578
5578
  if (err) return reject(err);
5579
5579
  resolve({ bytesRead, buffers: buffers2 });
5580
5580
  });
@@ -5582,17 +5582,17 @@ var require_fs = __commonJS({
5582
5582
  };
5583
5583
  exports2.writev = function(fd, buffers, ...args) {
5584
5584
  if (typeof args[args.length - 1] === "function") {
5585
- return fs13.writev(fd, buffers, ...args);
5585
+ return fs14.writev(fd, buffers, ...args);
5586
5586
  }
5587
5587
  return new Promise((resolve, reject) => {
5588
- fs13.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
5588
+ fs14.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
5589
5589
  if (err) return reject(err);
5590
5590
  resolve({ bytesWritten, buffers: buffers2 });
5591
5591
  });
5592
5592
  });
5593
5593
  };
5594
- if (typeof fs13.realpath.native === "function") {
5595
- exports2.realpath.native = u(fs13.realpath.native);
5594
+ if (typeof fs14.realpath.native === "function") {
5595
+ exports2.realpath.native = u(fs14.realpath.native);
5596
5596
  } else {
5597
5597
  process.emitWarning(
5598
5598
  "fs.realpath.native is not a function. Is fs being monkey-patched?",
@@ -5625,7 +5625,7 @@ var require_utils = __commonJS({
5625
5625
  var require_make_dir = __commonJS({
5626
5626
  "node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports2, module2) {
5627
5627
  "use strict";
5628
- var fs13 = require_fs();
5628
+ var fs14 = require_fs();
5629
5629
  var { checkPath } = require_utils();
5630
5630
  var getMode = (options) => {
5631
5631
  const defaults2 = { mode: 511 };
@@ -5634,14 +5634,14 @@ var require_make_dir = __commonJS({
5634
5634
  };
5635
5635
  module2.exports.makeDir = async (dir, options) => {
5636
5636
  checkPath(dir);
5637
- return fs13.mkdir(dir, {
5637
+ return fs14.mkdir(dir, {
5638
5638
  mode: getMode(options),
5639
5639
  recursive: true
5640
5640
  });
5641
5641
  };
5642
5642
  module2.exports.makeDirSync = (dir, options) => {
5643
5643
  checkPath(dir);
5644
- return fs13.mkdirSync(dir, {
5644
+ return fs14.mkdirSync(dir, {
5645
5645
  mode: getMode(options),
5646
5646
  recursive: true
5647
5647
  });
@@ -5673,13 +5673,13 @@ var require_path_exists = __commonJS({
5673
5673
  "node_modules/fs-extra/lib/path-exists/index.js"(exports2, module2) {
5674
5674
  "use strict";
5675
5675
  var u = require_universalify().fromPromise;
5676
- var fs13 = require_fs();
5676
+ var fs14 = require_fs();
5677
5677
  function pathExists2(path5) {
5678
- return fs13.access(path5).then(() => true).catch(() => false);
5678
+ return fs14.access(path5).then(() => true).catch(() => false);
5679
5679
  }
5680
5680
  module2.exports = {
5681
5681
  pathExists: u(pathExists2),
5682
- pathExistsSync: fs13.existsSync
5682
+ pathExistsSync: fs14.existsSync
5683
5683
  };
5684
5684
  }
5685
5685
  });
@@ -5688,16 +5688,16 @@ var require_path_exists = __commonJS({
5688
5688
  var require_utimes = __commonJS({
5689
5689
  "node_modules/fs-extra/lib/util/utimes.js"(exports2, module2) {
5690
5690
  "use strict";
5691
- var fs13 = require_fs();
5691
+ var fs14 = require_fs();
5692
5692
  var u = require_universalify().fromPromise;
5693
5693
  async function utimesMillis(path5, atime, mtime) {
5694
- const fd = await fs13.open(path5, "r+");
5694
+ const fd = await fs14.open(path5, "r+");
5695
5695
  let closeErr = null;
5696
5696
  try {
5697
- await fs13.futimes(fd, atime, mtime);
5697
+ await fs14.futimes(fd, atime, mtime);
5698
5698
  } finally {
5699
5699
  try {
5700
- await fs13.close(fd);
5700
+ await fs14.close(fd);
5701
5701
  } catch (e) {
5702
5702
  closeErr = e;
5703
5703
  }
@@ -5707,9 +5707,9 @@ var require_utimes = __commonJS({
5707
5707
  }
5708
5708
  }
5709
5709
  function utimesMillisSync(path5, atime, mtime) {
5710
- const fd = fs13.openSync(path5, "r+");
5711
- fs13.futimesSync(fd, atime, mtime);
5712
- return fs13.closeSync(fd);
5710
+ const fd = fs14.openSync(path5, "r+");
5711
+ fs14.futimesSync(fd, atime, mtime);
5712
+ return fs14.closeSync(fd);
5713
5713
  }
5714
5714
  module2.exports = {
5715
5715
  utimesMillis: u(utimesMillis),
@@ -5722,11 +5722,11 @@ var require_utimes = __commonJS({
5722
5722
  var require_stat = __commonJS({
5723
5723
  "node_modules/fs-extra/lib/util/stat.js"(exports2, module2) {
5724
5724
  "use strict";
5725
- var fs13 = require_fs();
5725
+ var fs14 = require_fs();
5726
5726
  var path5 = require("path");
5727
5727
  var u = require_universalify().fromPromise;
5728
5728
  function getStats(src, dest, opts) {
5729
- const statFunc = opts.dereference ? (file) => fs13.stat(file, { bigint: true }) : (file) => fs13.lstat(file, { bigint: true });
5729
+ const statFunc = opts.dereference ? (file) => fs14.stat(file, { bigint: true }) : (file) => fs14.lstat(file, { bigint: true });
5730
5730
  return Promise.all([
5731
5731
  statFunc(src),
5732
5732
  statFunc(dest).catch((err) => {
@@ -5737,7 +5737,7 @@ var require_stat = __commonJS({
5737
5737
  }
5738
5738
  function getStatsSync(src, dest, opts) {
5739
5739
  let destStat;
5740
- const statFunc = opts.dereference ? (file) => fs13.statSync(file, { bigint: true }) : (file) => fs13.lstatSync(file, { bigint: true });
5740
+ const statFunc = opts.dereference ? (file) => fs14.statSync(file, { bigint: true }) : (file) => fs14.lstatSync(file, { bigint: true });
5741
5741
  const srcStat = statFunc(src);
5742
5742
  try {
5743
5743
  destStat = statFunc(dest);
@@ -5799,7 +5799,7 @@ var require_stat = __commonJS({
5799
5799
  if (destParent === srcParent || destParent === path5.parse(destParent).root) return;
5800
5800
  let destStat;
5801
5801
  try {
5802
- destStat = await fs13.stat(destParent, { bigint: true });
5802
+ destStat = await fs14.stat(destParent, { bigint: true });
5803
5803
  } catch (err) {
5804
5804
  if (err.code === "ENOENT") return;
5805
5805
  throw err;
@@ -5815,7 +5815,7 @@ var require_stat = __commonJS({
5815
5815
  if (destParent === srcParent || destParent === path5.parse(destParent).root) return;
5816
5816
  let destStat;
5817
5817
  try {
5818
- destStat = fs13.statSync(destParent, { bigint: true });
5818
+ destStat = fs14.statSync(destParent, { bigint: true });
5819
5819
  } catch (err) {
5820
5820
  if (err.code === "ENOENT") return;
5821
5821
  throw err;
@@ -5882,7 +5882,7 @@ var require_async = __commonJS({
5882
5882
  var require_copy = __commonJS({
5883
5883
  "node_modules/fs-extra/lib/copy/copy.js"(exports2, module2) {
5884
5884
  "use strict";
5885
- var fs13 = require_fs();
5885
+ var fs14 = require_fs();
5886
5886
  var path5 = require("path");
5887
5887
  var { mkdirs } = require_mkdirs();
5888
5888
  var { pathExists: pathExists2 } = require_path_exists();
@@ -5918,7 +5918,7 @@ var require_copy = __commonJS({
5918
5918
  return opts.filter(src, dest);
5919
5919
  }
5920
5920
  async function getStatsAndPerformCopy(destStat, src, dest, opts) {
5921
- const statFn = opts.dereference ? fs13.stat : fs13.lstat;
5921
+ const statFn = opts.dereference ? fs14.stat : fs14.lstat;
5922
5922
  const srcStat = await statFn(src);
5923
5923
  if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
5924
5924
  if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
@@ -5930,7 +5930,7 @@ var require_copy = __commonJS({
5930
5930
  async function onFile(srcStat, destStat, src, dest, opts) {
5931
5931
  if (!destStat) return copyFile(srcStat, src, dest, opts);
5932
5932
  if (opts.overwrite) {
5933
- await fs13.unlink(dest);
5933
+ await fs14.unlink(dest);
5934
5934
  return copyFile(srcStat, src, dest, opts);
5935
5935
  }
5936
5936
  if (opts.errorOnExist) {
@@ -5938,27 +5938,27 @@ var require_copy = __commonJS({
5938
5938
  }
5939
5939
  }
5940
5940
  async function copyFile(srcStat, src, dest, opts) {
5941
- await fs13.copyFile(src, dest);
5941
+ await fs14.copyFile(src, dest);
5942
5942
  if (opts.preserveTimestamps) {
5943
5943
  if (fileIsNotWritable(srcStat.mode)) {
5944
5944
  await makeFileWritable(dest, srcStat.mode);
5945
5945
  }
5946
- const updatedSrcStat = await fs13.stat(src);
5946
+ const updatedSrcStat = await fs14.stat(src);
5947
5947
  await utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
5948
5948
  }
5949
- return fs13.chmod(dest, srcStat.mode);
5949
+ return fs14.chmod(dest, srcStat.mode);
5950
5950
  }
5951
5951
  function fileIsNotWritable(srcMode) {
5952
5952
  return (srcMode & 128) === 0;
5953
5953
  }
5954
5954
  function makeFileWritable(dest, srcMode) {
5955
- return fs13.chmod(dest, srcMode | 128);
5955
+ return fs14.chmod(dest, srcMode | 128);
5956
5956
  }
5957
5957
  async function onDir(srcStat, destStat, src, dest, opts) {
5958
5958
  if (!destStat) {
5959
- await fs13.mkdir(dest);
5959
+ await fs14.mkdir(dest);
5960
5960
  }
5961
- await asyncIteratorConcurrentProcess(await fs13.opendir(src), async (item) => {
5961
+ await asyncIteratorConcurrentProcess(await fs14.opendir(src), async (item) => {
5962
5962
  const srcItem = path5.join(src, item.name);
5963
5963
  const destItem = path5.join(dest, item.name);
5964
5964
  const include = await runFilter(srcItem, destItem, opts);
@@ -5968,22 +5968,22 @@ var require_copy = __commonJS({
5968
5968
  }
5969
5969
  });
5970
5970
  if (!destStat) {
5971
- await fs13.chmod(dest, srcStat.mode);
5971
+ await fs14.chmod(dest, srcStat.mode);
5972
5972
  }
5973
5973
  }
5974
5974
  async function onLink(destStat, src, dest, opts) {
5975
- let resolvedSrc = await fs13.readlink(src);
5975
+ let resolvedSrc = await fs14.readlink(src);
5976
5976
  if (opts.dereference) {
5977
5977
  resolvedSrc = path5.resolve(process.cwd(), resolvedSrc);
5978
5978
  }
5979
5979
  if (!destStat) {
5980
- return fs13.symlink(resolvedSrc, dest);
5980
+ return fs14.symlink(resolvedSrc, dest);
5981
5981
  }
5982
5982
  let resolvedDest = null;
5983
5983
  try {
5984
- resolvedDest = await fs13.readlink(dest);
5984
+ resolvedDest = await fs14.readlink(dest);
5985
5985
  } catch (e) {
5986
- if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs13.symlink(resolvedSrc, dest);
5986
+ if (e.code === "EINVAL" || e.code === "UNKNOWN") return fs14.symlink(resolvedSrc, dest);
5987
5987
  throw e;
5988
5988
  }
5989
5989
  if (opts.dereference) {
@@ -5997,8 +5997,8 @@ var require_copy = __commonJS({
5997
5997
  throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
5998
5998
  }
5999
5999
  }
6000
- await fs13.unlink(dest);
6001
- return fs13.symlink(resolvedSrc, dest);
6000
+ await fs14.unlink(dest);
6001
+ return fs14.symlink(resolvedSrc, dest);
6002
6002
  }
6003
6003
  module2.exports = copy;
6004
6004
  }
@@ -6008,7 +6008,7 @@ var require_copy = __commonJS({
6008
6008
  var require_copy_sync = __commonJS({
6009
6009
  "node_modules/fs-extra/lib/copy/copy-sync.js"(exports2, module2) {
6010
6010
  "use strict";
6011
- var fs13 = require_graceful_fs();
6011
+ var fs14 = require_graceful_fs();
6012
6012
  var path5 = require("path");
6013
6013
  var mkdirsSync = require_mkdirs().mkdirsSync;
6014
6014
  var utimesMillisSync = require_utimes().utimesMillisSync;
@@ -6031,11 +6031,11 @@ var require_copy_sync = __commonJS({
6031
6031
  stat.checkParentPathsSync(src, srcStat, dest, "copy");
6032
6032
  if (opts.filter && !opts.filter(src, dest)) return;
6033
6033
  const destParent = path5.dirname(dest);
6034
- if (!fs13.existsSync(destParent)) mkdirsSync(destParent);
6034
+ if (!fs14.existsSync(destParent)) mkdirsSync(destParent);
6035
6035
  return getStats(destStat, src, dest, opts);
6036
6036
  }
6037
6037
  function getStats(destStat, src, dest, opts) {
6038
- const statSync = opts.dereference ? fs13.statSync : fs13.lstatSync;
6038
+ const statSync = opts.dereference ? fs14.statSync : fs14.lstatSync;
6039
6039
  const srcStat = statSync(src);
6040
6040
  if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts);
6041
6041
  else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts);
@@ -6050,14 +6050,14 @@ var require_copy_sync = __commonJS({
6050
6050
  }
6051
6051
  function mayCopyFile(srcStat, src, dest, opts) {
6052
6052
  if (opts.overwrite) {
6053
- fs13.unlinkSync(dest);
6053
+ fs14.unlinkSync(dest);
6054
6054
  return copyFile(srcStat, src, dest, opts);
6055
6055
  } else if (opts.errorOnExist) {
6056
6056
  throw new Error(`'${dest}' already exists`);
6057
6057
  }
6058
6058
  }
6059
6059
  function copyFile(srcStat, src, dest, opts) {
6060
- fs13.copyFileSync(src, dest);
6060
+ fs14.copyFileSync(src, dest);
6061
6061
  if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
6062
6062
  return setDestMode(dest, srcStat.mode);
6063
6063
  }
@@ -6072,10 +6072,10 @@ var require_copy_sync = __commonJS({
6072
6072
  return setDestMode(dest, srcMode | 128);
6073
6073
  }
6074
6074
  function setDestMode(dest, srcMode) {
6075
- return fs13.chmodSync(dest, srcMode);
6075
+ return fs14.chmodSync(dest, srcMode);
6076
6076
  }
6077
6077
  function setDestTimestamps(src, dest) {
6078
- const updatedSrcStat = fs13.statSync(src);
6078
+ const updatedSrcStat = fs14.statSync(src);
6079
6079
  return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
6080
6080
  }
6081
6081
  function onDir(srcStat, destStat, src, dest, opts) {
@@ -6083,12 +6083,12 @@ var require_copy_sync = __commonJS({
6083
6083
  return copyDir(src, dest, opts);
6084
6084
  }
6085
6085
  function mkDirAndCopy(srcMode, src, dest, opts) {
6086
- fs13.mkdirSync(dest);
6086
+ fs14.mkdirSync(dest);
6087
6087
  copyDir(src, dest, opts);
6088
6088
  return setDestMode(dest, srcMode);
6089
6089
  }
6090
6090
  function copyDir(src, dest, opts) {
6091
- const dir = fs13.opendirSync(src);
6091
+ const dir = fs14.opendirSync(src);
6092
6092
  try {
6093
6093
  let dirent;
6094
6094
  while ((dirent = dir.readSync()) !== null) {
@@ -6106,18 +6106,18 @@ var require_copy_sync = __commonJS({
6106
6106
  return getStats(destStat, srcItem, destItem, opts);
6107
6107
  }
6108
6108
  function onLink(destStat, src, dest, opts) {
6109
- let resolvedSrc = fs13.readlinkSync(src);
6109
+ let resolvedSrc = fs14.readlinkSync(src);
6110
6110
  if (opts.dereference) {
6111
6111
  resolvedSrc = path5.resolve(process.cwd(), resolvedSrc);
6112
6112
  }
6113
6113
  if (!destStat) {
6114
- return fs13.symlinkSync(resolvedSrc, dest);
6114
+ return fs14.symlinkSync(resolvedSrc, dest);
6115
6115
  } else {
6116
6116
  let resolvedDest;
6117
6117
  try {
6118
- resolvedDest = fs13.readlinkSync(dest);
6118
+ resolvedDest = fs14.readlinkSync(dest);
6119
6119
  } catch (err) {
6120
- if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs13.symlinkSync(resolvedSrc, dest);
6120
+ if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs14.symlinkSync(resolvedSrc, dest);
6121
6121
  throw err;
6122
6122
  }
6123
6123
  if (opts.dereference) {
@@ -6135,8 +6135,8 @@ var require_copy_sync = __commonJS({
6135
6135
  }
6136
6136
  }
6137
6137
  function copyLink(resolvedSrc, dest) {
6138
- fs13.unlinkSync(dest);
6139
- return fs13.symlinkSync(resolvedSrc, dest);
6138
+ fs14.unlinkSync(dest);
6139
+ return fs14.symlinkSync(resolvedSrc, dest);
6140
6140
  }
6141
6141
  module2.exports = copySync;
6142
6142
  }
@@ -6158,13 +6158,13 @@ var require_copy2 = __commonJS({
6158
6158
  var require_remove = __commonJS({
6159
6159
  "node_modules/fs-extra/lib/remove/index.js"(exports2, module2) {
6160
6160
  "use strict";
6161
- var fs13 = require_graceful_fs();
6161
+ var fs14 = require_graceful_fs();
6162
6162
  var u = require_universalify().fromCallback;
6163
6163
  function remove2(path5, callback) {
6164
- fs13.rm(path5, { recursive: true, force: true }, callback);
6164
+ fs14.rm(path5, { recursive: true, force: true }, callback);
6165
6165
  }
6166
6166
  function removeSync(path5) {
6167
- fs13.rmSync(path5, { recursive: true, force: true });
6167
+ fs14.rmSync(path5, { recursive: true, force: true });
6168
6168
  }
6169
6169
  module2.exports = {
6170
6170
  remove: u(remove2),
@@ -6178,14 +6178,14 @@ var require_empty = __commonJS({
6178
6178
  "node_modules/fs-extra/lib/empty/index.js"(exports2, module2) {
6179
6179
  "use strict";
6180
6180
  var u = require_universalify().fromPromise;
6181
- var fs13 = require_fs();
6181
+ var fs14 = require_fs();
6182
6182
  var path5 = require("path");
6183
6183
  var mkdir = require_mkdirs();
6184
6184
  var remove2 = require_remove();
6185
6185
  var emptyDir = u(async function emptyDir2(dir) {
6186
6186
  let items;
6187
6187
  try {
6188
- items = await fs13.readdir(dir);
6188
+ items = await fs14.readdir(dir);
6189
6189
  } catch {
6190
6190
  return mkdir.mkdirs(dir);
6191
6191
  }
@@ -6194,7 +6194,7 @@ var require_empty = __commonJS({
6194
6194
  function emptyDirSync(dir) {
6195
6195
  let items;
6196
6196
  try {
6197
- items = fs13.readdirSync(dir);
6197
+ items = fs14.readdirSync(dir);
6198
6198
  } catch {
6199
6199
  return mkdir.mkdirsSync(dir);
6200
6200
  }
@@ -6218,51 +6218,51 @@ var require_file = __commonJS({
6218
6218
  "use strict";
6219
6219
  var u = require_universalify().fromPromise;
6220
6220
  var path5 = require("path");
6221
- var fs13 = require_fs();
6221
+ var fs14 = require_fs();
6222
6222
  var mkdir = require_mkdirs();
6223
6223
  async function createFile(file) {
6224
6224
  let stats;
6225
6225
  try {
6226
- stats = await fs13.stat(file);
6226
+ stats = await fs14.stat(file);
6227
6227
  } catch {
6228
6228
  }
6229
6229
  if (stats && stats.isFile()) return;
6230
6230
  const dir = path5.dirname(file);
6231
6231
  let dirStats = null;
6232
6232
  try {
6233
- dirStats = await fs13.stat(dir);
6233
+ dirStats = await fs14.stat(dir);
6234
6234
  } catch (err) {
6235
6235
  if (err.code === "ENOENT") {
6236
6236
  await mkdir.mkdirs(dir);
6237
- await fs13.writeFile(file, "");
6237
+ await fs14.writeFile(file, "");
6238
6238
  return;
6239
6239
  } else {
6240
6240
  throw err;
6241
6241
  }
6242
6242
  }
6243
6243
  if (dirStats.isDirectory()) {
6244
- await fs13.writeFile(file, "");
6244
+ await fs14.writeFile(file, "");
6245
6245
  } else {
6246
- await fs13.readdir(dir);
6246
+ await fs14.readdir(dir);
6247
6247
  }
6248
6248
  }
6249
6249
  function createFileSync(file) {
6250
6250
  let stats;
6251
6251
  try {
6252
- stats = fs13.statSync(file);
6252
+ stats = fs14.statSync(file);
6253
6253
  } catch {
6254
6254
  }
6255
6255
  if (stats && stats.isFile()) return;
6256
6256
  const dir = path5.dirname(file);
6257
6257
  try {
6258
- if (!fs13.statSync(dir).isDirectory()) {
6259
- fs13.readdirSync(dir);
6258
+ if (!fs14.statSync(dir).isDirectory()) {
6259
+ fs14.readdirSync(dir);
6260
6260
  }
6261
6261
  } catch (err) {
6262
6262
  if (err && err.code === "ENOENT") mkdir.mkdirsSync(dir);
6263
6263
  else throw err;
6264
6264
  }
6265
- fs13.writeFileSync(file, "");
6265
+ fs14.writeFileSync(file, "");
6266
6266
  }
6267
6267
  module2.exports = {
6268
6268
  createFile: u(createFile),
@@ -6277,19 +6277,19 @@ var require_link = __commonJS({
6277
6277
  "use strict";
6278
6278
  var u = require_universalify().fromPromise;
6279
6279
  var path5 = require("path");
6280
- var fs13 = require_fs();
6280
+ var fs14 = require_fs();
6281
6281
  var mkdir = require_mkdirs();
6282
6282
  var { pathExists: pathExists2 } = require_path_exists();
6283
6283
  var { areIdentical } = require_stat();
6284
6284
  async function createLink(srcpath, dstpath) {
6285
6285
  let dstStat;
6286
6286
  try {
6287
- dstStat = await fs13.lstat(dstpath);
6287
+ dstStat = await fs14.lstat(dstpath);
6288
6288
  } catch {
6289
6289
  }
6290
6290
  let srcStat;
6291
6291
  try {
6292
- srcStat = await fs13.lstat(srcpath);
6292
+ srcStat = await fs14.lstat(srcpath);
6293
6293
  } catch (err) {
6294
6294
  err.message = err.message.replace("lstat", "ensureLink");
6295
6295
  throw err;
@@ -6300,26 +6300,26 @@ var require_link = __commonJS({
6300
6300
  if (!dirExists) {
6301
6301
  await mkdir.mkdirs(dir);
6302
6302
  }
6303
- await fs13.link(srcpath, dstpath);
6303
+ await fs14.link(srcpath, dstpath);
6304
6304
  }
6305
6305
  function createLinkSync(srcpath, dstpath) {
6306
6306
  let dstStat;
6307
6307
  try {
6308
- dstStat = fs13.lstatSync(dstpath);
6308
+ dstStat = fs14.lstatSync(dstpath);
6309
6309
  } catch {
6310
6310
  }
6311
6311
  try {
6312
- const srcStat = fs13.lstatSync(srcpath);
6312
+ const srcStat = fs14.lstatSync(srcpath);
6313
6313
  if (dstStat && areIdentical(srcStat, dstStat)) return;
6314
6314
  } catch (err) {
6315
6315
  err.message = err.message.replace("lstat", "ensureLink");
6316
6316
  throw err;
6317
6317
  }
6318
6318
  const dir = path5.dirname(dstpath);
6319
- const dirExists = fs13.existsSync(dir);
6320
- if (dirExists) return fs13.linkSync(srcpath, dstpath);
6319
+ const dirExists = fs14.existsSync(dir);
6320
+ if (dirExists) return fs14.linkSync(srcpath, dstpath);
6321
6321
  mkdir.mkdirsSync(dir);
6322
- return fs13.linkSync(srcpath, dstpath);
6322
+ return fs14.linkSync(srcpath, dstpath);
6323
6323
  }
6324
6324
  module2.exports = {
6325
6325
  createLink: u(createLink),
@@ -6333,13 +6333,13 @@ var require_symlink_paths = __commonJS({
6333
6333
  "node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports2, module2) {
6334
6334
  "use strict";
6335
6335
  var path5 = require("path");
6336
- var fs13 = require_fs();
6336
+ var fs14 = require_fs();
6337
6337
  var { pathExists: pathExists2 } = require_path_exists();
6338
6338
  var u = require_universalify().fromPromise;
6339
6339
  async function symlinkPaths(srcpath, dstpath) {
6340
6340
  if (path5.isAbsolute(srcpath)) {
6341
6341
  try {
6342
- await fs13.lstat(srcpath);
6342
+ await fs14.lstat(srcpath);
6343
6343
  } catch (err) {
6344
6344
  err.message = err.message.replace("lstat", "ensureSymlink");
6345
6345
  throw err;
@@ -6359,7 +6359,7 @@ var require_symlink_paths = __commonJS({
6359
6359
  };
6360
6360
  }
6361
6361
  try {
6362
- await fs13.lstat(srcpath);
6362
+ await fs14.lstat(srcpath);
6363
6363
  } catch (err) {
6364
6364
  err.message = err.message.replace("lstat", "ensureSymlink");
6365
6365
  throw err;
@@ -6371,7 +6371,7 @@ var require_symlink_paths = __commonJS({
6371
6371
  }
6372
6372
  function symlinkPathsSync(srcpath, dstpath) {
6373
6373
  if (path5.isAbsolute(srcpath)) {
6374
- const exists2 = fs13.existsSync(srcpath);
6374
+ const exists2 = fs14.existsSync(srcpath);
6375
6375
  if (!exists2) throw new Error("absolute srcpath does not exist");
6376
6376
  return {
6377
6377
  toCwd: srcpath,
@@ -6380,14 +6380,14 @@ var require_symlink_paths = __commonJS({
6380
6380
  }
6381
6381
  const dstdir = path5.dirname(dstpath);
6382
6382
  const relativeToDst = path5.join(dstdir, srcpath);
6383
- const exists = fs13.existsSync(relativeToDst);
6383
+ const exists = fs14.existsSync(relativeToDst);
6384
6384
  if (exists) {
6385
6385
  return {
6386
6386
  toCwd: relativeToDst,
6387
6387
  toDst: srcpath
6388
6388
  };
6389
6389
  }
6390
- const srcExists = fs13.existsSync(srcpath);
6390
+ const srcExists = fs14.existsSync(srcpath);
6391
6391
  if (!srcExists) throw new Error("relative srcpath does not exist");
6392
6392
  return {
6393
6393
  toCwd: srcpath,
@@ -6405,13 +6405,13 @@ var require_symlink_paths = __commonJS({
6405
6405
  var require_symlink_type = __commonJS({
6406
6406
  "node_modules/fs-extra/lib/ensure/symlink-type.js"(exports2, module2) {
6407
6407
  "use strict";
6408
- var fs13 = require_fs();
6408
+ var fs14 = require_fs();
6409
6409
  var u = require_universalify().fromPromise;
6410
6410
  async function symlinkType(srcpath, type) {
6411
6411
  if (type) return type;
6412
6412
  let stats;
6413
6413
  try {
6414
- stats = await fs13.lstat(srcpath);
6414
+ stats = await fs14.lstat(srcpath);
6415
6415
  } catch {
6416
6416
  return "file";
6417
6417
  }
@@ -6421,7 +6421,7 @@ var require_symlink_type = __commonJS({
6421
6421
  if (type) return type;
6422
6422
  let stats;
6423
6423
  try {
6424
- stats = fs13.lstatSync(srcpath);
6424
+ stats = fs14.lstatSync(srcpath);
6425
6425
  } catch {
6426
6426
  return "file";
6427
6427
  }
@@ -6440,7 +6440,7 @@ var require_symlink = __commonJS({
6440
6440
  "use strict";
6441
6441
  var u = require_universalify().fromPromise;
6442
6442
  var path5 = require("path");
6443
- var fs13 = require_fs();
6443
+ var fs14 = require_fs();
6444
6444
  var { mkdirs, mkdirsSync } = require_mkdirs();
6445
6445
  var { symlinkPaths, symlinkPathsSync } = require_symlink_paths();
6446
6446
  var { symlinkType, symlinkTypeSync } = require_symlink_type();
@@ -6449,13 +6449,13 @@ var require_symlink = __commonJS({
6449
6449
  async function createSymlink(srcpath, dstpath, type) {
6450
6450
  let stats;
6451
6451
  try {
6452
- stats = await fs13.lstat(dstpath);
6452
+ stats = await fs14.lstat(dstpath);
6453
6453
  } catch {
6454
6454
  }
6455
6455
  if (stats && stats.isSymbolicLink()) {
6456
6456
  const [srcStat, dstStat] = await Promise.all([
6457
- fs13.stat(srcpath),
6458
- fs13.stat(dstpath)
6457
+ fs14.stat(srcpath),
6458
+ fs14.stat(dstpath)
6459
6459
  ]);
6460
6460
  if (areIdentical(srcStat, dstStat)) return;
6461
6461
  }
@@ -6466,27 +6466,27 @@ var require_symlink = __commonJS({
6466
6466
  if (!await pathExists2(dir)) {
6467
6467
  await mkdirs(dir);
6468
6468
  }
6469
- return fs13.symlink(srcpath, dstpath, toType);
6469
+ return fs14.symlink(srcpath, dstpath, toType);
6470
6470
  }
6471
6471
  function createSymlinkSync(srcpath, dstpath, type) {
6472
6472
  let stats;
6473
6473
  try {
6474
- stats = fs13.lstatSync(dstpath);
6474
+ stats = fs14.lstatSync(dstpath);
6475
6475
  } catch {
6476
6476
  }
6477
6477
  if (stats && stats.isSymbolicLink()) {
6478
- const srcStat = fs13.statSync(srcpath);
6479
- const dstStat = fs13.statSync(dstpath);
6478
+ const srcStat = fs14.statSync(srcpath);
6479
+ const dstStat = fs14.statSync(dstpath);
6480
6480
  if (areIdentical(srcStat, dstStat)) return;
6481
6481
  }
6482
6482
  const relative = symlinkPathsSync(srcpath, dstpath);
6483
6483
  srcpath = relative.toDst;
6484
6484
  type = symlinkTypeSync(relative.toCwd, type);
6485
6485
  const dir = path5.dirname(dstpath);
6486
- const exists = fs13.existsSync(dir);
6487
- if (exists) return fs13.symlinkSync(srcpath, dstpath, type);
6486
+ const exists = fs14.existsSync(dir);
6487
+ if (exists) return fs14.symlinkSync(srcpath, dstpath, type);
6488
6488
  mkdirsSync(dir);
6489
- return fs13.symlinkSync(srcpath, dstpath, type);
6489
+ return fs14.symlinkSync(srcpath, dstpath, type);
6490
6490
  }
6491
6491
  module2.exports = {
6492
6492
  createSymlink: u(createSymlink),
@@ -6555,9 +6555,9 @@ var require_jsonfile = __commonJS({
6555
6555
  if (typeof options === "string") {
6556
6556
  options = { encoding: options };
6557
6557
  }
6558
- const fs13 = options.fs || _fs;
6558
+ const fs14 = options.fs || _fs;
6559
6559
  const shouldThrow = "throws" in options ? options.throws : true;
6560
- let data = await universalify.fromCallback(fs13.readFile)(file, options);
6560
+ let data = await universalify.fromCallback(fs14.readFile)(file, options);
6561
6561
  data = stripBom(data);
6562
6562
  let obj;
6563
6563
  try {
@@ -6577,10 +6577,10 @@ var require_jsonfile = __commonJS({
6577
6577
  if (typeof options === "string") {
6578
6578
  options = { encoding: options };
6579
6579
  }
6580
- const fs13 = options.fs || _fs;
6580
+ const fs14 = options.fs || _fs;
6581
6581
  const shouldThrow = "throws" in options ? options.throws : true;
6582
6582
  try {
6583
- let content = fs13.readFileSync(file, options);
6583
+ let content = fs14.readFileSync(file, options);
6584
6584
  content = stripBom(content);
6585
6585
  return JSON.parse(content, options.reviver);
6586
6586
  } catch (err) {
@@ -6593,15 +6593,15 @@ var require_jsonfile = __commonJS({
6593
6593
  }
6594
6594
  }
6595
6595
  async function _writeFile(file, obj, options = {}) {
6596
- const fs13 = options.fs || _fs;
6596
+ const fs14 = options.fs || _fs;
6597
6597
  const str = stringify2(obj, options);
6598
- await universalify.fromCallback(fs13.writeFile)(file, str, options);
6598
+ await universalify.fromCallback(fs14.writeFile)(file, str, options);
6599
6599
  }
6600
6600
  var writeFile2 = universalify.fromPromise(_writeFile);
6601
6601
  function writeFileSync2(file, obj, options = {}) {
6602
- const fs13 = options.fs || _fs;
6602
+ const fs14 = options.fs || _fs;
6603
6603
  const str = stringify2(obj, options);
6604
- return fs13.writeFileSync(file, str, options);
6604
+ return fs14.writeFileSync(file, str, options);
6605
6605
  }
6606
6606
  module2.exports = {
6607
6607
  readFile: readFile2,
@@ -6632,7 +6632,7 @@ var require_output_file = __commonJS({
6632
6632
  "node_modules/fs-extra/lib/output-file/index.js"(exports2, module2) {
6633
6633
  "use strict";
6634
6634
  var u = require_universalify().fromPromise;
6635
- var fs13 = require_fs();
6635
+ var fs14 = require_fs();
6636
6636
  var path5 = require("path");
6637
6637
  var mkdir = require_mkdirs();
6638
6638
  var pathExists2 = require_path_exists().pathExists;
@@ -6641,14 +6641,14 @@ var require_output_file = __commonJS({
6641
6641
  if (!await pathExists2(dir)) {
6642
6642
  await mkdir.mkdirs(dir);
6643
6643
  }
6644
- return fs13.writeFile(file, data, encoding);
6644
+ return fs14.writeFile(file, data, encoding);
6645
6645
  }
6646
6646
  function outputFileSync(file, ...args) {
6647
6647
  const dir = path5.dirname(file);
6648
- if (!fs13.existsSync(dir)) {
6648
+ if (!fs14.existsSync(dir)) {
6649
6649
  mkdir.mkdirsSync(dir);
6650
6650
  }
6651
- fs13.writeFileSync(file, ...args);
6651
+ fs14.writeFileSync(file, ...args);
6652
6652
  }
6653
6653
  module2.exports = {
6654
6654
  outputFile: u(outputFile),
@@ -6707,7 +6707,7 @@ var require_json = __commonJS({
6707
6707
  var require_move = __commonJS({
6708
6708
  "node_modules/fs-extra/lib/move/move.js"(exports2, module2) {
6709
6709
  "use strict";
6710
- var fs13 = require_fs();
6710
+ var fs14 = require_fs();
6711
6711
  var path5 = require("path");
6712
6712
  var { copy } = require_copy2();
6713
6713
  var { remove: remove2 } = require_remove();
@@ -6734,7 +6734,7 @@ var require_move = __commonJS({
6734
6734
  }
6735
6735
  }
6736
6736
  try {
6737
- await fs13.rename(src, dest);
6737
+ await fs14.rename(src, dest);
6738
6738
  } catch (err) {
6739
6739
  if (err.code !== "EXDEV") {
6740
6740
  throw err;
@@ -6759,7 +6759,7 @@ var require_move = __commonJS({
6759
6759
  var require_move_sync = __commonJS({
6760
6760
  "node_modules/fs-extra/lib/move/move-sync.js"(exports2, module2) {
6761
6761
  "use strict";
6762
- var fs13 = require_graceful_fs();
6762
+ var fs14 = require_graceful_fs();
6763
6763
  var path5 = require("path");
6764
6764
  var copySync = require_copy2().copySync;
6765
6765
  var removeSync = require_remove().removeSync;
@@ -6784,12 +6784,12 @@ var require_move_sync = __commonJS({
6784
6784
  removeSync(dest);
6785
6785
  return rename(src, dest, overwrite);
6786
6786
  }
6787
- if (fs13.existsSync(dest)) throw new Error("dest already exists.");
6787
+ if (fs14.existsSync(dest)) throw new Error("dest already exists.");
6788
6788
  return rename(src, dest, overwrite);
6789
6789
  }
6790
6790
  function rename(src, dest, overwrite) {
6791
6791
  try {
6792
- fs13.renameSync(src, dest);
6792
+ fs14.renameSync(src, dest);
6793
6793
  } catch (err) {
6794
6794
  if (err.code !== "EXDEV") throw err;
6795
6795
  return moveAcrossDevice(src, dest, overwrite);
@@ -19200,7 +19200,7 @@ var require_buffer_list = __commonJS({
19200
19200
  }
19201
19201
  }, {
19202
19202
  key: "join",
19203
- value: function join11(s) {
19203
+ value: function join12(s) {
19204
19204
  if (this.length === 0) return "";
19205
19205
  var p = this.head;
19206
19206
  var ret = "" + p.data;
@@ -28077,10 +28077,10 @@ var require_lib2 = __commonJS({
28077
28077
  exports2.analyse = analyse;
28078
28078
  var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
28079
28079
  let fd;
28080
- const fs13 = (0, node_1.default)();
28080
+ const fs14 = (0, node_1.default)();
28081
28081
  const handler = (err, buffer) => {
28082
28082
  if (fd) {
28083
- fs13.closeSync(fd);
28083
+ fs14.closeSync(fd);
28084
28084
  }
28085
28085
  if (err) {
28086
28086
  reject(err);
@@ -28092,9 +28092,9 @@ var require_lib2 = __commonJS({
28092
28092
  };
28093
28093
  const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
28094
28094
  if (sampleSize > 0) {
28095
- fd = fs13.openSync(filepath, "r");
28095
+ fd = fs14.openSync(filepath, "r");
28096
28096
  let sample = Buffer.allocUnsafe(sampleSize);
28097
- fs13.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
28097
+ fs14.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
28098
28098
  if (err) {
28099
28099
  handler(err, null);
28100
28100
  } else {
@@ -28106,22 +28106,22 @@ var require_lib2 = __commonJS({
28106
28106
  });
28107
28107
  return;
28108
28108
  }
28109
- fs13.readFile(filepath, handler);
28109
+ fs14.readFile(filepath, handler);
28110
28110
  });
28111
28111
  exports2.detectFile = detectFile;
28112
28112
  var detectFileSync = (filepath, opts = {}) => {
28113
- const fs13 = (0, node_1.default)();
28113
+ const fs14 = (0, node_1.default)();
28114
28114
  if (opts && opts.sampleSize) {
28115
- const fd = fs13.openSync(filepath, "r");
28115
+ const fd = fs14.openSync(filepath, "r");
28116
28116
  let sample = Buffer.allocUnsafe(opts.sampleSize);
28117
- const bytesRead = fs13.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
28117
+ const bytesRead = fs14.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
28118
28118
  if (bytesRead < opts.sampleSize) {
28119
28119
  sample = sample.subarray(0, bytesRead);
28120
28120
  }
28121
- fs13.closeSync(fd);
28121
+ fs14.closeSync(fd);
28122
28122
  return (0, exports2.detect)(sample);
28123
28123
  }
28124
- return (0, exports2.detect)(fs13.readFileSync(filepath));
28124
+ return (0, exports2.detect)(fs14.readFileSync(filepath));
28125
28125
  };
28126
28126
  exports2.detectFileSync = detectFileSync;
28127
28127
  exports2.default = {
@@ -44464,16 +44464,16 @@ var require_chainedTokenCredential = __commonJS({
44464
44464
  // node_modules/uuid/dist/esm-node/rng.js
44465
44465
  function rng() {
44466
44466
  if (poolPtr > rnds8Pool.length - 16) {
44467
- import_crypto2.default.randomFillSync(rnds8Pool);
44467
+ import_crypto3.default.randomFillSync(rnds8Pool);
44468
44468
  poolPtr = 0;
44469
44469
  }
44470
44470
  return rnds8Pool.slice(poolPtr, poolPtr += 16);
44471
44471
  }
44472
- var import_crypto2, rnds8Pool, poolPtr;
44472
+ var import_crypto3, rnds8Pool, poolPtr;
44473
44473
  var init_rng = __esm({
44474
44474
  "node_modules/uuid/dist/esm-node/rng.js"() {
44475
44475
  "use strict";
44476
- import_crypto2 = __toESM(require("crypto"));
44476
+ import_crypto3 = __toESM(require("crypto"));
44477
44477
  rnds8Pool = new Uint8Array(256);
44478
44478
  poolPtr = rnds8Pool.length;
44479
44479
  }
@@ -44678,13 +44678,13 @@ function md5(bytes) {
44678
44678
  } else if (typeof bytes === "string") {
44679
44679
  bytes = Buffer.from(bytes, "utf8");
44680
44680
  }
44681
- return import_crypto3.default.createHash("md5").update(bytes).digest();
44681
+ return import_crypto4.default.createHash("md5").update(bytes).digest();
44682
44682
  }
44683
- var import_crypto3, md5_default;
44683
+ var import_crypto4, md5_default;
44684
44684
  var init_md5 = __esm({
44685
44685
  "node_modules/uuid/dist/esm-node/md5.js"() {
44686
44686
  "use strict";
44687
- import_crypto3 = __toESM(require("crypto"));
44687
+ import_crypto4 = __toESM(require("crypto"));
44688
44688
  md5_default = md5;
44689
44689
  }
44690
44690
  });
@@ -44733,13 +44733,13 @@ function sha1(bytes) {
44733
44733
  } else if (typeof bytes === "string") {
44734
44734
  bytes = Buffer.from(bytes, "utf8");
44735
44735
  }
44736
- return import_crypto4.default.createHash("sha1").update(bytes).digest();
44736
+ return import_crypto5.default.createHash("sha1").update(bytes).digest();
44737
44737
  }
44738
- var import_crypto4, sha1_default;
44738
+ var import_crypto5, sha1_default;
44739
44739
  var init_sha1 = __esm({
44740
44740
  "node_modules/uuid/dist/esm-node/sha1.js"() {
44741
44741
  "use strict";
44742
- import_crypto4 = __toESM(require("crypto"));
44742
+ import_crypto5 = __toESM(require("crypto"));
44743
44743
  sha1_default = sha1;
44744
44744
  }
44745
44745
  });
@@ -52396,7 +52396,7 @@ var require_msal_node = __commonJS({
52396
52396
  var crypto5 = require("crypto");
52397
52397
  var msalCommon = require_lib6();
52398
52398
  var jwt2 = require_jsonwebtoken();
52399
- var fs13 = require("fs");
52399
+ var fs14 = require("fs");
52400
52400
  var path5 = require("path");
52401
52401
  var Serializer = class {
52402
52402
  /**
@@ -62095,7 +62095,7 @@ Headers: ${JSON.stringify(headers)}`
62095
62095
  if (!identityEndpoint || !imdsEndpoint) {
62096
62096
  const fileDetectionPath = AZURE_ARC_FILE_DETECTION[process.platform];
62097
62097
  try {
62098
- fs13.accessSync(fileDetectionPath, fs13.constants.F_OK | fs13.constants.R_OK);
62098
+ fs14.accessSync(fileDetectionPath, fs14.constants.F_OK | fs14.constants.R_OK);
62099
62099
  identityEndpoint = DEFAULT_AZURE_ARC_IDENTITY_ENDPOINT;
62100
62100
  imdsEndpoint = HIMDS_EXECUTABLE_HELPER_STRING;
62101
62101
  } catch (err) {
@@ -62207,7 +62207,7 @@ Headers: ${JSON.stringify(headers)}`
62207
62207
  }
62208
62208
  let secretFileSize;
62209
62209
  try {
62210
- secretFileSize = await fs13.statSync(secretFilePath).size;
62210
+ secretFileSize = await fs14.statSync(secretFilePath).size;
62211
62211
  } catch (e) {
62212
62212
  throw createManagedIdentityError(unableToReadSecretFile);
62213
62213
  }
@@ -62216,7 +62216,7 @@ Headers: ${JSON.stringify(headers)}`
62216
62216
  }
62217
62217
  let secret;
62218
62218
  try {
62219
- secret = fs13.readFileSync(secretFilePath, EncodingTypes.UTF8);
62219
+ secret = fs14.readFileSync(secretFilePath, EncodingTypes.UTF8);
62220
62220
  } catch (e) {
62221
62221
  throw createManagedIdentityError(unableToReadSecretFile);
62222
62222
  }
@@ -115440,25 +115440,201 @@ var docsCommand = new Command("docs").alias("d").description("Open SmartStack do
115440
115440
  });
115441
115441
 
115442
115442
  // src/commands/init.ts
115443
- var import_fs_extra3 = __toESM(require_lib());
115444
- var import_path4 = require("path");
115443
+ var import_fs_extra4 = __toESM(require_lib());
115444
+ var import_path5 = require("path");
115445
115445
  var import_os2 = require("os");
115446
115446
  var import_child_process4 = require("child_process");
115447
+ var import_crypto2 = require("crypto");
115448
+
115449
+ // src/lib/file-tracker.ts
115447
115450
  var import_crypto = require("crypto");
115448
- var TEMPLATES_DIR2 = (0, import_path4.join)((0, import_path4.dirname)(__dirname), "templates", "project");
115449
- function checkPrerequisites() {
115450
- const check = (cmd, args) => {
115451
- try {
115452
- const result = (0, import_child_process4.spawnSync)(cmd, args, { encoding: "utf-8", shell: true, timeout: 1e4 });
115453
- return result.status === 0;
115454
- } catch {
115455
- return false;
115451
+ var import_path4 = require("path");
115452
+ var import_fs_extra3 = __toESM(require_lib());
115453
+ var INIT_STATE_FILE = "init-state.json";
115454
+ var SMARTSTACK_DIR = ".smartstack";
115455
+ function computeHash(content) {
115456
+ return (0, import_crypto.createHash)("sha256").update(content).digest("hex");
115457
+ }
115458
+ async function computeFileHash(filePath) {
115459
+ const content = await import_fs_extra3.default.readFile(filePath);
115460
+ return computeHash(content);
115461
+ }
115462
+ async function safeWriteFile(filePath, content, knownHash) {
115463
+ const newHash = computeHash(content);
115464
+ if (await import_fs_extra3.default.pathExists(filePath)) {
115465
+ const existingHash = await computeFileHash(filePath);
115466
+ if (existingHash === newHash) {
115467
+ return { action: "skipped_identical", hash: newHash };
115468
+ }
115469
+ if (knownHash) {
115470
+ if (existingHash === knownHash) {
115471
+ await import_fs_extra3.default.ensureDir((0, import_path4.dirname)(filePath));
115472
+ await import_fs_extra3.default.writeFile(filePath, content);
115473
+ return { action: "overwritten", hash: newHash };
115474
+ }
115475
+ return { action: "skipped_modified", hash: existingHash };
115476
+ }
115477
+ return { action: "skipped_modified", hash: existingHash };
115478
+ }
115479
+ await import_fs_extra3.default.ensureDir((0, import_path4.dirname)(filePath));
115480
+ await import_fs_extra3.default.writeFile(filePath, content);
115481
+ return { action: "created", hash: newHash };
115482
+ }
115483
+ async function loadInitState(projectDir) {
115484
+ const statePath = (0, import_path4.join)(projectDir, SMARTSTACK_DIR, INIT_STATE_FILE);
115485
+ try {
115486
+ if (await import_fs_extra3.default.pathExists(statePath)) {
115487
+ const content = await import_fs_extra3.default.readFile(statePath, "utf-8");
115488
+ return JSON.parse(content);
115456
115489
  }
115457
- };
115490
+ } catch {
115491
+ }
115492
+ return null;
115493
+ }
115494
+ async function saveInitState(projectDir, state) {
115495
+ const dir = (0, import_path4.join)(projectDir, SMARTSTACK_DIR);
115496
+ await import_fs_extra3.default.ensureDir(dir);
115497
+ const statePath = (0, import_path4.join)(dir, INIT_STATE_FILE);
115498
+ await import_fs_extra3.default.writeFile(statePath, JSON.stringify(state, null, 2), "utf-8");
115499
+ }
115500
+ var INIT_STEPS = [
115501
+ { id: "config", name: "Configuration files" },
115502
+ { id: "backend", name: "Backend structure" },
115503
+ { id: "frontend", name: "Frontend structure" },
115504
+ { id: "git", name: "Git initialization" },
115505
+ { id: "ralph", name: "Ralph configuration" }
115506
+ ];
115507
+ function createFreshInitState(projectConfig, cliVersion) {
115508
+ const now = (/* @__PURE__ */ new Date()).toISOString();
115458
115509
  return {
115459
- dotnet: check("dotnet", ["--version"])
115510
+ schemaVersion: 1,
115511
+ projectConfig,
115512
+ cliVersion,
115513
+ startedAt: now,
115514
+ updatedAt: now,
115515
+ steps: INIT_STEPS.map(({ id, name }) => ({
115516
+ id,
115517
+ name,
115518
+ status: "pending",
115519
+ files: []
115520
+ }))
115460
115521
  };
115461
115522
  }
115523
+ async function executeStep(state, stepId, projectDir, dryRun, stepFn) {
115524
+ const step = state.steps.find((s) => s.id === stepId);
115525
+ if (!step) throw new Error(`Unknown step: ${stepId}`);
115526
+ const stepIndex = state.steps.indexOf(step);
115527
+ const totalSteps = state.steps.length;
115528
+ if (step.status === "completed") {
115529
+ logger.step(stepIndex + 1, totalSteps, `${step.name} ${source_default.gray("\u2713 Already completed")}`);
115530
+ return;
115531
+ }
115532
+ step.status = "in_progress";
115533
+ step.startedAt = (/* @__PURE__ */ new Date()).toISOString();
115534
+ step.error = void 0;
115535
+ state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
115536
+ if (!dryRun) {
115537
+ await saveInitState(projectDir, state);
115538
+ }
115539
+ logger.step(stepIndex + 1, totalSteps, `${step.name}...`);
115540
+ try {
115541
+ await stepFn();
115542
+ step.status = "completed";
115543
+ step.completedAt = (/* @__PURE__ */ new Date()).toISOString();
115544
+ state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
115545
+ if (!dryRun) {
115546
+ await saveInitState(projectDir, state);
115547
+ }
115548
+ } catch (error) {
115549
+ step.status = "failed";
115550
+ step.error = error instanceof Error ? error.message : String(error);
115551
+ state.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
115552
+ if (!dryRun) {
115553
+ await saveInitState(projectDir, state);
115554
+ }
115555
+ throw error;
115556
+ }
115557
+ }
115558
+ function findKnownHash(state, stepId, relativePath) {
115559
+ const step = state.steps.find((s) => s.id === stepId);
115560
+ if (!step) return void 0;
115561
+ const record = step.files.find((f) => f.relativePath === relativePath);
115562
+ return record?.hash;
115563
+ }
115564
+ function recordFile(state, stepId, relativePath, hash) {
115565
+ const step = state.steps.find((s) => s.id === stepId);
115566
+ if (!step) return;
115567
+ const existing = step.files.find((f) => f.relativePath === relativePath);
115568
+ if (existing) {
115569
+ existing.hash = hash;
115570
+ } else {
115571
+ step.files.push({
115572
+ relativePath,
115573
+ hash,
115574
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
115575
+ });
115576
+ }
115577
+ }
115578
+ function logSafeWriteResult(relativePath, result) {
115579
+ switch (result.action) {
115580
+ case "created":
115581
+ logger.success(`Created ${relativePath}`);
115582
+ break;
115583
+ case "overwritten":
115584
+ logger.info(`Updated ${relativePath}`);
115585
+ break;
115586
+ case "skipped_modified":
115587
+ logger.warning(`Skipped ${relativePath} (modified by user)`);
115588
+ break;
115589
+ case "skipped_identical":
115590
+ break;
115591
+ }
115592
+ }
115593
+ function hasIncompleteSteps(state) {
115594
+ return state.steps.some((s) => s.status !== "completed");
115595
+ }
115596
+ function countCompletedSteps(state) {
115597
+ return state.steps.filter((s) => s.status === "completed").length;
115598
+ }
115599
+ function displayResumeSummary(state) {
115600
+ const completed = countCompletedSteps(state);
115601
+ const total = state.steps.length;
115602
+ logger.header("SmartStack Project Initialization (Resuming)");
115603
+ logger.info(`Resuming from previous attempt (${state.startedAt.split("T")[0]})`);
115604
+ logger.info(`Steps completed: ${completed}/${total}`);
115605
+ console.log();
115606
+ for (let i = 0; i < state.steps.length; i++) {
115607
+ const step = state.steps[i];
115608
+ const num = `[${i + 1}/${total}]`;
115609
+ switch (step.status) {
115610
+ case "completed":
115611
+ console.log(source_default.gray(` ${num} ${step.name}`) + source_default.green(" \u2713 Already completed"));
115612
+ break;
115613
+ case "failed":
115614
+ case "in_progress":
115615
+ console.log(source_default.yellow(` ${num} ${step.name}`) + source_default.yellow(" \u2192 Resuming..."));
115616
+ break;
115617
+ case "pending":
115618
+ console.log(source_default.gray(` ${num} ${step.name}`) + source_default.gray(" Pending"));
115619
+ break;
115620
+ }
115621
+ }
115622
+ console.log();
115623
+ }
115624
+
115625
+ // src/commands/init.ts
115626
+ var TEMPLATES_DIR2 = (0, import_path5.join)((0, import_path5.dirname)(__dirname), "templates", "project");
115627
+ function checkPrerequisites() {
115628
+ try {
115629
+ const result = (0, import_child_process4.spawnSync)("dotnet", ["--version"], { encoding: "utf-8", shell: true, timeout: 1e4 });
115630
+ if (result.status === 0 && result.stdout) {
115631
+ return { dotnet: true, dotnetVersion: result.stdout.trim() };
115632
+ }
115633
+ return { dotnet: false, dotnetVersion: null };
115634
+ } catch {
115635
+ return { dotnet: false, dotnetVersion: null };
115636
+ }
115637
+ }
115462
115638
  function validateCSharpNamespace(name) {
115463
115639
  if (!name || name.trim().length === 0) {
115464
115640
  return { valid: false, error: "Project name cannot be empty" };
@@ -115578,20 +115754,20 @@ function validateCSharpNamespace(name) {
115578
115754
  async function detectProjectContext(name, here) {
115579
115755
  const cwd = process.cwd();
115580
115756
  if (name && name.trim() && !here) {
115581
- const projectDir = (0, import_path4.isAbsolute)(name) ? name : (0, import_path4.join)(cwd, name);
115582
- if (projectDir === cwd || (0, import_path4.basename)(cwd) === name) {
115757
+ const projectDir = (0, import_path5.isAbsolute)(name) ? name : (0, import_path5.join)(cwd, name);
115758
+ if (projectDir === cwd || (0, import_path5.basename)(cwd) === name) {
115583
115759
  } else {
115584
- const projectName = (0, import_path4.basename)(name);
115760
+ const projectName = (0, import_path5.basename)(name);
115585
115761
  return { projectName, projectDir, inPlace: false };
115586
115762
  }
115587
115763
  }
115588
- const parentDir = (0, import_path4.dirname)(cwd);
115589
- const currentFolderName = (0, import_path4.basename)(cwd);
115764
+ const parentDir = (0, import_path5.dirname)(cwd);
115765
+ const currentFolderName = (0, import_path5.basename)(cwd);
115590
115766
  let detectedName;
115591
- const gitflowConfigPath = (0, import_path4.join)(cwd, ".claude", "gitflow", "config.json");
115592
- if (await import_fs_extra3.default.pathExists(gitflowConfigPath)) {
115767
+ const gitflowConfigPath = (0, import_path5.join)(cwd, ".claude", "gitflow", "config.json");
115768
+ if (await import_fs_extra4.default.pathExists(gitflowConfigPath)) {
115593
115769
  try {
115594
- const config = await import_fs_extra3.default.readJson(gitflowConfigPath);
115770
+ const config = await import_fs_extra4.default.readJson(gitflowConfigPath);
115595
115771
  if (config.repository?.name) {
115596
115772
  detectedName = config.repository.name;
115597
115773
  }
@@ -115599,15 +115775,15 @@ async function detectProjectContext(name, here) {
115599
115775
  }
115600
115776
  }
115601
115777
  if (!detectedName) {
115602
- const bareDir = (0, import_path4.join)(parentDir, ".bare");
115603
- if (await import_fs_extra3.default.pathExists(bareDir)) {
115604
- detectedName = (0, import_path4.basename)(parentDir);
115778
+ const bareDir = (0, import_path5.join)(parentDir, ".bare");
115779
+ if (await import_fs_extra4.default.pathExists(bareDir)) {
115780
+ detectedName = (0, import_path5.basename)(parentDir);
115605
115781
  }
115606
115782
  }
115607
115783
  if (!detectedName) {
115608
115784
  const worktreePatterns = /^(\d+-)?(?:main|master|develop|development)$/i;
115609
115785
  if (worktreePatterns.test(currentFolderName)) {
115610
- detectedName = (0, import_path4.basename)(parentDir);
115786
+ detectedName = (0, import_path5.basename)(parentDir);
115611
115787
  } else {
115612
115788
  detectedName = currentFolderName;
115613
115789
  }
@@ -115619,23 +115795,28 @@ async function detectProjectContext(name, here) {
115619
115795
  };
115620
115796
  }
115621
115797
  async function validateInPlaceDirectory(projectDir) {
115622
- if (await import_fs_extra3.default.pathExists((0, import_path4.join)(projectDir, ".smartstack", "config.json"))) {
115623
- return 'SmartStack is already initialized in this directory. Use "ss update" to update.';
115798
+ const hasConfig = await import_fs_extra4.default.pathExists((0, import_path5.join)(projectDir, ".smartstack", "config.json"));
115799
+ const existingState = await loadInitState(projectDir);
115800
+ if (existingState && hasIncompleteSteps(existingState)) {
115801
+ return { isResume: true, existingState };
115802
+ }
115803
+ if (hasConfig) {
115804
+ return { error: 'SmartStack is already initialized in this directory. Use "ss update" to update.', isResume: false };
115624
115805
  }
115625
- const files = await import_fs_extra3.default.readdir(projectDir);
115806
+ const files = await import_fs_extra4.default.readdir(projectDir);
115626
115807
  const hasSln = files.some((f) => f.endsWith(".sln"));
115627
115808
  if (hasSln) {
115628
- return "A .NET solution already exists in this directory. Cannot initialize SmartStack here.";
115809
+ return { error: "A .NET solution already exists in this directory. Cannot initialize SmartStack here.", isResume: false };
115629
115810
  }
115630
- const srcDir = (0, import_path4.join)(projectDir, "src");
115631
- if (await import_fs_extra3.default.pathExists(srcDir)) {
115632
- const srcFiles = await import_fs_extra3.default.readdir(srcDir);
115633
- const hasCsproj = srcFiles.some((f) => f.endsWith(".csproj") || import_fs_extra3.default.statSync((0, import_path4.join)(srcDir, f)).isDirectory());
115811
+ const srcDir = (0, import_path5.join)(projectDir, "src");
115812
+ if (await import_fs_extra4.default.pathExists(srcDir)) {
115813
+ const srcFiles = await import_fs_extra4.default.readdir(srcDir);
115814
+ const hasCsproj = srcFiles.some((f) => f.endsWith(".csproj") || import_fs_extra4.default.statSync((0, import_path5.join)(srcDir, f)).isDirectory());
115634
115815
  if (hasCsproj) {
115635
- return "A src/ directory with projects already exists. Cannot initialize SmartStack here.";
115816
+ return { error: "A src/ directory with projects already exists. Cannot initialize SmartStack here.", isResume: false };
115636
115817
  }
115637
115818
  }
115638
- return void 0;
115819
+ return { isResume: false };
115639
115820
  }
115640
115821
  async function checkMcpServers() {
115641
115822
  const result = {
@@ -115643,19 +115824,19 @@ async function checkMcpServers() {
115643
115824
  context7: { installed: false }
115644
115825
  };
115645
115826
  const possiblePaths = [
115646
- (0, import_path4.join)((0, import_os2.homedir)(), ".claude", "settings.json"),
115647
- (0, import_path4.join)((0, import_os2.homedir)(), ".claude.json"),
115648
- (0, import_path4.join)((0, import_os2.homedir)(), "AppData", "Roaming", "Claude", "settings.json"),
115649
- (0, import_path4.join)((0, import_os2.homedir)(), "Library", "Application Support", "Claude", "settings.json")
115827
+ (0, import_path5.join)((0, import_os2.homedir)(), ".claude", "settings.json"),
115828
+ (0, import_path5.join)((0, import_os2.homedir)(), ".claude.json"),
115829
+ (0, import_path5.join)((0, import_os2.homedir)(), "AppData", "Roaming", "Claude", "settings.json"),
115830
+ (0, import_path5.join)((0, import_os2.homedir)(), "Library", "Application Support", "Claude", "settings.json")
115650
115831
  ];
115651
115832
  const mcpSettingsPaths = [
115652
- (0, import_path4.join)((0, import_os2.homedir)(), ".claude", "mcp_servers.json"),
115653
- (0, import_path4.join)((0, import_os2.homedir)(), ".config", "claude-code", "mcp.json")
115833
+ (0, import_path5.join)((0, import_os2.homedir)(), ".claude", "mcp_servers.json"),
115834
+ (0, import_path5.join)((0, import_os2.homedir)(), ".config", "claude-code", "mcp.json")
115654
115835
  ];
115655
115836
  for (const settingsPath of [...possiblePaths, ...mcpSettingsPaths]) {
115656
115837
  try {
115657
- if (await import_fs_extra3.default.pathExists(settingsPath)) {
115658
- const content = await import_fs_extra3.default.readFile(settingsPath, "utf-8");
115838
+ if (await import_fs_extra4.default.pathExists(settingsPath)) {
115839
+ const content = await import_fs_extra4.default.readFile(settingsPath, "utf-8");
115659
115840
  const settings = JSON.parse(content);
115660
115841
  const mcpServers = settings.mcpServers || settings.mcp_servers || settings.servers || settings;
115661
115842
  if (mcpServers) {
@@ -115738,73 +115919,79 @@ async function getLatestNuGetVersion(packageName, prerelease) {
115738
115919
  }
115739
115920
  }
115740
115921
  async function loadTemplate(templateName, projectName) {
115741
- const templatePath = (0, import_path4.join)(TEMPLATES_DIR2, templateName);
115742
- if (!await import_fs_extra3.default.pathExists(templatePath)) {
115922
+ const templatePath = (0, import_path5.join)(TEMPLATES_DIR2, templateName);
115923
+ if (!await import_fs_extra4.default.pathExists(templatePath)) {
115743
115924
  throw new Error(`Template not found: ${templatePath}`);
115744
115925
  }
115745
- let content = await import_fs_extra3.default.readFile(templatePath, "utf-8");
115926
+ let content = await import_fs_extra4.default.readFile(templatePath, "utf-8");
115746
115927
  content = content.replace(/\{\{ProjectName\}\}/g, projectName);
115747
115928
  return content;
115748
115929
  }
115749
- async function createDualDbContextStructure(projectDir, projectName, dryRun) {
115930
+ async function createDualDbContextStructure(projectDir, projectName, state, dryRun) {
115750
115931
  if (dryRun) {
115751
115932
  logger.info("[DRY RUN] Would create Dual-DbContext structure");
115752
115933
  return;
115753
115934
  }
115754
- const srcDir = (0, import_path4.join)(projectDir, "src");
115935
+ const srcDir = (0, import_path5.join)(projectDir, "src");
115755
115936
  const directories = [
115756
- (0, import_path4.join)(srcDir, `${projectName}.Application`, "Common", "Interfaces"),
115757
- (0, import_path4.join)(srcDir, `${projectName}.Infrastructure`, "Persistence"),
115758
- (0, import_path4.join)(srcDir, `${projectName}.Infrastructure`, "Persistence", "Configurations"),
115759
- (0, import_path4.join)(srcDir, `${projectName}.Infrastructure`, "Services"),
115760
- (0, import_path4.join)(srcDir, `${projectName}.Domain`, "Entities")
115937
+ (0, import_path5.join)(srcDir, `${projectName}.Application`, "Common", "Interfaces"),
115938
+ (0, import_path5.join)(srcDir, `${projectName}.Infrastructure`, "Persistence"),
115939
+ (0, import_path5.join)(srcDir, `${projectName}.Infrastructure`, "Persistence", "Configurations"),
115940
+ (0, import_path5.join)(srcDir, `${projectName}.Infrastructure`, "Services"),
115941
+ (0, import_path5.join)(srcDir, `${projectName}.Domain`, "Entities")
115761
115942
  ];
115762
115943
  for (const dir of directories) {
115763
- await import_fs_extra3.default.ensureDir(dir);
115944
+ await import_fs_extra4.default.ensureDir(dir);
115764
115945
  }
115765
115946
  const templateFiles = [
115766
115947
  {
115767
115948
  template: "IExtensionsDbContext.cs.template",
115768
- destination: (0, import_path4.join)(srcDir, `${projectName}.Application`, "Common", "Interfaces", "IExtensionsDbContext.cs")
115949
+ destination: (0, import_path5.join)(srcDir, `${projectName}.Application`, "Common", "Interfaces", "IExtensionsDbContext.cs")
115769
115950
  },
115770
115951
  {
115771
115952
  template: "DependencyInjection.Application.cs.template",
115772
- destination: (0, import_path4.join)(srcDir, `${projectName}.Application`, "DependencyInjection.cs")
115953
+ destination: (0, import_path5.join)(srcDir, `${projectName}.Application`, "DependencyInjection.cs")
115773
115954
  },
115774
115955
  {
115775
115956
  template: "ExtensionsDbContext.cs.template",
115776
- destination: (0, import_path4.join)(srcDir, `${projectName}.Infrastructure`, "Persistence", "ExtensionsDbContext.cs")
115957
+ destination: (0, import_path5.join)(srcDir, `${projectName}.Infrastructure`, "Persistence", "ExtensionsDbContext.cs")
115777
115958
  },
115778
115959
  {
115779
115960
  template: "DesignTimeExtensionsDbContextFactory.cs.template",
115780
- destination: (0, import_path4.join)(srcDir, `${projectName}.Infrastructure`, "Persistence", "DesignTimeExtensionsDbContextFactory.cs")
115961
+ destination: (0, import_path5.join)(srcDir, `${projectName}.Infrastructure`, "Persistence", "DesignTimeExtensionsDbContextFactory.cs")
115781
115962
  },
115782
115963
  {
115783
115964
  template: "DependencyInjection.Infrastructure.cs.template",
115784
- destination: (0, import_path4.join)(srcDir, `${projectName}.Infrastructure`, "DependencyInjection.cs")
115965
+ destination: (0, import_path5.join)(srcDir, `${projectName}.Infrastructure`, "DependencyInjection.cs")
115785
115966
  }
115786
115967
  ];
115787
115968
  for (const { template, destination } of templateFiles) {
115788
115969
  try {
115789
115970
  const content = await loadTemplate(template, projectName);
115790
- await import_fs_extra3.default.writeFile(destination, content);
115791
- logger.info(`Created: ${(0, import_path4.basename)(destination)}`);
115971
+ const relPath = destination.replace(projectDir + "\\", "").replace(projectDir + "/", "").replace(/\\/g, "/");
115972
+ const result = await safeWriteFile(destination, content, findKnownHash(state, "backend", relPath));
115973
+ logSafeWriteResult(relPath, result);
115974
+ recordFile(state, "backend", relPath, result.hash);
115792
115975
  } catch (error) {
115793
115976
  logger.warning(`Could not create ${template}: ${error instanceof Error ? error.message : error}`);
115794
115977
  }
115795
115978
  }
115796
115979
  logger.success("Dual-DbContext structure created");
115797
115980
  }
115798
- async function createBackendStructure(config, dryRun) {
115981
+ async function createBackendStructure(config, state, dryRun) {
115799
115982
  const { name } = config;
115800
- const projectDir = config.projectDir ?? ((0, import_path4.isAbsolute)(name) ? name : (0, import_path4.join)(process.cwd(), name));
115801
- const projectName = (0, import_path4.basename)(name);
115802
- const srcDir = (0, import_path4.join)(projectDir, "src");
115803
- const slnPath = (0, import_path4.join)(projectDir, `${projectName}.sln`);
115983
+ const projectDir = config.projectDir ?? ((0, import_path5.isAbsolute)(name) ? name : (0, import_path5.join)(process.cwd(), name));
115984
+ const projectName = (0, import_path5.basename)(name);
115985
+ const srcDir = (0, import_path5.join)(projectDir, "src");
115986
+ const slnPath = (0, import_path5.join)(projectDir, `${projectName}.sln`);
115804
115987
  logger.info("Creating .NET solution structure...");
115805
- execCommand(`dotnet new sln -n "${projectName}" -o "${projectDir}"`, void 0, dryRun);
115806
- const slnxPath = (0, import_path4.join)(projectDir, `${projectName}.slnx`);
115807
- if (!dryRun && await import_fs_extra3.default.pathExists(slnxPath)) {
115988
+ if (dryRun || !await import_fs_extra4.default.pathExists(slnPath)) {
115989
+ execCommand(`dotnet new sln -n "${projectName}" -o "${projectDir}"`, void 0, dryRun);
115990
+ } else {
115991
+ logger.info(source_default.gray("Solution already exists, skipping creation"));
115992
+ }
115993
+ const slnxPath = (0, import_path5.join)(projectDir, `${projectName}.slnx`);
115994
+ if (!dryRun && await import_fs_extra4.default.pathExists(slnxPath)) {
115808
115995
  const slnContent = `Microsoft Visual Studio Solution File, Format Version 12.00
115809
115996
  # Visual Studio Version 17
115810
115997
  VisualStudioVersion = 17.0.31903.59
@@ -115816,8 +116003,8 @@ Global
115816
116003
  EndGlobalSection
115817
116004
  EndGlobal
115818
116005
  `;
115819
- await import_fs_extra3.default.writeFile(slnPath, slnContent);
115820
- await import_fs_extra3.default.remove(slnxPath);
116006
+ await import_fs_extra4.default.writeFile(slnPath, slnContent);
116007
+ await import_fs_extra4.default.remove(slnxPath);
115821
116008
  logger.info("Converted .slnx to .sln for VS Code compatibility");
115822
116009
  }
115823
116010
  const projects = [
@@ -115827,13 +116014,18 @@ EndGlobal
115827
116014
  { proj: `${projectName}.Api`, type: "webapi" }
115828
116015
  ];
115829
116016
  for (const { proj, type } of projects) {
115830
- const projDir = (0, import_path4.join)(srcDir, proj);
115831
- execCommand(`dotnet new ${type} -n "${proj}" -o "${projDir}"`, void 0, dryRun);
115832
- execCommand(`dotnet sln "${slnPath}" add "${projDir}"`, void 0, dryRun);
116017
+ const projDir = (0, import_path5.join)(srcDir, proj);
116018
+ const csprojPath = (0, import_path5.join)(projDir, `${proj}.csproj`);
116019
+ if (dryRun || !await import_fs_extra4.default.pathExists(csprojPath)) {
116020
+ execCommand(`dotnet new ${type} -n "${proj}" -o "${projDir}"`, void 0, dryRun);
116021
+ execCommand(`dotnet sln "${slnPath}" add "${projDir}"`, void 0, dryRun);
116022
+ } else {
116023
+ logger.info(source_default.gray(`Project ${proj} already exists, skipping creation`));
116024
+ }
115833
116025
  }
115834
- const apiDir = (0, import_path4.join)(srcDir, `${projectName}.Api`);
116026
+ const apiDir = (0, import_path5.join)(srcDir, `${projectName}.Api`);
115835
116027
  if (!dryRun) {
115836
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(apiDir, "wwwroot"));
116028
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(apiDir, "wwwroot"));
115837
116029
  }
115838
116030
  const launchSettings = {
115839
116031
  $schema: "https://json.schemastore.org/launchsettings.json",
@@ -115859,18 +116051,22 @@ EndGlobal
115859
116051
  }
115860
116052
  };
115861
116053
  if (!dryRun) {
115862
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(apiDir, "Properties"));
115863
- await import_fs_extra3.default.writeFile(
115864
- (0, import_path4.join)(apiDir, "Properties", "launchSettings.json"),
115865
- JSON.stringify(launchSettings, null, 2)
116054
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(apiDir, "Properties"));
116055
+ const launchRelPath = `src/${projectName}.Api/Properties/launchSettings.json`;
116056
+ const launchResult = await safeWriteFile(
116057
+ (0, import_path5.join)(apiDir, "Properties", "launchSettings.json"),
116058
+ JSON.stringify(launchSettings, null, 2),
116059
+ findKnownHash(state, "backend", launchRelPath)
115866
116060
  );
116061
+ logSafeWriteResult(launchRelPath, launchResult);
116062
+ recordFile(state, "backend", launchRelPath, launchResult.hash);
115867
116063
  }
115868
116064
  if (!dryRun) {
115869
116065
  for (const { proj, type } of projects) {
115870
116066
  if (type === "classlib") {
115871
- const class1Path = (0, import_path4.join)(srcDir, proj, "Class1.cs");
115872
- if (await import_fs_extra3.default.pathExists(class1Path)) {
115873
- await import_fs_extra3.default.remove(class1Path);
116067
+ const class1Path = (0, import_path5.join)(srcDir, proj, "Class1.cs");
116068
+ if (await import_fs_extra4.default.pathExists(class1Path)) {
116069
+ await import_fs_extra4.default.remove(class1Path);
115874
116070
  logger.info(`Removed placeholder: ${proj}/Class1.cs`);
115875
116071
  }
115876
116072
  }
@@ -115878,11 +116074,11 @@ EndGlobal
115878
116074
  }
115879
116075
  if (!dryRun) {
115880
116076
  for (const { proj } of projects) {
115881
- const csprojPath = (0, import_path4.join)(srcDir, proj, `${proj}.csproj`);
115882
- if (await import_fs_extra3.default.pathExists(csprojPath)) {
115883
- let content = await import_fs_extra3.default.readFile(csprojPath, "utf-8");
116077
+ const csprojPath = (0, import_path5.join)(srcDir, proj, `${proj}.csproj`);
116078
+ if (await import_fs_extra4.default.pathExists(csprojPath)) {
116079
+ let content = await import_fs_extra4.default.readFile(csprojPath, "utf-8");
115884
116080
  content = content.replace(/\s*<TargetFramework>.*<\/TargetFramework>\s*/g, "\n ");
115885
- await import_fs_extra3.default.writeFile(csprojPath, content);
116081
+ await import_fs_extra4.default.writeFile(csprojPath, content);
115886
116082
  }
115887
116083
  }
115888
116084
  logger.info("Configured projects to inherit TargetFramework from Directory.Build.props");
@@ -115896,7 +116092,7 @@ EndGlobal
115896
116092
  ];
115897
116093
  for (const { from: from3, to } of refs) {
115898
116094
  execCommand(
115899
- `dotnet add "${(0, import_path4.join)(srcDir, from3)}" reference "${(0, import_path4.join)(srcDir, to)}"`,
116095
+ `dotnet add "${(0, import_path5.join)(srcDir, from3)}" reference "${(0, import_path5.join)(srcDir, to)}"`,
115900
116096
  void 0,
115901
116097
  dryRun
115902
116098
  );
@@ -115947,23 +116143,29 @@ EndGlobal
115947
116143
  for (const { project, packages } of nugetPackages) {
115948
116144
  for (const pkg2 of packages) {
115949
116145
  if (pkg2 === "SmartStack" && smartstackVersion) {
115950
- execCommand(`dotnet add "${(0, import_path4.join)(srcDir, project)}" package ${pkg2} --version ${smartstackVersion}`, void 0, dryRun);
116146
+ execCommand(`dotnet add "${(0, import_path5.join)(srcDir, project)}" package ${pkg2} --version ${smartstackVersion}`, void 0, dryRun);
115951
116147
  } else {
115952
- execCommand(`dotnet add "${(0, import_path4.join)(srcDir, project)}" package ${pkg2}${prereleaseFlag}`, void 0, dryRun);
116148
+ execCommand(`dotnet add "${(0, import_path5.join)(srcDir, project)}" package ${pkg2}${prereleaseFlag}`, void 0, dryRun);
115953
116149
  }
115954
116150
  }
115955
116151
  }
115956
116152
  if (!dryRun) {
115957
- const apiDir2 = (0, import_path4.join)(srcDir, `${projectName}.Api`);
116153
+ const apiDir2 = (0, import_path5.join)(srcDir, `${projectName}.Api`);
115958
116154
  const programCs = await loadTemplate("Program.cs.template", projectName);
115959
- await import_fs_extra3.default.writeFile((0, import_path4.join)(apiDir2, "Program.cs"), programCs);
115960
- logger.info("Configured Program.cs with Dual-DbContext pattern");
115961
- const templatePath = (0, import_path4.join)(TEMPLATES_DIR2, "appsettings.json.template");
115962
- if (!await import_fs_extra3.default.pathExists(templatePath)) {
116155
+ const programRelPath = `src/${projectName}.Api/Program.cs`;
116156
+ const programResult = await safeWriteFile(
116157
+ (0, import_path5.join)(apiDir2, "Program.cs"),
116158
+ programCs,
116159
+ findKnownHash(state, "backend", programRelPath)
116160
+ );
116161
+ logSafeWriteResult(programRelPath, programResult);
116162
+ recordFile(state, "backend", programRelPath, programResult.hash);
116163
+ const templatePath = (0, import_path5.join)(TEMPLATES_DIR2, "appsettings.json.template");
116164
+ if (!await import_fs_extra4.default.pathExists(templatePath)) {
115963
116165
  throw new Error(`Template not found: ${templatePath}`);
115964
116166
  }
115965
- let appSettingsContent = await import_fs_extra3.default.readFile(templatePath, "utf-8");
115966
- const randomSecret = (0, import_crypto.randomBytes)(32).toString("hex");
116167
+ let appSettingsContent = await import_fs_extra4.default.readFile(templatePath, "utf-8");
116168
+ const randomSecret = (0, import_crypto2.randomBytes)(32).toString("hex");
115967
116169
  appSettingsContent = appSettingsContent.replace(/\{\{ProjectName\}\}/g, projectName).replace(/\{\{GenerateRandomSecret\}\}/g, randomSecret).replace(/\{\{ProjectDomain\}\}/g, `${projectName.toLowerCase()}.app`).replace(/\{\{ProjectNameLower\}\}/g, projectName.toLowerCase());
115968
116170
  const appSettings = JSON.parse(appSettingsContent);
115969
116171
  appSettings.MultiTenant = {
@@ -115973,10 +116175,14 @@ EndGlobal
115973
116175
  SystemTenantName: config.multiTenant.systemTenantName,
115974
116176
  AutoAssignUsersToSystemTenant: config.multiTenant.autoAssignUsersToSystemTenant
115975
116177
  };
115976
- await import_fs_extra3.default.writeFile(
115977
- (0, import_path4.join)(apiDir2, "appsettings.json"),
115978
- JSON.stringify(appSettings, null, 2)
116178
+ const appSettingsRelPath = `src/${projectName}.Api/appsettings.json`;
116179
+ const appSettingsResult = await safeWriteFile(
116180
+ (0, import_path5.join)(apiDir2, "appsettings.json"),
116181
+ JSON.stringify(appSettings, null, 2),
116182
+ findKnownHash(state, "backend", appSettingsRelPath)
115979
116183
  );
116184
+ logSafeWriteResult(appSettingsRelPath, appSettingsResult);
116185
+ recordFile(state, "backend", appSettingsRelPath, appSettingsResult.hash);
115980
116186
  const appSettingsDev = {
115981
116187
  Logging: {
115982
116188
  Sinks: {
@@ -115990,24 +116196,27 @@ EndGlobal
115990
116196
  Provider: "Development"
115991
116197
  }
115992
116198
  };
115993
- await import_fs_extra3.default.writeFile(
115994
- (0, import_path4.join)(apiDir2, "appsettings.Development.json"),
115995
- JSON.stringify(appSettingsDev, null, 2)
116199
+ const appSettingsDevRelPath = `src/${projectName}.Api/appsettings.Development.json`;
116200
+ const appSettingsDevResult = await safeWriteFile(
116201
+ (0, import_path5.join)(apiDir2, "appsettings.Development.json"),
116202
+ JSON.stringify(appSettingsDev, null, 2),
116203
+ findKnownHash(state, "backend", appSettingsDevRelPath)
115996
116204
  );
115997
- logger.info("Created appsettings.json configuration files");
116205
+ logSafeWriteResult(appSettingsDevRelPath, appSettingsDevResult);
116206
+ recordFile(state, "backend", appSettingsDevRelPath, appSettingsDevResult.hash);
115998
116207
  }
115999
116208
  logger.info("Creating Dual-DbContext structure...");
116000
- await createDualDbContextStructure(projectDir, projectName, dryRun);
116209
+ await createDualDbContextStructure(projectDir, projectName, state, dryRun);
116001
116210
  }
116002
- async function createConfigFiles(config, dryRun) {
116211
+ async function createConfigFiles(config, state, dryRun) {
116003
116212
  const { name } = config;
116004
- const projectDir = config.projectDir ?? ((0, import_path4.isAbsolute)(name) ? name : (0, import_path4.join)(process.cwd(), name));
116005
- const projectName = (0, import_path4.basename)(name);
116213
+ const projectDir = config.projectDir ?? ((0, import_path5.isAbsolute)(name) ? name : (0, import_path5.join)(process.cwd(), name));
116214
+ const projectName = (0, import_path5.basename)(name);
116006
116215
  if (dryRun) {
116007
116216
  logger.info("[DRY RUN] Would create configuration files");
116008
116217
  return;
116009
116218
  }
116010
- await import_fs_extra3.default.ensureDir(projectDir);
116219
+ await import_fs_extra4.default.ensureDir(projectDir);
116011
116220
  const targetFramework = "net10.0";
116012
116221
  const buildProps = `<Project>
116013
116222
  <PropertyGroup>
@@ -116018,7 +116227,10 @@ async function createConfigFiles(config, dryRun) {
116018
116227
  </PropertyGroup>
116019
116228
  </Project>
116020
116229
  `;
116021
- await import_fs_extra3.default.writeFile((0, import_path4.join)(projectDir, "Directory.Build.props"), buildProps);
116230
+ const relPath1 = "Directory.Build.props";
116231
+ const result1 = await safeWriteFile((0, import_path5.join)(projectDir, relPath1), buildProps, findKnownHash(state, "config", relPath1));
116232
+ logSafeWriteResult(relPath1, result1);
116233
+ recordFile(state, "config", relPath1, result1.hash);
116022
116234
  logger.info(`Target framework: ${source_default.cyan(targetFramework)}${config.preview ? " (preview)" : ""}`);
116023
116235
  const gitignore = `## .NET
116024
116236
  bin/
@@ -116048,8 +116260,11 @@ appsettings.*.Local.json
116048
116260
  *.db-shm
116049
116261
  *.db-wal
116050
116262
  `;
116051
- await import_fs_extra3.default.writeFile((0, import_path4.join)(projectDir, ".gitignore"), gitignore);
116052
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(projectDir, ".smartstack"));
116263
+ const relPath2 = ".gitignore";
116264
+ const result2 = await safeWriteFile((0, import_path5.join)(projectDir, relPath2), gitignore, findKnownHash(state, "config", relPath2));
116265
+ logSafeWriteResult(relPath2, result2);
116266
+ recordFile(state, "config", relPath2, result2.hash);
116267
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(projectDir, ".smartstack"));
116053
116268
  const smartstackConfig = {
116054
116269
  projectType: "client",
116055
116270
  dbContext: "extensions",
@@ -116057,12 +116272,15 @@ appsettings.*.Local.json
116057
116272
  smartStackVersion: "1.0.0",
116058
116273
  initialized: (/* @__PURE__ */ new Date()).toISOString()
116059
116274
  };
116060
- await import_fs_extra3.default.writeFile(
116061
- (0, import_path4.join)(projectDir, ".smartstack", "config.json"),
116062
- JSON.stringify(smartstackConfig, null, 2)
116275
+ const relPath3 = ".smartstack/config.json";
116276
+ const result3 = await safeWriteFile(
116277
+ (0, import_path5.join)(projectDir, relPath3),
116278
+ JSON.stringify(smartstackConfig, null, 2),
116279
+ findKnownHash(state, "config", relPath3)
116063
116280
  );
116064
- logger.success("Created .smartstack/config.json");
116065
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(projectDir, ".vscode"));
116281
+ logSafeWriteResult(relPath3, result3);
116282
+ recordFile(state, "config", relPath3, result3.hash);
116283
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(projectDir, ".vscode"));
116066
116284
  const launchJson = {
116067
116285
  version: "0.2.0",
116068
116286
  configurations: [
@@ -116091,7 +116309,10 @@ appsettings.*.Local.json
116091
116309
  }
116092
116310
  ]
116093
116311
  };
116094
- await import_fs_extra3.default.writeFile((0, import_path4.join)(projectDir, ".vscode", "launch.json"), JSON.stringify(launchJson, null, 2));
116312
+ const relPath4 = ".vscode/launch.json";
116313
+ const result4 = await safeWriteFile((0, import_path5.join)(projectDir, relPath4), JSON.stringify(launchJson, null, 2), findKnownHash(state, "config", relPath4));
116314
+ logSafeWriteResult(relPath4, result4);
116315
+ recordFile(state, "config", relPath4, result4.hash);
116095
116316
  const tasksJson = {
116096
116317
  version: "2.0.0",
116097
116318
  tasks: [
@@ -116143,7 +116364,10 @@ appsettings.*.Local.json
116143
116364
  }
116144
116365
  ]
116145
116366
  };
116146
- await import_fs_extra3.default.writeFile((0, import_path4.join)(projectDir, ".vscode", "tasks.json"), JSON.stringify(tasksJson, null, 2));
116367
+ const relPath5 = ".vscode/tasks.json";
116368
+ const result5 = await safeWriteFile((0, import_path5.join)(projectDir, relPath5), JSON.stringify(tasksJson, null, 2), findKnownHash(state, "config", relPath5));
116369
+ logSafeWriteResult(relPath5, result5);
116370
+ recordFile(state, "config", relPath5, result5.hash);
116147
116371
  const extensionsJson = {
116148
116372
  recommendations: [
116149
116373
  "ms-dotnettools.csdevkit",
@@ -116157,7 +116381,10 @@ appsettings.*.Local.json
116157
116381
  "esbenp.prettier-vscode"
116158
116382
  ]
116159
116383
  };
116160
- await import_fs_extra3.default.writeFile((0, import_path4.join)(projectDir, ".vscode", "extensions.json"), JSON.stringify(extensionsJson, null, 2));
116384
+ const relPath6 = ".vscode/extensions.json";
116385
+ const result6 = await safeWriteFile((0, import_path5.join)(projectDir, relPath6), JSON.stringify(extensionsJson, null, 2), findKnownHash(state, "config", relPath6));
116386
+ logSafeWriteResult(relPath6, result6);
116387
+ recordFile(state, "config", relPath6, result6.hash);
116161
116388
  const readme = `# ${projectName}
116162
116389
 
116163
116390
  A SmartStack application with .NET backend and React frontend.
@@ -116229,27 +116456,31 @@ ${projectName}/
116229
116456
 
116230
116457
  Generated with [SmartStack CLI](https://atlashub.io/products/smartstack-cli)
116231
116458
  `;
116232
- await import_fs_extra3.default.writeFile((0, import_path4.join)(projectDir, "README.md"), readme);
116459
+ const relPath7 = "README.md";
116460
+ const result7 = await safeWriteFile((0, import_path5.join)(projectDir, relPath7), readme, findKnownHash(state, "config", relPath7));
116461
+ logSafeWriteResult(relPath7, result7);
116462
+ recordFile(state, "config", relPath7, result7.hash);
116233
116463
  }
116234
- async function createFrontendStructure(config, dryRun) {
116464
+ async function createFrontendStructure(config, state, dryRun) {
116235
116465
  const { name } = config;
116236
- const projectDir = config.projectDir ?? ((0, import_path4.isAbsolute)(name) ? name : (0, import_path4.join)(process.cwd(), name));
116237
- const projectName = (0, import_path4.basename)(name);
116238
- const webDir = (0, import_path4.join)(projectDir, "web", `${projectName.toLowerCase()}-web`);
116466
+ const projectDir = config.projectDir ?? ((0, import_path5.isAbsolute)(name) ? name : (0, import_path5.join)(process.cwd(), name));
116467
+ const projectName = (0, import_path5.basename)(name);
116468
+ const webDir = (0, import_path5.join)(projectDir, "web", `${projectName.toLowerCase()}-web`);
116469
+ const webRelPrefix = `web/${projectName.toLowerCase()}-web`;
116239
116470
  logger.info("Creating React frontend structure...");
116240
116471
  if (dryRun) {
116241
116472
  logger.info("[DRY RUN] Would create React frontend at: " + webDir);
116242
116473
  return;
116243
116474
  }
116244
- await import_fs_extra3.default.ensureDir(webDir);
116245
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src"));
116246
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src", "components"));
116247
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src", "pages"));
116248
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src", "services"));
116249
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src", "hooks"));
116250
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src", "types"));
116251
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "src", "i18n"));
116252
- await import_fs_extra3.default.ensureDir((0, import_path4.join)(webDir, "public"));
116475
+ await import_fs_extra4.default.ensureDir(webDir);
116476
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src"));
116477
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src", "components"));
116478
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src", "pages"));
116479
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src", "services"));
116480
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src", "hooks"));
116481
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src", "types"));
116482
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "src", "i18n"));
116483
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(webDir, "public"));
116253
116484
  const smartstackNpmTag = config.preview ? "next" : "latest";
116254
116485
  const packageJson = {
116255
116486
  name: `${projectName.toLowerCase()}-web`,
@@ -116295,7 +116526,10 @@ async function createFrontendStructure(config, dryRun) {
116295
116526
  vite: "latest"
116296
116527
  }
116297
116528
  };
116298
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "package.json"), JSON.stringify(packageJson, null, 2));
116529
+ const pkg_relPath = `${webRelPrefix}/package.json`;
116530
+ const pkg_result = await safeWriteFile((0, import_path5.join)(webDir, "package.json"), JSON.stringify(packageJson, null, 2), findKnownHash(state, "frontend", pkg_relPath));
116531
+ logSafeWriteResult(pkg_relPath, pkg_result);
116532
+ recordFile(state, "frontend", pkg_relPath, pkg_result.hash);
116299
116533
  const envFile = `# =============================================================================
116300
116534
  # ${projectName} - Frontend Environment Configuration
116301
116535
  # =============================================================================
@@ -116318,7 +116552,10 @@ VITE_PORT=3000
116318
116552
  # Feature flags
116319
116553
  # VITE_ENABLE_DEVTOOLS=true
116320
116554
  `;
116321
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, ".env"), envFile);
116555
+ const env_relPath = `${webRelPrefix}/.env`;
116556
+ const env_result = await safeWriteFile((0, import_path5.join)(webDir, ".env"), envFile, findKnownHash(state, "frontend", env_relPath));
116557
+ logSafeWriteResult(env_relPath, env_result);
116558
+ recordFile(state, "frontend", env_relPath, env_result.hash);
116322
116559
  const envExampleFile = `# =============================================================================
116323
116560
  # ${projectName} - Frontend Environment Configuration
116324
116561
  # =============================================================================
@@ -116346,7 +116583,10 @@ VITE_PORT=3000
116346
116583
  # Feature flags (optional)
116347
116584
  # VITE_ENABLE_DEVTOOLS=true
116348
116585
  `;
116349
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, ".env.example"), envExampleFile);
116586
+ const envEx_relPath = `${webRelPrefix}/.env.example`;
116587
+ const envEx_result = await safeWriteFile((0, import_path5.join)(webDir, ".env.example"), envExampleFile, findKnownHash(state, "frontend", envEx_relPath));
116588
+ logSafeWriteResult(envEx_relPath, envEx_result);
116589
+ recordFile(state, "frontend", envEx_relPath, envEx_result.hash);
116350
116590
  const viteConfig = `import { defineConfig, loadEnv } from 'vite';
116351
116591
  import react from '@vitejs/plugin-react';
116352
116592
  import tailwindcss from '@tailwindcss/vite';
@@ -116386,7 +116626,10 @@ export default defineConfig(({ mode }) => {
116386
116626
  };
116387
116627
  });
116388
116628
  `;
116389
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "vite.config.ts"), viteConfig);
116629
+ const vite_relPath = `${webRelPrefix}/vite.config.ts`;
116630
+ const vite_result = await safeWriteFile((0, import_path5.join)(webDir, "vite.config.ts"), viteConfig, findKnownHash(state, "frontend", vite_relPath));
116631
+ logSafeWriteResult(vite_relPath, vite_result);
116632
+ recordFile(state, "frontend", vite_relPath, vite_result.hash);
116390
116633
  const tsConfig = {
116391
116634
  compilerOptions: {
116392
116635
  target: "ES2020",
@@ -116412,7 +116655,10 @@ export default defineConfig(({ mode }) => {
116412
116655
  },
116413
116656
  include: ["src"]
116414
116657
  };
116415
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
116658
+ const tsc_relPath = `${webRelPrefix}/tsconfig.json`;
116659
+ const tsc_result = await safeWriteFile((0, import_path5.join)(webDir, "tsconfig.json"), JSON.stringify(tsConfig, null, 2), findKnownHash(state, "frontend", tsc_relPath));
116660
+ logSafeWriteResult(tsc_relPath, tsc_result);
116661
+ recordFile(state, "frontend", tsc_relPath, tsc_result.hash);
116416
116662
  const indexHtml = `<!doctype html>
116417
116663
  <html lang="en">
116418
116664
  <head>
@@ -116427,7 +116673,10 @@ export default defineConfig(({ mode }) => {
116427
116673
  </body>
116428
116674
  </html>
116429
116675
  `;
116430
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "index.html"), indexHtml);
116676
+ const html_relPath = `${webRelPrefix}/index.html`;
116677
+ const html_result = await safeWriteFile((0, import_path5.join)(webDir, "index.html"), indexHtml, findKnownHash(state, "frontend", html_relPath));
116678
+ logSafeWriteResult(html_relPath, html_result);
116679
+ recordFile(state, "frontend", html_relPath, html_result.hash);
116431
116680
  const mainTsx = `import { StrictMode } from 'react';
116432
116681
  import { createRoot } from 'react-dom/client';
116433
116682
  import { BrowserRouter } from 'react-router-dom';
@@ -116452,7 +116701,10 @@ createRoot(document.getElementById('root')!).render(
116452
116701
  </StrictMode>,
116453
116702
  );
116454
116703
  `;
116455
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "src", "main.tsx"), mainTsx);
116704
+ const main_relPath = `${webRelPrefix}/src/main.tsx`;
116705
+ const main_result = await safeWriteFile((0, import_path5.join)(webDir, "src", "main.tsx"), mainTsx, findKnownHash(state, "frontend", main_relPath));
116706
+ logSafeWriteResult(main_relPath, main_result);
116707
+ recordFile(state, "frontend", main_relPath, main_result.hash);
116456
116708
  const appTsx = `import { useRoutes, Navigate } from 'react-router-dom';
116457
116709
  import { smartstackRoutes, mergeRoutes } from '@atlashub/smartstack';
116458
116710
  import type { RouteConfig } from '@atlashub/smartstack';
@@ -116483,10 +116735,16 @@ function App() {
116483
116735
 
116484
116736
  export default App;
116485
116737
  `;
116486
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "src", "App.tsx"), appTsx);
116738
+ const app_relPath = `${webRelPrefix}/src/App.tsx`;
116739
+ const app_result = await safeWriteFile((0, import_path5.join)(webDir, "src", "App.tsx"), appTsx, findKnownHash(state, "frontend", app_relPath));
116740
+ logSafeWriteResult(app_relPath, app_result);
116741
+ recordFile(state, "frontend", app_relPath, app_result.hash);
116487
116742
  const indexCss = `@import "tailwindcss";
116488
116743
  `;
116489
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "src", "index.css"), indexCss);
116744
+ const css_relPath = `${webRelPrefix}/src/index.css`;
116745
+ const css_result = await safeWriteFile((0, import_path5.join)(webDir, "src", "index.css"), indexCss, findKnownHash(state, "frontend", css_relPath));
116746
+ logSafeWriteResult(css_relPath, css_result);
116747
+ recordFile(state, "frontend", css_relPath, css_result.hash);
116490
116748
  const i18nConfig = `import i18n from 'i18next';
116491
116749
  import { initReactI18next } from 'react-i18next';
116492
116750
  import LanguageDetector from 'i18next-browser-languagedetector';
@@ -116517,15 +116775,27 @@ i18n
116517
116775
 
116518
116776
  export default i18n;
116519
116777
  `;
116520
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "src", "i18n", "index.ts"), i18nConfig);
116778
+ const i18n_relPath = `${webRelPrefix}/src/i18n/index.ts`;
116779
+ const i18n_result = await safeWriteFile((0, import_path5.join)(webDir, "src", "i18n", "index.ts"), i18nConfig, findKnownHash(state, "frontend", i18n_relPath));
116780
+ logSafeWriteResult(i18n_relPath, i18n_result);
116781
+ recordFile(state, "frontend", i18n_relPath, i18n_result.hash);
116521
116782
  const apiService = await loadTemplate("api.ts.template", projectName);
116522
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "src", "services", "api.ts"), apiService);
116783
+ const api_relPath = `${webRelPrefix}/src/services/api.ts`;
116784
+ const api_result = await safeWriteFile((0, import_path5.join)(webDir, "src", "services", "api.ts"), apiService, findKnownHash(state, "frontend", api_relPath));
116785
+ logSafeWriteResult(api_relPath, api_result);
116786
+ recordFile(state, "frontend", api_relPath, api_result.hash);
116523
116787
  const viteEnvDts = `/// <reference types="vite/client" />
116524
116788
  `;
116525
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "src", "vite-env.d.ts"), viteEnvDts);
116789
+ const envDts_relPath = `${webRelPrefix}/src/vite-env.d.ts`;
116790
+ const envDts_result = await safeWriteFile((0, import_path5.join)(webDir, "src", "vite-env.d.ts"), viteEnvDts, findKnownHash(state, "frontend", envDts_relPath));
116791
+ logSafeWriteResult(envDts_relPath, envDts_result);
116792
+ recordFile(state, "frontend", envDts_relPath, envDts_result.hash);
116526
116793
  const viteSvg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFBD4F"></stop><stop offset="100%" stop-color="#FF980E"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
116527
116794
  `;
116528
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, "public", "vite.svg"), viteSvg);
116795
+ const svg_relPath = `${webRelPrefix}/public/vite.svg`;
116796
+ const svg_result = await safeWriteFile((0, import_path5.join)(webDir, "public", "vite.svg"), viteSvg, findKnownHash(state, "frontend", svg_relPath));
116797
+ logSafeWriteResult(svg_relPath, svg_result);
116798
+ recordFile(state, "frontend", svg_relPath, svg_result.hash);
116529
116799
  const webGitignore = `# Dependencies
116530
116800
  node_modules/
116531
116801
 
@@ -116550,23 +116820,86 @@ npm-debug.log*
116550
116820
  .DS_Store
116551
116821
  Thumbs.db
116552
116822
  `;
116553
- await import_fs_extra3.default.writeFile((0, import_path4.join)(webDir, ".gitignore"), webGitignore);
116823
+ const gi_relPath = `${webRelPrefix}/.gitignore`;
116824
+ const gi_result = await safeWriteFile((0, import_path5.join)(webDir, ".gitignore"), webGitignore, findKnownHash(state, "frontend", gi_relPath));
116825
+ logSafeWriteResult(gi_relPath, gi_result);
116826
+ recordFile(state, "frontend", gi_relPath, gi_result.hash);
116554
116827
  logger.success("React frontend created at: " + webDir);
116555
116828
  }
116829
+ function checkGitIdentity(cwd) {
116830
+ const check = (key) => {
116831
+ try {
116832
+ const result = (0, import_child_process4.spawnSync)("git", ["config", key], { encoding: "utf-8", shell: true, cwd, timeout: 5e3 });
116833
+ return result.status === 0 && !!result.stdout.trim();
116834
+ } catch {
116835
+ return false;
116836
+ }
116837
+ };
116838
+ return { hasName: check("user.name"), hasEmail: check("user.email") };
116839
+ }
116840
+ async function ensureGitIdentity(projectDir, dryRun) {
116841
+ if (dryRun) return;
116842
+ const identity = checkGitIdentity(projectDir);
116843
+ if (identity.hasName && identity.hasEmail) return;
116844
+ logger.warning("Git user identity is not configured.");
116845
+ const answers = await lib_default.prompt([
116846
+ {
116847
+ type: "input",
116848
+ name: "gitName",
116849
+ message: "Git user name:",
116850
+ validate: (v) => v.trim().length > 0 || "Name is required",
116851
+ when: () => !identity.hasName
116852
+ },
116853
+ {
116854
+ type: "input",
116855
+ name: "gitEmail",
116856
+ message: "Git user email:",
116857
+ validate: (v) => v.trim().length > 0 || "Email is required",
116858
+ when: () => !identity.hasEmail
116859
+ },
116860
+ {
116861
+ type: "list",
116862
+ name: "scope",
116863
+ message: "Set this identity for:",
116864
+ choices: [
116865
+ { name: "This repository only (--local)", value: "local" },
116866
+ { name: "All repositories (--global)", value: "global" }
116867
+ ],
116868
+ default: "global"
116869
+ }
116870
+ ]);
116871
+ const flag = answers.scope === "global" ? "--global" : "--local";
116872
+ if (answers.gitName) {
116873
+ execCommand(`git config ${flag} user.name "${answers.gitName}"`, projectDir);
116874
+ }
116875
+ if (answers.gitEmail) {
116876
+ execCommand(`git config ${flag} user.email "${answers.gitEmail}"`, projectDir);
116877
+ }
116878
+ logger.success("Git identity configured");
116879
+ }
116556
116880
  async function initializeGit(config, dryRun) {
116557
116881
  const { name } = config;
116558
- const projectDir = config.projectDir ?? ((0, import_path4.isAbsolute)(name) ? name : (0, import_path4.join)(process.cwd(), name));
116559
- const gitDir = (0, import_path4.join)(projectDir, ".git");
116560
- const isGitInitialized = await import_fs_extra3.default.pathExists(gitDir);
116882
+ const projectDir = config.projectDir ?? ((0, import_path5.isAbsolute)(name) ? name : (0, import_path5.join)(process.cwd(), name));
116883
+ const gitDir = (0, import_path5.join)(projectDir, ".git");
116884
+ const isGitInitialized = await import_fs_extra4.default.pathExists(gitDir);
116561
116885
  if (isGitInitialized) {
116562
116886
  logger.info("Git repository already initialized, adding SmartStack files...");
116563
- execCommand("git add .", projectDir, dryRun);
116564
- execCommand('git commit -m "feat: initialize SmartStack project structure"', projectDir, dryRun);
116565
116887
  } else {
116566
116888
  logger.info("Initializing Git repository...");
116567
116889
  execCommand("git init", projectDir, dryRun);
116568
- execCommand("git add .", projectDir, dryRun);
116569
- execCommand('git commit -m "chore: initial SmartStack project setup"', projectDir, dryRun);
116890
+ }
116891
+ await ensureGitIdentity(projectDir, dryRun);
116892
+ const commitMsg = isGitInitialized ? "feat: initialize SmartStack project structure" : "chore: initial SmartStack project setup";
116893
+ execCommand("git add .", projectDir, dryRun);
116894
+ if (!dryRun) {
116895
+ try {
116896
+ (0, import_child_process4.execSync)("git diff --cached --quiet", { cwd: projectDir, shell: true });
116897
+ logger.info(source_default.gray("No new changes to commit (already committed)"));
116898
+ } catch {
116899
+ execCommand(`git commit -m "${commitMsg}"`, projectDir, dryRun);
116900
+ }
116901
+ } else {
116902
+ execCommand(`git commit -m "${commitMsg}"`, projectDir, dryRun);
116570
116903
  }
116571
116904
  }
116572
116905
  var initCommand = new Command("init").description("Initialize a new SmartStack project").argument("[name]", "Project name (optional, uses current folder if not provided)").option("--dry-run", "Show what would be created without actually creating").option("-y, --yes", "Skip prompts and use defaults").option("--skip-mcp-check", "Skip MCP servers verification").option("--multi-tenant", "Enable multi-tenant mode").option("--b2c", "Enable B2C (user tenant management)").option("--preview", "Use preview/prerelease versions (NuGet --prerelease + npm @next)").option("--here", "Initialize in current directory (use folder name as project name)").action(async (name, options) => {
@@ -116623,37 +116956,138 @@ var initCommand = new Command("init").description("Initialize a new SmartStack p
116623
116956
  logger.success("All required MCP servers are installed");
116624
116957
  }
116625
116958
  }
116626
- const prereqs = checkPrerequisites();
116627
- if (!prereqs.dotnet) {
116628
- logger.error(".NET SDK not found. Please install .NET 10.0 or later.");
116629
- process.exit(1);
116959
+ let prereqs = checkPrerequisites();
116960
+ const MIN_DOTNET_MAJOR = 10;
116961
+ const dotnetMissing = !prereqs.dotnet;
116962
+ const dotnetMajor = parseInt(prereqs.dotnetVersion?.split(".")[0] ?? "0", 10);
116963
+ const dotnetOutdated = prereqs.dotnet && dotnetMajor < MIN_DOTNET_MAJOR;
116964
+ const DOTNET_DOWNLOAD_URL = `https://dotnet.microsoft.com/download/dotnet/${MIN_DOTNET_MAJOR}.0`;
116965
+ const DOCS_URL = "https://docs.smartstack.app";
116966
+ const showInstallHelp = () => {
116967
+ logger.info("");
116968
+ logger.info(`Documentation: ${source_default.cyan(DOCS_URL)}`);
116969
+ logger.info(`Download .NET: ${source_default.cyan(DOTNET_DOWNLOAD_URL)}`);
116970
+ };
116971
+ if (dotnetMissing || dotnetOutdated) {
116972
+ if (dotnetMissing) {
116973
+ logger.error(".NET SDK not found.");
116974
+ } else {
116975
+ logger.error(`.NET SDK ${prereqs.dotnetVersion} detected \u2014 version ${MIN_DOTNET_MAJOR}.0 or later is required.`);
116976
+ }
116977
+ if (process.platform === "win32") {
116978
+ const wingetCmd = `winget install Microsoft.DotNet.SDK.${MIN_DOTNET_MAJOR}`;
116979
+ if (!options.yes) {
116980
+ const { installChoice } = await lib_default.prompt([{
116981
+ type: "list",
116982
+ name: "installChoice",
116983
+ message: `Install .NET SDK ${MIN_DOTNET_MAJOR}.0 via winget?`,
116984
+ choices: [
116985
+ { name: `Yes \u2014 run: ${wingetCmd}`, value: "winget" },
116986
+ { name: "No \u2014 I will install it manually", value: "manual" }
116987
+ ]
116988
+ }]);
116989
+ if (installChoice === "winget") {
116990
+ logger.info(`Running: ${source_default.cyan(wingetCmd)}`);
116991
+ try {
116992
+ (0, import_child_process4.execSync)(wingetCmd, { stdio: "inherit", timeout: 3e5 });
116993
+ const recheck = checkPrerequisites();
116994
+ const recheckMajor = parseInt(recheck.dotnetVersion?.split(".")[0] ?? "0", 10);
116995
+ if (recheck.dotnet && recheckMajor >= MIN_DOTNET_MAJOR) {
116996
+ logger.success(`.NET SDK ${recheck.dotnetVersion} installed successfully`);
116997
+ prereqs.dotnet = true;
116998
+ prereqs.dotnetVersion = recheck.dotnetVersion;
116999
+ } else {
117000
+ logger.error("Installation completed but .NET SDK still not detected.");
117001
+ logger.info("You may need to restart your terminal, then run ss init again.");
117002
+ showInstallHelp();
117003
+ process.exit(1);
117004
+ }
117005
+ } catch {
117006
+ logger.error("winget installation failed.");
117007
+ showInstallHelp();
117008
+ process.exit(1);
117009
+ }
117010
+ } else {
117011
+ logger.info("");
117012
+ logger.info(`Install manually: ${source_default.cyan(wingetCmd)}`);
117013
+ showInstallHelp();
117014
+ process.exit(1);
117015
+ }
117016
+ } else {
117017
+ logger.info(`Installing .NET SDK ${MIN_DOTNET_MAJOR}.0 via winget...`);
117018
+ try {
117019
+ (0, import_child_process4.execSync)(`winget install Microsoft.DotNet.SDK.${MIN_DOTNET_MAJOR}`, { stdio: "inherit", timeout: 3e5 });
117020
+ const recheck = checkPrerequisites();
117021
+ const recheckMajor = parseInt(recheck.dotnetVersion?.split(".")[0] ?? "0", 10);
117022
+ if (recheck.dotnet && recheckMajor >= MIN_DOTNET_MAJOR) {
117023
+ logger.success(`.NET SDK ${recheck.dotnetVersion} installed successfully`);
117024
+ prereqs.dotnet = true;
117025
+ prereqs.dotnetVersion = recheck.dotnetVersion;
117026
+ } else {
117027
+ logger.error("Installation completed but .NET SDK still not detected.");
117028
+ logger.info("Restart your terminal, then run ss init again.");
117029
+ showInstallHelp();
117030
+ process.exit(1);
117031
+ }
117032
+ } catch {
117033
+ logger.error("Automatic installation failed.");
117034
+ showInstallHelp();
117035
+ process.exit(1);
117036
+ }
117037
+ }
117038
+ } else {
117039
+ showInstallHelp();
117040
+ process.exit(1);
117041
+ }
117042
+ } else {
117043
+ logger.success(`.NET SDK ${prereqs.dotnetVersion} detected`);
116630
117044
  }
116631
117045
  const context = await detectProjectContext(name, options.here ?? false);
116632
117046
  const { projectName, projectDir, inPlace } = context;
117047
+ let resumeState;
116633
117048
  if (inPlace) {
116634
117049
  logger.info(`Detected project: ${source_default.cyan(projectName)}`);
116635
117050
  logger.info(`Directory: ${source_default.cyan(projectDir)}`);
116636
- const inPlaceError = await validateInPlaceDirectory(projectDir);
116637
- if (inPlaceError) {
116638
- logger.error(inPlaceError);
117051
+ const inPlaceResult = await validateInPlaceDirectory(projectDir);
117052
+ if (inPlaceResult.error) {
117053
+ logger.error(inPlaceResult.error);
116639
117054
  process.exit(1);
116640
117055
  }
116641
- if (!options.yes) {
116642
- const { confirm } = await lib_default.prompt([
116643
- {
116644
- type: "confirm",
116645
- name: "confirm",
116646
- message: `Initialize SmartStack project "${projectName}" in current directory?`,
116647
- default: true
117056
+ if (inPlaceResult.isResume) {
117057
+ resumeState = inPlaceResult.existingState;
117058
+ displayResumeSummary(resumeState);
117059
+ if (!options.yes) {
117060
+ const { confirmResume } = await lib_default.prompt([
117061
+ {
117062
+ type: "confirm",
117063
+ name: "confirmResume",
117064
+ message: "Resume initialization from where it left off?",
117065
+ default: true
117066
+ }
117067
+ ]);
117068
+ if (!confirmResume) {
117069
+ logger.info("Cancelled by user.");
117070
+ process.exit(0);
117071
+ }
117072
+ }
117073
+ } else {
117074
+ if (!options.yes) {
117075
+ const { confirm } = await lib_default.prompt([
117076
+ {
117077
+ type: "confirm",
117078
+ name: "confirm",
117079
+ message: `Initialize SmartStack project "${projectName}" in current directory?`,
117080
+ default: true
117081
+ }
117082
+ ]);
117083
+ if (!confirm) {
117084
+ logger.info("Cancelled by user.");
117085
+ process.exit(0);
116648
117086
  }
116649
- ]);
116650
- if (!confirm) {
116651
- logger.info("Cancelled by user.");
116652
- process.exit(0);
116653
117087
  }
116654
117088
  }
116655
117089
  } else {
116656
- if (await import_fs_extra3.default.pathExists(projectDir)) {
117090
+ if (await import_fs_extra4.default.pathExists(projectDir)) {
116657
117091
  logger.error(`Directory '${projectDir}' already exists.`);
116658
117092
  logger.info(`Tip: Use ${source_default.cyan("--here")} to initialize in the current directory instead.`);
116659
117093
  process.exit(1);
@@ -116691,9 +117125,9 @@ var initCommand = new Command("init").description("Initialize a new SmartStack p
116691
117125
  }
116692
117126
  if (!inPlace && finalProjectName !== projectName) {
116693
117127
  const cwd = process.cwd();
116694
- finalProjectDir = (0, import_path4.isAbsolute)(finalProjectName) ? finalProjectName : (0, import_path4.join)(cwd, finalProjectName);
117128
+ finalProjectDir = (0, import_path5.isAbsolute)(finalProjectName) ? finalProjectName : (0, import_path5.join)(cwd, finalProjectName);
116695
117129
  logger.info(`Project directory updated to: ${source_default.cyan(finalProjectDir)}`);
116696
- if (await import_fs_extra3.default.pathExists(finalProjectDir)) {
117130
+ if (await import_fs_extra4.default.pathExists(finalProjectDir)) {
116697
117131
  logger.error(`Directory '${finalProjectDir}' already exists.`);
116698
117132
  process.exit(1);
116699
117133
  }
@@ -116774,23 +117208,39 @@ var initCommand = new Command("init").description("Initialize a new SmartStack p
116774
117208
  }
116775
117209
  console.log();
116776
117210
  try {
117211
+ let cliVersion = "0.0.0";
117212
+ try {
117213
+ const pkgPath = (0, import_path5.join)((0, import_path5.dirname)((0, import_path5.dirname)(__dirname)), "package.json");
117214
+ const pkg2 = JSON.parse(await import_fs_extra4.default.readFile(pkgPath, "utf-8"));
117215
+ cliVersion = pkg2.version || "0.0.0";
117216
+ } catch {
117217
+ }
117218
+ const state = resumeState ?? createFreshInitState(config, cliVersion);
116777
117219
  if (!dryRun && !inPlace) {
116778
- await import_fs_extra3.default.ensureDir(finalProjectDir);
117220
+ await import_fs_extra4.default.ensureDir(finalProjectDir);
116779
117221
  }
116780
- await createConfigFiles(config, dryRun);
116781
- await createBackendStructure(config, dryRun);
116782
- await createFrontendStructure(config, dryRun);
116783
- await initializeGit(config, dryRun);
116784
- logger.info("Initializing Ralph configuration...");
116785
117222
  if (!dryRun) {
116786
- const ralphResult = await installRalphConfig({ projectPath: finalProjectDir });
116787
- if (ralphResult.success) {
116788
- logger.success("Ralph configuration created at .ralph/");
117223
+ await import_fs_extra4.default.ensureDir((0, import_path5.join)(finalProjectDir, ".smartstack"));
117224
+ await saveInitState(finalProjectDir, state);
117225
+ }
117226
+ await executeStep(state, "config", finalProjectDir, dryRun, () => createConfigFiles(config, state, dryRun));
117227
+ await executeStep(state, "backend", finalProjectDir, dryRun, () => createBackendStructure(config, state, dryRun));
117228
+ await executeStep(state, "frontend", finalProjectDir, dryRun, () => createFrontendStructure(config, state, dryRun));
117229
+ await executeStep(state, "git", finalProjectDir, dryRun, () => initializeGit(config, dryRun));
117230
+ await executeStep(state, "ralph", finalProjectDir, dryRun, async () => {
117231
+ if (!dryRun) {
117232
+ const ralphResult = await installRalphConfig({ projectPath: finalProjectDir });
117233
+ if (ralphResult.success) {
117234
+ logger.success("Ralph configuration created at .ralph/");
117235
+ } else {
117236
+ logger.warning("Could not create Ralph configuration (non-critical)");
117237
+ }
116789
117238
  } else {
116790
- logger.warning("Could not create Ralph configuration (non-critical)");
117239
+ logger.info("Would create .ralph/ directory with configuration");
116791
117240
  }
116792
- } else {
116793
- logger.info("Would create .ralph/ directory with configuration");
117241
+ });
117242
+ if (!dryRun) {
117243
+ await saveInitState(finalProjectDir, state);
116794
117244
  }
116795
117245
  const projectNameLower = finalProjectName.toLowerCase();
116796
117246
  const summary = [
@@ -116824,13 +117274,16 @@ var initCommand = new Command("init").description("Initialize a new SmartStack p
116824
117274
  logger.box(summary, "success");
116825
117275
  } catch (error) {
116826
117276
  logger.error(`Failed to create project: ${error instanceof Error ? error.message : error}`);
117277
+ console.log();
117278
+ logger.info(`Fix the issue and re-run: ${source_default.cyan("ss init --here")}`);
117279
+ logger.info("Your progress has been saved and will be resumed automatically.");
116827
117280
  process.exit(1);
116828
117281
  }
116829
117282
  });
116830
117283
 
116831
117284
  // src/commands/upgrade.ts
116832
- var import_fs_extra4 = __toESM(require_lib());
116833
- var import_path5 = require("path");
117285
+ var import_fs_extra5 = __toESM(require_lib());
117286
+ var import_path6 = require("path");
116834
117287
  var import_child_process5 = require("child_process");
116835
117288
 
116836
117289
  // src/migrations/app-tsx-migration.ts
@@ -121895,8 +122348,8 @@ var PathScurryBase = class {
121895
122348
  *
121896
122349
  * @internal
121897
122350
  */
121898
- constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs13 = defaultFS } = {}) {
121899
- this.#fs = fsFromOption(fs13);
122351
+ constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs: fs14 = defaultFS } = {}) {
122352
+ this.#fs = fsFromOption(fs14);
121900
122353
  if (cwd instanceof URL || cwd.startsWith("file://")) {
121901
122354
  cwd = (0, import_node_url.fileURLToPath)(cwd);
121902
122355
  }
@@ -122454,8 +122907,8 @@ var PathScurryWin32 = class extends PathScurryBase {
122454
122907
  /**
122455
122908
  * @internal
122456
122909
  */
122457
- newRoot(fs13) {
122458
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs13 });
122910
+ newRoot(fs14) {
122911
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs14 });
122459
122912
  }
122460
122913
  /**
122461
122914
  * Return true if the provided path string is an absolute path
@@ -122483,8 +122936,8 @@ var PathScurryPosix = class extends PathScurryBase {
122483
122936
  /**
122484
122937
  * @internal
122485
122938
  */
122486
- newRoot(fs13) {
122487
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs13 });
122939
+ newRoot(fs14) {
122940
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs14 });
122488
122941
  }
122489
122942
  /**
122490
122943
  * Return true if the provided path string is an absolute path
@@ -123609,12 +124062,12 @@ async function getLatestNpmVersion(packageName, prerelease) {
123609
124062
  }
123610
124063
  async function detectSmartStackProject() {
123611
124064
  const cwd = process.cwd();
123612
- const configPath = (0, import_path5.join)(cwd, ".smartstack", "config.json");
123613
- if (!await import_fs_extra4.default.pathExists(configPath)) {
124065
+ const configPath = (0, import_path6.join)(cwd, ".smartstack", "config.json");
124066
+ if (!await import_fs_extra5.default.pathExists(configPath)) {
123614
124067
  return { isProject: false, projectDir: cwd };
123615
124068
  }
123616
124069
  try {
123617
- const config = await import_fs_extra4.default.readJson(configPath);
124070
+ const config = await import_fs_extra5.default.readJson(configPath);
123618
124071
  return { isProject: true, config, projectDir: cwd };
123619
124072
  } catch (error) {
123620
124073
  logger.warning("Could not read .smartstack/config.json");
@@ -123622,20 +124075,20 @@ async function detectSmartStackProject() {
123622
124075
  }
123623
124076
  }
123624
124077
  async function findProjectsWithSmartStack(projectDir) {
123625
- const srcDir = (0, import_path5.join)(projectDir, "src");
123626
- if (!await import_fs_extra4.default.pathExists(srcDir)) {
124078
+ const srcDir = (0, import_path6.join)(projectDir, "src");
124079
+ if (!await import_fs_extra5.default.pathExists(srcDir)) {
123627
124080
  return [];
123628
124081
  }
123629
124082
  const projects = [];
123630
- const folders = await import_fs_extra4.default.readdir(srcDir);
124083
+ const folders = await import_fs_extra5.default.readdir(srcDir);
123631
124084
  for (const folder of folders) {
123632
- const folderPath = (0, import_path5.join)(srcDir, folder);
123633
- const stat = await import_fs_extra4.default.stat(folderPath);
124085
+ const folderPath = (0, import_path6.join)(srcDir, folder);
124086
+ const stat = await import_fs_extra5.default.stat(folderPath);
123634
124087
  if (stat.isDirectory()) {
123635
- const csprojFiles = (await import_fs_extra4.default.readdir(folderPath)).filter((f) => f.endsWith(".csproj"));
124088
+ const csprojFiles = (await import_fs_extra5.default.readdir(folderPath)).filter((f) => f.endsWith(".csproj"));
123636
124089
  for (const csproj of csprojFiles) {
123637
- const csprojPath = (0, import_path5.join)(folderPath, csproj);
123638
- const content = await import_fs_extra4.default.readFile(csprojPath, "utf-8");
124090
+ const csprojPath = (0, import_path6.join)(folderPath, csproj);
124091
+ const content = await import_fs_extra5.default.readFile(csprojPath, "utf-8");
123639
124092
  if (content.includes("SmartStack")) {
123640
124093
  projects.push(csprojPath);
123641
124094
  }
@@ -123645,17 +124098,17 @@ async function findProjectsWithSmartStack(projectDir) {
123645
124098
  return projects;
123646
124099
  }
123647
124100
  async function findFrontendDirectory(projectDir) {
123648
- const webDir = (0, import_path5.join)(projectDir, "web");
123649
- if (!await import_fs_extra4.default.pathExists(webDir)) {
124101
+ const webDir = (0, import_path6.join)(projectDir, "web");
124102
+ if (!await import_fs_extra5.default.pathExists(webDir)) {
123650
124103
  return null;
123651
124104
  }
123652
- const folders = await import_fs_extra4.default.readdir(webDir);
124105
+ const folders = await import_fs_extra5.default.readdir(webDir);
123653
124106
  for (const folder of folders) {
123654
- const packageJsonPath = (0, import_path5.join)(webDir, folder, "package.json");
123655
- if (await import_fs_extra4.default.pathExists(packageJsonPath)) {
123656
- const packageJson = await import_fs_extra4.default.readJson(packageJsonPath);
124107
+ const packageJsonPath = (0, import_path6.join)(webDir, folder, "package.json");
124108
+ if (await import_fs_extra5.default.pathExists(packageJsonPath)) {
124109
+ const packageJson = await import_fs_extra5.default.readJson(packageJsonPath);
123657
124110
  if (packageJson.dependencies?.["@atlashub/smartstack"]) {
123658
- return (0, import_path5.join)(webDir, folder);
124111
+ return (0, import_path6.join)(webDir, folder);
123659
124112
  }
123660
124113
  }
123661
124114
  }
@@ -123719,7 +124172,7 @@ async function executeMigrations(projectDir, fromVersion, toVersion, dryRun) {
123719
124172
  });
123720
124173
  for (const file of files) {
123721
124174
  try {
123722
- const content = await import_fs_extra4.default.readFile(file, "utf-8");
124175
+ const content = await import_fs_extra5.default.readFile(file, "utf-8");
123723
124176
  if (!fileMigration.detect(content, file)) {
123724
124177
  results.push({
123725
124178
  filePath: file.replace(projectDir, "").replace(/^[/\\]/, ""),
@@ -123730,7 +124183,7 @@ async function executeMigrations(projectDir, fromVersion, toVersion, dryRun) {
123730
124183
  }
123731
124184
  if (!dryRun) {
123732
124185
  const transformed = fileMigration.transform(content, file);
123733
- await import_fs_extra4.default.writeFile(file, transformed, "utf-8");
124186
+ await import_fs_extra5.default.writeFile(file, transformed, "utf-8");
123734
124187
  }
123735
124188
  results.push({
123736
124189
  filePath: file.replace(projectDir, "").replace(/^[/\\]/, ""),
@@ -123862,8 +124315,8 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
123862
124315
  }
123863
124316
  if (!dryRun && nugetVersion) {
123864
124317
  config.smartStackVersion = nugetVersion;
123865
- const configPath = (0, import_path5.join)(projectDir, ".smartstack", "config.json");
123866
- await import_fs_extra4.default.writeJson(configPath, config, { spaces: 2 });
124318
+ const configPath = (0, import_path6.join)(projectDir, ".smartstack", "config.json");
124319
+ await import_fs_extra5.default.writeJson(configPath, config, { spaces: 2 });
123867
124320
  logger.success(`Updated project version to ${source_default.cyan(nugetVersion)}`);
123868
124321
  console.log();
123869
124322
  }
@@ -123888,7 +124341,7 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
123888
124341
 
123889
124342
  // src/lib/license.ts
123890
124343
  var jwt = __toESM(require_jsonwebtoken());
123891
- var fs5 = __toESM(require_lib());
124344
+ var fs6 = __toESM(require_lib());
123892
124345
  var path3 = __toESM(require("path"));
123893
124346
  var os3 = __toESM(require("os"));
123894
124347
  var PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
@@ -123908,20 +124361,20 @@ function getLicenseFilePath() {
123908
124361
  }
123909
124362
  async function saveLicenseKey(licenseKey) {
123910
124363
  const licensePath = getLicenseFilePath();
123911
- await fs5.ensureDir(path3.dirname(licensePath));
123912
- await fs5.writeFile(licensePath, licenseKey.trim(), "utf-8");
124364
+ await fs6.ensureDir(path3.dirname(licensePath));
124365
+ await fs6.writeFile(licensePath, licenseKey.trim(), "utf-8");
123913
124366
  }
123914
124367
  async function loadLicenseKey() {
123915
124368
  const licensePath = getLicenseFilePath();
123916
- if (await fs5.pathExists(licensePath)) {
123917
- return (await fs5.readFile(licensePath, "utf-8")).trim();
124369
+ if (await fs6.pathExists(licensePath)) {
124370
+ return (await fs6.readFile(licensePath, "utf-8")).trim();
123918
124371
  }
123919
124372
  return null;
123920
124373
  }
123921
124374
  async function removeLicenseKey() {
123922
124375
  const licensePath = getLicenseFilePath();
123923
- if (await fs5.pathExists(licensePath)) {
123924
- await fs5.remove(licensePath);
124376
+ if (await fs6.pathExists(licensePath)) {
124377
+ await fs6.remove(licensePath);
123925
124378
  }
123926
124379
  }
123927
124380
  function validateLicenseKey(licenseKey) {
@@ -124292,24 +124745,24 @@ var checkMcpCommand = new Command("check-mcp").description("Check MCP servers re
124292
124745
 
124293
124746
  // src/commands/ralph.ts
124294
124747
  var import_cli_table33 = __toESM(require_cli_table3());
124295
- var import_fs_extra5 = __toESM(require_lib());
124296
- var import_path6 = require("path");
124748
+ var import_fs_extra6 = __toESM(require_lib());
124749
+ var import_path7 = require("path");
124297
124750
  function getRalphDir() {
124298
- return (0, import_path6.join)(process.cwd(), ".ralph");
124751
+ return (0, import_path7.join)(process.cwd(), ".ralph");
124299
124752
  }
124300
124753
  async function readRalphLogs(limit = 50) {
124301
- const logsDir = (0, import_path6.join)(getRalphDir(), "logs");
124302
- if (!await import_fs_extra5.default.pathExists(logsDir)) {
124754
+ const logsDir = (0, import_path7.join)(getRalphDir(), "logs");
124755
+ if (!await import_fs_extra6.default.pathExists(logsDir)) {
124303
124756
  return [];
124304
124757
  }
124305
124758
  try {
124306
- const files = await import_fs_extra5.default.readdir(logsDir);
124759
+ const files = await import_fs_extra6.default.readdir(logsDir);
124307
124760
  const logFiles = files.filter((f) => f.endsWith(".log")).sort().reverse();
124308
124761
  if (logFiles.length === 0) {
124309
124762
  return [];
124310
124763
  }
124311
- const latestLog = (0, import_path6.join)(logsDir, logFiles[0]);
124312
- const content = await import_fs_extra5.default.readFile(latestLog, "utf-8");
124764
+ const latestLog = (0, import_path7.join)(logsDir, logFiles[0]);
124765
+ const content = await import_fs_extra6.default.readFile(latestLog, "utf-8");
124313
124766
  const lines = content.split("\n");
124314
124767
  return lines.slice(-limit);
124315
124768
  } catch {
@@ -124317,17 +124770,17 @@ async function readRalphLogs(limit = 50) {
124317
124770
  }
124318
124771
  }
124319
124772
  async function listReports() {
124320
- const reportsDir = (0, import_path6.join)(getRalphDir(), "reports");
124321
- if (!await import_fs_extra5.default.pathExists(reportsDir)) {
124773
+ const reportsDir = (0, import_path7.join)(getRalphDir(), "reports");
124774
+ if (!await import_fs_extra6.default.pathExists(reportsDir)) {
124322
124775
  return [];
124323
124776
  }
124324
124777
  try {
124325
- const files = await import_fs_extra5.default.readdir(reportsDir);
124778
+ const files = await import_fs_extra6.default.readdir(reportsDir);
124326
124779
  const reports = [];
124327
124780
  for (const file of files) {
124328
124781
  if (file.endsWith(".md") || file.endsWith(".json")) {
124329
- const filePath = (0, import_path6.join)(reportsDir, file);
124330
- const stat = await import_fs_extra5.default.stat(filePath);
124782
+ const filePath = (0, import_path7.join)(reportsDir, file);
124783
+ const stat = await import_fs_extra6.default.stat(filePath);
124331
124784
  reports.push({
124332
124785
  name: file,
124333
124786
  date: stat.mtime,
@@ -124406,19 +124859,19 @@ ralphCommand.command("start").description("Verify prerequisites and prepare Ralp
124406
124859
  }
124407
124860
  }
124408
124861
  logger.step(4, 5, "Checking logs directory...");
124409
- const logsDir = (0, import_path6.join)(getRalphDir(), "logs");
124410
- if (await import_fs_extra5.default.pathExists(logsDir)) {
124862
+ const logsDir = (0, import_path7.join)(getRalphDir(), "logs");
124863
+ if (await import_fs_extra6.default.pathExists(logsDir)) {
124411
124864
  logger.success("Logs directory ready");
124412
124865
  } else {
124413
- await import_fs_extra5.default.ensureDir(logsDir);
124866
+ await import_fs_extra6.default.ensureDir(logsDir);
124414
124867
  logger.success("Logs directory created");
124415
124868
  }
124416
124869
  logger.step(5, 5, "Checking reports directory...");
124417
- const reportsDir = (0, import_path6.join)(getRalphDir(), "reports");
124418
- if (await import_fs_extra5.default.pathExists(reportsDir)) {
124870
+ const reportsDir = (0, import_path7.join)(getRalphDir(), "reports");
124871
+ if (await import_fs_extra6.default.pathExists(reportsDir)) {
124419
124872
  logger.success("Reports directory ready");
124420
124873
  } else {
124421
- await import_fs_extra5.default.ensureDir(reportsDir);
124874
+ await import_fs_extra6.default.ensureDir(reportsDir);
124422
124875
  logger.success("Reports directory created");
124423
124876
  }
124424
124877
  console.log();
@@ -124474,9 +124927,9 @@ ralphCommand.command("status").description("Show Ralph status and configuration"
124474
124927
  }
124475
124928
  console.log();
124476
124929
  }
124477
- const logsDir = (0, import_path6.join)(getRalphDir(), "logs");
124478
- if (await import_fs_extra5.default.pathExists(logsDir)) {
124479
- const logFiles = (await import_fs_extra5.default.readdir(logsDir)).filter((f) => f.endsWith(".log"));
124930
+ const logsDir = (0, import_path7.join)(getRalphDir(), "logs");
124931
+ if (await import_fs_extra6.default.pathExists(logsDir)) {
124932
+ const logFiles = (await import_fs_extra6.default.readdir(logsDir)).filter((f) => f.endsWith(".log"));
124480
124933
  if (logFiles.length > 0) {
124481
124934
  console.log(source_default.bold("Logs:"));
124482
124935
  console.log(` ${logFiles.length} log file(s)`);
@@ -124553,7 +125006,7 @@ ralphCommand.command("report").description("List or view feature reports").optio
124553
125006
  logger.header(`Report: ${reportToShow.name}`);
124554
125007
  console.log(source_default.gray(`Date: ${reportToShow.date.toLocaleString()}`));
124555
125008
  console.log(source_default.gray("\u2500".repeat(60)));
124556
- const content = await import_fs_extra5.default.readFile(reportToShow.path, "utf-8");
125009
+ const content = await import_fs_extra6.default.readFile(reportToShow.path, "utf-8");
124557
125010
  console.log(content);
124558
125011
  });
124559
125012
  ralphCommand.command("init").description("Initialize Ralph in the current project").option("-f, --force", "Overwrite existing configuration").action(async (options) => {
@@ -124586,8 +125039,8 @@ ralphCommand.command("init").description("Initialize Ralph in the current projec
124586
125039
  // src/commands/doctor.ts
124587
125040
  var import_cli_table34 = __toESM(require_cli_table3());
124588
125041
  var import_child_process7 = require("child_process");
124589
- var import_fs_extra6 = __toESM(require_lib());
124590
- var import_path7 = require("path");
125042
+ var import_fs_extra7 = __toESM(require_lib());
125043
+ var import_path8 = require("path");
124591
125044
  function getNodeVersion() {
124592
125045
  return process.version;
124593
125046
  }
@@ -124629,7 +125082,7 @@ function getNpmVersion() {
124629
125082
  }
124630
125083
  var doctorCommand = new Command("doctor").description("Run diagnostics and check SmartStack health").option("--json", "Output as JSON").option("-v, --verbose", "Show detailed information").action(async (options) => {
124631
125084
  const diagnostics = [];
124632
- const pkg2 = JSON.parse(await import_fs_extra6.default.readFile((0, import_path7.join)(__dirname, "..", "package.json"), "utf-8"));
125085
+ const pkg2 = JSON.parse(await import_fs_extra7.default.readFile((0, import_path8.join)(__dirname, "..", "package.json"), "utf-8"));
124633
125086
  if (!options.json) {
124634
125087
  console.log(source_default.cyan(`
124635
125088
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
@@ -124836,7 +125289,7 @@ ${source_default.gray(item.details)}`;
124836
125289
  var import_mssql = __toESM(require_mssql());
124837
125290
  var import_bcryptjs = __toESM(require_bcryptjs());
124838
125291
  var import_fs4 = require("fs");
124839
- var import_path8 = require("path");
125292
+ var import_path9 = require("path");
124840
125293
  var import_child_process8 = require("child_process");
124841
125294
  var DEFAULT_CONFIG = {
124842
125295
  schema: "core",
@@ -124857,7 +125310,7 @@ function findAppSettings(apiFolder) {
124857
125310
  return [];
124858
125311
  }
124859
125312
  const files = (0, import_fs4.readdirSync)(apiFolder);
124860
- return files.filter((f) => f.startsWith("appsettings") && f.endsWith(".json")).map((f) => (0, import_path8.join)(apiFolder, f));
125313
+ return files.filter((f) => f.startsWith("appsettings") && f.endsWith(".json")).map((f) => (0, import_path9.join)(apiFolder, f));
124861
125314
  }
124862
125315
  function extractConnectionString(filePath) {
124863
125316
  try {
@@ -124882,21 +125335,58 @@ function parseConnectionString(connStr) {
124882
125335
  useWindowsAuth: parts["integrated security"]?.toLowerCase() === "true" || parts["trusted_connection"]?.toLowerCase() === "true"
124883
125336
  };
124884
125337
  }
124885
- function executeSqlCmd(server, database, query) {
125338
+ function executeSqlCmd(server, database, query, sqlAuth) {
124886
125339
  const sqlServer = server === "(local)" ? "." : server;
124887
- const cmd = `sqlcmd -S "${sqlServer}" -d "${database}" -E -I -C -Q "${query.replace(/"/g, '\\"')}" -h -1 -W`;
125340
+ const authFlag = sqlAuth ? `-U "${sqlAuth.user}" -P "${sqlAuth.password}"` : "-E";
125341
+ const cmd = `sqlcmd -S "${sqlServer}" -d "${database}" ${authFlag} -I -C -Q "${query.replace(/"/g, '\\"')}" -h -1 -W`;
124888
125342
  return (0, import_child_process8.execSync)(cmd, { encoding: "utf-8" }).trim();
124889
125343
  }
125344
+ function isLoginFailure(error) {
125345
+ const msg = error instanceof Error ? error.message : String(error);
125346
+ return msg.includes("Login failed") || msg.includes("login failed");
125347
+ }
125348
+ async function promptSqlCredentials() {
125349
+ logger.warning("Windows Authentication failed. The current Windows account does not have SQL Server access.");
125350
+ console.log();
125351
+ logger.info("Options:");
125352
+ logger.info(` 1. Add this Windows account to SQL Server: ${source_default.cyan("CREATE LOGIN [DOMAIN\\\\User] FROM WINDOWS")}`);
125353
+ logger.info(` 2. Provide SQL Server credentials below`);
125354
+ console.log();
125355
+ const { useSqlAuth } = await lib_default.prompt([{
125356
+ type: "confirm",
125357
+ name: "useSqlAuth",
125358
+ message: "Try with SQL Server credentials instead?",
125359
+ default: true
125360
+ }]);
125361
+ if (!useSqlAuth) return null;
125362
+ const creds = await lib_default.prompt([
125363
+ {
125364
+ type: "input",
125365
+ name: "user",
125366
+ message: "SQL Server username:",
125367
+ default: "sa",
125368
+ validate: (v) => v.trim().length > 0 || "Username is required"
125369
+ },
125370
+ {
125371
+ type: "password",
125372
+ name: "password",
125373
+ message: "SQL Server password:",
125374
+ mask: "*",
125375
+ validate: (v) => v.length > 0 || "Password is required"
125376
+ }
125377
+ ]);
125378
+ return { user: creds.user, password: creds.password };
125379
+ }
124890
125380
  function detectSmartStackApp() {
124891
125381
  const cwd = process.cwd();
124892
- const configPath = (0, import_path8.join)(cwd, ".smartstack", "config.json");
125382
+ const configPath = (0, import_path9.join)(cwd, ".smartstack", "config.json");
124893
125383
  if ((0, import_fs4.existsSync)(configPath)) {
124894
- const srcDir = (0, import_path8.join)(cwd, "src");
125384
+ const srcDir = (0, import_path9.join)(cwd, "src");
124895
125385
  if ((0, import_fs4.existsSync)(srcDir)) {
124896
125386
  const folders = (0, import_fs4.readdirSync)(srcDir);
124897
125387
  const apiFolder = folders.find((f) => f.endsWith(".Api"));
124898
125388
  if (apiFolder) {
124899
- return (0, import_path8.join)(srcDir, apiFolder);
125389
+ return (0, import_path9.join)(srcDir, apiFolder);
124900
125390
  }
124901
125391
  }
124902
125392
  }
@@ -124936,7 +125426,7 @@ adminCommand.command("reset").description("Reset the localAdmin account password
124936
125426
  selectedFile = appSettingsFiles[0];
124937
125427
  } else {
124938
125428
  const choices = appSettingsFiles.map((f) => ({
124939
- name: (0, import_path8.basename)(f),
125429
+ name: (0, import_path9.basename)(f),
124940
125430
  value: f
124941
125431
  }));
124942
125432
  const { file } = await lib_default.prompt([
@@ -124951,10 +125441,10 @@ adminCommand.command("reset").description("Reset the localAdmin account password
124951
125441
  }
124952
125442
  connectionString = extractConnectionString(selectedFile);
124953
125443
  if (!connectionString) {
124954
- logger.error(`No connection string found in ${(0, import_path8.basename)(selectedFile)}`);
125444
+ logger.error(`No connection string found in ${(0, import_path9.basename)(selectedFile)}`);
124955
125445
  process.exit(1);
124956
125446
  }
124957
- logger.info(`Using: ${source_default.cyan((0, import_path8.basename)(selectedFile))}`);
125447
+ logger.info(`Using: ${source_default.cyan((0, import_path9.basename)(selectedFile))}`);
124958
125448
  }
124959
125449
  const adminEmail = options.email;
124960
125450
  if (!options.force) {
@@ -124973,36 +125463,58 @@ adminCommand.command("reset").description("Reset the localAdmin account password
124973
125463
  }
124974
125464
  const spinner = logger.spinner("Connecting to database...");
124975
125465
  const connInfo = parseConnectionString(connectionString);
125466
+ const resetViaSqlCmd = async (sqlAuth) => {
125467
+ const authLabel = sqlAuth ? "SQL Server Authentication" : "Windows Authentication";
125468
+ spinner.text = `Using ${authLabel} (sqlcmd)...`;
125469
+ const checkQuery = `SELECT COUNT(*) FROM [core].[auth_Users] WHERE Email = '${adminEmail}'`;
125470
+ const countResult = executeSqlCmd(connInfo.server, connInfo.database, checkQuery, sqlAuth);
125471
+ const exists = parseInt(countResult, 10) > 0;
125472
+ if (!exists) {
125473
+ spinner.fail(`Account ${source_default.yellow(adminEmail)} does not exist.`);
125474
+ logger.error("Cannot reset password for non-existent account.");
125475
+ logger.info("Use the application seeding or AdminTool to create the account first.");
125476
+ process.exit(1);
125477
+ }
125478
+ spinner.text = "Generating new password...";
125479
+ const newPassword = generatePassword();
125480
+ const passwordHash = await import_bcryptjs.default.hash(newPassword, 10);
125481
+ spinner.text = "Updating password...";
125482
+ const updateQuery = `UPDATE [core].[auth_Users] SET PasswordHash = '${passwordHash}', UpdatedAt = GETUTCDATE() WHERE Email = '${adminEmail}'`;
125483
+ executeSqlCmd(connInfo.server, connInfo.database, updateQuery, sqlAuth);
125484
+ spinner.succeed("Password reset successfully!");
125485
+ displayPasswordResult(adminEmail, newPassword);
125486
+ };
125487
+ const displayPasswordResult = (email, password) => {
125488
+ console.log();
125489
+ console.log(source_default.green("\u2550".repeat(60)));
125490
+ console.log(source_default.green.bold(" LOCAL ADMINISTRATOR PASSWORD RESET"));
125491
+ console.log(source_default.green("\u2550".repeat(60)));
125492
+ console.log();
125493
+ console.log(source_default.white(" Email: "), source_default.cyan(email));
125494
+ console.log(source_default.white(" Password: "), source_default.yellow.bold(password));
125495
+ console.log();
125496
+ console.log(source_default.red(" \u26A0 SAVE THIS PASSWORD NOW - IT WILL NOT BE SHOWN AGAIN"));
125497
+ console.log(source_default.green("\u2550".repeat(60)));
125498
+ console.log();
125499
+ };
124976
125500
  try {
124977
125501
  if (connInfo.useWindowsAuth) {
124978
- spinner.text = "Using Windows Authentication (sqlcmd)...";
124979
- const checkQuery = `SELECT COUNT(*) FROM [core].[auth_Users] WHERE Email = '${adminEmail}'`;
124980
- const countResult = executeSqlCmd(connInfo.server, connInfo.database, checkQuery);
124981
- const exists = parseInt(countResult, 10) > 0;
124982
- if (!exists) {
124983
- spinner.fail(`Account ${source_default.yellow(adminEmail)} does not exist.`);
124984
- logger.error("Cannot reset password for non-existent account.");
124985
- logger.info("Use the application seeding or AdminTool to create the account first.");
124986
- process.exit(1);
125502
+ try {
125503
+ await resetViaSqlCmd();
125504
+ } catch (winAuthError) {
125505
+ if (isLoginFailure(winAuthError)) {
125506
+ spinner.fail("Windows Authentication failed");
125507
+ console.log();
125508
+ const sqlCreds = await promptSqlCredentials();
125509
+ if (!sqlCreds) {
125510
+ process.exit(1);
125511
+ }
125512
+ spinner.start("Retrying with SQL Server credentials...");
125513
+ await resetViaSqlCmd(sqlCreds);
125514
+ } else {
125515
+ throw winAuthError;
125516
+ }
124987
125517
  }
124988
- spinner.text = "Generating new password...";
124989
- const newPassword = generatePassword();
124990
- const passwordHash = await import_bcryptjs.default.hash(newPassword, 10);
124991
- spinner.text = "Updating password...";
124992
- const updateQuery = `UPDATE [core].[auth_Users] SET PasswordHash = '${passwordHash}', UpdatedAt = GETUTCDATE() WHERE Email = '${adminEmail}'`;
124993
- executeSqlCmd(connInfo.server, connInfo.database, updateQuery);
124994
- spinner.succeed("Password reset successfully!");
124995
- console.log();
124996
- console.log(source_default.green("\u2550".repeat(60)));
124997
- console.log(source_default.green.bold(" LOCAL ADMINISTRATOR PASSWORD RESET"));
124998
- console.log(source_default.green("\u2550".repeat(60)));
124999
- console.log();
125000
- console.log(source_default.white(" Email: "), source_default.cyan(adminEmail));
125001
- console.log(source_default.white(" Password: "), source_default.yellow.bold(newPassword));
125002
- console.log();
125003
- console.log(source_default.red(" \u26A0 SAVE THIS PASSWORD NOW - IT WILL NOT BE SHOWN AGAIN"));
125004
- console.log(source_default.green("\u2550".repeat(60)));
125005
- console.log();
125006
125518
  } else {
125007
125519
  await import_mssql.default.connect(connectionString);
125008
125520
  spinner.text = "Connected. Checking account...";
@@ -125031,25 +125543,29 @@ adminCommand.command("reset").description("Reset the localAdmin account password
125031
125543
  `;
125032
125544
  await import_mssql.default.close();
125033
125545
  spinner.succeed("Password reset successfully!");
125034
- console.log();
125035
- console.log(source_default.green("\u2550".repeat(60)));
125036
- console.log(source_default.green.bold(" LOCAL ADMINISTRATOR PASSWORD RESET"));
125037
- console.log(source_default.green("\u2550".repeat(60)));
125038
- console.log();
125039
- console.log(source_default.white(" Email: "), source_default.cyan(adminEmail));
125040
- console.log(source_default.white(" Password: "), source_default.yellow.bold(newPassword));
125041
- console.log();
125042
- console.log(source_default.red(" \u26A0 SAVE THIS PASSWORD NOW - IT WILL NOT BE SHOWN AGAIN"));
125043
- console.log(source_default.green("\u2550".repeat(60)));
125044
- console.log();
125546
+ displayPasswordResult(adminEmail, newPassword);
125045
125547
  }
125046
125548
  } catch (error) {
125047
125549
  spinner.fail("Failed to reset password");
125048
125550
  if (error instanceof Error) {
125049
125551
  logger.error(error.message);
125552
+ if (isLoginFailure(error)) {
125553
+ console.log();
125554
+ logger.info("This error means SQL Server rejected the credentials.");
125555
+ logger.info(` Server: ${source_default.cyan(connInfo.server)}`);
125556
+ logger.info(` Database: ${source_default.cyan(connInfo.database)}`);
125557
+ console.log();
125558
+ logger.info("To fix this:");
125559
+ logger.info(` 1. Verify the database name exists on the server`);
125560
+ logger.info(` 2. Ensure your account has access to the database`);
125561
+ logger.info(` 3. Or use: ${source_default.cyan('ss admin reset --connection "Server=...;Database=...;User Id=sa;Password=..."')}`);
125562
+ }
125050
125563
  }
125051
125564
  if (!connInfo.useWindowsAuth) {
125052
- await import_mssql.default.close();
125565
+ try {
125566
+ await import_mssql.default.close();
125567
+ } catch {
125568
+ }
125053
125569
  }
125054
125570
  process.exit(1);
125055
125571
  }
@@ -125057,8 +125573,8 @@ adminCommand.command("reset").description("Reset the localAdmin account password
125057
125573
 
125058
125574
  // src/index.ts
125059
125575
  var import_fs5 = require("fs");
125060
- var import_path9 = require("path");
125061
- var pkg = JSON.parse((0, import_fs5.readFileSync)((0, import_path9.join)(__dirname, "..", "package.json"), "utf-8"));
125576
+ var import_path10 = require("path");
125577
+ var pkg = JSON.parse((0, import_fs5.readFileSync)((0, import_path10.join)(__dirname, "..", "package.json"), "utf-8"));
125062
125578
  var LICENSE_FREE_COMMANDS = ["license", "help", "--help", "-h", "--version", "-v"];
125063
125579
  async function main2() {
125064
125580
  const program2 = new Command();