@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.
- 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
package/dist/identity/migrate.js
CHANGED
|
@@ -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",
|
|
@@ -636,11 +661,20 @@ var init_repositoryRoot = __esm({
|
|
|
636
661
|
});
|
|
637
662
|
|
|
638
663
|
// packages/shared/dist/runtimeReader.js
|
|
664
|
+
var RuntimeError;
|
|
639
665
|
var init_runtimeReader = __esm({
|
|
640
666
|
"packages/shared/dist/runtimeReader.js"() {
|
|
641
667
|
"use strict";
|
|
642
668
|
init_runtimeSigners();
|
|
643
669
|
init_runtimeSigners();
|
|
670
|
+
RuntimeError = class extends Error {
|
|
671
|
+
reason;
|
|
672
|
+
constructor(reason) {
|
|
673
|
+
super(reason);
|
|
674
|
+
this.reason = reason;
|
|
675
|
+
this.name = "RuntimeError";
|
|
676
|
+
}
|
|
677
|
+
};
|
|
644
678
|
}
|
|
645
679
|
});
|
|
646
680
|
|
|
@@ -665,11 +699,1588 @@ var init_hookRuntime = __esm({
|
|
|
665
699
|
}
|
|
666
700
|
});
|
|
667
701
|
|
|
702
|
+
// node_modules/graceful-fs/polyfills.js
|
|
703
|
+
var require_polyfills = __commonJS({
|
|
704
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module2) {
|
|
705
|
+
var constants = __require("constants");
|
|
706
|
+
var origCwd = process.cwd;
|
|
707
|
+
var cwd = null;
|
|
708
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
709
|
+
process.cwd = function() {
|
|
710
|
+
if (!cwd)
|
|
711
|
+
cwd = origCwd.call(process);
|
|
712
|
+
return cwd;
|
|
713
|
+
};
|
|
714
|
+
try {
|
|
715
|
+
process.cwd();
|
|
716
|
+
} catch (er) {
|
|
717
|
+
}
|
|
718
|
+
if (typeof process.chdir === "function") {
|
|
719
|
+
chdir = process.chdir;
|
|
720
|
+
process.chdir = function(d) {
|
|
721
|
+
cwd = null;
|
|
722
|
+
chdir.call(process, d);
|
|
723
|
+
};
|
|
724
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
725
|
+
}
|
|
726
|
+
var chdir;
|
|
727
|
+
module2.exports = patch;
|
|
728
|
+
function patch(fs3) {
|
|
729
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
730
|
+
patchLchmod(fs3);
|
|
731
|
+
}
|
|
732
|
+
if (!fs3.lutimes) {
|
|
733
|
+
patchLutimes(fs3);
|
|
734
|
+
}
|
|
735
|
+
fs3.chown = chownFix(fs3.chown);
|
|
736
|
+
fs3.fchown = chownFix(fs3.fchown);
|
|
737
|
+
fs3.lchown = chownFix(fs3.lchown);
|
|
738
|
+
fs3.chmod = chmodFix(fs3.chmod);
|
|
739
|
+
fs3.fchmod = chmodFix(fs3.fchmod);
|
|
740
|
+
fs3.lchmod = chmodFix(fs3.lchmod);
|
|
741
|
+
fs3.chownSync = chownFixSync(fs3.chownSync);
|
|
742
|
+
fs3.fchownSync = chownFixSync(fs3.fchownSync);
|
|
743
|
+
fs3.lchownSync = chownFixSync(fs3.lchownSync);
|
|
744
|
+
fs3.chmodSync = chmodFixSync(fs3.chmodSync);
|
|
745
|
+
fs3.fchmodSync = chmodFixSync(fs3.fchmodSync);
|
|
746
|
+
fs3.lchmodSync = chmodFixSync(fs3.lchmodSync);
|
|
747
|
+
fs3.stat = statFix(fs3.stat);
|
|
748
|
+
fs3.fstat = statFix(fs3.fstat);
|
|
749
|
+
fs3.lstat = statFix(fs3.lstat);
|
|
750
|
+
fs3.statSync = statFixSync(fs3.statSync);
|
|
751
|
+
fs3.fstatSync = statFixSync(fs3.fstatSync);
|
|
752
|
+
fs3.lstatSync = statFixSync(fs3.lstatSync);
|
|
753
|
+
if (fs3.chmod && !fs3.lchmod) {
|
|
754
|
+
fs3.lchmod = function(path, mode, cb) {
|
|
755
|
+
if (cb) process.nextTick(cb);
|
|
756
|
+
};
|
|
757
|
+
fs3.lchmodSync = function() {
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
if (fs3.chown && !fs3.lchown) {
|
|
761
|
+
fs3.lchown = function(path, uid, gid, cb) {
|
|
762
|
+
if (cb) process.nextTick(cb);
|
|
763
|
+
};
|
|
764
|
+
fs3.lchownSync = function() {
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
if (platform === "win32") {
|
|
768
|
+
fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : (function(fs$rename) {
|
|
769
|
+
function rename2(from, to, cb) {
|
|
770
|
+
var start2 = Date.now();
|
|
771
|
+
var backoff = 0;
|
|
772
|
+
fs$rename(from, to, function CB(er) {
|
|
773
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
|
|
774
|
+
setTimeout(function() {
|
|
775
|
+
fs3.stat(to, function(stater, st) {
|
|
776
|
+
if (stater && stater.code === "ENOENT")
|
|
777
|
+
fs$rename(from, to, CB);
|
|
778
|
+
else
|
|
779
|
+
cb(er);
|
|
780
|
+
});
|
|
781
|
+
}, backoff);
|
|
782
|
+
if (backoff < 100)
|
|
783
|
+
backoff += 10;
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (cb) cb(er);
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
790
|
+
return rename2;
|
|
791
|
+
})(fs3.rename);
|
|
792
|
+
}
|
|
793
|
+
fs3.read = typeof fs3.read !== "function" ? fs3.read : (function(fs$read) {
|
|
794
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
795
|
+
var callback;
|
|
796
|
+
if (callback_ && typeof callback_ === "function") {
|
|
797
|
+
var eagCounter = 0;
|
|
798
|
+
callback = function(er, _, __) {
|
|
799
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
800
|
+
eagCounter++;
|
|
801
|
+
return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
|
|
802
|
+
}
|
|
803
|
+
callback_.apply(this, arguments);
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
|
|
807
|
+
}
|
|
808
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
809
|
+
return read;
|
|
810
|
+
})(fs3.read);
|
|
811
|
+
fs3.readSync = typeof fs3.readSync !== "function" ? fs3.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
812
|
+
return function(fd, buffer, offset, length, position) {
|
|
813
|
+
var eagCounter = 0;
|
|
814
|
+
while (true) {
|
|
815
|
+
try {
|
|
816
|
+
return fs$readSync.call(fs3, fd, buffer, offset, length, position);
|
|
817
|
+
} catch (er) {
|
|
818
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
819
|
+
eagCounter++;
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
throw er;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
})(fs3.readSync);
|
|
827
|
+
function patchLchmod(fs4) {
|
|
828
|
+
fs4.lchmod = function(path, mode, callback) {
|
|
829
|
+
fs4.open(
|
|
830
|
+
path,
|
|
831
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
832
|
+
mode,
|
|
833
|
+
function(err2, fd) {
|
|
834
|
+
if (err2) {
|
|
835
|
+
if (callback) callback(err2);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
fs4.fchmod(fd, mode, function(err3) {
|
|
839
|
+
fs4.close(fd, function(err22) {
|
|
840
|
+
if (callback) callback(err3 || err22);
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
);
|
|
845
|
+
};
|
|
846
|
+
fs4.lchmodSync = function(path, mode) {
|
|
847
|
+
var fd = fs4.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
848
|
+
var threw = true;
|
|
849
|
+
var ret;
|
|
850
|
+
try {
|
|
851
|
+
ret = fs4.fchmodSync(fd, mode);
|
|
852
|
+
threw = false;
|
|
853
|
+
} finally {
|
|
854
|
+
if (threw) {
|
|
855
|
+
try {
|
|
856
|
+
fs4.closeSync(fd);
|
|
857
|
+
} catch (er) {
|
|
858
|
+
}
|
|
859
|
+
} else {
|
|
860
|
+
fs4.closeSync(fd);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return ret;
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function patchLutimes(fs4) {
|
|
867
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs4.futimes) {
|
|
868
|
+
fs4.lutimes = function(path, at, mt, cb) {
|
|
869
|
+
fs4.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
870
|
+
if (er) {
|
|
871
|
+
if (cb) cb(er);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
fs4.futimes(fd, at, mt, function(er2) {
|
|
875
|
+
fs4.close(fd, function(er22) {
|
|
876
|
+
if (cb) cb(er2 || er22);
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
});
|
|
880
|
+
};
|
|
881
|
+
fs4.lutimesSync = function(path, at, mt) {
|
|
882
|
+
var fd = fs4.openSync(path, constants.O_SYMLINK);
|
|
883
|
+
var ret;
|
|
884
|
+
var threw = true;
|
|
885
|
+
try {
|
|
886
|
+
ret = fs4.futimesSync(fd, at, mt);
|
|
887
|
+
threw = false;
|
|
888
|
+
} finally {
|
|
889
|
+
if (threw) {
|
|
890
|
+
try {
|
|
891
|
+
fs4.closeSync(fd);
|
|
892
|
+
} catch (er) {
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
fs4.closeSync(fd);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return ret;
|
|
899
|
+
};
|
|
900
|
+
} else if (fs4.futimes) {
|
|
901
|
+
fs4.lutimes = function(_a, _b, _c, cb) {
|
|
902
|
+
if (cb) process.nextTick(cb);
|
|
903
|
+
};
|
|
904
|
+
fs4.lutimesSync = function() {
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
function chmodFix(orig) {
|
|
909
|
+
if (!orig) return orig;
|
|
910
|
+
return function(target, mode, cb) {
|
|
911
|
+
return orig.call(fs3, target, mode, function(er) {
|
|
912
|
+
if (chownErOk(er)) er = null;
|
|
913
|
+
if (cb) cb.apply(this, arguments);
|
|
914
|
+
});
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
function chmodFixSync(orig) {
|
|
918
|
+
if (!orig) return orig;
|
|
919
|
+
return function(target, mode) {
|
|
920
|
+
try {
|
|
921
|
+
return orig.call(fs3, target, mode);
|
|
922
|
+
} catch (er) {
|
|
923
|
+
if (!chownErOk(er)) throw er;
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
function chownFix(orig) {
|
|
928
|
+
if (!orig) return orig;
|
|
929
|
+
return function(target, uid, gid, cb) {
|
|
930
|
+
return orig.call(fs3, target, uid, gid, function(er) {
|
|
931
|
+
if (chownErOk(er)) er = null;
|
|
932
|
+
if (cb) cb.apply(this, arguments);
|
|
933
|
+
});
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
function chownFixSync(orig) {
|
|
937
|
+
if (!orig) return orig;
|
|
938
|
+
return function(target, uid, gid) {
|
|
939
|
+
try {
|
|
940
|
+
return orig.call(fs3, target, uid, gid);
|
|
941
|
+
} catch (er) {
|
|
942
|
+
if (!chownErOk(er)) throw er;
|
|
943
|
+
}
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
function statFix(orig) {
|
|
947
|
+
if (!orig) return orig;
|
|
948
|
+
return function(target, options, cb) {
|
|
949
|
+
if (typeof options === "function") {
|
|
950
|
+
cb = options;
|
|
951
|
+
options = null;
|
|
952
|
+
}
|
|
953
|
+
function callback(er, stats) {
|
|
954
|
+
if (stats) {
|
|
955
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
956
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
957
|
+
}
|
|
958
|
+
if (cb) cb.apply(this, arguments);
|
|
959
|
+
}
|
|
960
|
+
return options ? orig.call(fs3, target, options, callback) : orig.call(fs3, target, callback);
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
function statFixSync(orig) {
|
|
964
|
+
if (!orig) return orig;
|
|
965
|
+
return function(target, options) {
|
|
966
|
+
var stats = options ? orig.call(fs3, target, options) : orig.call(fs3, target);
|
|
967
|
+
if (stats) {
|
|
968
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
969
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
970
|
+
}
|
|
971
|
+
return stats;
|
|
972
|
+
};
|
|
973
|
+
}
|
|
974
|
+
function chownErOk(er) {
|
|
975
|
+
if (!er)
|
|
976
|
+
return true;
|
|
977
|
+
if (er.code === "ENOSYS")
|
|
978
|
+
return true;
|
|
979
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
980
|
+
if (nonroot) {
|
|
981
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
982
|
+
return true;
|
|
983
|
+
}
|
|
984
|
+
return false;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
|
|
990
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
991
|
+
var require_legacy_streams = __commonJS({
|
|
992
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
|
|
993
|
+
var Stream = __require("stream").Stream;
|
|
994
|
+
module2.exports = legacy;
|
|
995
|
+
function legacy(fs3) {
|
|
996
|
+
return {
|
|
997
|
+
ReadStream,
|
|
998
|
+
WriteStream
|
|
999
|
+
};
|
|
1000
|
+
function ReadStream(path, options) {
|
|
1001
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
1002
|
+
Stream.call(this);
|
|
1003
|
+
var self = this;
|
|
1004
|
+
this.path = path;
|
|
1005
|
+
this.fd = null;
|
|
1006
|
+
this.readable = true;
|
|
1007
|
+
this.paused = false;
|
|
1008
|
+
this.flags = "r";
|
|
1009
|
+
this.mode = 438;
|
|
1010
|
+
this.bufferSize = 64 * 1024;
|
|
1011
|
+
options = options || {};
|
|
1012
|
+
var keys = Object.keys(options);
|
|
1013
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
1014
|
+
var key = keys[index];
|
|
1015
|
+
this[key] = options[key];
|
|
1016
|
+
}
|
|
1017
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
1018
|
+
if (this.start !== void 0) {
|
|
1019
|
+
if ("number" !== typeof this.start) {
|
|
1020
|
+
throw TypeError("start must be a Number");
|
|
1021
|
+
}
|
|
1022
|
+
if (this.end === void 0) {
|
|
1023
|
+
this.end = Infinity;
|
|
1024
|
+
} else if ("number" !== typeof this.end) {
|
|
1025
|
+
throw TypeError("end must be a Number");
|
|
1026
|
+
}
|
|
1027
|
+
if (this.start > this.end) {
|
|
1028
|
+
throw new Error("start must be <= end");
|
|
1029
|
+
}
|
|
1030
|
+
this.pos = this.start;
|
|
1031
|
+
}
|
|
1032
|
+
if (this.fd !== null) {
|
|
1033
|
+
process.nextTick(function() {
|
|
1034
|
+
self._read();
|
|
1035
|
+
});
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
fs3.open(this.path, this.flags, this.mode, function(err2, fd) {
|
|
1039
|
+
if (err2) {
|
|
1040
|
+
self.emit("error", err2);
|
|
1041
|
+
self.readable = false;
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
self.fd = fd;
|
|
1045
|
+
self.emit("open", fd);
|
|
1046
|
+
self._read();
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
function WriteStream(path, options) {
|
|
1050
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
1051
|
+
Stream.call(this);
|
|
1052
|
+
this.path = path;
|
|
1053
|
+
this.fd = null;
|
|
1054
|
+
this.writable = true;
|
|
1055
|
+
this.flags = "w";
|
|
1056
|
+
this.encoding = "binary";
|
|
1057
|
+
this.mode = 438;
|
|
1058
|
+
this.bytesWritten = 0;
|
|
1059
|
+
options = options || {};
|
|
1060
|
+
var keys = Object.keys(options);
|
|
1061
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
1062
|
+
var key = keys[index];
|
|
1063
|
+
this[key] = options[key];
|
|
1064
|
+
}
|
|
1065
|
+
if (this.start !== void 0) {
|
|
1066
|
+
if ("number" !== typeof this.start) {
|
|
1067
|
+
throw TypeError("start must be a Number");
|
|
1068
|
+
}
|
|
1069
|
+
if (this.start < 0) {
|
|
1070
|
+
throw new Error("start must be >= zero");
|
|
1071
|
+
}
|
|
1072
|
+
this.pos = this.start;
|
|
1073
|
+
}
|
|
1074
|
+
this.busy = false;
|
|
1075
|
+
this._queue = [];
|
|
1076
|
+
if (this.fd === null) {
|
|
1077
|
+
this._open = fs3.open;
|
|
1078
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
1079
|
+
this.flush();
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
// node_modules/graceful-fs/clone.js
|
|
1087
|
+
var require_clone = __commonJS({
|
|
1088
|
+
"node_modules/graceful-fs/clone.js"(exports, module2) {
|
|
1089
|
+
"use strict";
|
|
1090
|
+
module2.exports = clone;
|
|
1091
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
1092
|
+
return obj.__proto__;
|
|
1093
|
+
};
|
|
1094
|
+
function clone(obj) {
|
|
1095
|
+
if (obj === null || typeof obj !== "object")
|
|
1096
|
+
return obj;
|
|
1097
|
+
if (obj instanceof Object)
|
|
1098
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
1099
|
+
else
|
|
1100
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
1101
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
1102
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
1103
|
+
});
|
|
1104
|
+
return copy;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
1110
|
+
var require_graceful_fs = __commonJS({
|
|
1111
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
|
|
1112
|
+
var fs3 = __require("fs");
|
|
1113
|
+
var polyfills = require_polyfills();
|
|
1114
|
+
var legacy = require_legacy_streams();
|
|
1115
|
+
var clone = require_clone();
|
|
1116
|
+
var util = __require("util");
|
|
1117
|
+
var gracefulQueue;
|
|
1118
|
+
var previousSymbol;
|
|
1119
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
1120
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
1121
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
1122
|
+
} else {
|
|
1123
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
1124
|
+
previousSymbol = "___graceful-fs.previous";
|
|
1125
|
+
}
|
|
1126
|
+
function noop() {
|
|
1127
|
+
}
|
|
1128
|
+
function publishQueue(context, queue2) {
|
|
1129
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
1130
|
+
get: function() {
|
|
1131
|
+
return queue2;
|
|
1132
|
+
}
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
var debug2 = noop;
|
|
1136
|
+
if (util.debuglog)
|
|
1137
|
+
debug2 = util.debuglog("gfs4");
|
|
1138
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
1139
|
+
debug2 = function() {
|
|
1140
|
+
var m = util.format.apply(util, arguments);
|
|
1141
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
1142
|
+
console.error(m);
|
|
1143
|
+
};
|
|
1144
|
+
if (!fs3[gracefulQueue]) {
|
|
1145
|
+
queue = global[gracefulQueue] || [];
|
|
1146
|
+
publishQueue(fs3, queue);
|
|
1147
|
+
fs3.close = (function(fs$close) {
|
|
1148
|
+
function close(fd, cb) {
|
|
1149
|
+
return fs$close.call(fs3, fd, function(err2) {
|
|
1150
|
+
if (!err2) {
|
|
1151
|
+
resetQueue();
|
|
1152
|
+
}
|
|
1153
|
+
if (typeof cb === "function")
|
|
1154
|
+
cb.apply(this, arguments);
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
Object.defineProperty(close, previousSymbol, {
|
|
1158
|
+
value: fs$close
|
|
1159
|
+
});
|
|
1160
|
+
return close;
|
|
1161
|
+
})(fs3.close);
|
|
1162
|
+
fs3.closeSync = (function(fs$closeSync) {
|
|
1163
|
+
function closeSync(fd) {
|
|
1164
|
+
fs$closeSync.apply(fs3, arguments);
|
|
1165
|
+
resetQueue();
|
|
1166
|
+
}
|
|
1167
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
1168
|
+
value: fs$closeSync
|
|
1169
|
+
});
|
|
1170
|
+
return closeSync;
|
|
1171
|
+
})(fs3.closeSync);
|
|
1172
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
1173
|
+
process.on("exit", function() {
|
|
1174
|
+
debug2(fs3[gracefulQueue]);
|
|
1175
|
+
__require("assert").equal(fs3[gracefulQueue].length, 0);
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
var queue;
|
|
1180
|
+
if (!global[gracefulQueue]) {
|
|
1181
|
+
publishQueue(global, fs3[gracefulQueue]);
|
|
1182
|
+
}
|
|
1183
|
+
module2.exports = patch(clone(fs3));
|
|
1184
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs3.__patched) {
|
|
1185
|
+
module2.exports = patch(fs3);
|
|
1186
|
+
fs3.__patched = true;
|
|
1187
|
+
}
|
|
1188
|
+
function patch(fs4) {
|
|
1189
|
+
polyfills(fs4);
|
|
1190
|
+
fs4.gracefulify = patch;
|
|
1191
|
+
fs4.createReadStream = createReadStream;
|
|
1192
|
+
fs4.createWriteStream = createWriteStream;
|
|
1193
|
+
var fs$readFile = fs4.readFile;
|
|
1194
|
+
fs4.readFile = readFile3;
|
|
1195
|
+
function readFile3(path, options, cb) {
|
|
1196
|
+
if (typeof options === "function")
|
|
1197
|
+
cb = options, options = null;
|
|
1198
|
+
return go$readFile(path, options, cb);
|
|
1199
|
+
function go$readFile(path2, options2, cb2, startTime) {
|
|
1200
|
+
return fs$readFile(path2, options2, function(err2) {
|
|
1201
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1202
|
+
enqueue([go$readFile, [path2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1203
|
+
else {
|
|
1204
|
+
if (typeof cb2 === "function")
|
|
1205
|
+
cb2.apply(this, arguments);
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
var fs$writeFile = fs4.writeFile;
|
|
1211
|
+
fs4.writeFile = writeFile2;
|
|
1212
|
+
function writeFile2(path, data, options, cb) {
|
|
1213
|
+
if (typeof options === "function")
|
|
1214
|
+
cb = options, options = null;
|
|
1215
|
+
return go$writeFile(path, data, options, cb);
|
|
1216
|
+
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
|
1217
|
+
return fs$writeFile(path2, data2, options2, function(err2) {
|
|
1218
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1219
|
+
enqueue([go$writeFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1220
|
+
else {
|
|
1221
|
+
if (typeof cb2 === "function")
|
|
1222
|
+
cb2.apply(this, arguments);
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
var fs$appendFile = fs4.appendFile;
|
|
1228
|
+
if (fs$appendFile)
|
|
1229
|
+
fs4.appendFile = appendFile;
|
|
1230
|
+
function appendFile(path, data, options, cb) {
|
|
1231
|
+
if (typeof options === "function")
|
|
1232
|
+
cb = options, options = null;
|
|
1233
|
+
return go$appendFile(path, data, options, cb);
|
|
1234
|
+
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
|
1235
|
+
return fs$appendFile(path2, data2, options2, function(err2) {
|
|
1236
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1237
|
+
enqueue([go$appendFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1238
|
+
else {
|
|
1239
|
+
if (typeof cb2 === "function")
|
|
1240
|
+
cb2.apply(this, arguments);
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
var fs$copyFile = fs4.copyFile;
|
|
1246
|
+
if (fs$copyFile)
|
|
1247
|
+
fs4.copyFile = copyFile;
|
|
1248
|
+
function copyFile(src, dest, flags2, cb) {
|
|
1249
|
+
if (typeof flags2 === "function") {
|
|
1250
|
+
cb = flags2;
|
|
1251
|
+
flags2 = 0;
|
|
1252
|
+
}
|
|
1253
|
+
return go$copyFile(src, dest, flags2, cb);
|
|
1254
|
+
function go$copyFile(src2, dest2, flags3, cb2, startTime) {
|
|
1255
|
+
return fs$copyFile(src2, dest2, flags3, function(err2) {
|
|
1256
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1257
|
+
enqueue([go$copyFile, [src2, dest2, flags3, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1258
|
+
else {
|
|
1259
|
+
if (typeof cb2 === "function")
|
|
1260
|
+
cb2.apply(this, arguments);
|
|
1261
|
+
}
|
|
1262
|
+
});
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
var fs$readdir = fs4.readdir;
|
|
1266
|
+
fs4.readdir = readdir2;
|
|
1267
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
1268
|
+
function readdir2(path, options, cb) {
|
|
1269
|
+
if (typeof options === "function")
|
|
1270
|
+
cb = options, options = null;
|
|
1271
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
|
|
1272
|
+
return fs$readdir(path2, fs$readdirCallback(
|
|
1273
|
+
path2,
|
|
1274
|
+
options2,
|
|
1275
|
+
cb2,
|
|
1276
|
+
startTime
|
|
1277
|
+
));
|
|
1278
|
+
} : function go$readdir2(path2, options2, cb2, startTime) {
|
|
1279
|
+
return fs$readdir(path2, options2, fs$readdirCallback(
|
|
1280
|
+
path2,
|
|
1281
|
+
options2,
|
|
1282
|
+
cb2,
|
|
1283
|
+
startTime
|
|
1284
|
+
));
|
|
1285
|
+
};
|
|
1286
|
+
return go$readdir(path, options, cb);
|
|
1287
|
+
function fs$readdirCallback(path2, options2, cb2, startTime) {
|
|
1288
|
+
return function(err2, files2) {
|
|
1289
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1290
|
+
enqueue([
|
|
1291
|
+
go$readdir,
|
|
1292
|
+
[path2, options2, cb2],
|
|
1293
|
+
err2,
|
|
1294
|
+
startTime || Date.now(),
|
|
1295
|
+
Date.now()
|
|
1296
|
+
]);
|
|
1297
|
+
else {
|
|
1298
|
+
if (files2 && files2.sort)
|
|
1299
|
+
files2.sort();
|
|
1300
|
+
if (typeof cb2 === "function")
|
|
1301
|
+
cb2.call(this, err2, files2);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
1307
|
+
var legStreams = legacy(fs4);
|
|
1308
|
+
ReadStream = legStreams.ReadStream;
|
|
1309
|
+
WriteStream = legStreams.WriteStream;
|
|
1310
|
+
}
|
|
1311
|
+
var fs$ReadStream = fs4.ReadStream;
|
|
1312
|
+
if (fs$ReadStream) {
|
|
1313
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
1314
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
1315
|
+
}
|
|
1316
|
+
var fs$WriteStream = fs4.WriteStream;
|
|
1317
|
+
if (fs$WriteStream) {
|
|
1318
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
1319
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
1320
|
+
}
|
|
1321
|
+
Object.defineProperty(fs4, "ReadStream", {
|
|
1322
|
+
get: function() {
|
|
1323
|
+
return ReadStream;
|
|
1324
|
+
},
|
|
1325
|
+
set: function(val) {
|
|
1326
|
+
ReadStream = val;
|
|
1327
|
+
},
|
|
1328
|
+
enumerable: true,
|
|
1329
|
+
configurable: true
|
|
1330
|
+
});
|
|
1331
|
+
Object.defineProperty(fs4, "WriteStream", {
|
|
1332
|
+
get: function() {
|
|
1333
|
+
return WriteStream;
|
|
1334
|
+
},
|
|
1335
|
+
set: function(val) {
|
|
1336
|
+
WriteStream = val;
|
|
1337
|
+
},
|
|
1338
|
+
enumerable: true,
|
|
1339
|
+
configurable: true
|
|
1340
|
+
});
|
|
1341
|
+
var FileReadStream = ReadStream;
|
|
1342
|
+
Object.defineProperty(fs4, "FileReadStream", {
|
|
1343
|
+
get: function() {
|
|
1344
|
+
return FileReadStream;
|
|
1345
|
+
},
|
|
1346
|
+
set: function(val) {
|
|
1347
|
+
FileReadStream = val;
|
|
1348
|
+
},
|
|
1349
|
+
enumerable: true,
|
|
1350
|
+
configurable: true
|
|
1351
|
+
});
|
|
1352
|
+
var FileWriteStream = WriteStream;
|
|
1353
|
+
Object.defineProperty(fs4, "FileWriteStream", {
|
|
1354
|
+
get: function() {
|
|
1355
|
+
return FileWriteStream;
|
|
1356
|
+
},
|
|
1357
|
+
set: function(val) {
|
|
1358
|
+
FileWriteStream = val;
|
|
1359
|
+
},
|
|
1360
|
+
enumerable: true,
|
|
1361
|
+
configurable: true
|
|
1362
|
+
});
|
|
1363
|
+
function ReadStream(path, options) {
|
|
1364
|
+
if (this instanceof ReadStream)
|
|
1365
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
1366
|
+
else
|
|
1367
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
1368
|
+
}
|
|
1369
|
+
function ReadStream$open() {
|
|
1370
|
+
var that = this;
|
|
1371
|
+
open2(that.path, that.flags, that.mode, function(err2, fd) {
|
|
1372
|
+
if (err2) {
|
|
1373
|
+
if (that.autoClose)
|
|
1374
|
+
that.destroy();
|
|
1375
|
+
that.emit("error", err2);
|
|
1376
|
+
} else {
|
|
1377
|
+
that.fd = fd;
|
|
1378
|
+
that.emit("open", fd);
|
|
1379
|
+
that.read();
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
function WriteStream(path, options) {
|
|
1384
|
+
if (this instanceof WriteStream)
|
|
1385
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
1386
|
+
else
|
|
1387
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
1388
|
+
}
|
|
1389
|
+
function WriteStream$open() {
|
|
1390
|
+
var that = this;
|
|
1391
|
+
open2(that.path, that.flags, that.mode, function(err2, fd) {
|
|
1392
|
+
if (err2) {
|
|
1393
|
+
that.destroy();
|
|
1394
|
+
that.emit("error", err2);
|
|
1395
|
+
} else {
|
|
1396
|
+
that.fd = fd;
|
|
1397
|
+
that.emit("open", fd);
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
function createReadStream(path, options) {
|
|
1402
|
+
return new fs4.ReadStream(path, options);
|
|
1403
|
+
}
|
|
1404
|
+
function createWriteStream(path, options) {
|
|
1405
|
+
return new fs4.WriteStream(path, options);
|
|
1406
|
+
}
|
|
1407
|
+
var fs$open = fs4.open;
|
|
1408
|
+
fs4.open = open2;
|
|
1409
|
+
function open2(path, flags2, mode, cb) {
|
|
1410
|
+
if (typeof mode === "function")
|
|
1411
|
+
cb = mode, mode = null;
|
|
1412
|
+
return go$open(path, flags2, mode, cb);
|
|
1413
|
+
function go$open(path2, flags3, mode2, cb2, startTime) {
|
|
1414
|
+
return fs$open(path2, flags3, mode2, function(err2, fd) {
|
|
1415
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1416
|
+
enqueue([go$open, [path2, flags3, mode2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1417
|
+
else {
|
|
1418
|
+
if (typeof cb2 === "function")
|
|
1419
|
+
cb2.apply(this, arguments);
|
|
1420
|
+
}
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
return fs4;
|
|
1425
|
+
}
|
|
1426
|
+
function enqueue(elem) {
|
|
1427
|
+
debug2("ENQUEUE", elem[0].name, elem[1]);
|
|
1428
|
+
fs3[gracefulQueue].push(elem);
|
|
1429
|
+
retry();
|
|
1430
|
+
}
|
|
1431
|
+
var retryTimer;
|
|
1432
|
+
function resetQueue() {
|
|
1433
|
+
var now = Date.now();
|
|
1434
|
+
for (var i2 = 0; i2 < fs3[gracefulQueue].length; ++i2) {
|
|
1435
|
+
if (fs3[gracefulQueue][i2].length > 2) {
|
|
1436
|
+
fs3[gracefulQueue][i2][3] = now;
|
|
1437
|
+
fs3[gracefulQueue][i2][4] = now;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
retry();
|
|
1441
|
+
}
|
|
1442
|
+
function retry() {
|
|
1443
|
+
clearTimeout(retryTimer);
|
|
1444
|
+
retryTimer = void 0;
|
|
1445
|
+
if (fs3[gracefulQueue].length === 0)
|
|
1446
|
+
return;
|
|
1447
|
+
var elem = fs3[gracefulQueue].shift();
|
|
1448
|
+
var fn = elem[0];
|
|
1449
|
+
var args2 = elem[1];
|
|
1450
|
+
var err2 = elem[2];
|
|
1451
|
+
var startTime = elem[3];
|
|
1452
|
+
var lastTime = elem[4];
|
|
1453
|
+
if (startTime === void 0) {
|
|
1454
|
+
debug2("RETRY", fn.name, args2);
|
|
1455
|
+
fn.apply(null, args2);
|
|
1456
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
1457
|
+
debug2("TIMEOUT", fn.name, args2);
|
|
1458
|
+
var cb = args2.pop();
|
|
1459
|
+
if (typeof cb === "function")
|
|
1460
|
+
cb.call(null, err2);
|
|
1461
|
+
} else {
|
|
1462
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
1463
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
1464
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
1465
|
+
if (sinceAttempt >= desiredDelay) {
|
|
1466
|
+
debug2("RETRY", fn.name, args2);
|
|
1467
|
+
fn.apply(null, args2.concat([startTime]));
|
|
1468
|
+
} else {
|
|
1469
|
+
fs3[gracefulQueue].push(elem);
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
if (retryTimer === void 0) {
|
|
1473
|
+
retryTimer = setTimeout(retry, 0);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
});
|
|
1478
|
+
|
|
1479
|
+
// node_modules/retry/lib/retry_operation.js
|
|
1480
|
+
var require_retry_operation = __commonJS({
|
|
1481
|
+
"node_modules/retry/lib/retry_operation.js"(exports, module2) {
|
|
1482
|
+
function RetryOperation(timeouts, options) {
|
|
1483
|
+
if (typeof options === "boolean") {
|
|
1484
|
+
options = { forever: options };
|
|
1485
|
+
}
|
|
1486
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
1487
|
+
this._timeouts = timeouts;
|
|
1488
|
+
this._options = options || {};
|
|
1489
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
1490
|
+
this._fn = null;
|
|
1491
|
+
this._errors = [];
|
|
1492
|
+
this._attempts = 1;
|
|
1493
|
+
this._operationTimeout = null;
|
|
1494
|
+
this._operationTimeoutCb = null;
|
|
1495
|
+
this._timeout = null;
|
|
1496
|
+
this._operationStart = null;
|
|
1497
|
+
if (this._options.forever) {
|
|
1498
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
module2.exports = RetryOperation;
|
|
1502
|
+
RetryOperation.prototype.reset = function() {
|
|
1503
|
+
this._attempts = 1;
|
|
1504
|
+
this._timeouts = this._originalTimeouts;
|
|
1505
|
+
};
|
|
1506
|
+
RetryOperation.prototype.stop = function() {
|
|
1507
|
+
if (this._timeout) {
|
|
1508
|
+
clearTimeout(this._timeout);
|
|
1509
|
+
}
|
|
1510
|
+
this._timeouts = [];
|
|
1511
|
+
this._cachedTimeouts = null;
|
|
1512
|
+
};
|
|
1513
|
+
RetryOperation.prototype.retry = function(err2) {
|
|
1514
|
+
if (this._timeout) {
|
|
1515
|
+
clearTimeout(this._timeout);
|
|
1516
|
+
}
|
|
1517
|
+
if (!err2) {
|
|
1518
|
+
return false;
|
|
1519
|
+
}
|
|
1520
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1521
|
+
if (err2 && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
1522
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
1523
|
+
return false;
|
|
1524
|
+
}
|
|
1525
|
+
this._errors.push(err2);
|
|
1526
|
+
var timeout = this._timeouts.shift();
|
|
1527
|
+
if (timeout === void 0) {
|
|
1528
|
+
if (this._cachedTimeouts) {
|
|
1529
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
1530
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
1531
|
+
timeout = this._timeouts.shift();
|
|
1532
|
+
} else {
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
var self = this;
|
|
1537
|
+
var timer = setTimeout(function() {
|
|
1538
|
+
self._attempts++;
|
|
1539
|
+
if (self._operationTimeoutCb) {
|
|
1540
|
+
self._timeout = setTimeout(function() {
|
|
1541
|
+
self._operationTimeoutCb(self._attempts);
|
|
1542
|
+
}, self._operationTimeout);
|
|
1543
|
+
if (self._options.unref) {
|
|
1544
|
+
self._timeout.unref();
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
self._fn(self._attempts);
|
|
1548
|
+
}, timeout);
|
|
1549
|
+
if (this._options.unref) {
|
|
1550
|
+
timer.unref();
|
|
1551
|
+
}
|
|
1552
|
+
return true;
|
|
1553
|
+
};
|
|
1554
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
1555
|
+
this._fn = fn;
|
|
1556
|
+
if (timeoutOps) {
|
|
1557
|
+
if (timeoutOps.timeout) {
|
|
1558
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
1559
|
+
}
|
|
1560
|
+
if (timeoutOps.cb) {
|
|
1561
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
var self = this;
|
|
1565
|
+
if (this._operationTimeoutCb) {
|
|
1566
|
+
this._timeout = setTimeout(function() {
|
|
1567
|
+
self._operationTimeoutCb();
|
|
1568
|
+
}, self._operationTimeout);
|
|
1569
|
+
}
|
|
1570
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
1571
|
+
this._fn(this._attempts);
|
|
1572
|
+
};
|
|
1573
|
+
RetryOperation.prototype.try = function(fn) {
|
|
1574
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
1575
|
+
this.attempt(fn);
|
|
1576
|
+
};
|
|
1577
|
+
RetryOperation.prototype.start = function(fn) {
|
|
1578
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
1579
|
+
this.attempt(fn);
|
|
1580
|
+
};
|
|
1581
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
1582
|
+
RetryOperation.prototype.errors = function() {
|
|
1583
|
+
return this._errors;
|
|
1584
|
+
};
|
|
1585
|
+
RetryOperation.prototype.attempts = function() {
|
|
1586
|
+
return this._attempts;
|
|
1587
|
+
};
|
|
1588
|
+
RetryOperation.prototype.mainError = function() {
|
|
1589
|
+
if (this._errors.length === 0) {
|
|
1590
|
+
return null;
|
|
1591
|
+
}
|
|
1592
|
+
var counts = {};
|
|
1593
|
+
var mainError = null;
|
|
1594
|
+
var mainErrorCount = 0;
|
|
1595
|
+
for (var i2 = 0; i2 < this._errors.length; i2++) {
|
|
1596
|
+
var error = this._errors[i2];
|
|
1597
|
+
var message = error.message;
|
|
1598
|
+
var count = (counts[message] || 0) + 1;
|
|
1599
|
+
counts[message] = count;
|
|
1600
|
+
if (count >= mainErrorCount) {
|
|
1601
|
+
mainError = error;
|
|
1602
|
+
mainErrorCount = count;
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
return mainError;
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
});
|
|
1609
|
+
|
|
1610
|
+
// node_modules/retry/lib/retry.js
|
|
1611
|
+
var require_retry = __commonJS({
|
|
1612
|
+
"node_modules/retry/lib/retry.js"(exports) {
|
|
1613
|
+
var RetryOperation = require_retry_operation();
|
|
1614
|
+
exports.operation = function(options) {
|
|
1615
|
+
var timeouts = exports.timeouts(options);
|
|
1616
|
+
return new RetryOperation(timeouts, {
|
|
1617
|
+
forever: options && options.forever,
|
|
1618
|
+
unref: options && options.unref,
|
|
1619
|
+
maxRetryTime: options && options.maxRetryTime
|
|
1620
|
+
});
|
|
1621
|
+
};
|
|
1622
|
+
exports.timeouts = function(options) {
|
|
1623
|
+
if (options instanceof Array) {
|
|
1624
|
+
return [].concat(options);
|
|
1625
|
+
}
|
|
1626
|
+
var opts = {
|
|
1627
|
+
retries: 10,
|
|
1628
|
+
factor: 2,
|
|
1629
|
+
minTimeout: 1 * 1e3,
|
|
1630
|
+
maxTimeout: Infinity,
|
|
1631
|
+
randomize: false
|
|
1632
|
+
};
|
|
1633
|
+
for (var key in options) {
|
|
1634
|
+
opts[key] = options[key];
|
|
1635
|
+
}
|
|
1636
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
1637
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
1638
|
+
}
|
|
1639
|
+
var timeouts = [];
|
|
1640
|
+
for (var i2 = 0; i2 < opts.retries; i2++) {
|
|
1641
|
+
timeouts.push(this.createTimeout(i2, opts));
|
|
1642
|
+
}
|
|
1643
|
+
if (options && options.forever && !timeouts.length) {
|
|
1644
|
+
timeouts.push(this.createTimeout(i2, opts));
|
|
1645
|
+
}
|
|
1646
|
+
timeouts.sort(function(a, b) {
|
|
1647
|
+
return a - b;
|
|
1648
|
+
});
|
|
1649
|
+
return timeouts;
|
|
1650
|
+
};
|
|
1651
|
+
exports.createTimeout = function(attempt, opts) {
|
|
1652
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
1653
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
1654
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
1655
|
+
return timeout;
|
|
1656
|
+
};
|
|
1657
|
+
exports.wrap = function(obj, options, methods) {
|
|
1658
|
+
if (options instanceof Array) {
|
|
1659
|
+
methods = options;
|
|
1660
|
+
options = null;
|
|
1661
|
+
}
|
|
1662
|
+
if (!methods) {
|
|
1663
|
+
methods = [];
|
|
1664
|
+
for (var key in obj) {
|
|
1665
|
+
if (typeof obj[key] === "function") {
|
|
1666
|
+
methods.push(key);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
for (var i2 = 0; i2 < methods.length; i2++) {
|
|
1671
|
+
var method = methods[i2];
|
|
1672
|
+
var original = obj[method];
|
|
1673
|
+
obj[method] = function retryWrapper(original2) {
|
|
1674
|
+
var op = exports.operation(options);
|
|
1675
|
+
var args2 = Array.prototype.slice.call(arguments, 1);
|
|
1676
|
+
var callback = args2.pop();
|
|
1677
|
+
args2.push(function(err2) {
|
|
1678
|
+
if (op.retry(err2)) {
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
if (err2) {
|
|
1682
|
+
arguments[0] = op.mainError();
|
|
1683
|
+
}
|
|
1684
|
+
callback.apply(this, arguments);
|
|
1685
|
+
});
|
|
1686
|
+
op.attempt(function() {
|
|
1687
|
+
original2.apply(obj, args2);
|
|
1688
|
+
});
|
|
1689
|
+
}.bind(obj, original);
|
|
1690
|
+
obj[method].options = options;
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
|
|
1696
|
+
// node_modules/retry/index.js
|
|
1697
|
+
var require_retry2 = __commonJS({
|
|
1698
|
+
"node_modules/retry/index.js"(exports, module2) {
|
|
1699
|
+
module2.exports = require_retry();
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
|
|
1703
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/signals.js
|
|
1704
|
+
var require_signals = __commonJS({
|
|
1705
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module2) {
|
|
1706
|
+
module2.exports = [
|
|
1707
|
+
"SIGABRT",
|
|
1708
|
+
"SIGALRM",
|
|
1709
|
+
"SIGHUP",
|
|
1710
|
+
"SIGINT",
|
|
1711
|
+
"SIGTERM"
|
|
1712
|
+
];
|
|
1713
|
+
if (process.platform !== "win32") {
|
|
1714
|
+
module2.exports.push(
|
|
1715
|
+
"SIGVTALRM",
|
|
1716
|
+
"SIGXCPU",
|
|
1717
|
+
"SIGXFSZ",
|
|
1718
|
+
"SIGUSR2",
|
|
1719
|
+
"SIGTRAP",
|
|
1720
|
+
"SIGSYS",
|
|
1721
|
+
"SIGQUIT",
|
|
1722
|
+
"SIGIOT"
|
|
1723
|
+
// should detect profiler and enable/disable accordingly.
|
|
1724
|
+
// see #21
|
|
1725
|
+
// 'SIGPROF'
|
|
1726
|
+
);
|
|
1727
|
+
}
|
|
1728
|
+
if (process.platform === "linux") {
|
|
1729
|
+
module2.exports.push(
|
|
1730
|
+
"SIGIO",
|
|
1731
|
+
"SIGPOLL",
|
|
1732
|
+
"SIGPWR",
|
|
1733
|
+
"SIGSTKFLT",
|
|
1734
|
+
"SIGUNUSED"
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
|
|
1740
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/index.js
|
|
1741
|
+
var require_signal_exit = __commonJS({
|
|
1742
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module2) {
|
|
1743
|
+
var process2 = global.process;
|
|
1744
|
+
var processOk = function(process3) {
|
|
1745
|
+
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";
|
|
1746
|
+
};
|
|
1747
|
+
if (!processOk(process2)) {
|
|
1748
|
+
module2.exports = function() {
|
|
1749
|
+
return function() {
|
|
1750
|
+
};
|
|
1751
|
+
};
|
|
1752
|
+
} else {
|
|
1753
|
+
assert = __require("assert");
|
|
1754
|
+
signals = require_signals();
|
|
1755
|
+
isWin = /^win/i.test(process2.platform);
|
|
1756
|
+
EE = __require("events");
|
|
1757
|
+
if (typeof EE !== "function") {
|
|
1758
|
+
EE = EE.EventEmitter;
|
|
1759
|
+
}
|
|
1760
|
+
if (process2.__signal_exit_emitter__) {
|
|
1761
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1762
|
+
} else {
|
|
1763
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1764
|
+
emitter.count = 0;
|
|
1765
|
+
emitter.emitted = {};
|
|
1766
|
+
}
|
|
1767
|
+
if (!emitter.infinite) {
|
|
1768
|
+
emitter.setMaxListeners(Infinity);
|
|
1769
|
+
emitter.infinite = true;
|
|
1770
|
+
}
|
|
1771
|
+
module2.exports = function(cb, opts) {
|
|
1772
|
+
if (!processOk(global.process)) {
|
|
1773
|
+
return function() {
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1777
|
+
if (loaded === false) {
|
|
1778
|
+
load();
|
|
1779
|
+
}
|
|
1780
|
+
var ev = "exit";
|
|
1781
|
+
if (opts && opts.alwaysLast) {
|
|
1782
|
+
ev = "afterexit";
|
|
1783
|
+
}
|
|
1784
|
+
var remove = function() {
|
|
1785
|
+
emitter.removeListener(ev, cb);
|
|
1786
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1787
|
+
unload();
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
emitter.on(ev, cb);
|
|
1791
|
+
return remove;
|
|
1792
|
+
};
|
|
1793
|
+
unload = function unload2() {
|
|
1794
|
+
if (!loaded || !processOk(global.process)) {
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
loaded = false;
|
|
1798
|
+
signals.forEach(function(sig) {
|
|
1799
|
+
try {
|
|
1800
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1801
|
+
} catch (er) {
|
|
1802
|
+
}
|
|
1803
|
+
});
|
|
1804
|
+
process2.emit = originalProcessEmit;
|
|
1805
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1806
|
+
emitter.count -= 1;
|
|
1807
|
+
};
|
|
1808
|
+
module2.exports.unload = unload;
|
|
1809
|
+
emit = function emit2(event, code, signal) {
|
|
1810
|
+
if (emitter.emitted[event]) {
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
emitter.emitted[event] = true;
|
|
1814
|
+
emitter.emit(event, code, signal);
|
|
1815
|
+
};
|
|
1816
|
+
sigListeners = {};
|
|
1817
|
+
signals.forEach(function(sig) {
|
|
1818
|
+
sigListeners[sig] = function listener() {
|
|
1819
|
+
if (!processOk(global.process)) {
|
|
1820
|
+
return;
|
|
1821
|
+
}
|
|
1822
|
+
var listeners = process2.listeners(sig);
|
|
1823
|
+
if (listeners.length === emitter.count) {
|
|
1824
|
+
unload();
|
|
1825
|
+
emit("exit", null, sig);
|
|
1826
|
+
emit("afterexit", null, sig);
|
|
1827
|
+
if (isWin && sig === "SIGHUP") {
|
|
1828
|
+
sig = "SIGINT";
|
|
1829
|
+
}
|
|
1830
|
+
process2.kill(process2.pid, sig);
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
});
|
|
1834
|
+
module2.exports.signals = function() {
|
|
1835
|
+
return signals;
|
|
1836
|
+
};
|
|
1837
|
+
loaded = false;
|
|
1838
|
+
load = function load2() {
|
|
1839
|
+
if (loaded || !processOk(global.process)) {
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
loaded = true;
|
|
1843
|
+
emitter.count += 1;
|
|
1844
|
+
signals = signals.filter(function(sig) {
|
|
1845
|
+
try {
|
|
1846
|
+
process2.on(sig, sigListeners[sig]);
|
|
1847
|
+
return true;
|
|
1848
|
+
} catch (er) {
|
|
1849
|
+
return false;
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
process2.emit = processEmit;
|
|
1853
|
+
process2.reallyExit = processReallyExit;
|
|
1854
|
+
};
|
|
1855
|
+
module2.exports.load = load;
|
|
1856
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1857
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1858
|
+
if (!processOk(global.process)) {
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1862
|
+
0;
|
|
1863
|
+
emit("exit", process2.exitCode, null);
|
|
1864
|
+
emit("afterexit", process2.exitCode, null);
|
|
1865
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1866
|
+
};
|
|
1867
|
+
originalProcessEmit = process2.emit;
|
|
1868
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1869
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1870
|
+
if (arg !== void 0) {
|
|
1871
|
+
process2.exitCode = arg;
|
|
1872
|
+
}
|
|
1873
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1874
|
+
emit("exit", process2.exitCode, null);
|
|
1875
|
+
emit("afterexit", process2.exitCode, null);
|
|
1876
|
+
return ret;
|
|
1877
|
+
} else {
|
|
1878
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
}
|
|
1882
|
+
var assert;
|
|
1883
|
+
var signals;
|
|
1884
|
+
var isWin;
|
|
1885
|
+
var EE;
|
|
1886
|
+
var emitter;
|
|
1887
|
+
var unload;
|
|
1888
|
+
var emit;
|
|
1889
|
+
var sigListeners;
|
|
1890
|
+
var loaded;
|
|
1891
|
+
var load;
|
|
1892
|
+
var originalProcessReallyExit;
|
|
1893
|
+
var processReallyExit;
|
|
1894
|
+
var originalProcessEmit;
|
|
1895
|
+
var processEmit;
|
|
1896
|
+
}
|
|
1897
|
+
});
|
|
1898
|
+
|
|
1899
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1900
|
+
var require_mtime_precision = __commonJS({
|
|
1901
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module2) {
|
|
1902
|
+
"use strict";
|
|
1903
|
+
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1904
|
+
function probe(file, fs3, callback) {
|
|
1905
|
+
const cachedPrecision = fs3[cacheSymbol];
|
|
1906
|
+
if (cachedPrecision) {
|
|
1907
|
+
return fs3.stat(file, (err2, stat) => {
|
|
1908
|
+
if (err2) {
|
|
1909
|
+
return callback(err2);
|
|
1910
|
+
}
|
|
1911
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1912
|
+
});
|
|
1913
|
+
}
|
|
1914
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1915
|
+
fs3.utimes(file, mtime, mtime, (err2) => {
|
|
1916
|
+
if (err2) {
|
|
1917
|
+
return callback(err2);
|
|
1918
|
+
}
|
|
1919
|
+
fs3.stat(file, (err3, stat) => {
|
|
1920
|
+
if (err3) {
|
|
1921
|
+
return callback(err3);
|
|
1922
|
+
}
|
|
1923
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1924
|
+
Object.defineProperty(fs3, cacheSymbol, { value: precision });
|
|
1925
|
+
callback(null, stat.mtime, precision);
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
function getMtime(precision) {
|
|
1930
|
+
let now = Date.now();
|
|
1931
|
+
if (precision === "s") {
|
|
1932
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1933
|
+
}
|
|
1934
|
+
return new Date(now);
|
|
1935
|
+
}
|
|
1936
|
+
module2.exports.probe = probe;
|
|
1937
|
+
module2.exports.getMtime = getMtime;
|
|
1938
|
+
}
|
|
1939
|
+
});
|
|
1940
|
+
|
|
1941
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1942
|
+
var require_lockfile = __commonJS({
|
|
1943
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module2) {
|
|
1944
|
+
"use strict";
|
|
1945
|
+
var path = __require("path");
|
|
1946
|
+
var fs3 = require_graceful_fs();
|
|
1947
|
+
var retry = require_retry2();
|
|
1948
|
+
var onExit = require_signal_exit();
|
|
1949
|
+
var mtimePrecision = require_mtime_precision();
|
|
1950
|
+
var locks = {};
|
|
1951
|
+
function getLockFile(file, options) {
|
|
1952
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1953
|
+
}
|
|
1954
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1955
|
+
if (!options.realpath) {
|
|
1956
|
+
return callback(null, path.resolve(file));
|
|
1957
|
+
}
|
|
1958
|
+
options.fs.realpath(file, callback);
|
|
1959
|
+
}
|
|
1960
|
+
function acquireLock(file, options, callback) {
|
|
1961
|
+
const lockfilePath = getLockFile(file, options);
|
|
1962
|
+
options.fs.mkdir(lockfilePath, (err2) => {
|
|
1963
|
+
if (!err2) {
|
|
1964
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err3, mtime, mtimePrecision2) => {
|
|
1965
|
+
if (err3) {
|
|
1966
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1967
|
+
});
|
|
1968
|
+
return callback(err3);
|
|
1969
|
+
}
|
|
1970
|
+
callback(null, mtime, mtimePrecision2);
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
if (err2.code !== "EEXIST") {
|
|
1974
|
+
return callback(err2);
|
|
1975
|
+
}
|
|
1976
|
+
if (options.stale <= 0) {
|
|
1977
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1978
|
+
}
|
|
1979
|
+
options.fs.stat(lockfilePath, (err3, stat) => {
|
|
1980
|
+
if (err3) {
|
|
1981
|
+
if (err3.code === "ENOENT") {
|
|
1982
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1983
|
+
}
|
|
1984
|
+
return callback(err3);
|
|
1985
|
+
}
|
|
1986
|
+
if (!isLockStale(stat, options)) {
|
|
1987
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1988
|
+
}
|
|
1989
|
+
removeLock(file, options, (err4) => {
|
|
1990
|
+
if (err4) {
|
|
1991
|
+
return callback(err4);
|
|
1992
|
+
}
|
|
1993
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1994
|
+
});
|
|
1995
|
+
});
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1998
|
+
function isLockStale(stat, options) {
|
|
1999
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
2000
|
+
}
|
|
2001
|
+
function removeLock(file, options, callback) {
|
|
2002
|
+
options.fs.rmdir(getLockFile(file, options), (err2) => {
|
|
2003
|
+
if (err2 && err2.code !== "ENOENT") {
|
|
2004
|
+
return callback(err2);
|
|
2005
|
+
}
|
|
2006
|
+
callback();
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
function updateLock(file, options) {
|
|
2010
|
+
const lock2 = locks[file];
|
|
2011
|
+
if (lock2.updateTimeout) {
|
|
2012
|
+
return;
|
|
2013
|
+
}
|
|
2014
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
2015
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
2016
|
+
lock2.updateTimeout = null;
|
|
2017
|
+
options.fs.stat(lock2.lockfilePath, (err2, stat) => {
|
|
2018
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
2019
|
+
if (err2) {
|
|
2020
|
+
if (err2.code === "ENOENT" || isOverThreshold) {
|
|
2021
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
2022
|
+
}
|
|
2023
|
+
lock2.updateDelay = 1e3;
|
|
2024
|
+
return updateLock(file, options);
|
|
2025
|
+
}
|
|
2026
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
2027
|
+
if (!isMtimeOurs) {
|
|
2028
|
+
return setLockAsCompromised(
|
|
2029
|
+
file,
|
|
2030
|
+
lock2,
|
|
2031
|
+
Object.assign(
|
|
2032
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
2033
|
+
{ code: "ECOMPROMISED" }
|
|
2034
|
+
)
|
|
2035
|
+
);
|
|
2036
|
+
}
|
|
2037
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
2038
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err3) => {
|
|
2039
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
2040
|
+
if (lock2.released) {
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
if (err3) {
|
|
2044
|
+
if (err3.code === "ENOENT" || isOverThreshold2) {
|
|
2045
|
+
return setLockAsCompromised(file, lock2, Object.assign(err3, { code: "ECOMPROMISED" }));
|
|
2046
|
+
}
|
|
2047
|
+
lock2.updateDelay = 1e3;
|
|
2048
|
+
return updateLock(file, options);
|
|
2049
|
+
}
|
|
2050
|
+
lock2.mtime = mtime;
|
|
2051
|
+
lock2.lastUpdate = Date.now();
|
|
2052
|
+
lock2.updateDelay = null;
|
|
2053
|
+
updateLock(file, options);
|
|
2054
|
+
});
|
|
2055
|
+
});
|
|
2056
|
+
}, lock2.updateDelay);
|
|
2057
|
+
if (lock2.updateTimeout.unref) {
|
|
2058
|
+
lock2.updateTimeout.unref();
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
function setLockAsCompromised(file, lock2, err2) {
|
|
2062
|
+
lock2.released = true;
|
|
2063
|
+
if (lock2.updateTimeout) {
|
|
2064
|
+
clearTimeout(lock2.updateTimeout);
|
|
2065
|
+
}
|
|
2066
|
+
if (locks[file] === lock2) {
|
|
2067
|
+
delete locks[file];
|
|
2068
|
+
}
|
|
2069
|
+
lock2.options.onCompromised(err2);
|
|
2070
|
+
}
|
|
2071
|
+
function lock(file, options, callback) {
|
|
2072
|
+
options = {
|
|
2073
|
+
stale: 1e4,
|
|
2074
|
+
update: null,
|
|
2075
|
+
realpath: true,
|
|
2076
|
+
retries: 0,
|
|
2077
|
+
fs: fs3,
|
|
2078
|
+
onCompromised: (err2) => {
|
|
2079
|
+
throw err2;
|
|
2080
|
+
},
|
|
2081
|
+
...options
|
|
2082
|
+
};
|
|
2083
|
+
options.retries = options.retries || 0;
|
|
2084
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
2085
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
2086
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
2087
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
2088
|
+
resolveCanonicalPath(file, options, (err2, file2) => {
|
|
2089
|
+
if (err2) {
|
|
2090
|
+
return callback(err2);
|
|
2091
|
+
}
|
|
2092
|
+
const operation = retry.operation(options.retries);
|
|
2093
|
+
operation.attempt(() => {
|
|
2094
|
+
acquireLock(file2, options, (err3, mtime, mtimePrecision2) => {
|
|
2095
|
+
if (operation.retry(err3)) {
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2098
|
+
if (err3) {
|
|
2099
|
+
return callback(operation.mainError());
|
|
2100
|
+
}
|
|
2101
|
+
const lock2 = locks[file2] = {
|
|
2102
|
+
lockfilePath: getLockFile(file2, options),
|
|
2103
|
+
mtime,
|
|
2104
|
+
mtimePrecision: mtimePrecision2,
|
|
2105
|
+
options,
|
|
2106
|
+
lastUpdate: Date.now()
|
|
2107
|
+
};
|
|
2108
|
+
updateLock(file2, options);
|
|
2109
|
+
callback(null, (releasedCallback) => {
|
|
2110
|
+
if (lock2.released) {
|
|
2111
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
2112
|
+
}
|
|
2113
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
2114
|
+
});
|
|
2115
|
+
});
|
|
2116
|
+
});
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
function unlock(file, options, callback) {
|
|
2120
|
+
options = {
|
|
2121
|
+
fs: fs3,
|
|
2122
|
+
realpath: true,
|
|
2123
|
+
...options
|
|
2124
|
+
};
|
|
2125
|
+
resolveCanonicalPath(file, options, (err2, file2) => {
|
|
2126
|
+
if (err2) {
|
|
2127
|
+
return callback(err2);
|
|
2128
|
+
}
|
|
2129
|
+
const lock2 = locks[file2];
|
|
2130
|
+
if (!lock2) {
|
|
2131
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
2132
|
+
}
|
|
2133
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
2134
|
+
lock2.released = true;
|
|
2135
|
+
delete locks[file2];
|
|
2136
|
+
removeLock(file2, options, callback);
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
function check(file, options, callback) {
|
|
2140
|
+
options = {
|
|
2141
|
+
stale: 1e4,
|
|
2142
|
+
realpath: true,
|
|
2143
|
+
fs: fs3,
|
|
2144
|
+
...options
|
|
2145
|
+
};
|
|
2146
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
2147
|
+
resolveCanonicalPath(file, options, (err2, file2) => {
|
|
2148
|
+
if (err2) {
|
|
2149
|
+
return callback(err2);
|
|
2150
|
+
}
|
|
2151
|
+
options.fs.stat(getLockFile(file2, options), (err3, stat) => {
|
|
2152
|
+
if (err3) {
|
|
2153
|
+
return err3.code === "ENOENT" ? callback(null, false) : callback(err3);
|
|
2154
|
+
}
|
|
2155
|
+
return callback(null, !isLockStale(stat, options));
|
|
2156
|
+
});
|
|
2157
|
+
});
|
|
2158
|
+
}
|
|
2159
|
+
function getLocks() {
|
|
2160
|
+
return locks;
|
|
2161
|
+
}
|
|
2162
|
+
onExit(() => {
|
|
2163
|
+
for (const file in locks) {
|
|
2164
|
+
const options = locks[file].options;
|
|
2165
|
+
try {
|
|
2166
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
2167
|
+
} catch (e) {
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
module2.exports.lock = lock;
|
|
2172
|
+
module2.exports.unlock = unlock;
|
|
2173
|
+
module2.exports.check = check;
|
|
2174
|
+
module2.exports.getLocks = getLocks;
|
|
2175
|
+
}
|
|
2176
|
+
});
|
|
2177
|
+
|
|
2178
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
2179
|
+
var require_adapter = __commonJS({
|
|
2180
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module2) {
|
|
2181
|
+
"use strict";
|
|
2182
|
+
var fs3 = require_graceful_fs();
|
|
2183
|
+
function createSyncFs(fs4) {
|
|
2184
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
2185
|
+
const newFs = { ...fs4 };
|
|
2186
|
+
methods.forEach((method) => {
|
|
2187
|
+
newFs[method] = (...args2) => {
|
|
2188
|
+
const callback = args2.pop();
|
|
2189
|
+
let ret;
|
|
2190
|
+
try {
|
|
2191
|
+
ret = fs4[`${method}Sync`](...args2);
|
|
2192
|
+
} catch (err2) {
|
|
2193
|
+
return callback(err2);
|
|
2194
|
+
}
|
|
2195
|
+
callback(null, ret);
|
|
2196
|
+
};
|
|
2197
|
+
});
|
|
2198
|
+
return newFs;
|
|
2199
|
+
}
|
|
2200
|
+
function toPromise(method) {
|
|
2201
|
+
return (...args2) => new Promise((resolve3, reject) => {
|
|
2202
|
+
args2.push((err2, result) => {
|
|
2203
|
+
if (err2) {
|
|
2204
|
+
reject(err2);
|
|
2205
|
+
} else {
|
|
2206
|
+
resolve3(result);
|
|
2207
|
+
}
|
|
2208
|
+
});
|
|
2209
|
+
method(...args2);
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
function toSync(method) {
|
|
2213
|
+
return (...args2) => {
|
|
2214
|
+
let err2;
|
|
2215
|
+
let result;
|
|
2216
|
+
args2.push((_err, _result) => {
|
|
2217
|
+
err2 = _err;
|
|
2218
|
+
result = _result;
|
|
2219
|
+
});
|
|
2220
|
+
method(...args2);
|
|
2221
|
+
if (err2) {
|
|
2222
|
+
throw err2;
|
|
2223
|
+
}
|
|
2224
|
+
return result;
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
function toSyncOptions(options) {
|
|
2228
|
+
options = { ...options };
|
|
2229
|
+
options.fs = createSyncFs(options.fs || fs3);
|
|
2230
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
2231
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
2232
|
+
}
|
|
2233
|
+
return options;
|
|
2234
|
+
}
|
|
2235
|
+
module2.exports = {
|
|
2236
|
+
toPromise,
|
|
2237
|
+
toSync,
|
|
2238
|
+
toSyncOptions
|
|
2239
|
+
};
|
|
2240
|
+
}
|
|
2241
|
+
});
|
|
2242
|
+
|
|
2243
|
+
// node_modules/proper-lockfile/index.js
|
|
2244
|
+
var require_proper_lockfile = __commonJS({
|
|
2245
|
+
"node_modules/proper-lockfile/index.js"(exports, module2) {
|
|
2246
|
+
"use strict";
|
|
2247
|
+
var lockfile = require_lockfile();
|
|
2248
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
2249
|
+
async function lock(file, options) {
|
|
2250
|
+
const release = await toPromise(lockfile.lock)(file, options);
|
|
2251
|
+
return toPromise(release);
|
|
2252
|
+
}
|
|
2253
|
+
function lockSync(file, options) {
|
|
2254
|
+
const release = toSync(lockfile.lock)(file, toSyncOptions(options));
|
|
2255
|
+
return toSync(release);
|
|
2256
|
+
}
|
|
2257
|
+
function unlock(file, options) {
|
|
2258
|
+
return toPromise(lockfile.unlock)(file, options);
|
|
2259
|
+
}
|
|
2260
|
+
function unlockSync(file, options) {
|
|
2261
|
+
return toSync(lockfile.unlock)(file, toSyncOptions(options));
|
|
2262
|
+
}
|
|
2263
|
+
function check(file, options) {
|
|
2264
|
+
return toPromise(lockfile.check)(file, options);
|
|
2265
|
+
}
|
|
2266
|
+
function checkSync(file, options) {
|
|
2267
|
+
return toSync(lockfile.check)(file, toSyncOptions(options));
|
|
2268
|
+
}
|
|
2269
|
+
module2.exports = lock;
|
|
2270
|
+
module2.exports.lock = lock;
|
|
2271
|
+
module2.exports.unlock = unlock;
|
|
2272
|
+
module2.exports.lockSync = lockSync;
|
|
2273
|
+
module2.exports.unlockSync = unlockSync;
|
|
2274
|
+
module2.exports.check = check;
|
|
2275
|
+
module2.exports.checkSync = checkSync;
|
|
2276
|
+
}
|
|
2277
|
+
});
|
|
2278
|
+
|
|
668
2279
|
// packages/cli/src/identity/migrate.ts
|
|
669
2280
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
670
2281
|
import { access, lstat as lstat2, mkdir as mkdir2, readFile as readFile2, readdir } from "node:fs/promises";
|
|
671
|
-
import { homedir as
|
|
672
|
-
import { dirname as dirname4, isAbsolute, join as
|
|
2282
|
+
import { homedir as homedir3 } from "node:os";
|
|
2283
|
+
import { dirname as dirname4, isAbsolute, join as join5, resolve as resolve2, sep as sep2 } from "node:path";
|
|
673
2284
|
|
|
674
2285
|
// packages/shared/dist/instructions.js
|
|
675
2286
|
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.
|
|
@@ -2178,8 +3789,8 @@ var Language = class _Language {
|
|
|
2178
3789
|
if (input instanceof Uint8Array) {
|
|
2179
3790
|
binary2 = input;
|
|
2180
3791
|
} else if (globalThis.process?.versions.node) {
|
|
2181
|
-
const
|
|
2182
|
-
binary2 = await
|
|
3792
|
+
const fs22 = await import("fs/promises");
|
|
3793
|
+
binary2 = await fs22.readFile(input);
|
|
2183
3794
|
} else {
|
|
2184
3795
|
const response = await fetch(input);
|
|
2185
3796
|
if (!response.ok) {
|
|
@@ -4863,12 +6474,20 @@ init_repositoryRoot();
|
|
|
4863
6474
|
|
|
4864
6475
|
// packages/local-setup/dist/storage.js
|
|
4865
6476
|
init_hookRuntime();
|
|
6477
|
+
init_hookRuntime();
|
|
4866
6478
|
import { createHash, randomUUID } from "node:crypto";
|
|
4867
6479
|
import { execFile as nodeExecFile } from "node:child_process";
|
|
6480
|
+
import fs2 from "node:fs";
|
|
4868
6481
|
import { open, rename, readFile, mkdir, lstat, chmod, writeFile, unlink, rmdir } from "node:fs/promises";
|
|
4869
6482
|
import { homedir } from "node:os";
|
|
4870
6483
|
import { dirname as dirname3, join as join3, win32 as win322, posix } from "node:path";
|
|
4871
|
-
|
|
6484
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
6485
|
+
var lockfileKey = /* @__PURE__ */ Symbol.for("mnemonik.proper-lockfile");
|
|
6486
|
+
function sharedLockfile() {
|
|
6487
|
+
const shared = globalThis;
|
|
6488
|
+
return shared[lockfileKey] ??= Promise.resolve().then(() => __toESM(require_proper_lockfile(), 1)).then((module2) => module2.default);
|
|
6489
|
+
}
|
|
6490
|
+
var codeIs = (error, code) => error.code === code;
|
|
4872
6491
|
function stateDirectory(platform = process.platform, env = process.env, home = homedir()) {
|
|
4873
6492
|
if (env.MNEMONIK_STATE_DIR)
|
|
4874
6493
|
return env.MNEMONIK_STATE_DIR;
|
|
@@ -4878,6 +6497,17 @@ function stateDirectory(platform = process.platform, env = process.env, home = h
|
|
|
4878
6497
|
return posix.join(home, "Library", "Application Support", "Mnemonik");
|
|
4879
6498
|
return posix.join(env.XDG_STATE_HOME || posix.join(home, ".local", "state"), "mnemonik");
|
|
4880
6499
|
}
|
|
6500
|
+
async function readBytes(path) {
|
|
6501
|
+
try {
|
|
6502
|
+
if (!(await lstat(path)).isFile())
|
|
6503
|
+
throw new Error("setup_requires_regular_file");
|
|
6504
|
+
return await readFile(path);
|
|
6505
|
+
} catch (error) {
|
|
6506
|
+
if (codeIs(error, "ENOENT"))
|
|
6507
|
+
return null;
|
|
6508
|
+
throw error;
|
|
6509
|
+
}
|
|
6510
|
+
}
|
|
4881
6511
|
async function syncDirectory(path) {
|
|
4882
6512
|
if (process.platform === "win32")
|
|
4883
6513
|
return;
|
|
@@ -4936,6 +6566,167 @@ async function atomicWrite(path, bytes, fault, assertOwned) {
|
|
|
4936
6566
|
await syncDirectory(dirname3(path));
|
|
4937
6567
|
return permissionStatus;
|
|
4938
6568
|
}
|
|
6569
|
+
async function withLock(path, waitMs, work) {
|
|
6570
|
+
const lockfile = await sharedLockfile();
|
|
6571
|
+
await mkdir(dirname3(path), { recursive: true, mode: 448 });
|
|
6572
|
+
const generation = randomUUID();
|
|
6573
|
+
const owner = join3(`${path}.lock`, "owner");
|
|
6574
|
+
let compromised = false;
|
|
6575
|
+
let acquired = false;
|
|
6576
|
+
const assertOwned = async () => {
|
|
6577
|
+
if (compromised || (await readBytes(owner).catch(() => null))?.toString() !== generation) {
|
|
6578
|
+
compromised = true;
|
|
6579
|
+
throw new Error("lock_lost");
|
|
6580
|
+
}
|
|
6581
|
+
};
|
|
6582
|
+
const leaseFs = {
|
|
6583
|
+
...fs2,
|
|
6584
|
+
mkdir: (dir, callback) => {
|
|
6585
|
+
void mkdir(dir).then(() => writeFile(owner, generation, { mode: 384, flag: "wx" })).then(() => callback(), callback);
|
|
6586
|
+
},
|
|
6587
|
+
rmdir: (dir, callback) => {
|
|
6588
|
+
void unlink(join3(dir, "owner")).catch((error) => {
|
|
6589
|
+
if (!codeIs(error, "ENOENT"))
|
|
6590
|
+
throw error;
|
|
6591
|
+
}).then(() => rmdir(dir)).then(() => callback(), callback);
|
|
6592
|
+
},
|
|
6593
|
+
rmdirSync: (dir) => {
|
|
6594
|
+
try {
|
|
6595
|
+
fs2.unlinkSync(join3(dir, "owner"));
|
|
6596
|
+
} catch (error) {
|
|
6597
|
+
if (!codeIs(error, "ENOENT"))
|
|
6598
|
+
throw error;
|
|
6599
|
+
}
|
|
6600
|
+
fs2.rmdirSync(dir);
|
|
6601
|
+
},
|
|
6602
|
+
stat: (file, callback) => {
|
|
6603
|
+
void (acquired ? assertOwned() : Promise.resolve()).then(() => fs2.stat(file, callback), () => callback(Object.assign(new Error("lock_lost"), { code: "ENOENT" })));
|
|
6604
|
+
}
|
|
6605
|
+
};
|
|
6606
|
+
const deadline = performance.now() + waitMs;
|
|
6607
|
+
let release;
|
|
6608
|
+
while (!release) {
|
|
6609
|
+
try {
|
|
6610
|
+
release = await lockfile.lock(path, {
|
|
6611
|
+
realpath: false,
|
|
6612
|
+
stale: 3e4,
|
|
6613
|
+
update: 5e3,
|
|
6614
|
+
retries: 0,
|
|
6615
|
+
fs: leaseFs,
|
|
6616
|
+
onCompromised: () => {
|
|
6617
|
+
compromised = true;
|
|
6618
|
+
}
|
|
6619
|
+
});
|
|
6620
|
+
} catch (error) {
|
|
6621
|
+
if (!codeIs(error, "ELOCKED"))
|
|
6622
|
+
throw error;
|
|
6623
|
+
if (performance.now() >= deadline)
|
|
6624
|
+
throw new RuntimeError("lock_held");
|
|
6625
|
+
await delay(Math.min(100, Math.max(1, deadline - performance.now())));
|
|
6626
|
+
}
|
|
6627
|
+
}
|
|
6628
|
+
acquired = true;
|
|
6629
|
+
try {
|
|
6630
|
+
return await work(assertOwned);
|
|
6631
|
+
} finally {
|
|
6632
|
+
if (await assertOwned().then(() => true, () => false))
|
|
6633
|
+
await release();
|
|
6634
|
+
}
|
|
6635
|
+
}
|
|
6636
|
+
|
|
6637
|
+
// packages/local-setup/dist/automaticUpdate.js
|
|
6638
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
6639
|
+
import { realpathSync } from "node:fs";
|
|
6640
|
+
import { stat as nodeStat, utimes } from "node:fs/promises";
|
|
6641
|
+
import { homedir as homedir2 } from "node:os";
|
|
6642
|
+
import { join as join4 } from "node:path";
|
|
6643
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
6644
|
+
var DAY_MS = 864e5;
|
|
6645
|
+
var statePath = (stateDir) => join4(stateDir, "automatic-update.json");
|
|
6646
|
+
function cliLauncherPath(options = {}) {
|
|
6647
|
+
const platform = options.platform ?? process.platform;
|
|
6648
|
+
const home = options.home ?? homedir2();
|
|
6649
|
+
return platform === "win32" ? join4(options.env?.LOCALAPPDATA || join4(home, "AppData", "Local"), "Mnemonik", "bin", "mnemonik.cmd") : join4(home, ".local", "bin", "mnemonik");
|
|
6650
|
+
}
|
|
6651
|
+
async function readState(path) {
|
|
6652
|
+
const bytes = await readBytes(path);
|
|
6653
|
+
if (!bytes)
|
|
6654
|
+
return {};
|
|
6655
|
+
const value = JSON.parse(bytes.toString());
|
|
6656
|
+
if (!value || typeof value !== "object" || value.lastAttempt !== void 0 && (!Number.isFinite(value.lastAttempt) || value.lastAttempt < 0))
|
|
6657
|
+
throw new Error("automatic_update_state_invalid");
|
|
6658
|
+
return value.lastAttempt === void 0 ? {} : { lastAttempt: value.lastAttempt };
|
|
6659
|
+
}
|
|
6660
|
+
async function maybeStartAutomaticUpdate(options = {}) {
|
|
6661
|
+
const stateDir = options.stateDir ?? stateDirectory(options.platform, options.env, options.home);
|
|
6662
|
+
const path = statePath(stateDir);
|
|
6663
|
+
try {
|
|
6664
|
+
const now = (options.now ?? Date.now)();
|
|
6665
|
+
const stat = options.stat ?? nodeStat;
|
|
6666
|
+
try {
|
|
6667
|
+
if (now - (await stat(path)).mtimeMs < DAY_MS)
|
|
6668
|
+
return false;
|
|
6669
|
+
} catch (error) {
|
|
6670
|
+
if (error.code !== "ENOENT")
|
|
6671
|
+
throw error;
|
|
6672
|
+
}
|
|
6673
|
+
if (!options.spawn && !(await stat(cliLauncherPath(options))).isFile())
|
|
6674
|
+
return false;
|
|
6675
|
+
return await withLock(path, 0, async (assertOwned) => {
|
|
6676
|
+
const state = await readState(path);
|
|
6677
|
+
if (state.lastAttempt !== void 0 && now - state.lastAttempt < DAY_MS)
|
|
6678
|
+
return false;
|
|
6679
|
+
await atomicWrite(path, Buffer.from(`${JSON.stringify({ lastAttempt: now })}
|
|
6680
|
+
`), void 0, assertOwned);
|
|
6681
|
+
await utimes(path, now / 1e3, now / 1e3);
|
|
6682
|
+
const platform = options.platform ?? process.platform;
|
|
6683
|
+
const launcher = cliLauncherPath(options);
|
|
6684
|
+
const command = platform === "win32" ? {
|
|
6685
|
+
file: options.env?.ComSpec || "cmd.exe",
|
|
6686
|
+
args: ["/d", "/s", "/c", `""${launcher}" update --automatic"`],
|
|
6687
|
+
windowsVerbatimArguments: true
|
|
6688
|
+
} : platform === "linux" && (options.env ?? process.env).INVOCATION_ID ? {
|
|
6689
|
+
// detached creates a process group, not a new systemd cgroup. An
|
|
6690
|
+
// updater spawned by the scanner must survive stopping that service.
|
|
6691
|
+
file: "systemd-run",
|
|
6692
|
+
args: [
|
|
6693
|
+
"--user",
|
|
6694
|
+
"--collect",
|
|
6695
|
+
"--quiet",
|
|
6696
|
+
`--setenv=MNEMONIK_STATE_DIR=${stateDir}`,
|
|
6697
|
+
"--",
|
|
6698
|
+
launcher,
|
|
6699
|
+
"update",
|
|
6700
|
+
"--automatic"
|
|
6701
|
+
]
|
|
6702
|
+
} : { file: launcher, args: ["update", "--automatic"] };
|
|
6703
|
+
const child = (options.spawn ?? nodeSpawn)(command.file, command.args, {
|
|
6704
|
+
detached: true,
|
|
6705
|
+
stdio: "ignore",
|
|
6706
|
+
windowsHide: true,
|
|
6707
|
+
..."windowsVerbatimArguments" in command ? { windowsVerbatimArguments: command.windowsVerbatimArguments } : {}
|
|
6708
|
+
});
|
|
6709
|
+
child.once("error", () => {
|
|
6710
|
+
});
|
|
6711
|
+
child.unref();
|
|
6712
|
+
return true;
|
|
6713
|
+
});
|
|
6714
|
+
} catch {
|
|
6715
|
+
return false;
|
|
6716
|
+
}
|
|
6717
|
+
}
|
|
6718
|
+
var HELPER_FLAG = "--mnemonik-automatic-update";
|
|
6719
|
+
function isHelperInvocation() {
|
|
6720
|
+
if (process.argv[2] !== HELPER_FLAG || !process.argv[3] || !process.argv[1])
|
|
6721
|
+
return false;
|
|
6722
|
+
try {
|
|
6723
|
+
return realpathSync(process.argv[1]) === realpathSync(fileURLToPath2(import.meta.url));
|
|
6724
|
+
} catch {
|
|
6725
|
+
return false;
|
|
6726
|
+
}
|
|
6727
|
+
}
|
|
6728
|
+
if (isHelperInvocation())
|
|
6729
|
+
void maybeStartAutomaticUpdate({ stateDir: process.argv[3] });
|
|
4939
6730
|
|
|
4940
6731
|
// packages/local-setup/dist/index.js
|
|
4941
6732
|
var MAX_ORIGINAL_BYTES = 64 * 1024;
|
|
@@ -4947,7 +6738,7 @@ var isRunId = (value) => {
|
|
|
4947
6738
|
return !!match && isCanonicalUuid(match[2]);
|
|
4948
6739
|
};
|
|
4949
6740
|
var IDENTITY = ".mnemonik.json";
|
|
4950
|
-
var RULE =
|
|
6741
|
+
var RULE = join5(".cursor", "rules", "memory_tools.mdc");
|
|
4951
6742
|
var digest = (bytes) => `sha256:${createHash2("sha256").update(bytes).digest("hex")}`;
|
|
4952
6743
|
var errorCode = (error) => error.code;
|
|
4953
6744
|
async function files(path) {
|
|
@@ -4983,7 +6774,7 @@ async function decodeHostPath(encoded, platform) {
|
|
|
4983
6774
|
if (!rest) return current;
|
|
4984
6775
|
const names = (await files(current)).filter((name2) => rest === name2 || rest.startsWith(`${name2}-`)).sort((a, b) => b.length - a.length);
|
|
4985
6776
|
for (const name2 of names) {
|
|
4986
|
-
const next =
|
|
6777
|
+
const next = join5(current, name2);
|
|
4987
6778
|
const tail = rest === name2 ? "" : rest.slice(name2.length + 1);
|
|
4988
6779
|
const result = await walk(next, tail);
|
|
4989
6780
|
if (result) return result;
|
|
@@ -5017,16 +6808,16 @@ function addCandidate(map, raw, source) {
|
|
|
5017
6808
|
}
|
|
5018
6809
|
async function addRecordPaths(map, statuses, stateDir) {
|
|
5019
6810
|
for (const [name2, directory, nested] of [
|
|
5020
|
-
["cli-project-setup",
|
|
5021
|
-
["cli-project-commands",
|
|
6811
|
+
["cli-project-setup", join5(stateDir, "project-setup"), false],
|
|
6812
|
+
["cli-project-commands", join5(stateDir, "project-commands"), true]
|
|
5022
6813
|
]) {
|
|
5023
6814
|
let found = false;
|
|
5024
6815
|
for (const first of await files(directory)) {
|
|
5025
|
-
const targets = nested ? (await files(
|
|
6816
|
+
const targets = nested ? (await files(join5(directory, first))).map((x) => join5(first, x)) : [first];
|
|
5026
6817
|
for (const relative of targets.filter((x) => x.endsWith(".json"))) {
|
|
5027
6818
|
found = true;
|
|
5028
6819
|
try {
|
|
5029
|
-
const record = JSON.parse(await readFile2(
|
|
6820
|
+
const record = JSON.parse(await readFile2(join5(directory, relative), "utf8"));
|
|
5030
6821
|
const root = typeof record.root === "string" ? record.root : record.resolvedRoot;
|
|
5031
6822
|
if (typeof root === "string") addCandidate(map, root, name2);
|
|
5032
6823
|
} catch {
|
|
@@ -5037,7 +6828,7 @@ async function addRecordPaths(map, statuses, stateDir) {
|
|
|
5037
6828
|
}
|
|
5038
6829
|
}
|
|
5039
6830
|
async function collectCandidates(options) {
|
|
5040
|
-
const home = options.home ??
|
|
6831
|
+
const home = options.home ?? homedir3();
|
|
5041
6832
|
const state = options.stateDir ?? stateDirectory(options.platform, process.env, home);
|
|
5042
6833
|
const platform = options.platform ?? process.platform;
|
|
5043
6834
|
const candidates = /* @__PURE__ */ new Map();
|
|
@@ -5047,7 +6838,7 @@ async function collectCandidates(options) {
|
|
|
5047
6838
|
addCandidate(candidates, resolve2(options.cwd ?? process.cwd(), selected), "owner-selected");
|
|
5048
6839
|
return { candidates, sources };
|
|
5049
6840
|
}
|
|
5050
|
-
for (const scanner of [
|
|
6841
|
+
for (const scanner of [join5(home, ".mnemonik", "scanner.json"), join5(state, "scanner.json")]) {
|
|
5051
6842
|
try {
|
|
5052
6843
|
const parsed = JSON.parse(await readFile2(scanner, "utf8"));
|
|
5053
6844
|
sources.push({ name: "scanner-state", path: scanner, status: "found" });
|
|
@@ -5071,18 +6862,18 @@ async function collectCandidates(options) {
|
|
|
5071
6862
|
}
|
|
5072
6863
|
await addRecordPaths(candidates, sources, state);
|
|
5073
6864
|
const configs = [
|
|
5074
|
-
["claude-config",
|
|
5075
|
-
["claude-config-and-recent",
|
|
5076
|
-
["codex-config",
|
|
5077
|
-
["cursor-config",
|
|
5078
|
-
["cursor-config",
|
|
5079
|
-
["grok-config",
|
|
6865
|
+
["claude-config", join5(home, ".claude", "settings.json")],
|
|
6866
|
+
["claude-config-and-recent", join5(home, ".claude.json")],
|
|
6867
|
+
["codex-config", join5(home, ".codex", "config.toml")],
|
|
6868
|
+
["cursor-config", join5(home, ".cursor", "mcp.json")],
|
|
6869
|
+
["cursor-config", join5(home, ".cursor", "hooks.json")],
|
|
6870
|
+
["grok-config", join5(home, ".grok", "config.toml")]
|
|
5080
6871
|
];
|
|
5081
6872
|
for (const [name2, path] of configs) await addConfig(candidates, sources, name2, path);
|
|
5082
6873
|
for (const [name2, directory] of [
|
|
5083
|
-
["claude-recent",
|
|
5084
|
-
["cursor-recent",
|
|
5085
|
-
["grok-recent",
|
|
6874
|
+
["claude-recent", join5(home, ".claude", "projects")],
|
|
6875
|
+
["cursor-recent", join5(home, ".cursor", "projects")],
|
|
6876
|
+
["grok-recent", join5(home, ".grok", "projects")]
|
|
5086
6877
|
]) {
|
|
5087
6878
|
const entries = await files(directory);
|
|
5088
6879
|
sources.push({ name: name2, path: directory, status: entries.length ? "found" : "absent" });
|
|
@@ -5091,15 +6882,15 @@ async function collectCandidates(options) {
|
|
|
5091
6882
|
if (decoded) addCandidate(candidates, decoded, name2);
|
|
5092
6883
|
}
|
|
5093
6884
|
}
|
|
5094
|
-
const codexSessions =
|
|
6885
|
+
const codexSessions = join5(home, ".codex", "sessions");
|
|
5095
6886
|
const sessionFiles = (await files(codexSessions)).filter((name2) => name2.endsWith(".jsonl"));
|
|
5096
6887
|
sources.push({
|
|
5097
6888
|
name: "codex-recent",
|
|
5098
|
-
path:
|
|
6889
|
+
path: join5(codexSessions, "*.jsonl"),
|
|
5099
6890
|
status: sessionFiles.length ? "found" : "absent"
|
|
5100
6891
|
});
|
|
5101
6892
|
for (const name2 of sessionFiles) {
|
|
5102
|
-
const first = (await readFile2(
|
|
6893
|
+
const first = (await readFile2(join5(codexSessions, name2), "utf8").catch(() => "")).split(
|
|
5103
6894
|
"\n"
|
|
5104
6895
|
)[0];
|
|
5105
6896
|
if (!first) continue;
|
|
@@ -5109,22 +6900,22 @@ async function collectCandidates(options) {
|
|
|
5109
6900
|
} catch {
|
|
5110
6901
|
}
|
|
5111
6902
|
}
|
|
5112
|
-
const cursorData = platform === "darwin" ?
|
|
5113
|
-
process.env.APPDATA ??
|
|
6903
|
+
const cursorData = platform === "darwin" ? join5(home, "Library", "Application Support", "Cursor", "User", "workspaceStorage") : platform === "win32" ? join5(
|
|
6904
|
+
process.env.APPDATA ?? join5(home, "AppData", "Roaming"),
|
|
5114
6905
|
"Cursor",
|
|
5115
6906
|
"User",
|
|
5116
6907
|
"workspaceStorage"
|
|
5117
|
-
) :
|
|
6908
|
+
) : join5(home, ".config", "Cursor", "User", "workspaceStorage");
|
|
5118
6909
|
const workspaces = await files(cursorData);
|
|
5119
6910
|
sources.push({
|
|
5120
6911
|
name: "cursor-workspaces",
|
|
5121
|
-
path:
|
|
6912
|
+
path: join5(cursorData, "*", "workspace.json"),
|
|
5122
6913
|
status: workspaces.length ? "found" : "absent"
|
|
5123
6914
|
});
|
|
5124
6915
|
for (const directory of workspaces) {
|
|
5125
6916
|
try {
|
|
5126
6917
|
const workspace = JSON.parse(
|
|
5127
|
-
await readFile2(
|
|
6918
|
+
await readFile2(join5(cursorData, directory, "workspace.json"), "utf8")
|
|
5128
6919
|
);
|
|
5129
6920
|
if (typeof workspace.folder === "string") {
|
|
5130
6921
|
const folder = workspace.folder.replace(/^file:\/\//u, "");
|
|
@@ -5171,7 +6962,7 @@ function classify(bytes) {
|
|
|
5171
6962
|
};
|
|
5172
6963
|
}
|
|
5173
6964
|
async function inspectProject(projectPath, sources) {
|
|
5174
|
-
const identityPath =
|
|
6965
|
+
const identityPath = join5(projectPath, IDENTITY);
|
|
5175
6966
|
try {
|
|
5176
6967
|
const directory = await lstat2(projectPath);
|
|
5177
6968
|
if (!directory.isDirectory())
|
|
@@ -5229,7 +7020,7 @@ async function inspectProject(projectPath, sources) {
|
|
|
5229
7020
|
};
|
|
5230
7021
|
}
|
|
5231
7022
|
const result = [identity];
|
|
5232
|
-
const rulePath =
|
|
7023
|
+
const rulePath = join5(projectPath, RULE);
|
|
5233
7024
|
try {
|
|
5234
7025
|
const bytes = await readFile2(rulePath);
|
|
5235
7026
|
const content = bytes.toString("utf8");
|
|
@@ -5263,7 +7054,7 @@ async function inspectProject(projectPath, sources) {
|
|
|
5263
7054
|
return result;
|
|
5264
7055
|
}
|
|
5265
7056
|
async function inventoryIdentityFiles(options) {
|
|
5266
|
-
const home = options.home ??
|
|
7057
|
+
const home = options.home ?? homedir3();
|
|
5267
7058
|
const state = options.stateDir ?? stateDirectory(options.platform, process.env, home);
|
|
5268
7059
|
const collected = await collectCandidates(options);
|
|
5269
7060
|
const entries = (await Promise.all(
|
|
@@ -5297,12 +7088,12 @@ async function inventoryIdentityFiles(options) {
|
|
|
5297
7088
|
};
|
|
5298
7089
|
}
|
|
5299
7090
|
async function loadIndex(state, runId) {
|
|
5300
|
-
const parent =
|
|
7091
|
+
const parent = join5(state, "identity-migration");
|
|
5301
7092
|
if (runId && !isRunId(runId)) throw new Error("invalid identity migration run id");
|
|
5302
7093
|
let id = runId;
|
|
5303
7094
|
if (!id) {
|
|
5304
7095
|
for (const candidate of (await files(parent)).filter(isRunId).sort().reverse())
|
|
5305
|
-
if (await access(
|
|
7096
|
+
if (await access(join5(parent, candidate, "index.json")).then(
|
|
5306
7097
|
() => true,
|
|
5307
7098
|
() => false
|
|
5308
7099
|
)) {
|
|
@@ -5311,7 +7102,7 @@ async function loadIndex(state, runId) {
|
|
|
5311
7102
|
}
|
|
5312
7103
|
}
|
|
5313
7104
|
if (!id) throw new Error("identity migration backup run not found");
|
|
5314
|
-
const path =
|
|
7105
|
+
const path = join5(parent, id, "index.json");
|
|
5315
7106
|
const index = JSON.parse(await readFile2(path, "utf8"));
|
|
5316
7107
|
if (index.runId !== id || !Array.isArray(index.entries)) throw new Error("invalid backup index");
|
|
5317
7108
|
for (const entry of index.entries)
|
|
@@ -5320,20 +7111,20 @@ async function loadIndex(state, runId) {
|
|
|
5320
7111
|
return { index, path };
|
|
5321
7112
|
}
|
|
5322
7113
|
async function readBackup(indexPath, entry) {
|
|
5323
|
-
const bytes = await readFile2(
|
|
7114
|
+
const bytes = await readFile2(join5(dirname4(indexPath), entry.backupFile));
|
|
5324
7115
|
const legacy = classify(bytes);
|
|
5325
7116
|
if (digest(bytes) !== entry.sha256 || legacy.state !== "v0" || legacy.projectId !== entry.projectId)
|
|
5326
7117
|
throw new Error("backup hash or UUID mismatch");
|
|
5327
7118
|
return bytes;
|
|
5328
7119
|
}
|
|
5329
7120
|
async function runIdentityMigration(options) {
|
|
5330
|
-
const state = options.stateDir ?? stateDirectory(options.platform, process.env, options.home ??
|
|
7121
|
+
const state = options.stateDir ?? stateDirectory(options.platform, process.env, options.home ?? homedir3());
|
|
5331
7122
|
if (options.mode === "report")
|
|
5332
7123
|
return { status: "reported", report: await inventoryIdentityFiles(options) };
|
|
5333
7124
|
if (options.mode === "backup") {
|
|
5334
7125
|
const report = await inventoryIdentityFiles(options);
|
|
5335
7126
|
const runId = `${String((options.now ?? (() => /* @__PURE__ */ new Date()))().getTime()).padStart(13, "0")}-${randomUUID2()}`;
|
|
5336
|
-
const directory =
|
|
7127
|
+
const directory = join5(state, "identity-migration", runId);
|
|
5337
7128
|
await mkdir2(directory, { recursive: true, mode: 448 });
|
|
5338
7129
|
const entries = [];
|
|
5339
7130
|
for (const item of report.entries.filter(
|
|
@@ -5343,7 +7134,7 @@ async function runIdentityMigration(options) {
|
|
|
5343
7134
|
const legacy = classify(bytes);
|
|
5344
7135
|
if (legacy.state !== "v0") continue;
|
|
5345
7136
|
const backupFile = `${createHash2("sha256").update(item.path).digest("hex")}.json`;
|
|
5346
|
-
await atomicWrite(
|
|
7137
|
+
await atomicWrite(join5(directory, backupFile), bytes);
|
|
5347
7138
|
const parsed = JSON.parse(bytes.toString("utf8"));
|
|
5348
7139
|
entries.push({
|
|
5349
7140
|
path: item.path,
|
|
@@ -5355,7 +7146,7 @@ async function runIdentityMigration(options) {
|
|
|
5355
7146
|
});
|
|
5356
7147
|
}
|
|
5357
7148
|
const index = { schemaVersion: 1, runId, createdAt: report.generatedAt, entries };
|
|
5358
|
-
const indexPath =
|
|
7149
|
+
const indexPath = join5(directory, "index.json");
|
|
5359
7150
|
await atomicWrite(indexPath, Buffer.from(`${JSON.stringify(index, null, 2)}
|
|
5360
7151
|
`));
|
|
5361
7152
|
return { status: "backed_up", runId, indexPath, count: entries.length, report };
|