@mnemonik/cli 7.109.3 → 7.110.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 (104) hide show
  1. package/dist/auth/credentials.js +297 -36
  2. package/dist/auth/index.d.ts +2 -0
  3. package/dist/auth/index.d.ts.map +1 -1
  4. package/dist/auth/index.js +1914 -19
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/auth/machineName.d.ts +8 -0
  7. package/dist/auth/machineName.d.ts.map +1 -0
  8. package/dist/auth/machineName.js +23 -0
  9. package/dist/auth/machineName.js.map +1 -0
  10. package/dist/consent.d.ts +29 -0
  11. package/dist/consent.d.ts.map +1 -0
  12. package/dist/consent.js +87 -0
  13. package/dist/consent.js.map +1 -0
  14. package/dist/diagnostics.js +301 -40
  15. package/dist/digests.json +102 -90
  16. package/dist/help.d.ts.map +1 -1
  17. package/dist/help.js +59 -44
  18. package/dist/help.js.map +1 -1
  19. package/dist/humanReason.d.ts +8 -0
  20. package/dist/humanReason.d.ts.map +1 -1
  21. package/dist/humanReason.js +44 -16
  22. package/dist/humanReason.js.map +1 -1
  23. package/dist/identity/migrate.js +1835 -44
  24. package/dist/install/hosts.d.ts +2 -0
  25. package/dist/install/hosts.d.ts.map +1 -1
  26. package/dist/install/hosts.js +23 -14
  27. package/dist/install/hosts.js.map +1 -1
  28. package/dist/install/journal.js +124 -11
  29. package/dist/install/journey.d.ts +20 -0
  30. package/dist/install/journey.d.ts.map +1 -1
  31. package/dist/install/journey.js +1913 -82
  32. package/dist/install/journey.js.map +1 -1
  33. package/dist/install/ownership.d.ts.map +1 -1
  34. package/dist/install/ownership.js +1818 -10
  35. package/dist/install/ownership.js.map +1 -1
  36. package/dist/install/transaction.js +1913 -19
  37. package/dist/install/ui.js +1910 -15
  38. package/dist/installation.js +133 -10
  39. package/dist/launcher.js +108 -4
  40. package/dist/output.d.ts +3 -0
  41. package/dist/output.d.ts.map +1 -1
  42. package/dist/output.js +11 -1
  43. package/dist/output.js.map +1 -1
  44. package/dist/preflight.d.ts +5 -0
  45. package/dist/preflight.d.ts.map +1 -1
  46. package/dist/preflight.js +14 -12
  47. package/dist/preflight.js.map +1 -1
  48. package/dist/project/eligibility.js +1917 -22
  49. package/dist/project/records.js +121 -8
  50. package/dist/project.d.ts +15 -0
  51. package/dist/project.d.ts.map +1 -1
  52. package/dist/project.js +229 -15
  53. package/dist/project.js.map +1 -1
  54. package/dist/router.d.ts +2 -0
  55. package/dist/router.d.ts.map +1 -1
  56. package/dist/router.js +2164 -122
  57. package/dist/router.js.map +1 -1
  58. package/dist/runtime/releaseSource.d.ts +6 -0
  59. package/dist/runtime/releaseSource.d.ts.map +1 -1
  60. package/dist/runtime/releaseSource.js +1933 -32
  61. package/dist/runtime/releaseSource.js.map +1 -1
  62. package/dist/runtime/selfUpdate.js +1809 -8
  63. package/dist/runtime/signers.js +28 -9
  64. package/dist/runtime/store.js +18 -6
  65. package/dist/runtime/updateCheck.d.ts +4 -0
  66. package/dist/runtime/updateCheck.d.ts.map +1 -0
  67. package/dist/runtime/updateCheck.js +6695 -0
  68. package/dist/runtime/updateCheck.js.map +1 -0
  69. package/dist/sbom.json +21 -21
  70. package/dist/scanner/control.d.ts +27 -1
  71. package/dist/scanner/control.d.ts.map +1 -1
  72. package/dist/scanner/control.js +207 -36
  73. package/dist/scanner/control.js.map +1 -1
  74. package/dist/scanner/discover.d.ts +5 -0
  75. package/dist/scanner/discover.d.ts.map +1 -1
  76. package/dist/scanner/discover.js +16 -6
  77. package/dist/scanner/discover.js.map +1 -1
  78. package/dist/scanner/enable.d.ts +2 -0
  79. package/dist/scanner/enable.d.ts.map +1 -1
  80. package/dist/scanner/enable.js +152 -14
  81. package/dist/scanner/enable.js.map +1 -1
  82. package/dist/scanner/picker.d.ts.map +1 -1
  83. package/dist/scanner/picker.js +5 -6
  84. package/dist/scanner/picker.js.map +1 -1
  85. package/dist/scanner/service.d.ts +2 -0
  86. package/dist/scanner/service.d.ts.map +1 -1
  87. package/dist/scanner/service.js +279 -54
  88. package/dist/scanner/service.js.map +1 -1
  89. package/dist/scanner/update.d.ts +8 -0
  90. package/dist/scanner/update.d.ts.map +1 -1
  91. package/dist/scanner/update.js +254 -20
  92. package/dist/scanner/update.js.map +1 -1
  93. package/dist/scanner-release.json +35 -30
  94. package/dist/screens/journey.d.ts +6 -1
  95. package/dist/screens/journey.d.ts.map +1 -1
  96. package/dist/screens/journey.js +29 -8
  97. package/dist/screens/journey.js.map +1 -1
  98. package/dist/status.d.ts +21 -0
  99. package/dist/status.d.ts.map +1 -1
  100. package/dist/status.js +1993 -39
  101. package/dist/status.js.map +1 -1
  102. package/dist/vendor/local-setup.js +256 -29
  103. package/dist/vendor/shared/runtimeSigners.js +38 -11
  104. package/package.json +31 -31
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
8
14
  var __esm = (fn, res, err2) => function __init() {
9
15
  if (err2) throw err2[0];
10
16
  try {
@@ -13,7 +19,7 @@ var __esm = (fn, res, err2) => function __init() {
13
19
  throw err2 = [e], e;
14
20
  }
15
21
  };
16
- var __commonJS = (cb, mod) => function __require() {
22
+ var __commonJS = (cb, mod) => function __require2() {
17
23
  try {
18
24
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
25
  } catch (e) {
@@ -510,8 +516,25 @@ function readIdentity(stdout) {
510
516
  throw new Error("acl_identity_unavailable");
511
517
  return { name: match[1], sid: match[2] };
512
518
  }
519
+ function* readWindowsIdentity() {
520
+ const user = readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
521
+ if (!ADMINISTRATOR_RID.test(user.sid))
522
+ return user;
523
+ const groups = yield [windowsCommand("whoami.exe"), groupArgs];
524
+ const local = /^"[^"\r\n]*","[^"\r\n]*","S-1-5-113",/m.test(groups);
525
+ return {
526
+ ...user,
527
+ localAdministratorSid: local ? `${user.sid.slice(0, user.sid.lastIndexOf("-"))}-500` : null
528
+ };
529
+ }
513
530
  function windowsCurrentAccountSync() {
514
- return currentIdentity ??= readIdentity(hookExecuteSync(windowsCommand("whoami.exe"), identityArgs));
531
+ if (currentIdentity)
532
+ return currentIdentity;
533
+ const commands = readWindowsIdentity();
534
+ let step = commands.next();
535
+ while (!step.done)
536
+ step = commands.next(hookExecuteSync(...step.value));
537
+ return currentIdentity = step.value;
515
538
  }
516
539
  function hookInvocation(file, args2) {
517
540
  if (win32.basename(file) === "whoami.exe") {
@@ -531,11 +554,13 @@ function hookExecuteSync(file, args2, input) {
531
554
  [file, args2] = hookInvocation(file, args2);
532
555
  return execFileSync(file, args2, { ...hookOptions(file, args2), input });
533
556
  }
534
- var identityArgs, currentIdentity, ttl, hookOptions;
557
+ var identityArgs, groupArgs, ADMINISTRATOR_RID, currentIdentity, ttl, hookOptions;
535
558
  var init_runtimeSigners = __esm({
536
559
  "packages/shared/dist/runtimeSigners.js"() {
537
560
  "use strict";
538
561
  identityArgs = ["/user", "/fo", "csv", "/nh"];
562
+ groupArgs = ["/groups", "/fo", "csv", "/nh"];
563
+ ADMINISTRATOR_RID = /^S-1-5-21-\d+-\d+-\d+-500$/;
539
564
  ttl = 10 * 6e4;
540
565
  hookOptions = (file, args2) => ({
541
566
  encoding: args2.includes("/u") ? "utf16le" : "utf8",
@@ -566,49 +591,1635 @@ var init_projectIdentityFile = __esm({
566
591
  }
567
592
  });
568
593
 
569
- // packages/shared/dist/repositoryRoot.js
570
- var init_repositoryRoot = __esm({
571
- "packages/shared/dist/repositoryRoot.js"() {
594
+ // packages/shared/dist/repositoryRoot.js
595
+ var init_repositoryRoot = __esm({
596
+ "packages/shared/dist/repositoryRoot.js"() {
597
+ "use strict";
598
+ init_projectIdentityFile();
599
+ }
600
+ });
601
+
602
+ // packages/shared/dist/runtimeReader.js
603
+ var RuntimeError;
604
+ var init_runtimeReader = __esm({
605
+ "packages/shared/dist/runtimeReader.js"() {
606
+ "use strict";
607
+ init_runtimeSigners();
608
+ init_runtimeSigners();
609
+ RuntimeError = class extends Error {
610
+ reason;
611
+ constructor(reason) {
612
+ super(reason);
613
+ this.reason = reason;
614
+ this.name = "RuntimeError";
615
+ }
616
+ };
617
+ }
618
+ });
619
+
620
+ // packages/shared/dist/projectSetupHandoff.js
621
+ var init_projectSetupHandoff = __esm({
622
+ "packages/shared/dist/projectSetupHandoff.js"() {
623
+ "use strict";
624
+ init_runtimeSigners();
625
+ init_runtimeReader();
626
+ }
627
+ });
628
+
629
+ // packages/shared/dist/hookRuntime.js
630
+ var init_hookRuntime = __esm({
631
+ "packages/shared/dist/hookRuntime.js"() {
632
+ "use strict";
633
+ init_runtimeSigners();
634
+ init_repositoryRoot();
635
+ init_runtimeReader();
636
+ init_runtimeSigners();
637
+ init_projectSetupHandoff();
638
+ }
639
+ });
640
+
641
+ // node_modules/graceful-fs/polyfills.js
642
+ var require_polyfills = __commonJS({
643
+ "node_modules/graceful-fs/polyfills.js"(exports, module2) {
644
+ var constants = __require("constants");
645
+ var origCwd = process.cwd;
646
+ var cwd = null;
647
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
648
+ process.cwd = function() {
649
+ if (!cwd)
650
+ cwd = origCwd.call(process);
651
+ return cwd;
652
+ };
653
+ try {
654
+ process.cwd();
655
+ } catch (er) {
656
+ }
657
+ if (typeof process.chdir === "function") {
658
+ chdir = process.chdir;
659
+ process.chdir = function(d) {
660
+ cwd = null;
661
+ chdir.call(process, d);
662
+ };
663
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
664
+ }
665
+ var chdir;
666
+ module2.exports = patch;
667
+ function patch(fs3) {
668
+ if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
669
+ patchLchmod(fs3);
670
+ }
671
+ if (!fs3.lutimes) {
672
+ patchLutimes(fs3);
673
+ }
674
+ fs3.chown = chownFix(fs3.chown);
675
+ fs3.fchown = chownFix(fs3.fchown);
676
+ fs3.lchown = chownFix(fs3.lchown);
677
+ fs3.chmod = chmodFix(fs3.chmod);
678
+ fs3.fchmod = chmodFix(fs3.fchmod);
679
+ fs3.lchmod = chmodFix(fs3.lchmod);
680
+ fs3.chownSync = chownFixSync(fs3.chownSync);
681
+ fs3.fchownSync = chownFixSync(fs3.fchownSync);
682
+ fs3.lchownSync = chownFixSync(fs3.lchownSync);
683
+ fs3.chmodSync = chmodFixSync(fs3.chmodSync);
684
+ fs3.fchmodSync = chmodFixSync(fs3.fchmodSync);
685
+ fs3.lchmodSync = chmodFixSync(fs3.lchmodSync);
686
+ fs3.stat = statFix(fs3.stat);
687
+ fs3.fstat = statFix(fs3.fstat);
688
+ fs3.lstat = statFix(fs3.lstat);
689
+ fs3.statSync = statFixSync(fs3.statSync);
690
+ fs3.fstatSync = statFixSync(fs3.fstatSync);
691
+ fs3.lstatSync = statFixSync(fs3.lstatSync);
692
+ if (fs3.chmod && !fs3.lchmod) {
693
+ fs3.lchmod = function(path, mode, cb) {
694
+ if (cb) process.nextTick(cb);
695
+ };
696
+ fs3.lchmodSync = function() {
697
+ };
698
+ }
699
+ if (fs3.chown && !fs3.lchown) {
700
+ fs3.lchown = function(path, uid, gid, cb) {
701
+ if (cb) process.nextTick(cb);
702
+ };
703
+ fs3.lchownSync = function() {
704
+ };
705
+ }
706
+ if (platform === "win32") {
707
+ fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : (function(fs$rename) {
708
+ function rename2(from, to, cb) {
709
+ var start2 = Date.now();
710
+ var backoff = 0;
711
+ fs$rename(from, to, function CB(er) {
712
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
713
+ setTimeout(function() {
714
+ fs3.stat(to, function(stater, st) {
715
+ if (stater && stater.code === "ENOENT")
716
+ fs$rename(from, to, CB);
717
+ else
718
+ cb(er);
719
+ });
720
+ }, backoff);
721
+ if (backoff < 100)
722
+ backoff += 10;
723
+ return;
724
+ }
725
+ if (cb) cb(er);
726
+ });
727
+ }
728
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
729
+ return rename2;
730
+ })(fs3.rename);
731
+ }
732
+ fs3.read = typeof fs3.read !== "function" ? fs3.read : (function(fs$read) {
733
+ function read(fd, buffer, offset, length, position, callback_) {
734
+ var callback;
735
+ if (callback_ && typeof callback_ === "function") {
736
+ var eagCounter = 0;
737
+ callback = function(er, _, __) {
738
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
739
+ eagCounter++;
740
+ return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
741
+ }
742
+ callback_.apply(this, arguments);
743
+ };
744
+ }
745
+ return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
746
+ }
747
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
748
+ return read;
749
+ })(fs3.read);
750
+ fs3.readSync = typeof fs3.readSync !== "function" ? fs3.readSync : /* @__PURE__ */ (function(fs$readSync) {
751
+ return function(fd, buffer, offset, length, position) {
752
+ var eagCounter = 0;
753
+ while (true) {
754
+ try {
755
+ return fs$readSync.call(fs3, fd, buffer, offset, length, position);
756
+ } catch (er) {
757
+ if (er.code === "EAGAIN" && eagCounter < 10) {
758
+ eagCounter++;
759
+ continue;
760
+ }
761
+ throw er;
762
+ }
763
+ }
764
+ };
765
+ })(fs3.readSync);
766
+ function patchLchmod(fs4) {
767
+ fs4.lchmod = function(path, mode, callback) {
768
+ fs4.open(
769
+ path,
770
+ constants.O_WRONLY | constants.O_SYMLINK,
771
+ mode,
772
+ function(err2, fd) {
773
+ if (err2) {
774
+ if (callback) callback(err2);
775
+ return;
776
+ }
777
+ fs4.fchmod(fd, mode, function(err3) {
778
+ fs4.close(fd, function(err22) {
779
+ if (callback) callback(err3 || err22);
780
+ });
781
+ });
782
+ }
783
+ );
784
+ };
785
+ fs4.lchmodSync = function(path, mode) {
786
+ var fd = fs4.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
787
+ var threw = true;
788
+ var ret;
789
+ try {
790
+ ret = fs4.fchmodSync(fd, mode);
791
+ threw = false;
792
+ } finally {
793
+ if (threw) {
794
+ try {
795
+ fs4.closeSync(fd);
796
+ } catch (er) {
797
+ }
798
+ } else {
799
+ fs4.closeSync(fd);
800
+ }
801
+ }
802
+ return ret;
803
+ };
804
+ }
805
+ function patchLutimes(fs4) {
806
+ if (constants.hasOwnProperty("O_SYMLINK") && fs4.futimes) {
807
+ fs4.lutimes = function(path, at, mt, cb) {
808
+ fs4.open(path, constants.O_SYMLINK, function(er, fd) {
809
+ if (er) {
810
+ if (cb) cb(er);
811
+ return;
812
+ }
813
+ fs4.futimes(fd, at, mt, function(er2) {
814
+ fs4.close(fd, function(er22) {
815
+ if (cb) cb(er2 || er22);
816
+ });
817
+ });
818
+ });
819
+ };
820
+ fs4.lutimesSync = function(path, at, mt) {
821
+ var fd = fs4.openSync(path, constants.O_SYMLINK);
822
+ var ret;
823
+ var threw = true;
824
+ try {
825
+ ret = fs4.futimesSync(fd, at, mt);
826
+ threw = false;
827
+ } finally {
828
+ if (threw) {
829
+ try {
830
+ fs4.closeSync(fd);
831
+ } catch (er) {
832
+ }
833
+ } else {
834
+ fs4.closeSync(fd);
835
+ }
836
+ }
837
+ return ret;
838
+ };
839
+ } else if (fs4.futimes) {
840
+ fs4.lutimes = function(_a, _b, _c, cb) {
841
+ if (cb) process.nextTick(cb);
842
+ };
843
+ fs4.lutimesSync = function() {
844
+ };
845
+ }
846
+ }
847
+ function chmodFix(orig) {
848
+ if (!orig) return orig;
849
+ return function(target, mode, cb) {
850
+ return orig.call(fs3, target, mode, function(er) {
851
+ if (chownErOk(er)) er = null;
852
+ if (cb) cb.apply(this, arguments);
853
+ });
854
+ };
855
+ }
856
+ function chmodFixSync(orig) {
857
+ if (!orig) return orig;
858
+ return function(target, mode) {
859
+ try {
860
+ return orig.call(fs3, target, mode);
861
+ } catch (er) {
862
+ if (!chownErOk(er)) throw er;
863
+ }
864
+ };
865
+ }
866
+ function chownFix(orig) {
867
+ if (!orig) return orig;
868
+ return function(target, uid, gid, cb) {
869
+ return orig.call(fs3, target, uid, gid, function(er) {
870
+ if (chownErOk(er)) er = null;
871
+ if (cb) cb.apply(this, arguments);
872
+ });
873
+ };
874
+ }
875
+ function chownFixSync(orig) {
876
+ if (!orig) return orig;
877
+ return function(target, uid, gid) {
878
+ try {
879
+ return orig.call(fs3, target, uid, gid);
880
+ } catch (er) {
881
+ if (!chownErOk(er)) throw er;
882
+ }
883
+ };
884
+ }
885
+ function statFix(orig) {
886
+ if (!orig) return orig;
887
+ return function(target, options, cb) {
888
+ if (typeof options === "function") {
889
+ cb = options;
890
+ options = null;
891
+ }
892
+ function callback(er, stats) {
893
+ if (stats) {
894
+ if (stats.uid < 0) stats.uid += 4294967296;
895
+ if (stats.gid < 0) stats.gid += 4294967296;
896
+ }
897
+ if (cb) cb.apply(this, arguments);
898
+ }
899
+ return options ? orig.call(fs3, target, options, callback) : orig.call(fs3, target, callback);
900
+ };
901
+ }
902
+ function statFixSync(orig) {
903
+ if (!orig) return orig;
904
+ return function(target, options) {
905
+ var stats = options ? orig.call(fs3, target, options) : orig.call(fs3, target);
906
+ if (stats) {
907
+ if (stats.uid < 0) stats.uid += 4294967296;
908
+ if (stats.gid < 0) stats.gid += 4294967296;
909
+ }
910
+ return stats;
911
+ };
912
+ }
913
+ function chownErOk(er) {
914
+ if (!er)
915
+ return true;
916
+ if (er.code === "ENOSYS")
917
+ return true;
918
+ var nonroot = !process.getuid || process.getuid() !== 0;
919
+ if (nonroot) {
920
+ if (er.code === "EINVAL" || er.code === "EPERM")
921
+ return true;
922
+ }
923
+ return false;
924
+ }
925
+ }
926
+ }
927
+ });
928
+
929
+ // node_modules/graceful-fs/legacy-streams.js
930
+ var require_legacy_streams = __commonJS({
931
+ "node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
932
+ var Stream = __require("stream").Stream;
933
+ module2.exports = legacy;
934
+ function legacy(fs3) {
935
+ return {
936
+ ReadStream,
937
+ WriteStream
938
+ };
939
+ function ReadStream(path, options) {
940
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
941
+ Stream.call(this);
942
+ var self = this;
943
+ this.path = path;
944
+ this.fd = null;
945
+ this.readable = true;
946
+ this.paused = false;
947
+ this.flags = "r";
948
+ this.mode = 438;
949
+ this.bufferSize = 64 * 1024;
950
+ options = options || {};
951
+ var keys = Object.keys(options);
952
+ for (var index = 0, length = keys.length; index < length; index++) {
953
+ var key = keys[index];
954
+ this[key] = options[key];
955
+ }
956
+ if (this.encoding) this.setEncoding(this.encoding);
957
+ if (this.start !== void 0) {
958
+ if ("number" !== typeof this.start) {
959
+ throw TypeError("start must be a Number");
960
+ }
961
+ if (this.end === void 0) {
962
+ this.end = Infinity;
963
+ } else if ("number" !== typeof this.end) {
964
+ throw TypeError("end must be a Number");
965
+ }
966
+ if (this.start > this.end) {
967
+ throw new Error("start must be <= end");
968
+ }
969
+ this.pos = this.start;
970
+ }
971
+ if (this.fd !== null) {
972
+ process.nextTick(function() {
973
+ self._read();
974
+ });
975
+ return;
976
+ }
977
+ fs3.open(this.path, this.flags, this.mode, function(err2, fd) {
978
+ if (err2) {
979
+ self.emit("error", err2);
980
+ self.readable = false;
981
+ return;
982
+ }
983
+ self.fd = fd;
984
+ self.emit("open", fd);
985
+ self._read();
986
+ });
987
+ }
988
+ function WriteStream(path, options) {
989
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
990
+ Stream.call(this);
991
+ this.path = path;
992
+ this.fd = null;
993
+ this.writable = true;
994
+ this.flags = "w";
995
+ this.encoding = "binary";
996
+ this.mode = 438;
997
+ this.bytesWritten = 0;
998
+ options = options || {};
999
+ var keys = Object.keys(options);
1000
+ for (var index = 0, length = keys.length; index < length; index++) {
1001
+ var key = keys[index];
1002
+ this[key] = options[key];
1003
+ }
1004
+ if (this.start !== void 0) {
1005
+ if ("number" !== typeof this.start) {
1006
+ throw TypeError("start must be a Number");
1007
+ }
1008
+ if (this.start < 0) {
1009
+ throw new Error("start must be >= zero");
1010
+ }
1011
+ this.pos = this.start;
1012
+ }
1013
+ this.busy = false;
1014
+ this._queue = [];
1015
+ if (this.fd === null) {
1016
+ this._open = fs3.open;
1017
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
1018
+ this.flush();
1019
+ }
1020
+ }
1021
+ }
1022
+ }
1023
+ });
1024
+
1025
+ // node_modules/graceful-fs/clone.js
1026
+ var require_clone = __commonJS({
1027
+ "node_modules/graceful-fs/clone.js"(exports, module2) {
1028
+ "use strict";
1029
+ module2.exports = clone;
1030
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
1031
+ return obj.__proto__;
1032
+ };
1033
+ function clone(obj) {
1034
+ if (obj === null || typeof obj !== "object")
1035
+ return obj;
1036
+ if (obj instanceof Object)
1037
+ var copy = { __proto__: getPrototypeOf(obj) };
1038
+ else
1039
+ var copy = /* @__PURE__ */ Object.create(null);
1040
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
1041
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
1042
+ });
1043
+ return copy;
1044
+ }
1045
+ }
1046
+ });
1047
+
1048
+ // node_modules/graceful-fs/graceful-fs.js
1049
+ var require_graceful_fs = __commonJS({
1050
+ "node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
1051
+ var fs3 = __require("fs");
1052
+ var polyfills = require_polyfills();
1053
+ var legacy = require_legacy_streams();
1054
+ var clone = require_clone();
1055
+ var util = __require("util");
1056
+ var gracefulQueue;
1057
+ var previousSymbol;
1058
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
1059
+ gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
1060
+ previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
1061
+ } else {
1062
+ gracefulQueue = "___graceful-fs.queue";
1063
+ previousSymbol = "___graceful-fs.previous";
1064
+ }
1065
+ function noop() {
1066
+ }
1067
+ function publishQueue(context, queue2) {
1068
+ Object.defineProperty(context, gracefulQueue, {
1069
+ get: function() {
1070
+ return queue2;
1071
+ }
1072
+ });
1073
+ }
1074
+ var debug2 = noop;
1075
+ if (util.debuglog)
1076
+ debug2 = util.debuglog("gfs4");
1077
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
1078
+ debug2 = function() {
1079
+ var m = util.format.apply(util, arguments);
1080
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
1081
+ console.error(m);
1082
+ };
1083
+ if (!fs3[gracefulQueue]) {
1084
+ queue = global[gracefulQueue] || [];
1085
+ publishQueue(fs3, queue);
1086
+ fs3.close = (function(fs$close) {
1087
+ function close(fd, cb) {
1088
+ return fs$close.call(fs3, fd, function(err2) {
1089
+ if (!err2) {
1090
+ resetQueue();
1091
+ }
1092
+ if (typeof cb === "function")
1093
+ cb.apply(this, arguments);
1094
+ });
1095
+ }
1096
+ Object.defineProperty(close, previousSymbol, {
1097
+ value: fs$close
1098
+ });
1099
+ return close;
1100
+ })(fs3.close);
1101
+ fs3.closeSync = (function(fs$closeSync) {
1102
+ function closeSync(fd) {
1103
+ fs$closeSync.apply(fs3, arguments);
1104
+ resetQueue();
1105
+ }
1106
+ Object.defineProperty(closeSync, previousSymbol, {
1107
+ value: fs$closeSync
1108
+ });
1109
+ return closeSync;
1110
+ })(fs3.closeSync);
1111
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
1112
+ process.on("exit", function() {
1113
+ debug2(fs3[gracefulQueue]);
1114
+ __require("assert").equal(fs3[gracefulQueue].length, 0);
1115
+ });
1116
+ }
1117
+ }
1118
+ var queue;
1119
+ if (!global[gracefulQueue]) {
1120
+ publishQueue(global, fs3[gracefulQueue]);
1121
+ }
1122
+ module2.exports = patch(clone(fs3));
1123
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs3.__patched) {
1124
+ module2.exports = patch(fs3);
1125
+ fs3.__patched = true;
1126
+ }
1127
+ function patch(fs4) {
1128
+ polyfills(fs4);
1129
+ fs4.gracefulify = patch;
1130
+ fs4.createReadStream = createReadStream;
1131
+ fs4.createWriteStream = createWriteStream;
1132
+ var fs$readFile = fs4.readFile;
1133
+ fs4.readFile = readFile3;
1134
+ function readFile3(path, options, cb) {
1135
+ if (typeof options === "function")
1136
+ cb = options, options = null;
1137
+ return go$readFile(path, options, cb);
1138
+ function go$readFile(path2, options2, cb2, startTime) {
1139
+ return fs$readFile(path2, options2, function(err2) {
1140
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1141
+ enqueue([go$readFile, [path2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1142
+ else {
1143
+ if (typeof cb2 === "function")
1144
+ cb2.apply(this, arguments);
1145
+ }
1146
+ });
1147
+ }
1148
+ }
1149
+ var fs$writeFile = fs4.writeFile;
1150
+ fs4.writeFile = writeFile2;
1151
+ function writeFile2(path, data, options, cb) {
1152
+ if (typeof options === "function")
1153
+ cb = options, options = null;
1154
+ return go$writeFile(path, data, options, cb);
1155
+ function go$writeFile(path2, data2, options2, cb2, startTime) {
1156
+ return fs$writeFile(path2, data2, options2, function(err2) {
1157
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1158
+ enqueue([go$writeFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1159
+ else {
1160
+ if (typeof cb2 === "function")
1161
+ cb2.apply(this, arguments);
1162
+ }
1163
+ });
1164
+ }
1165
+ }
1166
+ var fs$appendFile = fs4.appendFile;
1167
+ if (fs$appendFile)
1168
+ fs4.appendFile = appendFile2;
1169
+ function appendFile2(path, data, options, cb) {
1170
+ if (typeof options === "function")
1171
+ cb = options, options = null;
1172
+ return go$appendFile(path, data, options, cb);
1173
+ function go$appendFile(path2, data2, options2, cb2, startTime) {
1174
+ return fs$appendFile(path2, data2, options2, function(err2) {
1175
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1176
+ enqueue([go$appendFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1177
+ else {
1178
+ if (typeof cb2 === "function")
1179
+ cb2.apply(this, arguments);
1180
+ }
1181
+ });
1182
+ }
1183
+ }
1184
+ var fs$copyFile = fs4.copyFile;
1185
+ if (fs$copyFile)
1186
+ fs4.copyFile = copyFile;
1187
+ function copyFile(src, dest, flags2, cb) {
1188
+ if (typeof flags2 === "function") {
1189
+ cb = flags2;
1190
+ flags2 = 0;
1191
+ }
1192
+ return go$copyFile(src, dest, flags2, cb);
1193
+ function go$copyFile(src2, dest2, flags3, cb2, startTime) {
1194
+ return fs$copyFile(src2, dest2, flags3, function(err2) {
1195
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1196
+ enqueue([go$copyFile, [src2, dest2, flags3, cb2], err2, startTime || Date.now(), Date.now()]);
1197
+ else {
1198
+ if (typeof cb2 === "function")
1199
+ cb2.apply(this, arguments);
1200
+ }
1201
+ });
1202
+ }
1203
+ }
1204
+ var fs$readdir = fs4.readdir;
1205
+ fs4.readdir = readdir;
1206
+ var noReaddirOptionVersions = /^v[0-5]\./;
1207
+ function readdir(path, options, cb) {
1208
+ if (typeof options === "function")
1209
+ cb = options, options = null;
1210
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
1211
+ return fs$readdir(path2, fs$readdirCallback(
1212
+ path2,
1213
+ options2,
1214
+ cb2,
1215
+ startTime
1216
+ ));
1217
+ } : function go$readdir2(path2, options2, cb2, startTime) {
1218
+ return fs$readdir(path2, options2, fs$readdirCallback(
1219
+ path2,
1220
+ options2,
1221
+ cb2,
1222
+ startTime
1223
+ ));
1224
+ };
1225
+ return go$readdir(path, options, cb);
1226
+ function fs$readdirCallback(path2, options2, cb2, startTime) {
1227
+ return function(err2, files) {
1228
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1229
+ enqueue([
1230
+ go$readdir,
1231
+ [path2, options2, cb2],
1232
+ err2,
1233
+ startTime || Date.now(),
1234
+ Date.now()
1235
+ ]);
1236
+ else {
1237
+ if (files && files.sort)
1238
+ files.sort();
1239
+ if (typeof cb2 === "function")
1240
+ cb2.call(this, err2, files);
1241
+ }
1242
+ };
1243
+ }
1244
+ }
1245
+ if (process.version.substr(0, 4) === "v0.8") {
1246
+ var legStreams = legacy(fs4);
1247
+ ReadStream = legStreams.ReadStream;
1248
+ WriteStream = legStreams.WriteStream;
1249
+ }
1250
+ var fs$ReadStream = fs4.ReadStream;
1251
+ if (fs$ReadStream) {
1252
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
1253
+ ReadStream.prototype.open = ReadStream$open;
1254
+ }
1255
+ var fs$WriteStream = fs4.WriteStream;
1256
+ if (fs$WriteStream) {
1257
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
1258
+ WriteStream.prototype.open = WriteStream$open;
1259
+ }
1260
+ Object.defineProperty(fs4, "ReadStream", {
1261
+ get: function() {
1262
+ return ReadStream;
1263
+ },
1264
+ set: function(val) {
1265
+ ReadStream = val;
1266
+ },
1267
+ enumerable: true,
1268
+ configurable: true
1269
+ });
1270
+ Object.defineProperty(fs4, "WriteStream", {
1271
+ get: function() {
1272
+ return WriteStream;
1273
+ },
1274
+ set: function(val) {
1275
+ WriteStream = val;
1276
+ },
1277
+ enumerable: true,
1278
+ configurable: true
1279
+ });
1280
+ var FileReadStream = ReadStream;
1281
+ Object.defineProperty(fs4, "FileReadStream", {
1282
+ get: function() {
1283
+ return FileReadStream;
1284
+ },
1285
+ set: function(val) {
1286
+ FileReadStream = val;
1287
+ },
1288
+ enumerable: true,
1289
+ configurable: true
1290
+ });
1291
+ var FileWriteStream = WriteStream;
1292
+ Object.defineProperty(fs4, "FileWriteStream", {
1293
+ get: function() {
1294
+ return FileWriteStream;
1295
+ },
1296
+ set: function(val) {
1297
+ FileWriteStream = val;
1298
+ },
1299
+ enumerable: true,
1300
+ configurable: true
1301
+ });
1302
+ function ReadStream(path, options) {
1303
+ if (this instanceof ReadStream)
1304
+ return fs$ReadStream.apply(this, arguments), this;
1305
+ else
1306
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
1307
+ }
1308
+ function ReadStream$open() {
1309
+ var that = this;
1310
+ open2(that.path, that.flags, that.mode, function(err2, fd) {
1311
+ if (err2) {
1312
+ if (that.autoClose)
1313
+ that.destroy();
1314
+ that.emit("error", err2);
1315
+ } else {
1316
+ that.fd = fd;
1317
+ that.emit("open", fd);
1318
+ that.read();
1319
+ }
1320
+ });
1321
+ }
1322
+ function WriteStream(path, options) {
1323
+ if (this instanceof WriteStream)
1324
+ return fs$WriteStream.apply(this, arguments), this;
1325
+ else
1326
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
1327
+ }
1328
+ function WriteStream$open() {
1329
+ var that = this;
1330
+ open2(that.path, that.flags, that.mode, function(err2, fd) {
1331
+ if (err2) {
1332
+ that.destroy();
1333
+ that.emit("error", err2);
1334
+ } else {
1335
+ that.fd = fd;
1336
+ that.emit("open", fd);
1337
+ }
1338
+ });
1339
+ }
1340
+ function createReadStream(path, options) {
1341
+ return new fs4.ReadStream(path, options);
1342
+ }
1343
+ function createWriteStream(path, options) {
1344
+ return new fs4.WriteStream(path, options);
1345
+ }
1346
+ var fs$open = fs4.open;
1347
+ fs4.open = open2;
1348
+ function open2(path, flags2, mode, cb) {
1349
+ if (typeof mode === "function")
1350
+ cb = mode, mode = null;
1351
+ return go$open(path, flags2, mode, cb);
1352
+ function go$open(path2, flags3, mode2, cb2, startTime) {
1353
+ return fs$open(path2, flags3, mode2, function(err2, fd) {
1354
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1355
+ enqueue([go$open, [path2, flags3, mode2, cb2], err2, startTime || Date.now(), Date.now()]);
1356
+ else {
1357
+ if (typeof cb2 === "function")
1358
+ cb2.apply(this, arguments);
1359
+ }
1360
+ });
1361
+ }
1362
+ }
1363
+ return fs4;
1364
+ }
1365
+ function enqueue(elem) {
1366
+ debug2("ENQUEUE", elem[0].name, elem[1]);
1367
+ fs3[gracefulQueue].push(elem);
1368
+ retry();
1369
+ }
1370
+ var retryTimer;
1371
+ function resetQueue() {
1372
+ var now = Date.now();
1373
+ for (var i2 = 0; i2 < fs3[gracefulQueue].length; ++i2) {
1374
+ if (fs3[gracefulQueue][i2].length > 2) {
1375
+ fs3[gracefulQueue][i2][3] = now;
1376
+ fs3[gracefulQueue][i2][4] = now;
1377
+ }
1378
+ }
1379
+ retry();
1380
+ }
1381
+ function retry() {
1382
+ clearTimeout(retryTimer);
1383
+ retryTimer = void 0;
1384
+ if (fs3[gracefulQueue].length === 0)
1385
+ return;
1386
+ var elem = fs3[gracefulQueue].shift();
1387
+ var fn = elem[0];
1388
+ var args2 = elem[1];
1389
+ var err2 = elem[2];
1390
+ var startTime = elem[3];
1391
+ var lastTime = elem[4];
1392
+ if (startTime === void 0) {
1393
+ debug2("RETRY", fn.name, args2);
1394
+ fn.apply(null, args2);
1395
+ } else if (Date.now() - startTime >= 6e4) {
1396
+ debug2("TIMEOUT", fn.name, args2);
1397
+ var cb = args2.pop();
1398
+ if (typeof cb === "function")
1399
+ cb.call(null, err2);
1400
+ } else {
1401
+ var sinceAttempt = Date.now() - lastTime;
1402
+ var sinceStart = Math.max(lastTime - startTime, 1);
1403
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
1404
+ if (sinceAttempt >= desiredDelay) {
1405
+ debug2("RETRY", fn.name, args2);
1406
+ fn.apply(null, args2.concat([startTime]));
1407
+ } else {
1408
+ fs3[gracefulQueue].push(elem);
1409
+ }
1410
+ }
1411
+ if (retryTimer === void 0) {
1412
+ retryTimer = setTimeout(retry, 0);
1413
+ }
1414
+ }
1415
+ }
1416
+ });
1417
+
1418
+ // node_modules/retry/lib/retry_operation.js
1419
+ var require_retry_operation = __commonJS({
1420
+ "node_modules/retry/lib/retry_operation.js"(exports, module2) {
1421
+ function RetryOperation(timeouts, options) {
1422
+ if (typeof options === "boolean") {
1423
+ options = { forever: options };
1424
+ }
1425
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
1426
+ this._timeouts = timeouts;
1427
+ this._options = options || {};
1428
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
1429
+ this._fn = null;
1430
+ this._errors = [];
1431
+ this._attempts = 1;
1432
+ this._operationTimeout = null;
1433
+ this._operationTimeoutCb = null;
1434
+ this._timeout = null;
1435
+ this._operationStart = null;
1436
+ if (this._options.forever) {
1437
+ this._cachedTimeouts = this._timeouts.slice(0);
1438
+ }
1439
+ }
1440
+ module2.exports = RetryOperation;
1441
+ RetryOperation.prototype.reset = function() {
1442
+ this._attempts = 1;
1443
+ this._timeouts = this._originalTimeouts;
1444
+ };
1445
+ RetryOperation.prototype.stop = function() {
1446
+ if (this._timeout) {
1447
+ clearTimeout(this._timeout);
1448
+ }
1449
+ this._timeouts = [];
1450
+ this._cachedTimeouts = null;
1451
+ };
1452
+ RetryOperation.prototype.retry = function(err2) {
1453
+ if (this._timeout) {
1454
+ clearTimeout(this._timeout);
1455
+ }
1456
+ if (!err2) {
1457
+ return false;
1458
+ }
1459
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
1460
+ if (err2 && currentTime - this._operationStart >= this._maxRetryTime) {
1461
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
1462
+ return false;
1463
+ }
1464
+ this._errors.push(err2);
1465
+ var timeout = this._timeouts.shift();
1466
+ if (timeout === void 0) {
1467
+ if (this._cachedTimeouts) {
1468
+ this._errors.splice(this._errors.length - 1, this._errors.length);
1469
+ this._timeouts = this._cachedTimeouts.slice(0);
1470
+ timeout = this._timeouts.shift();
1471
+ } else {
1472
+ return false;
1473
+ }
1474
+ }
1475
+ var self = this;
1476
+ var timer = setTimeout(function() {
1477
+ self._attempts++;
1478
+ if (self._operationTimeoutCb) {
1479
+ self._timeout = setTimeout(function() {
1480
+ self._operationTimeoutCb(self._attempts);
1481
+ }, self._operationTimeout);
1482
+ if (self._options.unref) {
1483
+ self._timeout.unref();
1484
+ }
1485
+ }
1486
+ self._fn(self._attempts);
1487
+ }, timeout);
1488
+ if (this._options.unref) {
1489
+ timer.unref();
1490
+ }
1491
+ return true;
1492
+ };
1493
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
1494
+ this._fn = fn;
1495
+ if (timeoutOps) {
1496
+ if (timeoutOps.timeout) {
1497
+ this._operationTimeout = timeoutOps.timeout;
1498
+ }
1499
+ if (timeoutOps.cb) {
1500
+ this._operationTimeoutCb = timeoutOps.cb;
1501
+ }
1502
+ }
1503
+ var self = this;
1504
+ if (this._operationTimeoutCb) {
1505
+ this._timeout = setTimeout(function() {
1506
+ self._operationTimeoutCb();
1507
+ }, self._operationTimeout);
1508
+ }
1509
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
1510
+ this._fn(this._attempts);
1511
+ };
1512
+ RetryOperation.prototype.try = function(fn) {
1513
+ console.log("Using RetryOperation.try() is deprecated");
1514
+ this.attempt(fn);
1515
+ };
1516
+ RetryOperation.prototype.start = function(fn) {
1517
+ console.log("Using RetryOperation.start() is deprecated");
1518
+ this.attempt(fn);
1519
+ };
1520
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
1521
+ RetryOperation.prototype.errors = function() {
1522
+ return this._errors;
1523
+ };
1524
+ RetryOperation.prototype.attempts = function() {
1525
+ return this._attempts;
1526
+ };
1527
+ RetryOperation.prototype.mainError = function() {
1528
+ if (this._errors.length === 0) {
1529
+ return null;
1530
+ }
1531
+ var counts2 = {};
1532
+ var mainError = null;
1533
+ var mainErrorCount = 0;
1534
+ for (var i2 = 0; i2 < this._errors.length; i2++) {
1535
+ var error = this._errors[i2];
1536
+ var message = error.message;
1537
+ var count = (counts2[message] || 0) + 1;
1538
+ counts2[message] = count;
1539
+ if (count >= mainErrorCount) {
1540
+ mainError = error;
1541
+ mainErrorCount = count;
1542
+ }
1543
+ }
1544
+ return mainError;
1545
+ };
1546
+ }
1547
+ });
1548
+
1549
+ // node_modules/retry/lib/retry.js
1550
+ var require_retry = __commonJS({
1551
+ "node_modules/retry/lib/retry.js"(exports) {
1552
+ var RetryOperation = require_retry_operation();
1553
+ exports.operation = function(options) {
1554
+ var timeouts = exports.timeouts(options);
1555
+ return new RetryOperation(timeouts, {
1556
+ forever: options && options.forever,
1557
+ unref: options && options.unref,
1558
+ maxRetryTime: options && options.maxRetryTime
1559
+ });
1560
+ };
1561
+ exports.timeouts = function(options) {
1562
+ if (options instanceof Array) {
1563
+ return [].concat(options);
1564
+ }
1565
+ var opts = {
1566
+ retries: 10,
1567
+ factor: 2,
1568
+ minTimeout: 1 * 1e3,
1569
+ maxTimeout: Infinity,
1570
+ randomize: false
1571
+ };
1572
+ for (var key in options) {
1573
+ opts[key] = options[key];
1574
+ }
1575
+ if (opts.minTimeout > opts.maxTimeout) {
1576
+ throw new Error("minTimeout is greater than maxTimeout");
1577
+ }
1578
+ var timeouts = [];
1579
+ for (var i2 = 0; i2 < opts.retries; i2++) {
1580
+ timeouts.push(this.createTimeout(i2, opts));
1581
+ }
1582
+ if (options && options.forever && !timeouts.length) {
1583
+ timeouts.push(this.createTimeout(i2, opts));
1584
+ }
1585
+ timeouts.sort(function(a, b) {
1586
+ return a - b;
1587
+ });
1588
+ return timeouts;
1589
+ };
1590
+ exports.createTimeout = function(attempt, opts) {
1591
+ var random = opts.randomize ? Math.random() + 1 : 1;
1592
+ var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
1593
+ timeout = Math.min(timeout, opts.maxTimeout);
1594
+ return timeout;
1595
+ };
1596
+ exports.wrap = function(obj, options, methods) {
1597
+ if (options instanceof Array) {
1598
+ methods = options;
1599
+ options = null;
1600
+ }
1601
+ if (!methods) {
1602
+ methods = [];
1603
+ for (var key in obj) {
1604
+ if (typeof obj[key] === "function") {
1605
+ methods.push(key);
1606
+ }
1607
+ }
1608
+ }
1609
+ for (var i2 = 0; i2 < methods.length; i2++) {
1610
+ var method = methods[i2];
1611
+ var original = obj[method];
1612
+ obj[method] = function retryWrapper(original2) {
1613
+ var op = exports.operation(options);
1614
+ var args2 = Array.prototype.slice.call(arguments, 1);
1615
+ var callback = args2.pop();
1616
+ args2.push(function(err2) {
1617
+ if (op.retry(err2)) {
1618
+ return;
1619
+ }
1620
+ if (err2) {
1621
+ arguments[0] = op.mainError();
1622
+ }
1623
+ callback.apply(this, arguments);
1624
+ });
1625
+ op.attempt(function() {
1626
+ original2.apply(obj, args2);
1627
+ });
1628
+ }.bind(obj, original);
1629
+ obj[method].options = options;
1630
+ }
1631
+ };
1632
+ }
1633
+ });
1634
+
1635
+ // node_modules/retry/index.js
1636
+ var require_retry2 = __commonJS({
1637
+ "node_modules/retry/index.js"(exports, module2) {
1638
+ module2.exports = require_retry();
1639
+ }
1640
+ });
1641
+
1642
+ // node_modules/proper-lockfile/node_modules/signal-exit/signals.js
1643
+ var require_signals = __commonJS({
1644
+ "node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module2) {
1645
+ module2.exports = [
1646
+ "SIGABRT",
1647
+ "SIGALRM",
1648
+ "SIGHUP",
1649
+ "SIGINT",
1650
+ "SIGTERM"
1651
+ ];
1652
+ if (process.platform !== "win32") {
1653
+ module2.exports.push(
1654
+ "SIGVTALRM",
1655
+ "SIGXCPU",
1656
+ "SIGXFSZ",
1657
+ "SIGUSR2",
1658
+ "SIGTRAP",
1659
+ "SIGSYS",
1660
+ "SIGQUIT",
1661
+ "SIGIOT"
1662
+ // should detect profiler and enable/disable accordingly.
1663
+ // see #21
1664
+ // 'SIGPROF'
1665
+ );
1666
+ }
1667
+ if (process.platform === "linux") {
1668
+ module2.exports.push(
1669
+ "SIGIO",
1670
+ "SIGPOLL",
1671
+ "SIGPWR",
1672
+ "SIGSTKFLT",
1673
+ "SIGUNUSED"
1674
+ );
1675
+ }
1676
+ }
1677
+ });
1678
+
1679
+ // node_modules/proper-lockfile/node_modules/signal-exit/index.js
1680
+ var require_signal_exit = __commonJS({
1681
+ "node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module2) {
1682
+ var process2 = global.process;
1683
+ var processOk = function(process3) {
1684
+ return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
1685
+ };
1686
+ if (!processOk(process2)) {
1687
+ module2.exports = function() {
1688
+ return function() {
1689
+ };
1690
+ };
1691
+ } else {
1692
+ assert = __require("assert");
1693
+ signals = require_signals();
1694
+ isWin = /^win/i.test(process2.platform);
1695
+ EE = __require("events");
1696
+ if (typeof EE !== "function") {
1697
+ EE = EE.EventEmitter;
1698
+ }
1699
+ if (process2.__signal_exit_emitter__) {
1700
+ emitter = process2.__signal_exit_emitter__;
1701
+ } else {
1702
+ emitter = process2.__signal_exit_emitter__ = new EE();
1703
+ emitter.count = 0;
1704
+ emitter.emitted = {};
1705
+ }
1706
+ if (!emitter.infinite) {
1707
+ emitter.setMaxListeners(Infinity);
1708
+ emitter.infinite = true;
1709
+ }
1710
+ module2.exports = function(cb, opts) {
1711
+ if (!processOk(global.process)) {
1712
+ return function() {
1713
+ };
1714
+ }
1715
+ assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
1716
+ if (loaded === false) {
1717
+ load();
1718
+ }
1719
+ var ev = "exit";
1720
+ if (opts && opts.alwaysLast) {
1721
+ ev = "afterexit";
1722
+ }
1723
+ var remove = function() {
1724
+ emitter.removeListener(ev, cb);
1725
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
1726
+ unload();
1727
+ }
1728
+ };
1729
+ emitter.on(ev, cb);
1730
+ return remove;
1731
+ };
1732
+ unload = function unload2() {
1733
+ if (!loaded || !processOk(global.process)) {
1734
+ return;
1735
+ }
1736
+ loaded = false;
1737
+ signals.forEach(function(sig) {
1738
+ try {
1739
+ process2.removeListener(sig, sigListeners[sig]);
1740
+ } catch (er) {
1741
+ }
1742
+ });
1743
+ process2.emit = originalProcessEmit;
1744
+ process2.reallyExit = originalProcessReallyExit;
1745
+ emitter.count -= 1;
1746
+ };
1747
+ module2.exports.unload = unload;
1748
+ emit = function emit2(event, code, signal) {
1749
+ if (emitter.emitted[event]) {
1750
+ return;
1751
+ }
1752
+ emitter.emitted[event] = true;
1753
+ emitter.emit(event, code, signal);
1754
+ };
1755
+ sigListeners = {};
1756
+ signals.forEach(function(sig) {
1757
+ sigListeners[sig] = function listener() {
1758
+ if (!processOk(global.process)) {
1759
+ return;
1760
+ }
1761
+ var listeners = process2.listeners(sig);
1762
+ if (listeners.length === emitter.count) {
1763
+ unload();
1764
+ emit("exit", null, sig);
1765
+ emit("afterexit", null, sig);
1766
+ if (isWin && sig === "SIGHUP") {
1767
+ sig = "SIGINT";
1768
+ }
1769
+ process2.kill(process2.pid, sig);
1770
+ }
1771
+ };
1772
+ });
1773
+ module2.exports.signals = function() {
1774
+ return signals;
1775
+ };
1776
+ loaded = false;
1777
+ load = function load2() {
1778
+ if (loaded || !processOk(global.process)) {
1779
+ return;
1780
+ }
1781
+ loaded = true;
1782
+ emitter.count += 1;
1783
+ signals = signals.filter(function(sig) {
1784
+ try {
1785
+ process2.on(sig, sigListeners[sig]);
1786
+ return true;
1787
+ } catch (er) {
1788
+ return false;
1789
+ }
1790
+ });
1791
+ process2.emit = processEmit;
1792
+ process2.reallyExit = processReallyExit;
1793
+ };
1794
+ module2.exports.load = load;
1795
+ originalProcessReallyExit = process2.reallyExit;
1796
+ processReallyExit = function processReallyExit2(code) {
1797
+ if (!processOk(global.process)) {
1798
+ return;
1799
+ }
1800
+ process2.exitCode = code || /* istanbul ignore next */
1801
+ 0;
1802
+ emit("exit", process2.exitCode, null);
1803
+ emit("afterexit", process2.exitCode, null);
1804
+ originalProcessReallyExit.call(process2, process2.exitCode);
1805
+ };
1806
+ originalProcessEmit = process2.emit;
1807
+ processEmit = function processEmit2(ev, arg) {
1808
+ if (ev === "exit" && processOk(global.process)) {
1809
+ if (arg !== void 0) {
1810
+ process2.exitCode = arg;
1811
+ }
1812
+ var ret = originalProcessEmit.apply(this, arguments);
1813
+ emit("exit", process2.exitCode, null);
1814
+ emit("afterexit", process2.exitCode, null);
1815
+ return ret;
1816
+ } else {
1817
+ return originalProcessEmit.apply(this, arguments);
1818
+ }
1819
+ };
1820
+ }
1821
+ var assert;
1822
+ var signals;
1823
+ var isWin;
1824
+ var EE;
1825
+ var emitter;
1826
+ var unload;
1827
+ var emit;
1828
+ var sigListeners;
1829
+ var loaded;
1830
+ var load;
1831
+ var originalProcessReallyExit;
1832
+ var processReallyExit;
1833
+ var originalProcessEmit;
1834
+ var processEmit;
1835
+ }
1836
+ });
1837
+
1838
+ // node_modules/proper-lockfile/lib/mtime-precision.js
1839
+ var require_mtime_precision = __commonJS({
1840
+ "node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module2) {
572
1841
  "use strict";
573
- init_projectIdentityFile();
1842
+ var cacheSymbol = /* @__PURE__ */ Symbol();
1843
+ function probe(file, fs3, callback) {
1844
+ const cachedPrecision = fs3[cacheSymbol];
1845
+ if (cachedPrecision) {
1846
+ return fs3.stat(file, (err2, stat) => {
1847
+ if (err2) {
1848
+ return callback(err2);
1849
+ }
1850
+ callback(null, stat.mtime, cachedPrecision);
1851
+ });
1852
+ }
1853
+ const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
1854
+ fs3.utimes(file, mtime, mtime, (err2) => {
1855
+ if (err2) {
1856
+ return callback(err2);
1857
+ }
1858
+ fs3.stat(file, (err3, stat) => {
1859
+ if (err3) {
1860
+ return callback(err3);
1861
+ }
1862
+ const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
1863
+ Object.defineProperty(fs3, cacheSymbol, { value: precision });
1864
+ callback(null, stat.mtime, precision);
1865
+ });
1866
+ });
1867
+ }
1868
+ function getMtime(precision) {
1869
+ let now = Date.now();
1870
+ if (precision === "s") {
1871
+ now = Math.ceil(now / 1e3) * 1e3;
1872
+ }
1873
+ return new Date(now);
1874
+ }
1875
+ module2.exports.probe = probe;
1876
+ module2.exports.getMtime = getMtime;
574
1877
  }
575
1878
  });
576
1879
 
577
- // packages/shared/dist/runtimeReader.js
578
- var init_runtimeReader = __esm({
579
- "packages/shared/dist/runtimeReader.js"() {
1880
+ // node_modules/proper-lockfile/lib/lockfile.js
1881
+ var require_lockfile = __commonJS({
1882
+ "node_modules/proper-lockfile/lib/lockfile.js"(exports, module2) {
580
1883
  "use strict";
581
- init_runtimeSigners();
582
- init_runtimeSigners();
1884
+ var path = __require("path");
1885
+ var fs3 = require_graceful_fs();
1886
+ var retry = require_retry2();
1887
+ var onExit = require_signal_exit();
1888
+ var mtimePrecision = require_mtime_precision();
1889
+ var locks = {};
1890
+ function getLockFile(file, options) {
1891
+ return options.lockfilePath || `${file}.lock`;
1892
+ }
1893
+ function resolveCanonicalPath(file, options, callback) {
1894
+ if (!options.realpath) {
1895
+ return callback(null, path.resolve(file));
1896
+ }
1897
+ options.fs.realpath(file, callback);
1898
+ }
1899
+ function acquireLock(file, options, callback) {
1900
+ const lockfilePath = getLockFile(file, options);
1901
+ options.fs.mkdir(lockfilePath, (err2) => {
1902
+ if (!err2) {
1903
+ return mtimePrecision.probe(lockfilePath, options.fs, (err3, mtime, mtimePrecision2) => {
1904
+ if (err3) {
1905
+ options.fs.rmdir(lockfilePath, () => {
1906
+ });
1907
+ return callback(err3);
1908
+ }
1909
+ callback(null, mtime, mtimePrecision2);
1910
+ });
1911
+ }
1912
+ if (err2.code !== "EEXIST") {
1913
+ return callback(err2);
1914
+ }
1915
+ if (options.stale <= 0) {
1916
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
1917
+ }
1918
+ options.fs.stat(lockfilePath, (err3, stat) => {
1919
+ if (err3) {
1920
+ if (err3.code === "ENOENT") {
1921
+ return acquireLock(file, { ...options, stale: 0 }, callback);
1922
+ }
1923
+ return callback(err3);
1924
+ }
1925
+ if (!isLockStale(stat, options)) {
1926
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
1927
+ }
1928
+ removeLock(file, options, (err4) => {
1929
+ if (err4) {
1930
+ return callback(err4);
1931
+ }
1932
+ acquireLock(file, { ...options, stale: 0 }, callback);
1933
+ });
1934
+ });
1935
+ });
1936
+ }
1937
+ function isLockStale(stat, options) {
1938
+ return stat.mtime.getTime() < Date.now() - options.stale;
1939
+ }
1940
+ function removeLock(file, options, callback) {
1941
+ options.fs.rmdir(getLockFile(file, options), (err2) => {
1942
+ if (err2 && err2.code !== "ENOENT") {
1943
+ return callback(err2);
1944
+ }
1945
+ callback();
1946
+ });
1947
+ }
1948
+ function updateLock(file, options) {
1949
+ const lock2 = locks[file];
1950
+ if (lock2.updateTimeout) {
1951
+ return;
1952
+ }
1953
+ lock2.updateDelay = lock2.updateDelay || options.update;
1954
+ lock2.updateTimeout = setTimeout(() => {
1955
+ lock2.updateTimeout = null;
1956
+ options.fs.stat(lock2.lockfilePath, (err2, stat) => {
1957
+ const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
1958
+ if (err2) {
1959
+ if (err2.code === "ENOENT" || isOverThreshold) {
1960
+ return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
1961
+ }
1962
+ lock2.updateDelay = 1e3;
1963
+ return updateLock(file, options);
1964
+ }
1965
+ const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
1966
+ if (!isMtimeOurs) {
1967
+ return setLockAsCompromised(
1968
+ file,
1969
+ lock2,
1970
+ Object.assign(
1971
+ new Error("Unable to update lock within the stale threshold"),
1972
+ { code: "ECOMPROMISED" }
1973
+ )
1974
+ );
1975
+ }
1976
+ const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
1977
+ options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err3) => {
1978
+ const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
1979
+ if (lock2.released) {
1980
+ return;
1981
+ }
1982
+ if (err3) {
1983
+ if (err3.code === "ENOENT" || isOverThreshold2) {
1984
+ return setLockAsCompromised(file, lock2, Object.assign(err3, { code: "ECOMPROMISED" }));
1985
+ }
1986
+ lock2.updateDelay = 1e3;
1987
+ return updateLock(file, options);
1988
+ }
1989
+ lock2.mtime = mtime;
1990
+ lock2.lastUpdate = Date.now();
1991
+ lock2.updateDelay = null;
1992
+ updateLock(file, options);
1993
+ });
1994
+ });
1995
+ }, lock2.updateDelay);
1996
+ if (lock2.updateTimeout.unref) {
1997
+ lock2.updateTimeout.unref();
1998
+ }
1999
+ }
2000
+ function setLockAsCompromised(file, lock2, err2) {
2001
+ lock2.released = true;
2002
+ if (lock2.updateTimeout) {
2003
+ clearTimeout(lock2.updateTimeout);
2004
+ }
2005
+ if (locks[file] === lock2) {
2006
+ delete locks[file];
2007
+ }
2008
+ lock2.options.onCompromised(err2);
2009
+ }
2010
+ function lock(file, options, callback) {
2011
+ options = {
2012
+ stale: 1e4,
2013
+ update: null,
2014
+ realpath: true,
2015
+ retries: 0,
2016
+ fs: fs3,
2017
+ onCompromised: (err2) => {
2018
+ throw err2;
2019
+ },
2020
+ ...options
2021
+ };
2022
+ options.retries = options.retries || 0;
2023
+ options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
2024
+ options.stale = Math.max(options.stale || 0, 2e3);
2025
+ options.update = options.update == null ? options.stale / 2 : options.update || 0;
2026
+ options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
2027
+ resolveCanonicalPath(file, options, (err2, file2) => {
2028
+ if (err2) {
2029
+ return callback(err2);
2030
+ }
2031
+ const operation = retry.operation(options.retries);
2032
+ operation.attempt(() => {
2033
+ acquireLock(file2, options, (err3, mtime, mtimePrecision2) => {
2034
+ if (operation.retry(err3)) {
2035
+ return;
2036
+ }
2037
+ if (err3) {
2038
+ return callback(operation.mainError());
2039
+ }
2040
+ const lock2 = locks[file2] = {
2041
+ lockfilePath: getLockFile(file2, options),
2042
+ mtime,
2043
+ mtimePrecision: mtimePrecision2,
2044
+ options,
2045
+ lastUpdate: Date.now()
2046
+ };
2047
+ updateLock(file2, options);
2048
+ callback(null, (releasedCallback) => {
2049
+ if (lock2.released) {
2050
+ return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
2051
+ }
2052
+ unlock(file2, { ...options, realpath: false }, releasedCallback);
2053
+ });
2054
+ });
2055
+ });
2056
+ });
2057
+ }
2058
+ function unlock(file, options, callback) {
2059
+ options = {
2060
+ fs: fs3,
2061
+ realpath: true,
2062
+ ...options
2063
+ };
2064
+ resolveCanonicalPath(file, options, (err2, file2) => {
2065
+ if (err2) {
2066
+ return callback(err2);
2067
+ }
2068
+ const lock2 = locks[file2];
2069
+ if (!lock2) {
2070
+ return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
2071
+ }
2072
+ lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
2073
+ lock2.released = true;
2074
+ delete locks[file2];
2075
+ removeLock(file2, options, callback);
2076
+ });
2077
+ }
2078
+ function check(file, options, callback) {
2079
+ options = {
2080
+ stale: 1e4,
2081
+ realpath: true,
2082
+ fs: fs3,
2083
+ ...options
2084
+ };
2085
+ options.stale = Math.max(options.stale || 0, 2e3);
2086
+ resolveCanonicalPath(file, options, (err2, file2) => {
2087
+ if (err2) {
2088
+ return callback(err2);
2089
+ }
2090
+ options.fs.stat(getLockFile(file2, options), (err3, stat) => {
2091
+ if (err3) {
2092
+ return err3.code === "ENOENT" ? callback(null, false) : callback(err3);
2093
+ }
2094
+ return callback(null, !isLockStale(stat, options));
2095
+ });
2096
+ });
2097
+ }
2098
+ function getLocks() {
2099
+ return locks;
2100
+ }
2101
+ onExit(() => {
2102
+ for (const file in locks) {
2103
+ const options = locks[file].options;
2104
+ try {
2105
+ options.fs.rmdirSync(getLockFile(file, options));
2106
+ } catch (e) {
2107
+ }
2108
+ }
2109
+ });
2110
+ module2.exports.lock = lock;
2111
+ module2.exports.unlock = unlock;
2112
+ module2.exports.check = check;
2113
+ module2.exports.getLocks = getLocks;
583
2114
  }
584
2115
  });
585
2116
 
586
- // packages/shared/dist/projectSetupHandoff.js
587
- var init_projectSetupHandoff = __esm({
588
- "packages/shared/dist/projectSetupHandoff.js"() {
2117
+ // node_modules/proper-lockfile/lib/adapter.js
2118
+ var require_adapter = __commonJS({
2119
+ "node_modules/proper-lockfile/lib/adapter.js"(exports, module2) {
589
2120
  "use strict";
590
- init_runtimeSigners();
591
- init_runtimeReader();
2121
+ var fs3 = require_graceful_fs();
2122
+ function createSyncFs(fs4) {
2123
+ const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
2124
+ const newFs = { ...fs4 };
2125
+ methods.forEach((method) => {
2126
+ newFs[method] = (...args2) => {
2127
+ const callback = args2.pop();
2128
+ let ret;
2129
+ try {
2130
+ ret = fs4[`${method}Sync`](...args2);
2131
+ } catch (err2) {
2132
+ return callback(err2);
2133
+ }
2134
+ callback(null, ret);
2135
+ };
2136
+ });
2137
+ return newFs;
2138
+ }
2139
+ function toPromise(method) {
2140
+ return (...args2) => new Promise((resolve2, reject) => {
2141
+ args2.push((err2, result) => {
2142
+ if (err2) {
2143
+ reject(err2);
2144
+ } else {
2145
+ resolve2(result);
2146
+ }
2147
+ });
2148
+ method(...args2);
2149
+ });
2150
+ }
2151
+ function toSync(method) {
2152
+ return (...args2) => {
2153
+ let err2;
2154
+ let result;
2155
+ args2.push((_err, _result) => {
2156
+ err2 = _err;
2157
+ result = _result;
2158
+ });
2159
+ method(...args2);
2160
+ if (err2) {
2161
+ throw err2;
2162
+ }
2163
+ return result;
2164
+ };
2165
+ }
2166
+ function toSyncOptions(options) {
2167
+ options = { ...options };
2168
+ options.fs = createSyncFs(options.fs || fs3);
2169
+ if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
2170
+ throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
2171
+ }
2172
+ return options;
2173
+ }
2174
+ module2.exports = {
2175
+ toPromise,
2176
+ toSync,
2177
+ toSyncOptions
2178
+ };
592
2179
  }
593
2180
  });
594
2181
 
595
- // packages/shared/dist/hookRuntime.js
596
- var init_hookRuntime = __esm({
597
- "packages/shared/dist/hookRuntime.js"() {
2182
+ // node_modules/proper-lockfile/index.js
2183
+ var require_proper_lockfile = __commonJS({
2184
+ "node_modules/proper-lockfile/index.js"(exports, module2) {
598
2185
  "use strict";
599
- init_runtimeSigners();
600
- init_repositoryRoot();
601
- init_runtimeReader();
602
- init_runtimeSigners();
603
- init_projectSetupHandoff();
2186
+ var lockfile = require_lockfile();
2187
+ var { toPromise, toSync, toSyncOptions } = require_adapter();
2188
+ async function lock(file, options) {
2189
+ const release = await toPromise(lockfile.lock)(file, options);
2190
+ return toPromise(release);
2191
+ }
2192
+ function lockSync(file, options) {
2193
+ const release = toSync(lockfile.lock)(file, toSyncOptions(options));
2194
+ return toSync(release);
2195
+ }
2196
+ function unlock(file, options) {
2197
+ return toPromise(lockfile.unlock)(file, options);
2198
+ }
2199
+ function unlockSync(file, options) {
2200
+ return toSync(lockfile.unlock)(file, toSyncOptions(options));
2201
+ }
2202
+ function check(file, options) {
2203
+ return toPromise(lockfile.check)(file, options);
2204
+ }
2205
+ function checkSync(file, options) {
2206
+ return toSync(lockfile.check)(file, toSyncOptions(options));
2207
+ }
2208
+ module2.exports = lock;
2209
+ module2.exports.lock = lock;
2210
+ module2.exports.unlock = unlock;
2211
+ module2.exports.lockSync = lockSync;
2212
+ module2.exports.unlockSync = unlockSync;
2213
+ module2.exports.check = check;
2214
+ module2.exports.checkSync = checkSync;
604
2215
  }
605
2216
  });
606
2217
 
607
2218
  // packages/cli/src/install/journey.ts
608
2219
  import { appendFile, mkdir as mkdir2, readFile as readFile2, rm } from "node:fs/promises";
609
- import { basename as basename2, join as join4 } from "node:path";
610
- import { homedir as homedir2 } from "node:os";
611
- import { setTimeout as delay } from "node:timers/promises";
2220
+ import { basename as basename2, join as join5 } from "node:path";
2221
+ import { homedir as homedir3 } from "node:os";
2222
+ import { setTimeout as delay2 } from "node:timers/promises";
612
2223
 
613
2224
  // packages/shared/dist/instructions.js
614
2225
  var INSTRUCTIONS_CONTENT = `Mnemonik provides persistent project memory: decisions, rationale, tasks, and policies across sessions. If no block begins "PROJECT_CONTEXT schemaVersion=", session_bootstrap({ cwd }) loads project context when cwd is the real absolute path of the project root; a placeholder or relative path fails. With that block, context is loaded and no session_bootstrap call is needed. Code and docs show current artifacts, git shows changes, and memory carries the why; memory_search recalls rationale or intent, then Grep or Read verifies current source.
@@ -2117,8 +3728,8 @@ var Language = class _Language {
2117
3728
  if (input instanceof Uint8Array) {
2118
3729
  binary2 = input;
2119
3730
  } else if (globalThis.process?.versions.node) {
2120
- const fs2 = await import("fs/promises");
2121
- binary2 = await fs2.readFile(input);
3731
+ const fs22 = await import("fs/promises");
3732
+ binary2 = await fs22.readFile(input);
2122
3733
  } else {
2123
3734
  const response = await fetch(input);
2124
3735
  if (!response.ok) {
@@ -4893,13 +6504,21 @@ function apiOrigin(env = process.env) {
4893
6504
 
4894
6505
  // packages/local-setup/dist/storage.js
4895
6506
  init_hookRuntime();
6507
+ init_hookRuntime();
4896
6508
  import { createHash, randomUUID } from "node:crypto";
4897
6509
  import { execFile as nodeExecFile } from "node:child_process";
6510
+ import fs2 from "node:fs";
4898
6511
  import { open, rename, readFile, mkdir, lstat, chmod, writeFile, unlink, rmdir } from "node:fs/promises";
4899
6512
  import { homedir } from "node:os";
4900
6513
  import { dirname as dirname3, join as join3, win32 as win322, posix } from "node:path";
4901
- init_hookRuntime();
6514
+ import { setTimeout as delay } from "node:timers/promises";
6515
+ var lockfileKey = /* @__PURE__ */ Symbol.for("mnemonik.proper-lockfile");
6516
+ function sharedLockfile() {
6517
+ const shared = globalThis;
6518
+ return shared[lockfileKey] ??= Promise.resolve().then(() => __toESM(require_proper_lockfile(), 1)).then((module2) => module2.default);
6519
+ }
4902
6520
  var hash2 = (bytes) => createHash("sha256").update(bytes).digest("hex");
6521
+ var codeIs = (error, code) => error.code === code;
4903
6522
  function stateDirectory(platform = process.platform, env = process.env, home = homedir()) {
4904
6523
  if (env.MNEMONIK_STATE_DIR)
4905
6524
  return env.MNEMONIK_STATE_DIR;
@@ -4910,6 +6529,17 @@ function stateDirectory(platform = process.platform, env = process.env, home = h
4910
6529
  return posix.join(env.XDG_STATE_HOME || posix.join(home, ".local", "state"), "mnemonik");
4911
6530
  }
4912
6531
  var recordPath = (root, state = stateDirectory()) => join3(state, "project-setup", `${hash2(root)}.json`);
6532
+ async function readBytes(path) {
6533
+ try {
6534
+ if (!(await lstat(path)).isFile())
6535
+ throw new Error("setup_requires_regular_file");
6536
+ return await readFile(path);
6537
+ } catch (error) {
6538
+ if (codeIs(error, "ENOENT"))
6539
+ return null;
6540
+ throw error;
6541
+ }
6542
+ }
4913
6543
  async function syncDirectory(path) {
4914
6544
  if (process.platform === "win32")
4915
6545
  return;
@@ -4968,12 +6598,173 @@ async function atomicWrite(path, bytes, fault, assertOwned) {
4968
6598
  await syncDirectory(dirname3(path));
4969
6599
  return permissionStatus;
4970
6600
  }
6601
+ async function withLock(path, waitMs, work) {
6602
+ const lockfile = await sharedLockfile();
6603
+ await mkdir(dirname3(path), { recursive: true, mode: 448 });
6604
+ const generation = randomUUID();
6605
+ const owner = join3(`${path}.lock`, "owner");
6606
+ let compromised = false;
6607
+ let acquired = false;
6608
+ const assertOwned = async () => {
6609
+ if (compromised || (await readBytes(owner).catch(() => null))?.toString() !== generation) {
6610
+ compromised = true;
6611
+ throw new Error("lock_lost");
6612
+ }
6613
+ };
6614
+ const leaseFs = {
6615
+ ...fs2,
6616
+ mkdir: (dir, callback) => {
6617
+ void mkdir(dir).then(() => writeFile(owner, generation, { mode: 384, flag: "wx" })).then(() => callback(), callback);
6618
+ },
6619
+ rmdir: (dir, callback) => {
6620
+ void unlink(join3(dir, "owner")).catch((error) => {
6621
+ if (!codeIs(error, "ENOENT"))
6622
+ throw error;
6623
+ }).then(() => rmdir(dir)).then(() => callback(), callback);
6624
+ },
6625
+ rmdirSync: (dir) => {
6626
+ try {
6627
+ fs2.unlinkSync(join3(dir, "owner"));
6628
+ } catch (error) {
6629
+ if (!codeIs(error, "ENOENT"))
6630
+ throw error;
6631
+ }
6632
+ fs2.rmdirSync(dir);
6633
+ },
6634
+ stat: (file, callback) => {
6635
+ void (acquired ? assertOwned() : Promise.resolve()).then(() => fs2.stat(file, callback), () => callback(Object.assign(new Error("lock_lost"), { code: "ENOENT" })));
6636
+ }
6637
+ };
6638
+ const deadline = performance.now() + waitMs;
6639
+ let release;
6640
+ while (!release) {
6641
+ try {
6642
+ release = await lockfile.lock(path, {
6643
+ realpath: false,
6644
+ stale: 3e4,
6645
+ update: 5e3,
6646
+ retries: 0,
6647
+ fs: leaseFs,
6648
+ onCompromised: () => {
6649
+ compromised = true;
6650
+ }
6651
+ });
6652
+ } catch (error) {
6653
+ if (!codeIs(error, "ELOCKED"))
6654
+ throw error;
6655
+ if (performance.now() >= deadline)
6656
+ throw new RuntimeError("lock_held");
6657
+ await delay(Math.min(100, Math.max(1, deadline - performance.now())));
6658
+ }
6659
+ }
6660
+ acquired = true;
6661
+ try {
6662
+ return await work(assertOwned);
6663
+ } finally {
6664
+ if (await assertOwned().then(() => true, () => false))
6665
+ await release();
6666
+ }
6667
+ }
6668
+
6669
+ // packages/local-setup/dist/automaticUpdate.js
6670
+ import { spawn as nodeSpawn } from "node:child_process";
6671
+ import { realpathSync } from "node:fs";
6672
+ import { stat as nodeStat, utimes } from "node:fs/promises";
6673
+ import { homedir as homedir2 } from "node:os";
6674
+ import { join as join4 } from "node:path";
6675
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
6676
+ var DAY_MS = 864e5;
6677
+ var statePath = (stateDir) => join4(stateDir, "automatic-update.json");
6678
+ function cliLauncherPath(options = {}) {
6679
+ const platform = options.platform ?? process.platform;
6680
+ const home = options.home ?? homedir2();
6681
+ return platform === "win32" ? join4(options.env?.LOCALAPPDATA || join4(home, "AppData", "Local"), "Mnemonik", "bin", "mnemonik.cmd") : join4(home, ".local", "bin", "mnemonik");
6682
+ }
6683
+ async function readState(path) {
6684
+ const bytes = await readBytes(path);
6685
+ if (!bytes)
6686
+ return {};
6687
+ const value = JSON.parse(bytes.toString());
6688
+ if (!value || typeof value !== "object" || value.lastAttempt !== void 0 && (!Number.isFinite(value.lastAttempt) || value.lastAttempt < 0))
6689
+ throw new Error("automatic_update_state_invalid");
6690
+ return value.lastAttempt === void 0 ? {} : { lastAttempt: value.lastAttempt };
6691
+ }
6692
+ async function maybeStartAutomaticUpdate(options = {}) {
6693
+ const stateDir = options.stateDir ?? stateDirectory(options.platform, options.env, options.home);
6694
+ const path = statePath(stateDir);
6695
+ try {
6696
+ const now = (options.now ?? Date.now)();
6697
+ const stat = options.stat ?? nodeStat;
6698
+ try {
6699
+ if (now - (await stat(path)).mtimeMs < DAY_MS)
6700
+ return false;
6701
+ } catch (error) {
6702
+ if (error.code !== "ENOENT")
6703
+ throw error;
6704
+ }
6705
+ if (!options.spawn && !(await stat(cliLauncherPath(options))).isFile())
6706
+ return false;
6707
+ return await withLock(path, 0, async (assertOwned) => {
6708
+ const state = await readState(path);
6709
+ if (state.lastAttempt !== void 0 && now - state.lastAttempt < DAY_MS)
6710
+ return false;
6711
+ await atomicWrite(path, Buffer.from(`${JSON.stringify({ lastAttempt: now })}
6712
+ `), void 0, assertOwned);
6713
+ await utimes(path, now / 1e3, now / 1e3);
6714
+ const platform = options.platform ?? process.platform;
6715
+ const launcher = cliLauncherPath(options);
6716
+ const command = platform === "win32" ? {
6717
+ file: options.env?.ComSpec || "cmd.exe",
6718
+ args: ["/d", "/s", "/c", `""${launcher}" update --automatic"`],
6719
+ windowsVerbatimArguments: true
6720
+ } : platform === "linux" && (options.env ?? process.env).INVOCATION_ID ? {
6721
+ // detached creates a process group, not a new systemd cgroup. An
6722
+ // updater spawned by the scanner must survive stopping that service.
6723
+ file: "systemd-run",
6724
+ args: [
6725
+ "--user",
6726
+ "--collect",
6727
+ "--quiet",
6728
+ `--setenv=MNEMONIK_STATE_DIR=${stateDir}`,
6729
+ "--",
6730
+ launcher,
6731
+ "update",
6732
+ "--automatic"
6733
+ ]
6734
+ } : { file: launcher, args: ["update", "--automatic"] };
6735
+ const child = (options.spawn ?? nodeSpawn)(command.file, command.args, {
6736
+ detached: true,
6737
+ stdio: "ignore",
6738
+ windowsHide: true,
6739
+ ..."windowsVerbatimArguments" in command ? { windowsVerbatimArguments: command.windowsVerbatimArguments } : {}
6740
+ });
6741
+ child.once("error", () => {
6742
+ });
6743
+ child.unref();
6744
+ return true;
6745
+ });
6746
+ } catch {
6747
+ return false;
6748
+ }
6749
+ }
6750
+ var HELPER_FLAG = "--mnemonik-automatic-update";
6751
+ function isHelperInvocation() {
6752
+ if (process.argv[2] !== HELPER_FLAG || !process.argv[3] || !process.argv[1])
6753
+ return false;
6754
+ try {
6755
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath2(import.meta.url));
6756
+ } catch {
6757
+ return false;
6758
+ }
6759
+ }
6760
+ if (isHelperInvocation())
6761
+ void maybeStartAutomaticUpdate({ stateDir: process.argv[3] });
4971
6762
 
4972
6763
  // packages/local-setup/dist/index.js
4973
6764
  var MAX_ORIGINAL_BYTES = 64 * 1024;
4974
6765
 
4975
6766
  // packages/cli/src/install/journey.ts
4976
- import { nodeVersionHelp, runPreflight } from "../preflight.js";
6767
+ import { detectEditors, nodeVersionHelp, runPreflight } from "../preflight.js";
4977
6768
  import {
4978
6769
  createRealProjectRuntime,
4979
6770
  folderRefusalMessage,
@@ -4996,6 +6787,7 @@ import {
4996
6787
  renderRollbackResult,
4997
6788
  journeyAnswers,
4998
6789
  INSTALLATION_STOPPED,
6790
+ APPROVAL_WAITING,
4999
6791
  stepProgress
5000
6792
  } from "../screens/journey.js";
5001
6793
  import { interrupted } from "./journal.js";
@@ -5008,10 +6800,14 @@ import { compensate, revokeInstallComponent } from "./transaction.js";
5008
6800
  import * as ownership from "./ownership.js";
5009
6801
  import { ensureLauncher, launcherPathAction, LauncherError } from "../launcher.js";
5010
6802
  import { launchHostLabels as labels, launchHosts } from "./adapters.js";
6803
+ import { missingConsent } from "../consent.js";
5011
6804
  var FINAL_REPORT_TIMEOUT_MS = 3e3;
5012
6805
  var EARLIER_INSTALL_REMOVED = "An earlier installation did not finish and was removed.";
5013
6806
  var EARLIER_INSTALL_RUNNING = "An earlier installation is still running. Try again when it finishes.";
5014
6807
  var EARLIER_INSTALL_KEPT = "An earlier installation did not finish and could not be removed.";
6808
+ function automaticWaitAnswer(flags2, step, answered) {
6809
+ return flags2.has("retry") && !answered.some((wait) => wait.step === step && wait.answer === "retry") ? "retry" : "skip";
6810
+ }
5015
6811
  function hostReadinessConditions(results, scanner) {
5016
6812
  return results.filter((r) => r.status !== "READY").map((r) => {
5017
6813
  return {
@@ -5023,7 +6819,7 @@ function hostReadinessConditions(results, scanner) {
5023
6819
  }
5024
6820
  async function waitForInstallation(check, timeout, clock = {}) {
5025
6821
  const now = clock.now ?? Date.now;
5026
- const sleep = clock.sleep ?? delay;
6822
+ const sleep = clock.sleep ?? delay2;
5027
6823
  let document;
5028
6824
  for (; ; ) {
5029
6825
  const deadline = now() + 12e4;
@@ -5067,25 +6863,28 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5067
6863
  return 2;
5068
6864
  }
5069
6865
  if (automatic || flags2.has("hosts") || flags2.has("components")) {
6866
+ const editors = components.some((c) => c === "hooks" || c === "mcp");
5070
6867
  const required = [
5071
6868
  scanner ? "accept-indexing" : "accept-limited",
5072
- "apply",
5073
- ...automatic && scanner ? ["scan-roots"] : []
6869
+ ...automatic && editors ? ["hosts"] : [],
6870
+ ...automatic && scanner ? ["scan-roots"] : [],
6871
+ "apply"
5074
6872
  ];
5075
6873
  for (const flag of required)
5076
- if (!flags2.has(flag)) {
5077
- if (json)
5078
- output.json({
5079
- status: "action_required",
5080
- reason: "consent_required",
5081
- flag: `--${flag}`,
5082
- action: `Rerun with --${flag}`
5083
- });
5084
- else output.error(`Missing required consent flag: --${flag}`);
5085
- return 3;
5086
- }
6874
+ if (!flags2.has(flag))
6875
+ return missingConsent(
6876
+ output,
6877
+ json,
6878
+ flag,
6879
+ "install",
6880
+ flag === "hosts" ? (await detectEditors(
6881
+ deps.home ?? homedir3(),
6882
+ deps.cwd ?? process.cwd(),
6883
+ deps.preflight?.pathExists
6884
+ )).map(({ host }) => ({ value: host, label: labels[host] })) : []
6885
+ );
5087
6886
  }
5088
- const home = deps.home ?? homedir2();
6887
+ const home = deps.home ?? homedir3();
5089
6888
  let cwd = deps.cwd ?? process.cwd();
5090
6889
  let answers;
5091
6890
  let stopped = false;
@@ -5143,12 +6942,12 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5143
6942
  scanner = components.includes("scanner");
5144
6943
  names = [...new Set(previous.data.hostRequest?.selections.map((s) => s.host) ?? [])];
5145
6944
  }
5146
- const indexingSkippedPath = join4(stateDir, "indexing-skipped");
6945
+ const indexingSkippedPath = join5(stateDir, "indexing-skipped");
5147
6946
  const hasLaunchHost = (await ownership.readOwnership(stateDir)).targets.some(
5148
6947
  (target) => launchHosts.includes(target.host)
5149
6948
  );
5150
6949
  const indexingOnly = Boolean(
5151
- !previous && !automatic && !flags2.has("hosts") && !flags2.has("components") && hasLaunchHost && !await readFile2(join4(stateDir, "scanner/state.json")).then(
6950
+ !previous && !automatic && !flags2.has("hosts") && !flags2.has("components") && hasLaunchHost && !await readFile2(join5(stateDir, "scanner/state.json")).then(
5152
6951
  () => true,
5153
6952
  () => false
5154
6953
  )
@@ -5183,7 +6982,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5183
6982
  return 130;
5184
6983
  }
5185
6984
  const root = preflight.project.root ?? cwd;
5186
- const logPath = join4(stateDir, "install.log");
6985
+ const logPath = join5(stateDir, "install.log");
5187
6986
  const log = async (detail) => {
5188
6987
  await mkdir2(stateDir, { recursive: true, mode: 448 });
5189
6988
  await appendFile(logPath, `${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), detail })}
@@ -5211,6 +7010,17 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5211
7010
  output.line();
5212
7011
  return answers ? answers.choose(choices) : "Skip";
5213
7012
  };
7013
+ const waits = [];
7014
+ const repositories = [];
7015
+ const answerWait = async (step, title) => {
7016
+ let answer;
7017
+ if (automatic) {
7018
+ answer = automaticWaitAnswer(flags2, step, waits);
7019
+ if (!json) output.line(` ${title}`);
7020
+ } else answer = await choose(title, ["Retry", "Skip"]) === "Retry" ? "retry" : "skip";
7021
+ waits.push({ step, answer });
7022
+ return answer;
7023
+ };
5214
7024
  let prepared;
5215
7025
  let scannerInstallFailed = false;
5216
7026
  let scannerFailureRendered = false;
@@ -5275,11 +7085,12 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5275
7085
  }
5276
7086
  };
5277
7087
  let restart = false;
7088
+ let earlierRemoved = false;
5278
7089
  try {
5279
- if (previous?.data.joined && !automatic) renderInterrupted(output);
7090
+ if (previous?.data.joined && !automatic) renderInterrupted(output, previous.data);
5280
7091
  if (previous?.data.joined && (automatic || await answers?.choose(["Resume", "Rollback"]) !== "Resume")) {
5281
7092
  const signedIn = JSON.parse(
5282
- await readFile2(join4(stateDir, "installation.json"), "utf8").catch(() => "{}")
7093
+ await readFile2(join5(stateDir, "installation.json"), "utf8").catch(() => "{}")
5283
7094
  ).account;
5284
7095
  if (automatic && typeof signedIn === "string" && previous.data.account !== "scanner" && previous.data.account !== signedIn) {
5285
7096
  output.error(EARLIER_INSTALL_KEPT);
@@ -5312,7 +7123,8 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5312
7123
  closeInteraction();
5313
7124
  return 1;
5314
7125
  }
5315
- output.line(EARLIER_INSTALL_REMOVED);
7126
+ if (!json) output.line(EARLIER_INSTALL_REMOVED);
7127
+ earlierRemoved = true;
5316
7128
  previous = void 0;
5317
7129
  }
5318
7130
  if (indexingOnly) {
@@ -5371,12 +7183,11 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5371
7183
  } catch (error) {
5372
7184
  activeProgress?.stop();
5373
7185
  activeProgress = void 0;
5374
- if (automatic || await choose("Sign-in did not finish.", ["Retry", "Skip"]) !== "Retry")
5375
- throw error;
7186
+ if (await answerWait("sign_in", "Sign-in did not finish.") !== "retry") throw error;
5376
7187
  }
5377
7188
  }
5378
- if (!automatic && !indexingOnly) output.line(completedStep(3, "Configure editors"));
5379
- startProgress(indexingOnly ? "Getting ready" : "Configuring your editors");
7189
+ if (!automatic && !indexingOnly) output.line(completedStep(3, "Configure coding tools"));
7190
+ startProgress(indexingOnly ? "Getting ready" : "Configuring your coding tools");
5380
7191
  const managed = await management();
5381
7192
  reportFinal = async (readiness) => {
5382
7193
  const versions = await ownership.readInstallVersions(stateDir, readiness.scanner?.version ?? void 0).catch(() => void 0);
@@ -5445,7 +7256,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5445
7256
  );
5446
7257
  const afterHosts = async (journal, results, refreshHosts) => {
5447
7258
  completeProgress(
5448
- indexingOnly ? "Ready" : `${names.length} ${names.length === 1 ? "editor" : "editors"} configured`
7259
+ indexingOnly ? "Ready" : `${names.length} ${names.length === 1 ? "coding tool" : "coding tools"} configured`
5449
7260
  );
5450
7261
  journal.data.components = components;
5451
7262
  journal.data.roots = roots;
@@ -5464,6 +7275,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5464
7275
  reason: `project_setup_required: ${state}: ${root2}`,
5465
7276
  action
5466
7277
  };
7278
+ repositories.push({ folder: root2, outcome: "not_connected", reason: state, action });
5467
7279
  projectConditions.push(condition);
5468
7280
  projectReadiness.push(
5469
7281
  ...serializeReadiness({
@@ -5475,6 +7287,21 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5475
7287
  const finish = async (scannerPlan) => {
5476
7288
  prepared = scannerPlan;
5477
7289
  let limitMessage;
7290
+ if (!automatic && !flags2.has("apply")) {
7291
+ activeProgress?.stop();
7292
+ activeProgress = void 0;
7293
+ for (; ; ) {
7294
+ const applyLines = renderJourney("apply", output);
7295
+ const choice = await answers?.choose(["Install and upload", "Back", "Cancel"]);
7296
+ replaceScreen(applyLines);
7297
+ if (choice === "Back") {
7298
+ restart = true;
7299
+ throw new Error("install_back");
7300
+ }
7301
+ if (choice !== "Install and upload") throw new Error("install_cancelled");
7302
+ break;
7303
+ }
7304
+ }
5478
7305
  if (scannerPlan) {
5479
7306
  startProgress("Connecting your project folders");
5480
7307
  if (!executor) {
@@ -5538,7 +7365,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5538
7365
  if (connectedRoot) {
5539
7366
  leaveProjectForPerson(
5540
7367
  repo.path,
5541
- join4(repo.path, ".mnemonik.json"),
7368
+ join5(repo.path, ".mnemonik.json"),
5542
7369
  "duplicate_project_id",
5543
7370
  connectedRoot
5544
7371
  );
@@ -5551,7 +7378,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5551
7378
  allowNestedInherit: false,
5552
7379
  ...linkProjectId ? { intent: { action: "link", projectId: linkProjectId } } : {}
5553
7380
  };
5554
- const target = await journal.plan(join4(repo.path, ".mnemonik.json"), null, {
7381
+ const target = await journal.plan(join5(repo.path, ".mnemonik.json"), null, {
5555
7382
  kind: "project"
5556
7383
  });
5557
7384
  await journal.event("project_stage_intent", repo.path);
@@ -5562,6 +7389,12 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5562
7389
  if (message) {
5563
7390
  limitedRoots.push(repo.path);
5564
7391
  limitMessage = message.join("\n");
7392
+ repositories.push({
7393
+ folder: repo.path,
7394
+ outcome: "not_connected",
7395
+ reason: "project_limit_reached",
7396
+ action: projectLimitMessage(staged, repo.path)?.join(" ")
7397
+ });
5565
7398
  continue;
5566
7399
  }
5567
7400
  leaveProjectForPerson(
@@ -5585,22 +7418,6 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5585
7418
  roots = scannerPlan.roots;
5586
7419
  journal.data.roots = roots;
5587
7420
  }
5588
- if (!automatic && !flags2.has("apply")) {
5589
- activeProgress?.stop();
5590
- activeProgress = void 0;
5591
- for (; ; ) {
5592
- const applyLines = renderJourney("apply", output);
5593
- const choice = await answers?.choose(["Install and upload", "Back", "Cancel"]);
5594
- replaceScreen(applyLines);
5595
- if (choice === "Back") {
5596
- restart = true;
5597
- throw new Error("install_back");
5598
- }
5599
- if (choice !== "Install and upload") throw new Error("install_cancelled");
5600
- break;
5601
- }
5602
- if (scannerPlan) startProgress("Connecting your project folders");
5603
- }
5604
7421
  journal.data.phase = "applying";
5605
7422
  if (automatic) startProgress("Finishing installation");
5606
7423
  await journal.event("apply");
@@ -5614,8 +7431,13 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5614
7431
  });
5615
7432
  if (result2?.status !== "done") throw new Error("project_apply_failed");
5616
7433
  project.uuid = result2.projectId;
7434
+ repositories.push({
7435
+ folder: project.root,
7436
+ outcome: "connected",
7437
+ ...result2.projectId ? { projectId: result2.projectId } : {}
7438
+ });
5617
7439
  const target = journal.data.targets.find(
5618
- (t) => t.path === join4(project.root, ".mnemonik.json")
7440
+ (t) => t.path === join5(project.root, ".mnemonik.json")
5619
7441
  );
5620
7442
  if (target) {
5621
7443
  target.status = "committed";
@@ -5711,7 +7533,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5711
7533
  });
5712
7534
  const checked = projectConditions.length ? { document: await check(), skipped: false } : await waitForInstallation(
5713
7535
  check,
5714
- async () => await choose("Installation checks did not finish.", ["Retry", "Skip"]) === "Retry" ? "Retry" : "Skip",
7536
+ async () => await answerWait("installation_checks", "Installation checks did not finish.") === "retry" ? "Retry" : "Skip",
5715
7537
  managed
5716
7538
  );
5717
7539
  document = checked.document ?? serializeReadiness({ installation: { conditions: [] } });
@@ -5753,6 +7575,9 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5753
7575
  home,
5754
7576
  noBrowser: flags2.has("no-browser"),
5755
7577
  approvalAnnounced: true,
7578
+ awaitingApproval: () => {
7579
+ if (!automatic) startProgress(APPROVAL_WAITING);
7580
+ },
5756
7581
  exclusions: String(flags2.get("exclusions") ?? "").split(",").filter(Boolean),
5757
7582
  ...deps.scannerService,
5758
7583
  ...deps.scannerEnable,
@@ -5765,7 +7590,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5765
7590
  phase === "service" ? "Waiting for background indexing to start, up to 2 minutes." : "Waiting for indexing to begin, up to 1 minute."
5766
7591
  );
5767
7592
  },
5768
- timeout: async () => await choose("Background indexing did not start.", ["Retry", "Skip"]) === "Retry" ? "retry" : "skip"
7593
+ timeout: async () => answerWait("indexing_start", "Background indexing did not start.")
5769
7594
  },
5770
7595
  finish
5771
7596
  );
@@ -5792,7 +7617,7 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5792
7617
  for (const target of journal.data.targets.filter(
5793
7618
  (t) => t.kind === "project" && t.status !== "committed" && t.status !== "restored"
5794
7619
  )) {
5795
- const projectRoot = join4(target.path, "..");
7620
+ const projectRoot = join5(target.path, "..");
5796
7621
  const linkProjectId = linkIntents.get(projectRoot);
5797
7622
  await executor?.rollback({
5798
7623
  cwd: projectRoot,
@@ -5898,7 +7723,10 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5898
7723
  targets: result.results,
5899
7724
  reports: result.reports,
5900
7725
  runId: result.journal.runId,
5901
- phase: result.journal.phase
7726
+ phase: result.journal.phase,
7727
+ repositories,
7728
+ waits,
7729
+ ...earlierRemoved ? { earlierInstallationRemoved: true } : {}
5902
7730
  });
5903
7731
  else {
5904
7732
  output.installSection();
@@ -5956,7 +7784,9 @@ async function joinedInstall(flags2, deps, output, authorize, management) {
5956
7784
  output.json({
5957
7785
  status: "ACTION_REQUIRED",
5958
7786
  reason,
5959
- ...error instanceof LauncherError ? { launcher: error.launcher } : {}
7787
+ ...error instanceof LauncherError ? { launcher: error.launcher } : {},
7788
+ repositories,
7789
+ waits
5960
7790
  });
5961
7791
  else {
5962
7792
  await log({ error: reason }).catch(() => void 0);
@@ -5975,6 +7805,7 @@ export {
5975
7805
  EARLIER_INSTALL_KEPT,
5976
7806
  EARLIER_INSTALL_REMOVED,
5977
7807
  EARLIER_INSTALL_RUNNING,
7808
+ automaticWaitAnswer,
5978
7809
  hostReadinessConditions,
5979
7810
  joinedInstall,
5980
7811
  waitForInstallation