@mnemonik/cli 7.109.2 → 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) {
@@ -496,7 +502,9 @@ var require_ignore = __commonJS({
496
502
  });
497
503
 
498
504
  // packages/shared/dist/runtimeSigners.js
505
+ import { basename, dirname as dirname2, join as join2, resolve, sep, win32 } from "node:path";
499
506
  import { createHash, createPublicKey, randomUUID, timingSafeEqual, verify as verifySignature } from "node:crypto";
507
+ import { execFile, execFileSync } from "node:child_process";
500
508
  function decodeBase64(text, length) {
501
509
  const bytes = Buffer.from(text, "base64");
502
510
  if (bytes.length !== length || bytes.toString("base64") !== text)
@@ -525,12 +533,72 @@ function verifyMinisign(message, signatureText, identity = RELEASE_MINISIGN_PUBL
525
533
  if (!verifySignature(null, signedMessage, publicKey, fileSignature) || !verifySignature(null, Buffer.concat([fileSignature, Buffer.from(trustedComment)]), publicKey, globalSignature))
526
534
  throw new Error("unsigned");
527
535
  }
528
- var RELEASE_MINISIGN_PUBLIC_KEY, ttl;
536
+ function windowsCommand(file) {
537
+ const root = process.env.SystemRoot;
538
+ if (!root || !win32.isAbsolute(root))
539
+ throw new Error("acl_system_root_unavailable");
540
+ return win32.join(root, "System32", file);
541
+ }
542
+ function readIdentity(stdout) {
543
+ const match = /^"([^"\r\n]+)","(S-1-(?:\d+-)+\d+)"$/.exec(stdout.trim());
544
+ if (!match?.[1] || !match[2] || stdout.includes("\uFFFD"))
545
+ throw new Error("acl_identity_unavailable");
546
+ return { name: match[1], sid: match[2] };
547
+ }
548
+ function* readWindowsIdentity() {
549
+ const user = readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
550
+ if (!ADMINISTRATOR_RID.test(user.sid))
551
+ return user;
552
+ const groups = yield [windowsCommand("whoami.exe"), groupArgs];
553
+ const local = /^"[^"\r\n]*","[^"\r\n]*","S-1-5-113",/m.test(groups);
554
+ return {
555
+ ...user,
556
+ localAdministratorSid: local ? `${user.sid.slice(0, user.sid.lastIndexOf("-"))}-500` : null
557
+ };
558
+ }
559
+ function windowsCurrentAccountSync() {
560
+ if (currentIdentity)
561
+ return currentIdentity;
562
+ const commands = readWindowsIdentity();
563
+ let step = commands.next();
564
+ while (!step.done)
565
+ step = commands.next(hookExecuteSync(...step.value));
566
+ return currentIdentity = step.value;
567
+ }
568
+ function hookInvocation(file, args2) {
569
+ if (win32.basename(file) === "whoami.exe") {
570
+ if ([file, ...args2].some((arg) => /[%!"\r\n]/.test(arg)))
571
+ throw new Error("acl_path_unavailable");
572
+ const command = args2.map((arg) => /^(?:[a-z0-9]+|\/[a-z]+)$/i.test(arg) ? arg : `"${arg}"`).join(" ");
573
+ return [
574
+ windowsCommand("cmd.exe"),
575
+ ["/d", "/v:off", "/s", "/c", `"chcp 65001>nul & "${file}" ${command}"`]
576
+ ];
577
+ }
578
+ if (win32.basename(file) === "cmd.exe")
579
+ return [file, ["/u", ...args2]];
580
+ return [file, args2];
581
+ }
582
+ function hookExecuteSync(file, args2, input) {
583
+ [file, args2] = hookInvocation(file, args2);
584
+ return execFileSync(file, args2, { ...hookOptions(file, args2), input });
585
+ }
586
+ var RELEASE_MINISIGN_PUBLIC_KEY, identityArgs, groupArgs, ADMINISTRATOR_RID, currentIdentity, ttl, hookOptions;
529
587
  var init_runtimeSigners = __esm({
530
588
  "packages/shared/dist/runtimeSigners.js"() {
531
589
  "use strict";
532
590
  RELEASE_MINISIGN_PUBLIC_KEY = "RWSBYwgbjz0qKB4/ToA3dywBiAlQeBjoQpib4OHdjP2nDbpQnOVqpPm0";
591
+ identityArgs = ["/user", "/fo", "csv", "/nh"];
592
+ groupArgs = ["/groups", "/fo", "csv", "/nh"];
593
+ ADMINISTRATOR_RID = /^S-1-5-21-\d+-\d+-\d+-500$/;
533
594
  ttl = 10 * 6e4;
595
+ hookOptions = (file, args2) => ({
596
+ encoding: args2.includes("/u") ? "utf16le" : "utf8",
597
+ timeout: win32.basename(file) === "powershell.exe" ? 3e4 : 5e3,
598
+ windowsHide: true,
599
+ maxBuffer: 16 * 1024 * 1024,
600
+ windowsVerbatimArguments: win32.basename(file) === "cmd.exe"
601
+ });
534
602
  }
535
603
  });
536
604
 
@@ -562,11 +630,20 @@ var init_repositoryRoot = __esm({
562
630
  });
563
631
 
564
632
  // packages/shared/dist/runtimeReader.js
633
+ var RuntimeError;
565
634
  var init_runtimeReader = __esm({
566
635
  "packages/shared/dist/runtimeReader.js"() {
567
636
  "use strict";
568
637
  init_runtimeSigners();
569
638
  init_runtimeSigners();
639
+ RuntimeError = class extends Error {
640
+ reason;
641
+ constructor(reason) {
642
+ super(reason);
643
+ this.reason = reason;
644
+ this.name = "RuntimeError";
645
+ }
646
+ };
570
647
  }
571
648
  });
572
649
 
@@ -591,10 +668,1587 @@ var init_hookRuntime = __esm({
591
668
  }
592
669
  });
593
670
 
671
+ // node_modules/graceful-fs/polyfills.js
672
+ var require_polyfills = __commonJS({
673
+ "node_modules/graceful-fs/polyfills.js"(exports, module2) {
674
+ var constants = __require("constants");
675
+ var origCwd = process.cwd;
676
+ var cwd = null;
677
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
678
+ process.cwd = function() {
679
+ if (!cwd)
680
+ cwd = origCwd.call(process);
681
+ return cwd;
682
+ };
683
+ try {
684
+ process.cwd();
685
+ } catch (er) {
686
+ }
687
+ if (typeof process.chdir === "function") {
688
+ chdir = process.chdir;
689
+ process.chdir = function(d) {
690
+ cwd = null;
691
+ chdir.call(process, d);
692
+ };
693
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
694
+ }
695
+ var chdir;
696
+ module2.exports = patch;
697
+ function patch(fs3) {
698
+ if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
699
+ patchLchmod(fs3);
700
+ }
701
+ if (!fs3.lutimes) {
702
+ patchLutimes(fs3);
703
+ }
704
+ fs3.chown = chownFix(fs3.chown);
705
+ fs3.fchown = chownFix(fs3.fchown);
706
+ fs3.lchown = chownFix(fs3.lchown);
707
+ fs3.chmod = chmodFix(fs3.chmod);
708
+ fs3.fchmod = chmodFix(fs3.fchmod);
709
+ fs3.lchmod = chmodFix(fs3.lchmod);
710
+ fs3.chownSync = chownFixSync(fs3.chownSync);
711
+ fs3.fchownSync = chownFixSync(fs3.fchownSync);
712
+ fs3.lchownSync = chownFixSync(fs3.lchownSync);
713
+ fs3.chmodSync = chmodFixSync(fs3.chmodSync);
714
+ fs3.fchmodSync = chmodFixSync(fs3.fchmodSync);
715
+ fs3.lchmodSync = chmodFixSync(fs3.lchmodSync);
716
+ fs3.stat = statFix(fs3.stat);
717
+ fs3.fstat = statFix(fs3.fstat);
718
+ fs3.lstat = statFix(fs3.lstat);
719
+ fs3.statSync = statFixSync(fs3.statSync);
720
+ fs3.fstatSync = statFixSync(fs3.fstatSync);
721
+ fs3.lstatSync = statFixSync(fs3.lstatSync);
722
+ if (fs3.chmod && !fs3.lchmod) {
723
+ fs3.lchmod = function(path, mode, cb) {
724
+ if (cb) process.nextTick(cb);
725
+ };
726
+ fs3.lchmodSync = function() {
727
+ };
728
+ }
729
+ if (fs3.chown && !fs3.lchown) {
730
+ fs3.lchown = function(path, uid, gid, cb) {
731
+ if (cb) process.nextTick(cb);
732
+ };
733
+ fs3.lchownSync = function() {
734
+ };
735
+ }
736
+ if (platform === "win32") {
737
+ fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : (function(fs$rename) {
738
+ function rename2(from, to, cb) {
739
+ var start2 = Date.now();
740
+ var backoff = 0;
741
+ fs$rename(from, to, function CB(er) {
742
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
743
+ setTimeout(function() {
744
+ fs3.stat(to, function(stater, st) {
745
+ if (stater && stater.code === "ENOENT")
746
+ fs$rename(from, to, CB);
747
+ else
748
+ cb(er);
749
+ });
750
+ }, backoff);
751
+ if (backoff < 100)
752
+ backoff += 10;
753
+ return;
754
+ }
755
+ if (cb) cb(er);
756
+ });
757
+ }
758
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
759
+ return rename2;
760
+ })(fs3.rename);
761
+ }
762
+ fs3.read = typeof fs3.read !== "function" ? fs3.read : (function(fs$read) {
763
+ function read(fd, buffer, offset, length, position, callback_) {
764
+ var callback;
765
+ if (callback_ && typeof callback_ === "function") {
766
+ var eagCounter = 0;
767
+ callback = function(er, _, __) {
768
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
769
+ eagCounter++;
770
+ return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
771
+ }
772
+ callback_.apply(this, arguments);
773
+ };
774
+ }
775
+ return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
776
+ }
777
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
778
+ return read;
779
+ })(fs3.read);
780
+ fs3.readSync = typeof fs3.readSync !== "function" ? fs3.readSync : /* @__PURE__ */ (function(fs$readSync) {
781
+ return function(fd, buffer, offset, length, position) {
782
+ var eagCounter = 0;
783
+ while (true) {
784
+ try {
785
+ return fs$readSync.call(fs3, fd, buffer, offset, length, position);
786
+ } catch (er) {
787
+ if (er.code === "EAGAIN" && eagCounter < 10) {
788
+ eagCounter++;
789
+ continue;
790
+ }
791
+ throw er;
792
+ }
793
+ }
794
+ };
795
+ })(fs3.readSync);
796
+ function patchLchmod(fs4) {
797
+ fs4.lchmod = function(path, mode, callback) {
798
+ fs4.open(
799
+ path,
800
+ constants.O_WRONLY | constants.O_SYMLINK,
801
+ mode,
802
+ function(err2, fd) {
803
+ if (err2) {
804
+ if (callback) callback(err2);
805
+ return;
806
+ }
807
+ fs4.fchmod(fd, mode, function(err3) {
808
+ fs4.close(fd, function(err22) {
809
+ if (callback) callback(err3 || err22);
810
+ });
811
+ });
812
+ }
813
+ );
814
+ };
815
+ fs4.lchmodSync = function(path, mode) {
816
+ var fd = fs4.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
817
+ var threw = true;
818
+ var ret;
819
+ try {
820
+ ret = fs4.fchmodSync(fd, mode);
821
+ threw = false;
822
+ } finally {
823
+ if (threw) {
824
+ try {
825
+ fs4.closeSync(fd);
826
+ } catch (er) {
827
+ }
828
+ } else {
829
+ fs4.closeSync(fd);
830
+ }
831
+ }
832
+ return ret;
833
+ };
834
+ }
835
+ function patchLutimes(fs4) {
836
+ if (constants.hasOwnProperty("O_SYMLINK") && fs4.futimes) {
837
+ fs4.lutimes = function(path, at, mt, cb) {
838
+ fs4.open(path, constants.O_SYMLINK, function(er, fd) {
839
+ if (er) {
840
+ if (cb) cb(er);
841
+ return;
842
+ }
843
+ fs4.futimes(fd, at, mt, function(er2) {
844
+ fs4.close(fd, function(er22) {
845
+ if (cb) cb(er2 || er22);
846
+ });
847
+ });
848
+ });
849
+ };
850
+ fs4.lutimesSync = function(path, at, mt) {
851
+ var fd = fs4.openSync(path, constants.O_SYMLINK);
852
+ var ret;
853
+ var threw = true;
854
+ try {
855
+ ret = fs4.futimesSync(fd, at, mt);
856
+ threw = false;
857
+ } finally {
858
+ if (threw) {
859
+ try {
860
+ fs4.closeSync(fd);
861
+ } catch (er) {
862
+ }
863
+ } else {
864
+ fs4.closeSync(fd);
865
+ }
866
+ }
867
+ return ret;
868
+ };
869
+ } else if (fs4.futimes) {
870
+ fs4.lutimes = function(_a, _b, _c, cb) {
871
+ if (cb) process.nextTick(cb);
872
+ };
873
+ fs4.lutimesSync = function() {
874
+ };
875
+ }
876
+ }
877
+ function chmodFix(orig) {
878
+ if (!orig) return orig;
879
+ return function(target, mode, cb) {
880
+ return orig.call(fs3, target, mode, function(er) {
881
+ if (chownErOk(er)) er = null;
882
+ if (cb) cb.apply(this, arguments);
883
+ });
884
+ };
885
+ }
886
+ function chmodFixSync(orig) {
887
+ if (!orig) return orig;
888
+ return function(target, mode) {
889
+ try {
890
+ return orig.call(fs3, target, mode);
891
+ } catch (er) {
892
+ if (!chownErOk(er)) throw er;
893
+ }
894
+ };
895
+ }
896
+ function chownFix(orig) {
897
+ if (!orig) return orig;
898
+ return function(target, uid, gid, cb) {
899
+ return orig.call(fs3, target, uid, gid, function(er) {
900
+ if (chownErOk(er)) er = null;
901
+ if (cb) cb.apply(this, arguments);
902
+ });
903
+ };
904
+ }
905
+ function chownFixSync(orig) {
906
+ if (!orig) return orig;
907
+ return function(target, uid, gid) {
908
+ try {
909
+ return orig.call(fs3, target, uid, gid);
910
+ } catch (er) {
911
+ if (!chownErOk(er)) throw er;
912
+ }
913
+ };
914
+ }
915
+ function statFix(orig) {
916
+ if (!orig) return orig;
917
+ return function(target, options, cb) {
918
+ if (typeof options === "function") {
919
+ cb = options;
920
+ options = null;
921
+ }
922
+ function callback(er, stats) {
923
+ if (stats) {
924
+ if (stats.uid < 0) stats.uid += 4294967296;
925
+ if (stats.gid < 0) stats.gid += 4294967296;
926
+ }
927
+ if (cb) cb.apply(this, arguments);
928
+ }
929
+ return options ? orig.call(fs3, target, options, callback) : orig.call(fs3, target, callback);
930
+ };
931
+ }
932
+ function statFixSync(orig) {
933
+ if (!orig) return orig;
934
+ return function(target, options) {
935
+ var stats = options ? orig.call(fs3, target, options) : orig.call(fs3, target);
936
+ if (stats) {
937
+ if (stats.uid < 0) stats.uid += 4294967296;
938
+ if (stats.gid < 0) stats.gid += 4294967296;
939
+ }
940
+ return stats;
941
+ };
942
+ }
943
+ function chownErOk(er) {
944
+ if (!er)
945
+ return true;
946
+ if (er.code === "ENOSYS")
947
+ return true;
948
+ var nonroot = !process.getuid || process.getuid() !== 0;
949
+ if (nonroot) {
950
+ if (er.code === "EINVAL" || er.code === "EPERM")
951
+ return true;
952
+ }
953
+ return false;
954
+ }
955
+ }
956
+ }
957
+ });
958
+
959
+ // node_modules/graceful-fs/legacy-streams.js
960
+ var require_legacy_streams = __commonJS({
961
+ "node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
962
+ var Stream = __require("stream").Stream;
963
+ module2.exports = legacy;
964
+ function legacy(fs3) {
965
+ return {
966
+ ReadStream,
967
+ WriteStream
968
+ };
969
+ function ReadStream(path, options) {
970
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
971
+ Stream.call(this);
972
+ var self = this;
973
+ this.path = path;
974
+ this.fd = null;
975
+ this.readable = true;
976
+ this.paused = false;
977
+ this.flags = "r";
978
+ this.mode = 438;
979
+ this.bufferSize = 64 * 1024;
980
+ options = options || {};
981
+ var keys = Object.keys(options);
982
+ for (var index = 0, length = keys.length; index < length; index++) {
983
+ var key = keys[index];
984
+ this[key] = options[key];
985
+ }
986
+ if (this.encoding) this.setEncoding(this.encoding);
987
+ if (this.start !== void 0) {
988
+ if ("number" !== typeof this.start) {
989
+ throw TypeError("start must be a Number");
990
+ }
991
+ if (this.end === void 0) {
992
+ this.end = Infinity;
993
+ } else if ("number" !== typeof this.end) {
994
+ throw TypeError("end must be a Number");
995
+ }
996
+ if (this.start > this.end) {
997
+ throw new Error("start must be <= end");
998
+ }
999
+ this.pos = this.start;
1000
+ }
1001
+ if (this.fd !== null) {
1002
+ process.nextTick(function() {
1003
+ self._read();
1004
+ });
1005
+ return;
1006
+ }
1007
+ fs3.open(this.path, this.flags, this.mode, function(err2, fd) {
1008
+ if (err2) {
1009
+ self.emit("error", err2);
1010
+ self.readable = false;
1011
+ return;
1012
+ }
1013
+ self.fd = fd;
1014
+ self.emit("open", fd);
1015
+ self._read();
1016
+ });
1017
+ }
1018
+ function WriteStream(path, options) {
1019
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
1020
+ Stream.call(this);
1021
+ this.path = path;
1022
+ this.fd = null;
1023
+ this.writable = true;
1024
+ this.flags = "w";
1025
+ this.encoding = "binary";
1026
+ this.mode = 438;
1027
+ this.bytesWritten = 0;
1028
+ options = options || {};
1029
+ var keys = Object.keys(options);
1030
+ for (var index = 0, length = keys.length; index < length; index++) {
1031
+ var key = keys[index];
1032
+ this[key] = options[key];
1033
+ }
1034
+ if (this.start !== void 0) {
1035
+ if ("number" !== typeof this.start) {
1036
+ throw TypeError("start must be a Number");
1037
+ }
1038
+ if (this.start < 0) {
1039
+ throw new Error("start must be >= zero");
1040
+ }
1041
+ this.pos = this.start;
1042
+ }
1043
+ this.busy = false;
1044
+ this._queue = [];
1045
+ if (this.fd === null) {
1046
+ this._open = fs3.open;
1047
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
1048
+ this.flush();
1049
+ }
1050
+ }
1051
+ }
1052
+ }
1053
+ });
1054
+
1055
+ // node_modules/graceful-fs/clone.js
1056
+ var require_clone = __commonJS({
1057
+ "node_modules/graceful-fs/clone.js"(exports, module2) {
1058
+ "use strict";
1059
+ module2.exports = clone;
1060
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
1061
+ return obj.__proto__;
1062
+ };
1063
+ function clone(obj) {
1064
+ if (obj === null || typeof obj !== "object")
1065
+ return obj;
1066
+ if (obj instanceof Object)
1067
+ var copy = { __proto__: getPrototypeOf(obj) };
1068
+ else
1069
+ var copy = /* @__PURE__ */ Object.create(null);
1070
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
1071
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
1072
+ });
1073
+ return copy;
1074
+ }
1075
+ }
1076
+ });
1077
+
1078
+ // node_modules/graceful-fs/graceful-fs.js
1079
+ var require_graceful_fs = __commonJS({
1080
+ "node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
1081
+ var fs3 = __require("fs");
1082
+ var polyfills = require_polyfills();
1083
+ var legacy = require_legacy_streams();
1084
+ var clone = require_clone();
1085
+ var util = __require("util");
1086
+ var gracefulQueue;
1087
+ var previousSymbol;
1088
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
1089
+ gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
1090
+ previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
1091
+ } else {
1092
+ gracefulQueue = "___graceful-fs.queue";
1093
+ previousSymbol = "___graceful-fs.previous";
1094
+ }
1095
+ function noop() {
1096
+ }
1097
+ function publishQueue(context, queue2) {
1098
+ Object.defineProperty(context, gracefulQueue, {
1099
+ get: function() {
1100
+ return queue2;
1101
+ }
1102
+ });
1103
+ }
1104
+ var debug2 = noop;
1105
+ if (util.debuglog)
1106
+ debug2 = util.debuglog("gfs4");
1107
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
1108
+ debug2 = function() {
1109
+ var m = util.format.apply(util, arguments);
1110
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
1111
+ console.error(m);
1112
+ };
1113
+ if (!fs3[gracefulQueue]) {
1114
+ queue = global[gracefulQueue] || [];
1115
+ publishQueue(fs3, queue);
1116
+ fs3.close = (function(fs$close) {
1117
+ function close(fd, cb) {
1118
+ return fs$close.call(fs3, fd, function(err2) {
1119
+ if (!err2) {
1120
+ resetQueue();
1121
+ }
1122
+ if (typeof cb === "function")
1123
+ cb.apply(this, arguments);
1124
+ });
1125
+ }
1126
+ Object.defineProperty(close, previousSymbol, {
1127
+ value: fs$close
1128
+ });
1129
+ return close;
1130
+ })(fs3.close);
1131
+ fs3.closeSync = (function(fs$closeSync) {
1132
+ function closeSync(fd) {
1133
+ fs$closeSync.apply(fs3, arguments);
1134
+ resetQueue();
1135
+ }
1136
+ Object.defineProperty(closeSync, previousSymbol, {
1137
+ value: fs$closeSync
1138
+ });
1139
+ return closeSync;
1140
+ })(fs3.closeSync);
1141
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
1142
+ process.on("exit", function() {
1143
+ debug2(fs3[gracefulQueue]);
1144
+ __require("assert").equal(fs3[gracefulQueue].length, 0);
1145
+ });
1146
+ }
1147
+ }
1148
+ var queue;
1149
+ if (!global[gracefulQueue]) {
1150
+ publishQueue(global, fs3[gracefulQueue]);
1151
+ }
1152
+ module2.exports = patch(clone(fs3));
1153
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs3.__patched) {
1154
+ module2.exports = patch(fs3);
1155
+ fs3.__patched = true;
1156
+ }
1157
+ function patch(fs4) {
1158
+ polyfills(fs4);
1159
+ fs4.gracefulify = patch;
1160
+ fs4.createReadStream = createReadStream;
1161
+ fs4.createWriteStream = createWriteStream;
1162
+ var fs$readFile = fs4.readFile;
1163
+ fs4.readFile = readFile3;
1164
+ function readFile3(path, options, cb) {
1165
+ if (typeof options === "function")
1166
+ cb = options, options = null;
1167
+ return go$readFile(path, options, cb);
1168
+ function go$readFile(path2, options2, cb2, startTime) {
1169
+ return fs$readFile(path2, options2, function(err2) {
1170
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1171
+ enqueue([go$readFile, [path2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1172
+ else {
1173
+ if (typeof cb2 === "function")
1174
+ cb2.apply(this, arguments);
1175
+ }
1176
+ });
1177
+ }
1178
+ }
1179
+ var fs$writeFile = fs4.writeFile;
1180
+ fs4.writeFile = writeFile2;
1181
+ function writeFile2(path, data, options, cb) {
1182
+ if (typeof options === "function")
1183
+ cb = options, options = null;
1184
+ return go$writeFile(path, data, options, cb);
1185
+ function go$writeFile(path2, data2, options2, cb2, startTime) {
1186
+ return fs$writeFile(path2, data2, options2, function(err2) {
1187
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1188
+ enqueue([go$writeFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1189
+ else {
1190
+ if (typeof cb2 === "function")
1191
+ cb2.apply(this, arguments);
1192
+ }
1193
+ });
1194
+ }
1195
+ }
1196
+ var fs$appendFile = fs4.appendFile;
1197
+ if (fs$appendFile)
1198
+ fs4.appendFile = appendFile;
1199
+ function appendFile(path, data, options, cb) {
1200
+ if (typeof options === "function")
1201
+ cb = options, options = null;
1202
+ return go$appendFile(path, data, options, cb);
1203
+ function go$appendFile(path2, data2, options2, cb2, startTime) {
1204
+ return fs$appendFile(path2, data2, options2, function(err2) {
1205
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1206
+ enqueue([go$appendFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1207
+ else {
1208
+ if (typeof cb2 === "function")
1209
+ cb2.apply(this, arguments);
1210
+ }
1211
+ });
1212
+ }
1213
+ }
1214
+ var fs$copyFile = fs4.copyFile;
1215
+ if (fs$copyFile)
1216
+ fs4.copyFile = copyFile;
1217
+ function copyFile(src, dest, flags2, cb) {
1218
+ if (typeof flags2 === "function") {
1219
+ cb = flags2;
1220
+ flags2 = 0;
1221
+ }
1222
+ return go$copyFile(src, dest, flags2, cb);
1223
+ function go$copyFile(src2, dest2, flags3, cb2, startTime) {
1224
+ return fs$copyFile(src2, dest2, flags3, function(err2) {
1225
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1226
+ enqueue([go$copyFile, [src2, dest2, flags3, cb2], err2, startTime || Date.now(), Date.now()]);
1227
+ else {
1228
+ if (typeof cb2 === "function")
1229
+ cb2.apply(this, arguments);
1230
+ }
1231
+ });
1232
+ }
1233
+ }
1234
+ var fs$readdir = fs4.readdir;
1235
+ fs4.readdir = readdir;
1236
+ var noReaddirOptionVersions = /^v[0-5]\./;
1237
+ function readdir(path, options, cb) {
1238
+ if (typeof options === "function")
1239
+ cb = options, options = null;
1240
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
1241
+ return fs$readdir(path2, fs$readdirCallback(
1242
+ path2,
1243
+ options2,
1244
+ cb2,
1245
+ startTime
1246
+ ));
1247
+ } : function go$readdir2(path2, options2, cb2, startTime) {
1248
+ return fs$readdir(path2, options2, fs$readdirCallback(
1249
+ path2,
1250
+ options2,
1251
+ cb2,
1252
+ startTime
1253
+ ));
1254
+ };
1255
+ return go$readdir(path, options, cb);
1256
+ function fs$readdirCallback(path2, options2, cb2, startTime) {
1257
+ return function(err2, files) {
1258
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1259
+ enqueue([
1260
+ go$readdir,
1261
+ [path2, options2, cb2],
1262
+ err2,
1263
+ startTime || Date.now(),
1264
+ Date.now()
1265
+ ]);
1266
+ else {
1267
+ if (files && files.sort)
1268
+ files.sort();
1269
+ if (typeof cb2 === "function")
1270
+ cb2.call(this, err2, files);
1271
+ }
1272
+ };
1273
+ }
1274
+ }
1275
+ if (process.version.substr(0, 4) === "v0.8") {
1276
+ var legStreams = legacy(fs4);
1277
+ ReadStream = legStreams.ReadStream;
1278
+ WriteStream = legStreams.WriteStream;
1279
+ }
1280
+ var fs$ReadStream = fs4.ReadStream;
1281
+ if (fs$ReadStream) {
1282
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
1283
+ ReadStream.prototype.open = ReadStream$open;
1284
+ }
1285
+ var fs$WriteStream = fs4.WriteStream;
1286
+ if (fs$WriteStream) {
1287
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
1288
+ WriteStream.prototype.open = WriteStream$open;
1289
+ }
1290
+ Object.defineProperty(fs4, "ReadStream", {
1291
+ get: function() {
1292
+ return ReadStream;
1293
+ },
1294
+ set: function(val) {
1295
+ ReadStream = val;
1296
+ },
1297
+ enumerable: true,
1298
+ configurable: true
1299
+ });
1300
+ Object.defineProperty(fs4, "WriteStream", {
1301
+ get: function() {
1302
+ return WriteStream;
1303
+ },
1304
+ set: function(val) {
1305
+ WriteStream = val;
1306
+ },
1307
+ enumerable: true,
1308
+ configurable: true
1309
+ });
1310
+ var FileReadStream = ReadStream;
1311
+ Object.defineProperty(fs4, "FileReadStream", {
1312
+ get: function() {
1313
+ return FileReadStream;
1314
+ },
1315
+ set: function(val) {
1316
+ FileReadStream = val;
1317
+ },
1318
+ enumerable: true,
1319
+ configurable: true
1320
+ });
1321
+ var FileWriteStream = WriteStream;
1322
+ Object.defineProperty(fs4, "FileWriteStream", {
1323
+ get: function() {
1324
+ return FileWriteStream;
1325
+ },
1326
+ set: function(val) {
1327
+ FileWriteStream = val;
1328
+ },
1329
+ enumerable: true,
1330
+ configurable: true
1331
+ });
1332
+ function ReadStream(path, options) {
1333
+ if (this instanceof ReadStream)
1334
+ return fs$ReadStream.apply(this, arguments), this;
1335
+ else
1336
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
1337
+ }
1338
+ function ReadStream$open() {
1339
+ var that = this;
1340
+ open2(that.path, that.flags, that.mode, function(err2, fd) {
1341
+ if (err2) {
1342
+ if (that.autoClose)
1343
+ that.destroy();
1344
+ that.emit("error", err2);
1345
+ } else {
1346
+ that.fd = fd;
1347
+ that.emit("open", fd);
1348
+ that.read();
1349
+ }
1350
+ });
1351
+ }
1352
+ function WriteStream(path, options) {
1353
+ if (this instanceof WriteStream)
1354
+ return fs$WriteStream.apply(this, arguments), this;
1355
+ else
1356
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
1357
+ }
1358
+ function WriteStream$open() {
1359
+ var that = this;
1360
+ open2(that.path, that.flags, that.mode, function(err2, fd) {
1361
+ if (err2) {
1362
+ that.destroy();
1363
+ that.emit("error", err2);
1364
+ } else {
1365
+ that.fd = fd;
1366
+ that.emit("open", fd);
1367
+ }
1368
+ });
1369
+ }
1370
+ function createReadStream(path, options) {
1371
+ return new fs4.ReadStream(path, options);
1372
+ }
1373
+ function createWriteStream(path, options) {
1374
+ return new fs4.WriteStream(path, options);
1375
+ }
1376
+ var fs$open = fs4.open;
1377
+ fs4.open = open2;
1378
+ function open2(path, flags2, mode, cb) {
1379
+ if (typeof mode === "function")
1380
+ cb = mode, mode = null;
1381
+ return go$open(path, flags2, mode, cb);
1382
+ function go$open(path2, flags3, mode2, cb2, startTime) {
1383
+ return fs$open(path2, flags3, mode2, function(err2, fd) {
1384
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1385
+ enqueue([go$open, [path2, flags3, mode2, cb2], err2, startTime || Date.now(), Date.now()]);
1386
+ else {
1387
+ if (typeof cb2 === "function")
1388
+ cb2.apply(this, arguments);
1389
+ }
1390
+ });
1391
+ }
1392
+ }
1393
+ return fs4;
1394
+ }
1395
+ function enqueue(elem) {
1396
+ debug2("ENQUEUE", elem[0].name, elem[1]);
1397
+ fs3[gracefulQueue].push(elem);
1398
+ retry();
1399
+ }
1400
+ var retryTimer;
1401
+ function resetQueue() {
1402
+ var now = Date.now();
1403
+ for (var i2 = 0; i2 < fs3[gracefulQueue].length; ++i2) {
1404
+ if (fs3[gracefulQueue][i2].length > 2) {
1405
+ fs3[gracefulQueue][i2][3] = now;
1406
+ fs3[gracefulQueue][i2][4] = now;
1407
+ }
1408
+ }
1409
+ retry();
1410
+ }
1411
+ function retry() {
1412
+ clearTimeout(retryTimer);
1413
+ retryTimer = void 0;
1414
+ if (fs3[gracefulQueue].length === 0)
1415
+ return;
1416
+ var elem = fs3[gracefulQueue].shift();
1417
+ var fn = elem[0];
1418
+ var args2 = elem[1];
1419
+ var err2 = elem[2];
1420
+ var startTime = elem[3];
1421
+ var lastTime = elem[4];
1422
+ if (startTime === void 0) {
1423
+ debug2("RETRY", fn.name, args2);
1424
+ fn.apply(null, args2);
1425
+ } else if (Date.now() - startTime >= 6e4) {
1426
+ debug2("TIMEOUT", fn.name, args2);
1427
+ var cb = args2.pop();
1428
+ if (typeof cb === "function")
1429
+ cb.call(null, err2);
1430
+ } else {
1431
+ var sinceAttempt = Date.now() - lastTime;
1432
+ var sinceStart = Math.max(lastTime - startTime, 1);
1433
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
1434
+ if (sinceAttempt >= desiredDelay) {
1435
+ debug2("RETRY", fn.name, args2);
1436
+ fn.apply(null, args2.concat([startTime]));
1437
+ } else {
1438
+ fs3[gracefulQueue].push(elem);
1439
+ }
1440
+ }
1441
+ if (retryTimer === void 0) {
1442
+ retryTimer = setTimeout(retry, 0);
1443
+ }
1444
+ }
1445
+ }
1446
+ });
1447
+
1448
+ // node_modules/retry/lib/retry_operation.js
1449
+ var require_retry_operation = __commonJS({
1450
+ "node_modules/retry/lib/retry_operation.js"(exports, module2) {
1451
+ function RetryOperation(timeouts, options) {
1452
+ if (typeof options === "boolean") {
1453
+ options = { forever: options };
1454
+ }
1455
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
1456
+ this._timeouts = timeouts;
1457
+ this._options = options || {};
1458
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
1459
+ this._fn = null;
1460
+ this._errors = [];
1461
+ this._attempts = 1;
1462
+ this._operationTimeout = null;
1463
+ this._operationTimeoutCb = null;
1464
+ this._timeout = null;
1465
+ this._operationStart = null;
1466
+ if (this._options.forever) {
1467
+ this._cachedTimeouts = this._timeouts.slice(0);
1468
+ }
1469
+ }
1470
+ module2.exports = RetryOperation;
1471
+ RetryOperation.prototype.reset = function() {
1472
+ this._attempts = 1;
1473
+ this._timeouts = this._originalTimeouts;
1474
+ };
1475
+ RetryOperation.prototype.stop = function() {
1476
+ if (this._timeout) {
1477
+ clearTimeout(this._timeout);
1478
+ }
1479
+ this._timeouts = [];
1480
+ this._cachedTimeouts = null;
1481
+ };
1482
+ RetryOperation.prototype.retry = function(err2) {
1483
+ if (this._timeout) {
1484
+ clearTimeout(this._timeout);
1485
+ }
1486
+ if (!err2) {
1487
+ return false;
1488
+ }
1489
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
1490
+ if (err2 && currentTime - this._operationStart >= this._maxRetryTime) {
1491
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
1492
+ return false;
1493
+ }
1494
+ this._errors.push(err2);
1495
+ var timeout = this._timeouts.shift();
1496
+ if (timeout === void 0) {
1497
+ if (this._cachedTimeouts) {
1498
+ this._errors.splice(this._errors.length - 1, this._errors.length);
1499
+ this._timeouts = this._cachedTimeouts.slice(0);
1500
+ timeout = this._timeouts.shift();
1501
+ } else {
1502
+ return false;
1503
+ }
1504
+ }
1505
+ var self = this;
1506
+ var timer = setTimeout(function() {
1507
+ self._attempts++;
1508
+ if (self._operationTimeoutCb) {
1509
+ self._timeout = setTimeout(function() {
1510
+ self._operationTimeoutCb(self._attempts);
1511
+ }, self._operationTimeout);
1512
+ if (self._options.unref) {
1513
+ self._timeout.unref();
1514
+ }
1515
+ }
1516
+ self._fn(self._attempts);
1517
+ }, timeout);
1518
+ if (this._options.unref) {
1519
+ timer.unref();
1520
+ }
1521
+ return true;
1522
+ };
1523
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
1524
+ this._fn = fn;
1525
+ if (timeoutOps) {
1526
+ if (timeoutOps.timeout) {
1527
+ this._operationTimeout = timeoutOps.timeout;
1528
+ }
1529
+ if (timeoutOps.cb) {
1530
+ this._operationTimeoutCb = timeoutOps.cb;
1531
+ }
1532
+ }
1533
+ var self = this;
1534
+ if (this._operationTimeoutCb) {
1535
+ this._timeout = setTimeout(function() {
1536
+ self._operationTimeoutCb();
1537
+ }, self._operationTimeout);
1538
+ }
1539
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
1540
+ this._fn(this._attempts);
1541
+ };
1542
+ RetryOperation.prototype.try = function(fn) {
1543
+ console.log("Using RetryOperation.try() is deprecated");
1544
+ this.attempt(fn);
1545
+ };
1546
+ RetryOperation.prototype.start = function(fn) {
1547
+ console.log("Using RetryOperation.start() is deprecated");
1548
+ this.attempt(fn);
1549
+ };
1550
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
1551
+ RetryOperation.prototype.errors = function() {
1552
+ return this._errors;
1553
+ };
1554
+ RetryOperation.prototype.attempts = function() {
1555
+ return this._attempts;
1556
+ };
1557
+ RetryOperation.prototype.mainError = function() {
1558
+ if (this._errors.length === 0) {
1559
+ return null;
1560
+ }
1561
+ var counts = {};
1562
+ var mainError = null;
1563
+ var mainErrorCount = 0;
1564
+ for (var i2 = 0; i2 < this._errors.length; i2++) {
1565
+ var error = this._errors[i2];
1566
+ var message = error.message;
1567
+ var count = (counts[message] || 0) + 1;
1568
+ counts[message] = count;
1569
+ if (count >= mainErrorCount) {
1570
+ mainError = error;
1571
+ mainErrorCount = count;
1572
+ }
1573
+ }
1574
+ return mainError;
1575
+ };
1576
+ }
1577
+ });
1578
+
1579
+ // node_modules/retry/lib/retry.js
1580
+ var require_retry = __commonJS({
1581
+ "node_modules/retry/lib/retry.js"(exports) {
1582
+ var RetryOperation = require_retry_operation();
1583
+ exports.operation = function(options) {
1584
+ var timeouts = exports.timeouts(options);
1585
+ return new RetryOperation(timeouts, {
1586
+ forever: options && options.forever,
1587
+ unref: options && options.unref,
1588
+ maxRetryTime: options && options.maxRetryTime
1589
+ });
1590
+ };
1591
+ exports.timeouts = function(options) {
1592
+ if (options instanceof Array) {
1593
+ return [].concat(options);
1594
+ }
1595
+ var opts = {
1596
+ retries: 10,
1597
+ factor: 2,
1598
+ minTimeout: 1 * 1e3,
1599
+ maxTimeout: Infinity,
1600
+ randomize: false
1601
+ };
1602
+ for (var key in options) {
1603
+ opts[key] = options[key];
1604
+ }
1605
+ if (opts.minTimeout > opts.maxTimeout) {
1606
+ throw new Error("minTimeout is greater than maxTimeout");
1607
+ }
1608
+ var timeouts = [];
1609
+ for (var i2 = 0; i2 < opts.retries; i2++) {
1610
+ timeouts.push(this.createTimeout(i2, opts));
1611
+ }
1612
+ if (options && options.forever && !timeouts.length) {
1613
+ timeouts.push(this.createTimeout(i2, opts));
1614
+ }
1615
+ timeouts.sort(function(a, b) {
1616
+ return a - b;
1617
+ });
1618
+ return timeouts;
1619
+ };
1620
+ exports.createTimeout = function(attempt, opts) {
1621
+ var random = opts.randomize ? Math.random() + 1 : 1;
1622
+ var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
1623
+ timeout = Math.min(timeout, opts.maxTimeout);
1624
+ return timeout;
1625
+ };
1626
+ exports.wrap = function(obj, options, methods) {
1627
+ if (options instanceof Array) {
1628
+ methods = options;
1629
+ options = null;
1630
+ }
1631
+ if (!methods) {
1632
+ methods = [];
1633
+ for (var key in obj) {
1634
+ if (typeof obj[key] === "function") {
1635
+ methods.push(key);
1636
+ }
1637
+ }
1638
+ }
1639
+ for (var i2 = 0; i2 < methods.length; i2++) {
1640
+ var method = methods[i2];
1641
+ var original = obj[method];
1642
+ obj[method] = function retryWrapper(original2) {
1643
+ var op = exports.operation(options);
1644
+ var args2 = Array.prototype.slice.call(arguments, 1);
1645
+ var callback = args2.pop();
1646
+ args2.push(function(err2) {
1647
+ if (op.retry(err2)) {
1648
+ return;
1649
+ }
1650
+ if (err2) {
1651
+ arguments[0] = op.mainError();
1652
+ }
1653
+ callback.apply(this, arguments);
1654
+ });
1655
+ op.attempt(function() {
1656
+ original2.apply(obj, args2);
1657
+ });
1658
+ }.bind(obj, original);
1659
+ obj[method].options = options;
1660
+ }
1661
+ };
1662
+ }
1663
+ });
1664
+
1665
+ // node_modules/retry/index.js
1666
+ var require_retry2 = __commonJS({
1667
+ "node_modules/retry/index.js"(exports, module2) {
1668
+ module2.exports = require_retry();
1669
+ }
1670
+ });
1671
+
1672
+ // node_modules/proper-lockfile/node_modules/signal-exit/signals.js
1673
+ var require_signals = __commonJS({
1674
+ "node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module2) {
1675
+ module2.exports = [
1676
+ "SIGABRT",
1677
+ "SIGALRM",
1678
+ "SIGHUP",
1679
+ "SIGINT",
1680
+ "SIGTERM"
1681
+ ];
1682
+ if (process.platform !== "win32") {
1683
+ module2.exports.push(
1684
+ "SIGVTALRM",
1685
+ "SIGXCPU",
1686
+ "SIGXFSZ",
1687
+ "SIGUSR2",
1688
+ "SIGTRAP",
1689
+ "SIGSYS",
1690
+ "SIGQUIT",
1691
+ "SIGIOT"
1692
+ // should detect profiler and enable/disable accordingly.
1693
+ // see #21
1694
+ // 'SIGPROF'
1695
+ );
1696
+ }
1697
+ if (process.platform === "linux") {
1698
+ module2.exports.push(
1699
+ "SIGIO",
1700
+ "SIGPOLL",
1701
+ "SIGPWR",
1702
+ "SIGSTKFLT",
1703
+ "SIGUNUSED"
1704
+ );
1705
+ }
1706
+ }
1707
+ });
1708
+
1709
+ // node_modules/proper-lockfile/node_modules/signal-exit/index.js
1710
+ var require_signal_exit = __commonJS({
1711
+ "node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module2) {
1712
+ var process2 = global.process;
1713
+ var processOk = function(process3) {
1714
+ 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";
1715
+ };
1716
+ if (!processOk(process2)) {
1717
+ module2.exports = function() {
1718
+ return function() {
1719
+ };
1720
+ };
1721
+ } else {
1722
+ assert = __require("assert");
1723
+ signals = require_signals();
1724
+ isWin = /^win/i.test(process2.platform);
1725
+ EE = __require("events");
1726
+ if (typeof EE !== "function") {
1727
+ EE = EE.EventEmitter;
1728
+ }
1729
+ if (process2.__signal_exit_emitter__) {
1730
+ emitter = process2.__signal_exit_emitter__;
1731
+ } else {
1732
+ emitter = process2.__signal_exit_emitter__ = new EE();
1733
+ emitter.count = 0;
1734
+ emitter.emitted = {};
1735
+ }
1736
+ if (!emitter.infinite) {
1737
+ emitter.setMaxListeners(Infinity);
1738
+ emitter.infinite = true;
1739
+ }
1740
+ module2.exports = function(cb, opts) {
1741
+ if (!processOk(global.process)) {
1742
+ return function() {
1743
+ };
1744
+ }
1745
+ assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
1746
+ if (loaded === false) {
1747
+ load();
1748
+ }
1749
+ var ev = "exit";
1750
+ if (opts && opts.alwaysLast) {
1751
+ ev = "afterexit";
1752
+ }
1753
+ var remove = function() {
1754
+ emitter.removeListener(ev, cb);
1755
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
1756
+ unload();
1757
+ }
1758
+ };
1759
+ emitter.on(ev, cb);
1760
+ return remove;
1761
+ };
1762
+ unload = function unload2() {
1763
+ if (!loaded || !processOk(global.process)) {
1764
+ return;
1765
+ }
1766
+ loaded = false;
1767
+ signals.forEach(function(sig) {
1768
+ try {
1769
+ process2.removeListener(sig, sigListeners[sig]);
1770
+ } catch (er) {
1771
+ }
1772
+ });
1773
+ process2.emit = originalProcessEmit;
1774
+ process2.reallyExit = originalProcessReallyExit;
1775
+ emitter.count -= 1;
1776
+ };
1777
+ module2.exports.unload = unload;
1778
+ emit = function emit2(event, code, signal) {
1779
+ if (emitter.emitted[event]) {
1780
+ return;
1781
+ }
1782
+ emitter.emitted[event] = true;
1783
+ emitter.emit(event, code, signal);
1784
+ };
1785
+ sigListeners = {};
1786
+ signals.forEach(function(sig) {
1787
+ sigListeners[sig] = function listener() {
1788
+ if (!processOk(global.process)) {
1789
+ return;
1790
+ }
1791
+ var listeners = process2.listeners(sig);
1792
+ if (listeners.length === emitter.count) {
1793
+ unload();
1794
+ emit("exit", null, sig);
1795
+ emit("afterexit", null, sig);
1796
+ if (isWin && sig === "SIGHUP") {
1797
+ sig = "SIGINT";
1798
+ }
1799
+ process2.kill(process2.pid, sig);
1800
+ }
1801
+ };
1802
+ });
1803
+ module2.exports.signals = function() {
1804
+ return signals;
1805
+ };
1806
+ loaded = false;
1807
+ load = function load2() {
1808
+ if (loaded || !processOk(global.process)) {
1809
+ return;
1810
+ }
1811
+ loaded = true;
1812
+ emitter.count += 1;
1813
+ signals = signals.filter(function(sig) {
1814
+ try {
1815
+ process2.on(sig, sigListeners[sig]);
1816
+ return true;
1817
+ } catch (er) {
1818
+ return false;
1819
+ }
1820
+ });
1821
+ process2.emit = processEmit;
1822
+ process2.reallyExit = processReallyExit;
1823
+ };
1824
+ module2.exports.load = load;
1825
+ originalProcessReallyExit = process2.reallyExit;
1826
+ processReallyExit = function processReallyExit2(code) {
1827
+ if (!processOk(global.process)) {
1828
+ return;
1829
+ }
1830
+ process2.exitCode = code || /* istanbul ignore next */
1831
+ 0;
1832
+ emit("exit", process2.exitCode, null);
1833
+ emit("afterexit", process2.exitCode, null);
1834
+ originalProcessReallyExit.call(process2, process2.exitCode);
1835
+ };
1836
+ originalProcessEmit = process2.emit;
1837
+ processEmit = function processEmit2(ev, arg) {
1838
+ if (ev === "exit" && processOk(global.process)) {
1839
+ if (arg !== void 0) {
1840
+ process2.exitCode = arg;
1841
+ }
1842
+ var ret = originalProcessEmit.apply(this, arguments);
1843
+ emit("exit", process2.exitCode, null);
1844
+ emit("afterexit", process2.exitCode, null);
1845
+ return ret;
1846
+ } else {
1847
+ return originalProcessEmit.apply(this, arguments);
1848
+ }
1849
+ };
1850
+ }
1851
+ var assert;
1852
+ var signals;
1853
+ var isWin;
1854
+ var EE;
1855
+ var emitter;
1856
+ var unload;
1857
+ var emit;
1858
+ var sigListeners;
1859
+ var loaded;
1860
+ var load;
1861
+ var originalProcessReallyExit;
1862
+ var processReallyExit;
1863
+ var originalProcessEmit;
1864
+ var processEmit;
1865
+ }
1866
+ });
1867
+
1868
+ // node_modules/proper-lockfile/lib/mtime-precision.js
1869
+ var require_mtime_precision = __commonJS({
1870
+ "node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module2) {
1871
+ "use strict";
1872
+ var cacheSymbol = /* @__PURE__ */ Symbol();
1873
+ function probe(file, fs3, callback) {
1874
+ const cachedPrecision = fs3[cacheSymbol];
1875
+ if (cachedPrecision) {
1876
+ return fs3.stat(file, (err2, stat) => {
1877
+ if (err2) {
1878
+ return callback(err2);
1879
+ }
1880
+ callback(null, stat.mtime, cachedPrecision);
1881
+ });
1882
+ }
1883
+ const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
1884
+ fs3.utimes(file, mtime, mtime, (err2) => {
1885
+ if (err2) {
1886
+ return callback(err2);
1887
+ }
1888
+ fs3.stat(file, (err3, stat) => {
1889
+ if (err3) {
1890
+ return callback(err3);
1891
+ }
1892
+ const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
1893
+ Object.defineProperty(fs3, cacheSymbol, { value: precision });
1894
+ callback(null, stat.mtime, precision);
1895
+ });
1896
+ });
1897
+ }
1898
+ function getMtime(precision) {
1899
+ let now = Date.now();
1900
+ if (precision === "s") {
1901
+ now = Math.ceil(now / 1e3) * 1e3;
1902
+ }
1903
+ return new Date(now);
1904
+ }
1905
+ module2.exports.probe = probe;
1906
+ module2.exports.getMtime = getMtime;
1907
+ }
1908
+ });
1909
+
1910
+ // node_modules/proper-lockfile/lib/lockfile.js
1911
+ var require_lockfile = __commonJS({
1912
+ "node_modules/proper-lockfile/lib/lockfile.js"(exports, module2) {
1913
+ "use strict";
1914
+ var path = __require("path");
1915
+ var fs3 = require_graceful_fs();
1916
+ var retry = require_retry2();
1917
+ var onExit = require_signal_exit();
1918
+ var mtimePrecision = require_mtime_precision();
1919
+ var locks = {};
1920
+ function getLockFile(file, options) {
1921
+ return options.lockfilePath || `${file}.lock`;
1922
+ }
1923
+ function resolveCanonicalPath(file, options, callback) {
1924
+ if (!options.realpath) {
1925
+ return callback(null, path.resolve(file));
1926
+ }
1927
+ options.fs.realpath(file, callback);
1928
+ }
1929
+ function acquireLock(file, options, callback) {
1930
+ const lockfilePath = getLockFile(file, options);
1931
+ options.fs.mkdir(lockfilePath, (err2) => {
1932
+ if (!err2) {
1933
+ return mtimePrecision.probe(lockfilePath, options.fs, (err3, mtime, mtimePrecision2) => {
1934
+ if (err3) {
1935
+ options.fs.rmdir(lockfilePath, () => {
1936
+ });
1937
+ return callback(err3);
1938
+ }
1939
+ callback(null, mtime, mtimePrecision2);
1940
+ });
1941
+ }
1942
+ if (err2.code !== "EEXIST") {
1943
+ return callback(err2);
1944
+ }
1945
+ if (options.stale <= 0) {
1946
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
1947
+ }
1948
+ options.fs.stat(lockfilePath, (err3, stat) => {
1949
+ if (err3) {
1950
+ if (err3.code === "ENOENT") {
1951
+ return acquireLock(file, { ...options, stale: 0 }, callback);
1952
+ }
1953
+ return callback(err3);
1954
+ }
1955
+ if (!isLockStale(stat, options)) {
1956
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
1957
+ }
1958
+ removeLock(file, options, (err4) => {
1959
+ if (err4) {
1960
+ return callback(err4);
1961
+ }
1962
+ acquireLock(file, { ...options, stale: 0 }, callback);
1963
+ });
1964
+ });
1965
+ });
1966
+ }
1967
+ function isLockStale(stat, options) {
1968
+ return stat.mtime.getTime() < Date.now() - options.stale;
1969
+ }
1970
+ function removeLock(file, options, callback) {
1971
+ options.fs.rmdir(getLockFile(file, options), (err2) => {
1972
+ if (err2 && err2.code !== "ENOENT") {
1973
+ return callback(err2);
1974
+ }
1975
+ callback();
1976
+ });
1977
+ }
1978
+ function updateLock(file, options) {
1979
+ const lock2 = locks[file];
1980
+ if (lock2.updateTimeout) {
1981
+ return;
1982
+ }
1983
+ lock2.updateDelay = lock2.updateDelay || options.update;
1984
+ lock2.updateTimeout = setTimeout(() => {
1985
+ lock2.updateTimeout = null;
1986
+ options.fs.stat(lock2.lockfilePath, (err2, stat) => {
1987
+ const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
1988
+ if (err2) {
1989
+ if (err2.code === "ENOENT" || isOverThreshold) {
1990
+ return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
1991
+ }
1992
+ lock2.updateDelay = 1e3;
1993
+ return updateLock(file, options);
1994
+ }
1995
+ const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
1996
+ if (!isMtimeOurs) {
1997
+ return setLockAsCompromised(
1998
+ file,
1999
+ lock2,
2000
+ Object.assign(
2001
+ new Error("Unable to update lock within the stale threshold"),
2002
+ { code: "ECOMPROMISED" }
2003
+ )
2004
+ );
2005
+ }
2006
+ const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
2007
+ options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err3) => {
2008
+ const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
2009
+ if (lock2.released) {
2010
+ return;
2011
+ }
2012
+ if (err3) {
2013
+ if (err3.code === "ENOENT" || isOverThreshold2) {
2014
+ return setLockAsCompromised(file, lock2, Object.assign(err3, { code: "ECOMPROMISED" }));
2015
+ }
2016
+ lock2.updateDelay = 1e3;
2017
+ return updateLock(file, options);
2018
+ }
2019
+ lock2.mtime = mtime;
2020
+ lock2.lastUpdate = Date.now();
2021
+ lock2.updateDelay = null;
2022
+ updateLock(file, options);
2023
+ });
2024
+ });
2025
+ }, lock2.updateDelay);
2026
+ if (lock2.updateTimeout.unref) {
2027
+ lock2.updateTimeout.unref();
2028
+ }
2029
+ }
2030
+ function setLockAsCompromised(file, lock2, err2) {
2031
+ lock2.released = true;
2032
+ if (lock2.updateTimeout) {
2033
+ clearTimeout(lock2.updateTimeout);
2034
+ }
2035
+ if (locks[file] === lock2) {
2036
+ delete locks[file];
2037
+ }
2038
+ lock2.options.onCompromised(err2);
2039
+ }
2040
+ function lock(file, options, callback) {
2041
+ options = {
2042
+ stale: 1e4,
2043
+ update: null,
2044
+ realpath: true,
2045
+ retries: 0,
2046
+ fs: fs3,
2047
+ onCompromised: (err2) => {
2048
+ throw err2;
2049
+ },
2050
+ ...options
2051
+ };
2052
+ options.retries = options.retries || 0;
2053
+ options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
2054
+ options.stale = Math.max(options.stale || 0, 2e3);
2055
+ options.update = options.update == null ? options.stale / 2 : options.update || 0;
2056
+ options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
2057
+ resolveCanonicalPath(file, options, (err2, file2) => {
2058
+ if (err2) {
2059
+ return callback(err2);
2060
+ }
2061
+ const operation = retry.operation(options.retries);
2062
+ operation.attempt(() => {
2063
+ acquireLock(file2, options, (err3, mtime, mtimePrecision2) => {
2064
+ if (operation.retry(err3)) {
2065
+ return;
2066
+ }
2067
+ if (err3) {
2068
+ return callback(operation.mainError());
2069
+ }
2070
+ const lock2 = locks[file2] = {
2071
+ lockfilePath: getLockFile(file2, options),
2072
+ mtime,
2073
+ mtimePrecision: mtimePrecision2,
2074
+ options,
2075
+ lastUpdate: Date.now()
2076
+ };
2077
+ updateLock(file2, options);
2078
+ callback(null, (releasedCallback) => {
2079
+ if (lock2.released) {
2080
+ return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
2081
+ }
2082
+ unlock(file2, { ...options, realpath: false }, releasedCallback);
2083
+ });
2084
+ });
2085
+ });
2086
+ });
2087
+ }
2088
+ function unlock(file, options, callback) {
2089
+ options = {
2090
+ fs: fs3,
2091
+ realpath: true,
2092
+ ...options
2093
+ };
2094
+ resolveCanonicalPath(file, options, (err2, file2) => {
2095
+ if (err2) {
2096
+ return callback(err2);
2097
+ }
2098
+ const lock2 = locks[file2];
2099
+ if (!lock2) {
2100
+ return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
2101
+ }
2102
+ lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
2103
+ lock2.released = true;
2104
+ delete locks[file2];
2105
+ removeLock(file2, options, callback);
2106
+ });
2107
+ }
2108
+ function check(file, options, callback) {
2109
+ options = {
2110
+ stale: 1e4,
2111
+ realpath: true,
2112
+ fs: fs3,
2113
+ ...options
2114
+ };
2115
+ options.stale = Math.max(options.stale || 0, 2e3);
2116
+ resolveCanonicalPath(file, options, (err2, file2) => {
2117
+ if (err2) {
2118
+ return callback(err2);
2119
+ }
2120
+ options.fs.stat(getLockFile(file2, options), (err3, stat) => {
2121
+ if (err3) {
2122
+ return err3.code === "ENOENT" ? callback(null, false) : callback(err3);
2123
+ }
2124
+ return callback(null, !isLockStale(stat, options));
2125
+ });
2126
+ });
2127
+ }
2128
+ function getLocks() {
2129
+ return locks;
2130
+ }
2131
+ onExit(() => {
2132
+ for (const file in locks) {
2133
+ const options = locks[file].options;
2134
+ try {
2135
+ options.fs.rmdirSync(getLockFile(file, options));
2136
+ } catch (e) {
2137
+ }
2138
+ }
2139
+ });
2140
+ module2.exports.lock = lock;
2141
+ module2.exports.unlock = unlock;
2142
+ module2.exports.check = check;
2143
+ module2.exports.getLocks = getLocks;
2144
+ }
2145
+ });
2146
+
2147
+ // node_modules/proper-lockfile/lib/adapter.js
2148
+ var require_adapter = __commonJS({
2149
+ "node_modules/proper-lockfile/lib/adapter.js"(exports, module2) {
2150
+ "use strict";
2151
+ var fs3 = require_graceful_fs();
2152
+ function createSyncFs(fs4) {
2153
+ const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
2154
+ const newFs = { ...fs4 };
2155
+ methods.forEach((method) => {
2156
+ newFs[method] = (...args2) => {
2157
+ const callback = args2.pop();
2158
+ let ret;
2159
+ try {
2160
+ ret = fs4[`${method}Sync`](...args2);
2161
+ } catch (err2) {
2162
+ return callback(err2);
2163
+ }
2164
+ callback(null, ret);
2165
+ };
2166
+ });
2167
+ return newFs;
2168
+ }
2169
+ function toPromise(method) {
2170
+ return (...args2) => new Promise((resolve3, reject) => {
2171
+ args2.push((err2, result) => {
2172
+ if (err2) {
2173
+ reject(err2);
2174
+ } else {
2175
+ resolve3(result);
2176
+ }
2177
+ });
2178
+ method(...args2);
2179
+ });
2180
+ }
2181
+ function toSync(method) {
2182
+ return (...args2) => {
2183
+ let err2;
2184
+ let result;
2185
+ args2.push((_err, _result) => {
2186
+ err2 = _err;
2187
+ result = _result;
2188
+ });
2189
+ method(...args2);
2190
+ if (err2) {
2191
+ throw err2;
2192
+ }
2193
+ return result;
2194
+ };
2195
+ }
2196
+ function toSyncOptions(options) {
2197
+ options = { ...options };
2198
+ options.fs = createSyncFs(options.fs || fs3);
2199
+ if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
2200
+ throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
2201
+ }
2202
+ return options;
2203
+ }
2204
+ module2.exports = {
2205
+ toPromise,
2206
+ toSync,
2207
+ toSyncOptions
2208
+ };
2209
+ }
2210
+ });
2211
+
2212
+ // node_modules/proper-lockfile/index.js
2213
+ var require_proper_lockfile = __commonJS({
2214
+ "node_modules/proper-lockfile/index.js"(exports, module2) {
2215
+ "use strict";
2216
+ var lockfile = require_lockfile();
2217
+ var { toPromise, toSync, toSyncOptions } = require_adapter();
2218
+ async function lock(file, options) {
2219
+ const release = await toPromise(lockfile.lock)(file, options);
2220
+ return toPromise(release);
2221
+ }
2222
+ function lockSync(file, options) {
2223
+ const release = toSync(lockfile.lock)(file, toSyncOptions(options));
2224
+ return toSync(release);
2225
+ }
2226
+ function unlock(file, options) {
2227
+ return toPromise(lockfile.unlock)(file, options);
2228
+ }
2229
+ function unlockSync(file, options) {
2230
+ return toSync(lockfile.unlock)(file, toSyncOptions(options));
2231
+ }
2232
+ function check(file, options) {
2233
+ return toPromise(lockfile.check)(file, options);
2234
+ }
2235
+ function checkSync(file, options) {
2236
+ return toSync(lockfile.check)(file, toSyncOptions(options));
2237
+ }
2238
+ module2.exports = lock;
2239
+ module2.exports.lock = lock;
2240
+ module2.exports.unlock = unlock;
2241
+ module2.exports.lockSync = lockSync;
2242
+ module2.exports.unlockSync = unlockSync;
2243
+ module2.exports.check = check;
2244
+ module2.exports.checkSync = checkSync;
2245
+ }
2246
+ });
2247
+
594
2248
  // packages/cli/src/runtime/releaseSource.ts
