@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.
- package/dist/auth/credentials.js +297 -36
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +1914 -19
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/machineName.d.ts +8 -0
- package/dist/auth/machineName.d.ts.map +1 -0
- package/dist/auth/machineName.js +23 -0
- package/dist/auth/machineName.js.map +1 -0
- package/dist/consent.d.ts +29 -0
- package/dist/consent.d.ts.map +1 -0
- package/dist/consent.js +87 -0
- package/dist/consent.js.map +1 -0
- package/dist/diagnostics.js +301 -40
- package/dist/digests.json +102 -90
- package/dist/help.d.ts.map +1 -1
- package/dist/help.js +59 -44
- package/dist/help.js.map +1 -1
- package/dist/humanReason.d.ts +8 -0
- package/dist/humanReason.d.ts.map +1 -1
- package/dist/humanReason.js +44 -16
- package/dist/humanReason.js.map +1 -1
- package/dist/identity/migrate.js +1835 -44
- package/dist/install/hosts.d.ts +2 -0
- package/dist/install/hosts.d.ts.map +1 -1
- package/dist/install/hosts.js +23 -14
- package/dist/install/hosts.js.map +1 -1
- package/dist/install/journal.js +124 -11
- package/dist/install/journey.d.ts +20 -0
- package/dist/install/journey.d.ts.map +1 -1
- package/dist/install/journey.js +1913 -82
- package/dist/install/journey.js.map +1 -1
- package/dist/install/ownership.d.ts.map +1 -1
- package/dist/install/ownership.js +1818 -10
- package/dist/install/ownership.js.map +1 -1
- package/dist/install/transaction.js +1913 -19
- package/dist/install/ui.js +1910 -15
- package/dist/installation.js +133 -10
- package/dist/launcher.js +108 -4
- package/dist/output.d.ts +3 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +11 -1
- package/dist/output.js.map +1 -1
- package/dist/preflight.d.ts +5 -0
- package/dist/preflight.d.ts.map +1 -1
- package/dist/preflight.js +14 -12
- package/dist/preflight.js.map +1 -1
- package/dist/project/eligibility.js +1917 -22
- package/dist/project/records.js +121 -8
- package/dist/project.d.ts +15 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +229 -15
- package/dist/project.js.map +1 -1
- package/dist/router.d.ts +2 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +2164 -122
- package/dist/router.js.map +1 -1
- package/dist/runtime/releaseSource.d.ts +6 -0
- package/dist/runtime/releaseSource.d.ts.map +1 -1
- package/dist/runtime/releaseSource.js +1933 -32
- package/dist/runtime/releaseSource.js.map +1 -1
- package/dist/runtime/selfUpdate.js +1809 -8
- package/dist/runtime/signers.js +28 -9
- package/dist/runtime/store.js +18 -6
- package/dist/runtime/updateCheck.d.ts +4 -0
- package/dist/runtime/updateCheck.d.ts.map +1 -0
- package/dist/runtime/updateCheck.js +6695 -0
- package/dist/runtime/updateCheck.js.map +1 -0
- package/dist/sbom.json +21 -21
- package/dist/scanner/control.d.ts +27 -1
- package/dist/scanner/control.d.ts.map +1 -1
- package/dist/scanner/control.js +207 -36
- package/dist/scanner/control.js.map +1 -1
- package/dist/scanner/discover.d.ts +5 -0
- package/dist/scanner/discover.d.ts.map +1 -1
- package/dist/scanner/discover.js +16 -6
- package/dist/scanner/discover.js.map +1 -1
- package/dist/scanner/enable.d.ts +2 -0
- package/dist/scanner/enable.d.ts.map +1 -1
- package/dist/scanner/enable.js +152 -14
- package/dist/scanner/enable.js.map +1 -1
- package/dist/scanner/picker.d.ts.map +1 -1
- package/dist/scanner/picker.js +5 -6
- package/dist/scanner/picker.js.map +1 -1
- package/dist/scanner/service.d.ts +2 -0
- package/dist/scanner/service.d.ts.map +1 -1
- package/dist/scanner/service.js +279 -54
- package/dist/scanner/service.js.map +1 -1
- package/dist/scanner/update.d.ts +8 -0
- package/dist/scanner/update.d.ts.map +1 -1
- package/dist/scanner/update.js +254 -20
- package/dist/scanner/update.js.map +1 -1
- package/dist/scanner-release.json +35 -30
- package/dist/screens/journey.d.ts +6 -1
- package/dist/screens/journey.d.ts.map +1 -1
- package/dist/screens/journey.js +29 -8
- package/dist/screens/journey.js.map +1 -1
- package/dist/status.d.ts +21 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +1993 -39
- package/dist/status.js.map +1 -1
- package/dist/vendor/local-setup.js +256 -29
- package/dist/vendor/shared/runtimeSigners.js +38 -11
- 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
|
|
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
|
-
|
|
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",
|
|
@@ -575,11 +600,20 @@ var init_repositoryRoot = __esm({
|
|
|
575
600
|
});
|
|
576
601
|
|
|
577
602
|
// packages/shared/dist/runtimeReader.js
|
|
603
|
+
var RuntimeError;
|
|
578
604
|
var init_runtimeReader = __esm({
|
|
579
605
|
"packages/shared/dist/runtimeReader.js"() {
|
|
580
606
|
"use strict";
|
|
581
607
|
init_runtimeSigners();
|
|
582
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
|
+
};
|
|
583
617
|
}
|
|
584
618
|
});
|
|
585
619
|
|
|
@@ -604,10 +638,1587 @@ var init_hookRuntime = __esm({
|
|
|
604
638
|
}
|
|
605
639
|
});
|
|
606
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 = appendFile;
|
|
1169
|
+
function appendFile(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 counts = {};
|
|
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 = (counts[message] || 0) + 1;
|
|
1538
|
+
counts[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) {
|
|
1841
|
+
"use strict";
|
|
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;
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
|
|
1880
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1881
|
+
var require_lockfile = __commonJS({
|
|
1882
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module2) {
|
|
1883
|
+
"use strict";
|
|
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;
|
|
2114
|
+
}
|
|
2115
|
+
});
|
|
2116
|
+
|
|
2117
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
2118
|
+
var require_adapter = __commonJS({
|
|
2119
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module2) {
|
|
2120
|
+
"use strict";
|
|
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
|
+
};
|
|
2179
|
+
}
|
|
2180
|
+
});
|
|
2181
|
+
|
|
2182
|
+
// node_modules/proper-lockfile/index.js
|
|
2183
|
+
var require_proper_lockfile = __commonJS({
|
|
2184
|
+
"node_modules/proper-lockfile/index.js"(exports, module2) {
|
|
2185
|
+
"use strict";
|
|
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;
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
2217
|
+
|
|
607
2218
|
// packages/cli/src/runtime/selfUpdate.ts
|
|
608
2219
|
import { humanReason } from "../humanReason.js";
|
|
609
2220
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
610
|
-
import { join as
|
|
2221
|
+
import { join as join5 } from "node:path";
|
|
611
2222
|
|
|
612
2223
|
// packages/shared/dist/instructions.js
|
|
613
2224
|
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.
|
|
@@ -2116,8 +3727,8 @@ var Language = class _Language {
|
|
|
2116
3727
|
if (input instanceof Uint8Array) {
|
|
2117
3728
|
binary2 = input;
|
|
2118
3729
|
} else if (globalThis.process?.versions.node) {
|
|
2119
|
-
const
|
|
2120
|
-
binary2 = await
|
|
3730
|
+
const fs22 = await import("fs/promises");
|
|
3731
|
+
binary2 = await fs22.readFile(input);
|
|
2121
3732
|
} else {
|
|
2122
3733
|
const response = await fetch(input);
|
|
2123
3734
|
if (!response.ok) {
|
|
@@ -4801,11 +6412,40 @@ init_repositoryRoot();
|
|
|
4801
6412
|
|
|
4802
6413
|
// packages/local-setup/dist/storage.js
|
|
4803
6414
|
init_hookRuntime();
|
|
6415
|
+
init_hookRuntime();
|
|
4804
6416
|
import { createHash, randomUUID } from "node:crypto";
|
|
4805
6417
|
import { execFile as nodeExecFile } from "node:child_process";
|
|
6418
|
+
import fs2 from "node:fs";
|
|
4806
6419
|
import { open, rename, readFile, mkdir, lstat, chmod, writeFile, unlink, rmdir } from "node:fs/promises";
|
|
6420
|
+
import { homedir } from "node:os";
|
|
4807
6421
|
import { dirname as dirname3, join as join3, win32 as win322, posix } from "node:path";
|
|
4808
|
-
|
|
6422
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
6423
|
+
var lockfileKey = /* @__PURE__ */ Symbol.for("mnemonik.proper-lockfile");
|
|
6424
|
+
function sharedLockfile() {
|
|
6425
|
+
const shared = globalThis;
|
|
6426
|
+
return shared[lockfileKey] ??= Promise.resolve().then(() => __toESM(require_proper_lockfile(), 1)).then((module2) => module2.default);
|
|
6427
|
+
}
|
|
6428
|
+
var codeIs = (error, code) => error.code === code;
|
|
6429
|
+
function stateDirectory(platform = process.platform, env = process.env, home = homedir()) {
|
|
6430
|
+
if (env.MNEMONIK_STATE_DIR)
|
|
6431
|
+
return env.MNEMONIK_STATE_DIR;
|
|
6432
|
+
if (platform === "win32")
|
|
6433
|
+
return win322.join(env.LOCALAPPDATA || win322.join(home, "AppData", "Local"), "Mnemonik");
|
|
6434
|
+
if (platform === "darwin")
|
|
6435
|
+
return posix.join(home, "Library", "Application Support", "Mnemonik");
|
|
6436
|
+
return posix.join(env.XDG_STATE_HOME || posix.join(home, ".local", "state"), "mnemonik");
|
|
6437
|
+
}
|
|
6438
|
+
async function readBytes(path) {
|
|
6439
|
+
try {
|
|
6440
|
+
if (!(await lstat(path)).isFile())
|
|
6441
|
+
throw new Error("setup_requires_regular_file");
|
|
6442
|
+
return await readFile(path);
|
|
6443
|
+
} catch (error) {
|
|
6444
|
+
if (codeIs(error, "ENOENT"))
|
|
6445
|
+
return null;
|
|
6446
|
+
throw error;
|
|
6447
|
+
}
|
|
6448
|
+
}
|
|
4809
6449
|
async function syncDirectory(path) {
|
|
4810
6450
|
if (process.platform === "win32")
|
|
4811
6451
|
return;
|
|
@@ -4864,6 +6504,167 @@ async function atomicWrite(path, bytes, fault, assertOwned) {
|
|
|
4864
6504
|
await syncDirectory(dirname3(path));
|
|
4865
6505
|
return permissionStatus;
|
|
4866
6506
|
}
|
|
6507
|
+
async function withLock(path, waitMs, work) {
|
|
6508
|
+
const lockfile = await sharedLockfile();
|
|
6509
|
+
await mkdir(dirname3(path), { recursive: true, mode: 448 });
|
|
6510
|
+
const generation = randomUUID();
|
|
6511
|
+
const owner = join3(`${path}.lock`, "owner");
|
|
6512
|
+
let compromised = false;
|
|
6513
|
+
let acquired = false;
|
|
6514
|
+
const assertOwned = async () => {
|
|
6515
|
+
if (compromised || (await readBytes(owner).catch(() => null))?.toString() !== generation) {
|
|
6516
|
+
compromised = true;
|
|
6517
|
+
throw new Error("lock_lost");
|
|
6518
|
+
}
|
|
6519
|
+
};
|
|
6520
|
+
const leaseFs = {
|
|
6521
|
+
...fs2,
|
|
6522
|
+
mkdir: (dir, callback) => {
|
|
6523
|
+
void mkdir(dir).then(() => writeFile(owner, generation, { mode: 384, flag: "wx" })).then(() => callback(), callback);
|
|
6524
|
+
},
|
|
6525
|
+
rmdir: (dir, callback) => {
|
|
6526
|
+
void unlink(join3(dir, "owner")).catch((error) => {
|
|
6527
|
+
if (!codeIs(error, "ENOENT"))
|
|
6528
|
+
throw error;
|
|
6529
|
+
}).then(() => rmdir(dir)).then(() => callback(), callback);
|
|
6530
|
+
},
|
|
6531
|
+
rmdirSync: (dir) => {
|
|
6532
|
+
try {
|
|
6533
|
+
fs2.unlinkSync(join3(dir, "owner"));
|
|
6534
|
+
} catch (error) {
|
|
6535
|
+
if (!codeIs(error, "ENOENT"))
|
|
6536
|
+
throw error;
|
|
6537
|
+
}
|
|
6538
|
+
fs2.rmdirSync(dir);
|
|
6539
|
+
},
|
|
6540
|
+
stat: (file, callback) => {
|
|
6541
|
+
void (acquired ? assertOwned() : Promise.resolve()).then(() => fs2.stat(file, callback), () => callback(Object.assign(new Error("lock_lost"), { code: "ENOENT" })));
|
|
6542
|
+
}
|
|
6543
|
+
};
|
|
6544
|
+
const deadline = performance.now() + waitMs;
|
|
6545
|
+
let release;
|
|
6546
|
+
while (!release) {
|
|
6547
|
+
try {
|
|
6548
|
+
release = await lockfile.lock(path, {
|
|
6549
|
+
realpath: false,
|
|
6550
|
+
stale: 3e4,
|
|
6551
|
+
update: 5e3,
|
|
6552
|
+
retries: 0,
|
|
6553
|
+
fs: leaseFs,
|
|
6554
|
+
onCompromised: () => {
|
|
6555
|
+
compromised = true;
|
|
6556
|
+
}
|
|
6557
|
+
});
|
|
6558
|
+
} catch (error) {
|
|
6559
|
+
if (!codeIs(error, "ELOCKED"))
|
|
6560
|
+
throw error;
|
|
6561
|
+
if (performance.now() >= deadline)
|
|
6562
|
+
throw new RuntimeError("lock_held");
|
|
6563
|
+
await delay(Math.min(100, Math.max(1, deadline - performance.now())));
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
acquired = true;
|
|
6567
|
+
try {
|
|
6568
|
+
return await work(assertOwned);
|
|
6569
|
+
} finally {
|
|
6570
|
+
if (await assertOwned().then(() => true, () => false))
|
|
6571
|
+
await release();
|
|
6572
|
+
}
|
|
6573
|
+
}
|
|
6574
|
+
|
|
6575
|
+
// packages/local-setup/dist/automaticUpdate.js
|
|
6576
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
6577
|
+
import { realpathSync } from "node:fs";
|
|
6578
|
+
import { stat as nodeStat, utimes } from "node:fs/promises";
|
|
6579
|
+
import { homedir as homedir2 } from "node:os";
|
|
6580
|
+
import { join as join4 } from "node:path";
|
|
6581
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6582
|
+
var DAY_MS = 864e5;
|
|
6583
|
+
var statePath = (stateDir) => join4(stateDir, "automatic-update.json");
|
|
6584
|
+
function cliLauncherPath(options = {}) {
|
|
6585
|
+
const platform = options.platform ?? process.platform;
|
|
6586
|
+
const home = options.home ?? homedir2();
|
|
6587
|
+
return platform === "win32" ? join4(options.env?.LOCALAPPDATA || join4(home, "AppData", "Local"), "Mnemonik", "bin", "mnemonik.cmd") : join4(home, ".local", "bin", "mnemonik");
|
|
6588
|
+
}
|
|
6589
|
+
async function readState(path) {
|
|
6590
|
+
const bytes = await readBytes(path);
|
|
6591
|
+
if (!bytes)
|
|
6592
|
+
return {};
|
|
6593
|
+
const value = JSON.parse(bytes.toString());
|
|
6594
|
+
if (!value || typeof value !== "object" || value.lastAttempt !== void 0 && (!Number.isFinite(value.lastAttempt) || value.lastAttempt < 0))
|
|
6595
|
+
throw new Error("automatic_update_state_invalid");
|
|
6596
|
+
return value.lastAttempt === void 0 ? {} : { lastAttempt: value.lastAttempt };
|
|
6597
|
+
}
|
|
6598
|
+
async function maybeStartAutomaticUpdate(options = {}) {
|
|
6599
|
+
const stateDir = options.stateDir ?? stateDirectory(options.platform, options.env, options.home);
|
|
6600
|
+
const path = statePath(stateDir);
|
|
6601
|
+
try {
|
|
6602
|
+
const now = (options.now ?? Date.now)();
|
|
6603
|
+
const stat = options.stat ?? nodeStat;
|
|
6604
|
+
try {
|
|
6605
|
+
if (now - (await stat(path)).mtimeMs < DAY_MS)
|
|
6606
|
+
return false;
|
|
6607
|
+
} catch (error) {
|
|
6608
|
+
if (error.code !== "ENOENT")
|
|
6609
|
+
throw error;
|
|
6610
|
+
}
|
|
6611
|
+
if (!options.spawn && !(await stat(cliLauncherPath(options))).isFile())
|
|
6612
|
+
return false;
|
|
6613
|
+
return await withLock(path, 0, async (assertOwned) => {
|
|
6614
|
+
const state = await readState(path);
|
|
6615
|
+
if (state.lastAttempt !== void 0 && now - state.lastAttempt < DAY_MS)
|
|
6616
|
+
return false;
|
|
6617
|
+
await atomicWrite(path, Buffer.from(`${JSON.stringify({ lastAttempt: now })}
|
|
6618
|
+
`), void 0, assertOwned);
|
|
6619
|
+
await utimes(path, now / 1e3, now / 1e3);
|
|
6620
|
+
const platform = options.platform ?? process.platform;
|
|
6621
|
+
const launcher = cliLauncherPath(options);
|
|
6622
|
+
const command = platform === "win32" ? {
|
|
6623
|
+
file: options.env?.ComSpec || "cmd.exe",
|
|
6624
|
+
args: ["/d", "/s", "/c", `""${launcher}" update --automatic"`],
|
|
6625
|
+
windowsVerbatimArguments: true
|
|
6626
|
+
} : platform === "linux" && (options.env ?? process.env).INVOCATION_ID ? {
|
|
6627
|
+
// detached creates a process group, not a new systemd cgroup. An
|
|
6628
|
+
// updater spawned by the scanner must survive stopping that service.
|
|
6629
|
+
file: "systemd-run",
|
|
6630
|
+
args: [
|
|
6631
|
+
"--user",
|
|
6632
|
+
"--collect",
|
|
6633
|
+
"--quiet",
|
|
6634
|
+
`--setenv=MNEMONIK_STATE_DIR=${stateDir}`,
|
|
6635
|
+
"--",
|
|
6636
|
+
launcher,
|
|
6637
|
+
"update",
|
|
6638
|
+
"--automatic"
|
|
6639
|
+
]
|
|
6640
|
+
} : { file: launcher, args: ["update", "--automatic"] };
|
|
6641
|
+
const child = (options.spawn ?? nodeSpawn)(command.file, command.args, {
|
|
6642
|
+
detached: true,
|
|
6643
|
+
stdio: "ignore",
|
|
6644
|
+
windowsHide: true,
|
|
6645
|
+
..."windowsVerbatimArguments" in command ? { windowsVerbatimArguments: command.windowsVerbatimArguments } : {}
|
|
6646
|
+
});
|
|
6647
|
+
child.once("error", () => {
|
|
6648
|
+
});
|
|
6649
|
+
child.unref();
|
|
6650
|
+
return true;
|
|
6651
|
+
});
|
|
6652
|
+
} catch {
|
|
6653
|
+
return false;
|
|
6654
|
+
}
|
|
6655
|
+
}
|
|
6656
|
+
var HELPER_FLAG = "--mnemonik-automatic-update";
|
|
6657
|
+
function isHelperInvocation() {
|
|
6658
|
+
if (process.argv[2] !== HELPER_FLAG || !process.argv[3] || !process.argv[1])
|
|
6659
|
+
return false;
|
|
6660
|
+
try {
|
|
6661
|
+
return realpathSync(process.argv[1]) === realpathSync(fileURLToPath2(import.meta.url));
|
|
6662
|
+
} catch {
|
|
6663
|
+
return false;
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
if (isHelperInvocation())
|
|
6667
|
+
void maybeStartAutomaticUpdate({ stateDir: process.argv[3] });
|
|
4867
6668
|
|
|
4868
6669
|
// packages/local-setup/dist/index.js
|
|
4869
6670
|
var MAX_ORIGINAL_BYTES = 64 * 1024;
|
|
@@ -4925,7 +6726,7 @@ function cliUpdateLine(result) {
|
|
|
4925
6726
|
return humanReason(result.reason ?? "update_failed");
|
|
4926
6727
|
}
|
|
4927
6728
|
async function cliUpdateHint(store, current) {
|
|
4928
|
-
const path =
|
|
6729
|
+
const path = join5(store.state, "cli-update-check.json");
|
|
4929
6730
|
const devReleaseSource = process.env.MNEMONIK_DEV_RELEASE_DIR ?? "";
|
|
4930
6731
|
let cached;
|
|
4931
6732
|
try {
|