595
- import { createHash as createHash2 } from "node:crypto";
596
- import { execFile } from "node:child_process";
597
- import { readFile, realpath } from "node:fs/promises";
2249
+ import { createHash as createHash3 } from "node:crypto";
2250
+ import { execFile as execFile2 } from "node:child_process";
2251
+ import { readFile as readFile2, realpath } from "node:fs/promises";
598
2252
  import { readFileSync } from "node:fs";
599
2253
 
600
2254
  // packages/shared/dist/instructions.js
@@ -2104,8 +3758,8 @@ var Language = class _Language {
2104
3758
  if (input instanceof Uint8Array) {
2105
3759
  binary2 = input;
2106
3760
  } else if (globalThis.process?.versions.node) {
2107
- const fs2 = await import("fs/promises");
2108
- binary2 = await fs2.readFile(input);
3761
+ const fs22 = await import("fs/promises");
3762
+ binary2 = await fs22.readFile(input);
2109
3763
  } else {
2110
3764
  const response = await fetch(input);
2111
3765
  if (!response.ok) {
@@ -2207,13 +3861,13 @@ async function Module2(moduleArg = {}) {
2207
3861
  }
2208
3862
  readAsync = /* @__PURE__ */ __name(async (url) => {
2209
3863
  if (isFileURI(url)) {
2210
- return new Promise((resolve2, reject) => {
3864
+ return new Promise((resolve3, reject) => {
2211
3865
  var xhr = new XMLHttpRequest();
2212
3866
  xhr.open("GET", url, true);
2213
3867
  xhr.responseType = "arraybuffer";
2214
3868
  xhr.onload = () => {
2215
3869
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
2216
- resolve2(xhr.response);
3870
+ resolve3(xhr.response);
2217
3871
  return;
2218
3872
  }
2219
3873
  reject(xhr.status);
@@ -2409,9 +4063,9 @@ async function Module2(moduleArg = {}) {
2409
4063
  __name(receiveInstantiationResult, "receiveInstantiationResult");
2410
4064
  var info22 = getWasmImports();
2411
4065
  if (Module["instantiateWasm"]) {
2412
- return new Promise((resolve2, reject) => {
4066
+ return new Promise((resolve3, reject) => {
2413
4067
  Module["instantiateWasm"](info22, (mod, inst) => {
2414
- resolve2(receiveInstance(mod, inst));
4068
+ resolve3(receiveInstance(mod, inst));
2415
4069
  });
2416
4070
  });
2417
4071
  }
@@ -3742,8 +5396,8 @@ async function Module2(moduleArg = {}) {
3742
5396
  if (runtimeInitialized) {
3743
5397
  moduleRtn = Module;
3744
5398
  } else {
3745
- moduleRtn = new Promise((resolve2, reject) => {
3746
- readyPromiseResolve = resolve2;
5399
+ moduleRtn = new Promise((resolve3, reject) => {
5400
+ readyPromiseResolve = resolve3;
3747
5401
  readyPromiseReject = reject;
3748
5402
  });
3749
5403
  }
@@ -4789,25 +6443,266 @@ init_repositoryRoot();
4789
6443
 
4790
6444
  // packages/local-setup/dist/storage.js
4791
6445
  init_hookRuntime();
4792
- import { homedir } from "node:os";
4793
- import { dirname as dirname2, join as join2, win32, posix } from "node:path";
4794
6446
  init_hookRuntime();
6447
+ import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
6448
+ import { execFile as nodeExecFile } from "node:child_process";
6449
+ import fs2 from "node:fs";
6450
+ import { open, rename, readFile, mkdir, lstat, chmod, writeFile, unlink, rmdir } from "node:fs/promises";
6451
+ import { homedir } from "node:os";
6452
+ import { dirname as dirname3, join as join3, win32 as win322, posix } from "node:path";
6453
+ import { setTimeout as delay } from "node:timers/promises";
6454
+ var lockfileKey = /* @__PURE__ */ Symbol.for("mnemonik.proper-lockfile");
6455
+ function sharedLockfile() {
6456
+ const shared = globalThis;
6457
+ return shared[lockfileKey] ??= Promise.resolve().then(() => __toESM(require_proper_lockfile(), 1)).then((module2) => module2.default);
6458
+ }
6459
+ var codeIs = (error, code) => error.code === code;
4795
6460
  function stateDirectory(platform = process.platform, env = process.env, home = homedir()) {
4796
6461
  if (env.MNEMONIK_STATE_DIR)
4797
6462
  return env.MNEMONIK_STATE_DIR;
4798
6463
  if (platform === "win32")
4799
- return win32.join(env.LOCALAPPDATA || win32.join(home, "AppData", "Local"), "Mnemonik");
6464
+ return win322.join(env.LOCALAPPDATA || win322.join(home, "AppData", "Local"), "Mnemonik");
4800
6465
  if (platform === "darwin")
4801
6466
  return posix.join(home, "Library", "Application Support", "Mnemonik");
4802
6467
  return posix.join(env.XDG_STATE_HOME || posix.join(home, ".local", "state"), "mnemonik");
4803
6468
  }
6469
+ async function readBytes(path) {
6470
+ try {
6471
+ if (!(await lstat(path)).isFile())
6472
+ throw new Error("setup_requires_regular_file");
6473
+ return await readFile(path);
6474
+ } catch (error) {
6475
+ if (codeIs(error, "ENOENT"))
6476
+ return null;
6477
+ throw error;
6478
+ }
6479
+ }
6480
+ async function syncDirectory(path) {
6481
+ if (process.platform === "win32")
6482
+ return;
6483
+ const fd = await open(path, "r");
6484
+ try {
6485
+ await fd.sync();
6486
+ } finally {
6487
+ await fd.close();
6488
+ }
6489
+ }
6490
+ var windowsCurrentAccount = windowsCurrentAccountSync;
6491
+ async function windowsCurrentUserAcl(path, directory = false, options = {}, created = false) {
6492
+ const username = options.username ?? `*${windowsCurrentAccount().sid}`;
6493
+ const grant = `${username}:${directory ? "(OI)(CI)F" : "F"}`;
6494
+ const execFile3 = options.execFile ?? nodeExecFile;
6495
+ await new Promise((resolve3, reject) => {
6496
+ execFile3("icacls.exe", [
6497
+ path,
6498
+ "/inheritance:r",
6499
+ "/grant:r",
6500
+ grant,
6501
+ ...created ? ["/remove:g", "*S-1-5-32-544", "*S-1-5-18"] : []
6502
+ ], (error) => {
6503
+ if (error)
6504
+ reject(error);
6505
+ else
6506
+ resolve3();
6507
+ });
6508
+ });
6509
+ }
6510
+ async function protectStateFile(path, platform = process.platform, aclOptions) {
6511
+ if (platform === "win32")
6512
+ await windowsCurrentUserAcl(path, false, aclOptions);
6513
+ else
6514
+ await chmod(path, 384);
6515
+ return "private";
6516
+ }
6517
+ async function atomicWrite(path, bytes, fault, assertOwned) {
6518
+ await assertOwned?.();
6519
+ const temp = `${path}.${randomUUID2()}.tmp`;
6520
+ const fd = await open(temp, "wx", 384);
6521
+ let permissionStatus;
6522
+ try {
6523
+ permissionStatus = await protectStateFile(temp);
6524
+ const split = Math.ceil(bytes.length / 2);
6525
+ await fd.writeFile(bytes.subarray(0, split));
6526
+ await fault?.("mid_write");
6527
+ await assertOwned?.();
6528
+ await fd.writeFile(bytes.subarray(split));
6529
+ await fd.sync();
6530
+ } finally {
6531
+ await fd.close();
6532
+ }
6533
+ await assertOwned?.();
6534
+ await rename(temp, path);
6535
+ await syncDirectory(dirname3(path));
6536
+ return permissionStatus;
6537
+ }
6538
+ async function withLock(path, waitMs, work) {
6539
+ const lockfile = await sharedLockfile();
6540
+ await mkdir(dirname3(path), { recursive: true, mode: 448 });
6541
+ const generation = randomUUID2();
6542
+ const owner = join3(`${path}.lock`, "owner");
6543
+ let compromised = false;
6544
+ let acquired = false;
6545
+ const assertOwned = async () => {
6546
+ if (compromised || (await readBytes(owner).catch(() => null))?.toString() !== generation) {
6547
+ compromised = true;
6548
+ throw new Error("lock_lost");
6549
+ }
6550
+ };
6551
+ const leaseFs = {
6552
+ ...fs2,
6553
+ mkdir: (dir, callback) => {
6554
+ void mkdir(dir).then(() => writeFile(owner, generation, { mode: 384, flag: "wx" })).then(() => callback(), callback);
6555
+ },
6556
+ rmdir: (dir, callback) => {
6557
+ void unlink(join3(dir, "owner")).catch((error) => {
6558
+ if (!codeIs(error, "ENOENT"))
6559
+ throw error;
6560
+ }).then(() => rmdir(dir)).then(() => callback(), callback);
6561
+ },
6562
+ rmdirSync: (dir) => {
6563
+ try {
6564
+ fs2.unlinkSync(join3(dir, "owner"));
6565
+ } catch (error) {
6566
+ if (!codeIs(error, "ENOENT"))
6567
+ throw error;
6568
+ }
6569
+ fs2.rmdirSync(dir);
6570
+ },
6571
+ stat: (file, callback) => {
6572
+ void (acquired ? assertOwned() : Promise.resolve()).then(() => fs2.stat(file, callback), () => callback(Object.assign(new Error("lock_lost"), { code: "ENOENT" })));
6573
+ }
6574
+ };
6575
+ const deadline = performance.now() + waitMs;
6576
+ let release;
6577
+ while (!release) {
6578
+ try {
6579
+ release = await lockfile.lock(path, {
6580
+ realpath: false,
6581
+ stale: 3e4,
6582
+ update: 5e3,
6583
+ retries: 0,
6584
+ fs: leaseFs,
6585
+ onCompromised: () => {
6586
+ compromised = true;
6587
+ }
6588
+ });
6589
+ } catch (error) {
6590
+ if (!codeIs(error, "ELOCKED"))
6591
+ throw error;
6592
+ if (performance.now() >= deadline)
6593
+ throw new RuntimeError("lock_held");
6594
+ await delay(Math.min(100, Math.max(1, deadline - performance.now())));
6595
+ }
6596
+ }
6597
+ acquired = true;
6598
+ try {
6599
+ return await work(assertOwned);
6600
+ } finally {
6601
+ if (await assertOwned().then(() => true, () => false))
6602
+ await release();
6603
+ }
6604
+ }
6605
+
6606
+ // packages/local-setup/dist/automaticUpdate.js
6607
+ import { spawn as nodeSpawn } from "node:child_process";
6608
+ import { realpathSync } from "node:fs";
6609
+ import { stat as nodeStat, utimes } from "node:fs/promises";
6610
+ import { homedir as homedir2 } from "node:os";
6611
+ import { join as join4 } from "node:path";
6612
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
6613
+ var DAY_MS = 864e5;
6614
+ var statePath = (stateDir) => join4(stateDir, "automatic-update.json");
6615
+ function cliLauncherPath(options = {}) {
6616
+ const platform = options.platform ?? process.platform;
6617
+ const home = options.home ?? homedir2();
6618
+ return platform === "win32" ? join4(options.env?.LOCALAPPDATA || join4(home, "AppData", "Local"), "Mnemonik", "bin", "mnemonik.cmd") : join4(home, ".local", "bin", "mnemonik");
6619
+ }
6620
+ async function readState(path) {
6621
+ const bytes = await readBytes(path);
6622
+ if (!bytes)
6623
+ return {};
6624
+ const value = JSON.parse(bytes.toString());
6625
+ if (!value || typeof value !== "object" || value.lastAttempt !== void 0 && (!Number.isFinite(value.lastAttempt) || value.lastAttempt < 0))
6626
+ throw new Error("automatic_update_state_invalid");
6627
+ return value.lastAttempt === void 0 ? {} : { lastAttempt: value.lastAttempt };
6628
+ }
6629
+ async function maybeStartAutomaticUpdate(options = {}) {
6630
+ const stateDir = options.stateDir ?? stateDirectory(options.platform, options.env, options.home);
6631
+ const path = statePath(stateDir);
6632
+ try {
6633
+ const now = (options.now ?? Date.now)();
6634
+ const stat = options.stat ?? nodeStat;
6635
+ try {
6636
+ if (now - (await stat(path)).mtimeMs < DAY_MS)
6637
+ return false;
6638
+ } catch (error) {
6639
+ if (error.code !== "ENOENT")
6640
+ throw error;
6641
+ }
6642
+ if (!options.spawn && !(await stat(cliLauncherPath(options))).isFile())
6643
+ return false;
6644
+ return await withLock(path, 0, async (assertOwned) => {
6645
+ const state = await readState(path);
6646
+ if (state.lastAttempt !== void 0 && now - state.lastAttempt < DAY_MS)
6647
+ return false;
6648
+ await atomicWrite(path, Buffer.from(`${JSON.stringify({ lastAttempt: now })}
6649
+ `), void 0, assertOwned);
6650
+ await utimes(path, now / 1e3, now / 1e3);
6651
+ const platform = options.platform ?? process.platform;
6652
+ const launcher = cliLauncherPath(options);
6653
+ const command = platform === "win32" ? {
6654
+ file: options.env?.ComSpec || "cmd.exe",
6655
+ args: ["/d", "/s", "/c", `""${launcher}" update --automatic"`],
6656
+ windowsVerbatimArguments: true
6657
+ } : platform === "linux" && (options.env ?? process.env).INVOCATION_ID ? {
6658
+ // detached creates a process group, not a new systemd cgroup. An
6659
+ // updater spawned by the scanner must survive stopping that service.
6660
+ file: "systemd-run",
6661
+ args: [
6662
+ "--user",
6663
+ "--collect",
6664
+ "--quiet",
6665
+ `--setenv=MNEMONIK_STATE_DIR=${stateDir}`,
6666
+ "--",
6667
+ launcher,
6668
+ "update",
6669
+ "--automatic"
6670
+ ]
6671
+ } : { file: launcher, args: ["update", "--automatic"] };
6672
+ const child = (options.spawn ?? nodeSpawn)(command.file, command.args, {
6673
+ detached: true,
6674
+ stdio: "ignore",
6675
+ windowsHide: true,
6676
+ ..."windowsVerbatimArguments" in command ? { windowsVerbatimArguments: command.windowsVerbatimArguments } : {}
6677
+ });
6678
+ child.once("error", () => {
6679
+ });
6680
+ child.unref();
6681
+ return true;
6682
+ });
6683
+ } catch {
6684
+ return false;
6685
+ }
6686
+ }
6687
+ var HELPER_FLAG = "--mnemonik-automatic-update";
6688
+ function isHelperInvocation() {
6689
+ if (process.argv[2] !== HELPER_FLAG || !process.argv[3] || !process.argv[1])
6690
+ return false;
6691
+ try {
6692
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath2(import.meta.url));
6693
+ } catch {
6694
+ return false;
6695
+ }
6696
+ }
6697
+ if (isHelperInvocation())
6698
+ void maybeStartAutomaticUpdate({ stateDir: process.argv[3] });
4804
6699
 
4805
6700
  // packages/local-setup/dist/index.js
4806
6701
  var MAX_ORIGINAL_BYTES = 64 * 1024;
4807
6702
 
4808
6703
  // packages/cli/src/runtime/releaseSource.ts
4809
6704
  init_hookRuntime();
4810
- import { dirname as dirname3, join as join3, resolve } from "node:path";
6705
+ import { dirname as dirname4, join as join5, resolve as resolve2 } from "node:path";
4811
6706
  import { promisify } from "node:util";
4812
6707
  import { unpack } from "./bootstrap.js";
4813
6708
  import {
@@ -4832,7 +6727,7 @@ function permitted(url) {
4832
6727
  function devReleaseActive() {
4833
6728
  if (process.env.MNEMONIK_DEV_RELEASE_DIR) return true;
4834
6729
  try {
4835
- return JSON.parse(readFileSync(join3(stateDirectory(), "host-ownership.json"), "utf8")).devReleaseSource === true;
6730
+ return JSON.parse(readFileSync(join5(stateDirectory(), "host-ownership.json"), "utf8")).devReleaseSource === true;
4836
6731
  } catch (error) {
4837
6732
  if (error.code === "ENOENT") return false;
4838
6733
  throw error;
@@ -4855,10 +6750,10 @@ async function devBytes(url) {
4855
6750
  if (!directory) return void 0;
4856
6751
  const local = async (name3) => {
4857
6752
  if (!/^[a-zA-Z0-9._-]+$/.test(name3)) throw new RuntimeError2("permission");
4858
- const root = await realpath(resolve(directory));
4859
- const path = join3(root, name3);
6753
+ const root = await realpath(resolve2(directory));
6754
+ const path = join5(root, name3);
4860
6755
  if (await realpath(path) !== path) throw new RuntimeError2("permission");
4861
- return readFile(path);
6756
+ return readFile2(path);
4862
6757
  };
4863
6758
  if (url.href.startsWith(releaseRoot)) return local(url.pathname.split("/").at(-1) ?? "");
4864
6759
  if (url.origin !== "https://registry.npmjs.org") return void 0;
@@ -4896,7 +6791,7 @@ async function devBytes(url) {
4896
6791
  name: name2,
4897
6792
  version,
4898
6793
  dist: {
4899
- integrity: "sha512-" + createHash2("sha512").update(bytes).digest("base64"),
6794
+ integrity: "sha512-" + createHash3("sha512").update(bytes).digest("base64"),
4900
6795
  tarball: `https://registry.npmjs.org/@mnemonik/-/${filename}`
4901
6796
  }
4902
6797
  })
@@ -5033,8 +6928,8 @@ async function npmReleaseSource(fetcher = fetch, view = async () => {
5033
6928
  "--proxy=null",
5034
6929
  "--https-proxy=null"
5035
6930
  ];
5036
- const windowsNpm = join3(dirname3(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
5037
- const { stdout } = await promisify(execFile)(
6931
+ const windowsNpm = join5(dirname4(process.execPath), "node_modules", "npm", "bin", "npm-cli.js");
6932
+ const { stdout } = await promisify(execFile2)(
5038
6933
  process.platform === "win32" ? process.execPath : "npm",
5039
6934
  process.platform === "win32" ? [windowsNpm, ...args2] : args2,
5040
6935
  { env: { ...process.env, NPM_CONFIG_IGNORE_SCRIPTS: "true" } }
@@ -5044,7 +6939,7 @@ async function npmReleaseSource(fetcher = fetch, view = async () => {
5044
6939
  const dist = await view();
5045
6940
  const tarball = await releaseBytes(dist["dist.tarball"], fetcher);
5046
6941
  const match = /^(sha512|sha256)-([A-Za-z0-9+/=]+)$/.exec(dist["dist.integrity"]);
5047
- if (!match || createHash2(match[1] ?? "sha512").update(tarball).digest("base64") !== match[2])
6942
+ if (!match || createHash3(match[1] ?? "sha512").update(tarball).digest("base64") !== match[2])
5048
6943
  throw new RuntimeError2("digest_mismatch");
5049
6944
  const contents = unpack(tarball);
5050
6945
  const pkg = JSON.parse(contents["package.json"]?.toString() ?? "{}");
@@ -5087,19 +6982,25 @@ async function npmReleaseSource(fetcher = fetch, view = async () => {
5087
6982
  };
5088
6983
  }
5089
6984
  var tarballFilesSize = (files) => Object.values(files).reduce((sum, b) => sum + b.length, 0);
6985
+ var trustedScannerRelease = async () => JSON.parse(
6986
+ await readFile2(
6987
+ process.env.MNEMONIK_DEV_RELEASE_DIR ? join5(process.env.MNEMONIK_DEV_RELEASE_DIR, "scanner-release.json") : new URL("../scanner-release.json", import.meta.url),
6988
+ "utf8"
6989
+ )
6990
+ );
5090
6991
  async function releaseSource(artifact) {
5091
6992
  if (artifact === "cli") return npmReleaseSource();
5092
- const trusted = JSON.parse(
5093
- await readFile(
5094
- process.env.MNEMONIK_DEV_RELEASE_DIR ? join3(process.env.MNEMONIK_DEV_RELEASE_DIR, "scanner-release.json") : new URL("../scanner-release.json", import.meta.url),
5095
- "utf8"
5096
- )
5097
- );
5098
- return scannerReleaseSource(trusted);
6993
+ return scannerReleaseSource(await trustedScannerRelease());
6994
+ }
6995
+ async function expectedScannerDisclosureVersion(platform = `${process.platform === "win32" ? "win" : process.platform}-${process.arch}`) {
6996
+ const trusted = await trustedScannerRelease().catch(() => void 0);
6997
+ const version = trusted?.platforms?.[platform]?.disclosureVersion;
6998
+ return typeof version === "string" ? version : void 0;
5099
6999
  }
5100
7000
  export {
5101
7001
  devReadiness,
5102
7002
  devReleaseActive,
7003
+ expectedScannerDisclosureVersion,
5103
7004
  npmReleaseSource,
5104
7005
  releaseBytes,
5105
7006
  releasePackageNames,