switchroom 0.7.11 → 0.7.13
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/agent-scheduler/index.js +1 -1
- package/dist/cli/switchroom.js +2815 -941
- package/dist/vault/approvals/kernel-server.js +1 -1
- package/dist/vault/broker/server.js +1815 -59
- package/package.json +4 -2
- package/telegram-plugin/dist/foreman/foreman.js +1534 -6
- package/telegram-plugin/dist/gateway/gateway.js +1542 -14
|
@@ -23299,7 +23299,7 @@ var init_schema = __esm(() => {
|
|
|
23299
23299
|
}).optional()
|
|
23300
23300
|
});
|
|
23301
23301
|
VaultConfigSchema = exports_external.object({
|
|
23302
|
-
path: exports_external.string().default("~/.switchroom/vault.enc").describe("Path to encrypted vault file"),
|
|
23302
|
+
path: exports_external.string().default("~/.switchroom/vault/vault.enc").describe("Path to encrypted vault file. v0.7.12+ canonical default is " + "`~/.switchroom/vault/vault.enc` (parent-dir bind-mount enables " + "atomic-rename writes from the broker container). Older installs " + "with `~/.switchroom/vault.enc` are auto-migrated on `switchroom " + "apply`; the legacy path becomes a symlink for v0.7.10/.11 CLI " + "compatibility (sunset in v0.7.14)."),
|
|
23303
23303
|
broker: exports_external.object({
|
|
23304
23304
|
socket: exports_external.string().default("~/.switchroom/vault-broker.sock").describe("Unix domain socket path for the vault-broker daemon"),
|
|
23305
23305
|
enabled: exports_external.boolean().default(true).describe("Whether to start the vault-broker daemon on agent launch"),
|
|
@@ -23459,6 +23459,1526 @@ var init_loader = __esm(() => {
|
|
|
23459
23459
|
};
|
|
23460
23460
|
});
|
|
23461
23461
|
|
|
23462
|
+
// ../node_modules/.bun/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
|
|
23463
|
+
var require_polyfills = __commonJS((exports, module) => {
|
|
23464
|
+
var constants = __require("constants");
|
|
23465
|
+
var origCwd = process.cwd;
|
|
23466
|
+
var cwd = null;
|
|
23467
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
23468
|
+
process.cwd = function() {
|
|
23469
|
+
if (!cwd)
|
|
23470
|
+
cwd = origCwd.call(process);
|
|
23471
|
+
return cwd;
|
|
23472
|
+
};
|
|
23473
|
+
try {
|
|
23474
|
+
process.cwd();
|
|
23475
|
+
} catch (er) {}
|
|
23476
|
+
if (typeof process.chdir === "function") {
|
|
23477
|
+
chdir = process.chdir;
|
|
23478
|
+
process.chdir = function(d) {
|
|
23479
|
+
cwd = null;
|
|
23480
|
+
chdir.call(process, d);
|
|
23481
|
+
};
|
|
23482
|
+
if (Object.setPrototypeOf)
|
|
23483
|
+
Object.setPrototypeOf(process.chdir, chdir);
|
|
23484
|
+
}
|
|
23485
|
+
var chdir;
|
|
23486
|
+
module.exports = patch;
|
|
23487
|
+
function patch(fs) {
|
|
23488
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
23489
|
+
patchLchmod(fs);
|
|
23490
|
+
}
|
|
23491
|
+
if (!fs.lutimes) {
|
|
23492
|
+
patchLutimes(fs);
|
|
23493
|
+
}
|
|
23494
|
+
fs.chown = chownFix(fs.chown);
|
|
23495
|
+
fs.fchown = chownFix(fs.fchown);
|
|
23496
|
+
fs.lchown = chownFix(fs.lchown);
|
|
23497
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
23498
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
23499
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
23500
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
23501
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
23502
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
23503
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
23504
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
23505
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
23506
|
+
fs.stat = statFix(fs.stat);
|
|
23507
|
+
fs.fstat = statFix(fs.fstat);
|
|
23508
|
+
fs.lstat = statFix(fs.lstat);
|
|
23509
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
23510
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
23511
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
23512
|
+
if (fs.chmod && !fs.lchmod) {
|
|
23513
|
+
fs.lchmod = function(path, mode, cb) {
|
|
23514
|
+
if (cb)
|
|
23515
|
+
process.nextTick(cb);
|
|
23516
|
+
};
|
|
23517
|
+
fs.lchmodSync = function() {};
|
|
23518
|
+
}
|
|
23519
|
+
if (fs.chown && !fs.lchown) {
|
|
23520
|
+
fs.lchown = function(path, uid, gid, cb) {
|
|
23521
|
+
if (cb)
|
|
23522
|
+
process.nextTick(cb);
|
|
23523
|
+
};
|
|
23524
|
+
fs.lchownSync = function() {};
|
|
23525
|
+
}
|
|
23526
|
+
if (platform === "win32") {
|
|
23527
|
+
fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) {
|
|
23528
|
+
function rename(from, to, cb) {
|
|
23529
|
+
var start = Date.now();
|
|
23530
|
+
var backoff = 0;
|
|
23531
|
+
fs$rename(from, to, function CB(er) {
|
|
23532
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 60000) {
|
|
23533
|
+
setTimeout(function() {
|
|
23534
|
+
fs.stat(to, function(stater, st) {
|
|
23535
|
+
if (stater && stater.code === "ENOENT")
|
|
23536
|
+
fs$rename(from, to, CB);
|
|
23537
|
+
else
|
|
23538
|
+
cb(er);
|
|
23539
|
+
});
|
|
23540
|
+
}, backoff);
|
|
23541
|
+
if (backoff < 100)
|
|
23542
|
+
backoff += 10;
|
|
23543
|
+
return;
|
|
23544
|
+
}
|
|
23545
|
+
if (cb)
|
|
23546
|
+
cb(er);
|
|
23547
|
+
});
|
|
23548
|
+
}
|
|
23549
|
+
if (Object.setPrototypeOf)
|
|
23550
|
+
Object.setPrototypeOf(rename, fs$rename);
|
|
23551
|
+
return rename;
|
|
23552
|
+
}(fs.rename);
|
|
23553
|
+
}
|
|
23554
|
+
fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) {
|
|
23555
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
23556
|
+
var callback;
|
|
23557
|
+
if (callback_ && typeof callback_ === "function") {
|
|
23558
|
+
var eagCounter = 0;
|
|
23559
|
+
callback = function(er, _, __) {
|
|
23560
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
23561
|
+
eagCounter++;
|
|
23562
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
23563
|
+
}
|
|
23564
|
+
callback_.apply(this, arguments);
|
|
23565
|
+
};
|
|
23566
|
+
}
|
|
23567
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
23568
|
+
}
|
|
23569
|
+
if (Object.setPrototypeOf)
|
|
23570
|
+
Object.setPrototypeOf(read, fs$read);
|
|
23571
|
+
return read;
|
|
23572
|
+
}(fs.read);
|
|
23573
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : function(fs$readSync) {
|
|
23574
|
+
return function(fd, buffer, offset, length, position) {
|
|
23575
|
+
var eagCounter = 0;
|
|
23576
|
+
while (true) {
|
|
23577
|
+
try {
|
|
23578
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
23579
|
+
} catch (er) {
|
|
23580
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
23581
|
+
eagCounter++;
|
|
23582
|
+
continue;
|
|
23583
|
+
}
|
|
23584
|
+
throw er;
|
|
23585
|
+
}
|
|
23586
|
+
}
|
|
23587
|
+
};
|
|
23588
|
+
}(fs.readSync);
|
|
23589
|
+
function patchLchmod(fs2) {
|
|
23590
|
+
fs2.lchmod = function(path, mode, callback) {
|
|
23591
|
+
fs2.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
23592
|
+
if (err) {
|
|
23593
|
+
if (callback)
|
|
23594
|
+
callback(err);
|
|
23595
|
+
return;
|
|
23596
|
+
}
|
|
23597
|
+
fs2.fchmod(fd, mode, function(err2) {
|
|
23598
|
+
fs2.close(fd, function(err22) {
|
|
23599
|
+
if (callback)
|
|
23600
|
+
callback(err2 || err22);
|
|
23601
|
+
});
|
|
23602
|
+
});
|
|
23603
|
+
});
|
|
23604
|
+
};
|
|
23605
|
+
fs2.lchmodSync = function(path, mode) {
|
|
23606
|
+
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
23607
|
+
var threw = true;
|
|
23608
|
+
var ret;
|
|
23609
|
+
try {
|
|
23610
|
+
ret = fs2.fchmodSync(fd, mode);
|
|
23611
|
+
threw = false;
|
|
23612
|
+
} finally {
|
|
23613
|
+
if (threw) {
|
|
23614
|
+
try {
|
|
23615
|
+
fs2.closeSync(fd);
|
|
23616
|
+
} catch (er) {}
|
|
23617
|
+
} else {
|
|
23618
|
+
fs2.closeSync(fd);
|
|
23619
|
+
}
|
|
23620
|
+
}
|
|
23621
|
+
return ret;
|
|
23622
|
+
};
|
|
23623
|
+
}
|
|
23624
|
+
function patchLutimes(fs2) {
|
|
23625
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
|
|
23626
|
+
fs2.lutimes = function(path, at, mt, cb) {
|
|
23627
|
+
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
23628
|
+
if (er) {
|
|
23629
|
+
if (cb)
|
|
23630
|
+
cb(er);
|
|
23631
|
+
return;
|
|
23632
|
+
}
|
|
23633
|
+
fs2.futimes(fd, at, mt, function(er2) {
|
|
23634
|
+
fs2.close(fd, function(er22) {
|
|
23635
|
+
if (cb)
|
|
23636
|
+
cb(er2 || er22);
|
|
23637
|
+
});
|
|
23638
|
+
});
|
|
23639
|
+
});
|
|
23640
|
+
};
|
|
23641
|
+
fs2.lutimesSync = function(path, at, mt) {
|
|
23642
|
+
var fd = fs2.openSync(path, constants.O_SYMLINK);
|
|
23643
|
+
var ret;
|
|
23644
|
+
var threw = true;
|
|
23645
|
+
try {
|
|
23646
|
+
ret = fs2.futimesSync(fd, at, mt);
|
|
23647
|
+
threw = false;
|
|
23648
|
+
} finally {
|
|
23649
|
+
if (threw) {
|
|
23650
|
+
try {
|
|
23651
|
+
fs2.closeSync(fd);
|
|
23652
|
+
} catch (er) {}
|
|
23653
|
+
} else {
|
|
23654
|
+
fs2.closeSync(fd);
|
|
23655
|
+
}
|
|
23656
|
+
}
|
|
23657
|
+
return ret;
|
|
23658
|
+
};
|
|
23659
|
+
} else if (fs2.futimes) {
|
|
23660
|
+
fs2.lutimes = function(_a, _b, _c, cb) {
|
|
23661
|
+
if (cb)
|
|
23662
|
+
process.nextTick(cb);
|
|
23663
|
+
};
|
|
23664
|
+
fs2.lutimesSync = function() {};
|
|
23665
|
+
}
|
|
23666
|
+
}
|
|
23667
|
+
function chmodFix(orig) {
|
|
23668
|
+
if (!orig)
|
|
23669
|
+
return orig;
|
|
23670
|
+
return function(target, mode, cb) {
|
|
23671
|
+
return orig.call(fs, target, mode, function(er) {
|
|
23672
|
+
if (chownErOk(er))
|
|
23673
|
+
er = null;
|
|
23674
|
+
if (cb)
|
|
23675
|
+
cb.apply(this, arguments);
|
|
23676
|
+
});
|
|
23677
|
+
};
|
|
23678
|
+
}
|
|
23679
|
+
function chmodFixSync(orig) {
|
|
23680
|
+
if (!orig)
|
|
23681
|
+
return orig;
|
|
23682
|
+
return function(target, mode) {
|
|
23683
|
+
try {
|
|
23684
|
+
return orig.call(fs, target, mode);
|
|
23685
|
+
} catch (er) {
|
|
23686
|
+
if (!chownErOk(er))
|
|
23687
|
+
throw er;
|
|
23688
|
+
}
|
|
23689
|
+
};
|
|
23690
|
+
}
|
|
23691
|
+
function chownFix(orig) {
|
|
23692
|
+
if (!orig)
|
|
23693
|
+
return orig;
|
|
23694
|
+
return function(target, uid, gid, cb) {
|
|
23695
|
+
return orig.call(fs, target, uid, gid, function(er) {
|
|
23696
|
+
if (chownErOk(er))
|
|
23697
|
+
er = null;
|
|
23698
|
+
if (cb)
|
|
23699
|
+
cb.apply(this, arguments);
|
|
23700
|
+
});
|
|
23701
|
+
};
|
|
23702
|
+
}
|
|
23703
|
+
function chownFixSync(orig) {
|
|
23704
|
+
if (!orig)
|
|
23705
|
+
return orig;
|
|
23706
|
+
return function(target, uid, gid) {
|
|
23707
|
+
try {
|
|
23708
|
+
return orig.call(fs, target, uid, gid);
|
|
23709
|
+
} catch (er) {
|
|
23710
|
+
if (!chownErOk(er))
|
|
23711
|
+
throw er;
|
|
23712
|
+
}
|
|
23713
|
+
};
|
|
23714
|
+
}
|
|
23715
|
+
function statFix(orig) {
|
|
23716
|
+
if (!orig)
|
|
23717
|
+
return orig;
|
|
23718
|
+
return function(target, options, cb) {
|
|
23719
|
+
if (typeof options === "function") {
|
|
23720
|
+
cb = options;
|
|
23721
|
+
options = null;
|
|
23722
|
+
}
|
|
23723
|
+
function callback(er, stats) {
|
|
23724
|
+
if (stats) {
|
|
23725
|
+
if (stats.uid < 0)
|
|
23726
|
+
stats.uid += 4294967296;
|
|
23727
|
+
if (stats.gid < 0)
|
|
23728
|
+
stats.gid += 4294967296;
|
|
23729
|
+
}
|
|
23730
|
+
if (cb)
|
|
23731
|
+
cb.apply(this, arguments);
|
|
23732
|
+
}
|
|
23733
|
+
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
23734
|
+
};
|
|
23735
|
+
}
|
|
23736
|
+
function statFixSync(orig) {
|
|
23737
|
+
if (!orig)
|
|
23738
|
+
return orig;
|
|
23739
|
+
return function(target, options) {
|
|
23740
|
+
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
23741
|
+
if (stats) {
|
|
23742
|
+
if (stats.uid < 0)
|
|
23743
|
+
stats.uid += 4294967296;
|
|
23744
|
+
if (stats.gid < 0)
|
|
23745
|
+
stats.gid += 4294967296;
|
|
23746
|
+
}
|
|
23747
|
+
return stats;
|
|
23748
|
+
};
|
|
23749
|
+
}
|
|
23750
|
+
function chownErOk(er) {
|
|
23751
|
+
if (!er)
|
|
23752
|
+
return true;
|
|
23753
|
+
if (er.code === "ENOSYS")
|
|
23754
|
+
return true;
|
|
23755
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
23756
|
+
if (nonroot) {
|
|
23757
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
23758
|
+
return true;
|
|
23759
|
+
}
|
|
23760
|
+
return false;
|
|
23761
|
+
}
|
|
23762
|
+
}
|
|
23763
|
+
});
|
|
23764
|
+
|
|
23765
|
+
// ../node_modules/.bun/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
|
|
23766
|
+
var require_legacy_streams = __commonJS((exports, module) => {
|
|
23767
|
+
var Stream = __require("stream").Stream;
|
|
23768
|
+
module.exports = legacy;
|
|
23769
|
+
function legacy(fs) {
|
|
23770
|
+
return {
|
|
23771
|
+
ReadStream,
|
|
23772
|
+
WriteStream
|
|
23773
|
+
};
|
|
23774
|
+
function ReadStream(path, options) {
|
|
23775
|
+
if (!(this instanceof ReadStream))
|
|
23776
|
+
return new ReadStream(path, options);
|
|
23777
|
+
Stream.call(this);
|
|
23778
|
+
var self = this;
|
|
23779
|
+
this.path = path;
|
|
23780
|
+
this.fd = null;
|
|
23781
|
+
this.readable = true;
|
|
23782
|
+
this.paused = false;
|
|
23783
|
+
this.flags = "r";
|
|
23784
|
+
this.mode = 438;
|
|
23785
|
+
this.bufferSize = 64 * 1024;
|
|
23786
|
+
options = options || {};
|
|
23787
|
+
var keys = Object.keys(options);
|
|
23788
|
+
for (var index = 0, length = keys.length;index < length; index++) {
|
|
23789
|
+
var key = keys[index];
|
|
23790
|
+
this[key] = options[key];
|
|
23791
|
+
}
|
|
23792
|
+
if (this.encoding)
|
|
23793
|
+
this.setEncoding(this.encoding);
|
|
23794
|
+
if (this.start !== undefined) {
|
|
23795
|
+
if (typeof this.start !== "number") {
|
|
23796
|
+
throw TypeError("start must be a Number");
|
|
23797
|
+
}
|
|
23798
|
+
if (this.end === undefined) {
|
|
23799
|
+
this.end = Infinity;
|
|
23800
|
+
} else if (typeof this.end !== "number") {
|
|
23801
|
+
throw TypeError("end must be a Number");
|
|
23802
|
+
}
|
|
23803
|
+
if (this.start > this.end) {
|
|
23804
|
+
throw new Error("start must be <= end");
|
|
23805
|
+
}
|
|
23806
|
+
this.pos = this.start;
|
|
23807
|
+
}
|
|
23808
|
+
if (this.fd !== null) {
|
|
23809
|
+
process.nextTick(function() {
|
|
23810
|
+
self._read();
|
|
23811
|
+
});
|
|
23812
|
+
return;
|
|
23813
|
+
}
|
|
23814
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
23815
|
+
if (err) {
|
|
23816
|
+
self.emit("error", err);
|
|
23817
|
+
self.readable = false;
|
|
23818
|
+
return;
|
|
23819
|
+
}
|
|
23820
|
+
self.fd = fd;
|
|
23821
|
+
self.emit("open", fd);
|
|
23822
|
+
self._read();
|
|
23823
|
+
});
|
|
23824
|
+
}
|
|
23825
|
+
function WriteStream(path, options) {
|
|
23826
|
+
if (!(this instanceof WriteStream))
|
|
23827
|
+
return new WriteStream(path, options);
|
|
23828
|
+
Stream.call(this);
|
|
23829
|
+
this.path = path;
|
|
23830
|
+
this.fd = null;
|
|
23831
|
+
this.writable = true;
|
|
23832
|
+
this.flags = "w";
|
|
23833
|
+
this.encoding = "binary";
|
|
23834
|
+
this.mode = 438;
|
|
23835
|
+
this.bytesWritten = 0;
|
|
23836
|
+
options = options || {};
|
|
23837
|
+
var keys = Object.keys(options);
|
|
23838
|
+
for (var index = 0, length = keys.length;index < length; index++) {
|
|
23839
|
+
var key = keys[index];
|
|
23840
|
+
this[key] = options[key];
|
|
23841
|
+
}
|
|
23842
|
+
if (this.start !== undefined) {
|
|
23843
|
+
if (typeof this.start !== "number") {
|
|
23844
|
+
throw TypeError("start must be a Number");
|
|
23845
|
+
}
|
|
23846
|
+
if (this.start < 0) {
|
|
23847
|
+
throw new Error("start must be >= zero");
|
|
23848
|
+
}
|
|
23849
|
+
this.pos = this.start;
|
|
23850
|
+
}
|
|
23851
|
+
this.busy = false;
|
|
23852
|
+
this._queue = [];
|
|
23853
|
+
if (this.fd === null) {
|
|
23854
|
+
this._open = fs.open;
|
|
23855
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, undefined]);
|
|
23856
|
+
this.flush();
|
|
23857
|
+
}
|
|
23858
|
+
}
|
|
23859
|
+
}
|
|
23860
|
+
});
|
|
23861
|
+
|
|
23862
|
+
// ../node_modules/.bun/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
|
|
23863
|
+
var require_clone = __commonJS((exports, module) => {
|
|
23864
|
+
module.exports = clone;
|
|
23865
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
23866
|
+
return obj.__proto__;
|
|
23867
|
+
};
|
|
23868
|
+
function clone(obj) {
|
|
23869
|
+
if (obj === null || typeof obj !== "object")
|
|
23870
|
+
return obj;
|
|
23871
|
+
if (obj instanceof Object)
|
|
23872
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
23873
|
+
else
|
|
23874
|
+
var copy = Object.create(null);
|
|
23875
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
23876
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
23877
|
+
});
|
|
23878
|
+
return copy;
|
|
23879
|
+
}
|
|
23880
|
+
});
|
|
23881
|
+
|
|
23882
|
+
// ../node_modules/.bun/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
|
|
23883
|
+
var require_graceful_fs = __commonJS((exports, module) => {
|
|
23884
|
+
var fs = __require("fs");
|
|
23885
|
+
var polyfills = require_polyfills();
|
|
23886
|
+
var legacy = require_legacy_streams();
|
|
23887
|
+
var clone = require_clone();
|
|
23888
|
+
var util3 = __require("util");
|
|
23889
|
+
var gracefulQueue;
|
|
23890
|
+
var previousSymbol;
|
|
23891
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
23892
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
23893
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
23894
|
+
} else {
|
|
23895
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
23896
|
+
previousSymbol = "___graceful-fs.previous";
|
|
23897
|
+
}
|
|
23898
|
+
function noop() {}
|
|
23899
|
+
function publishQueue(context, queue2) {
|
|
23900
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
23901
|
+
get: function() {
|
|
23902
|
+
return queue2;
|
|
23903
|
+
}
|
|
23904
|
+
});
|
|
23905
|
+
}
|
|
23906
|
+
var debug = noop;
|
|
23907
|
+
if (util3.debuglog)
|
|
23908
|
+
debug = util3.debuglog("gfs4");
|
|
23909
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
23910
|
+
debug = function() {
|
|
23911
|
+
var m = util3.format.apply(util3, arguments);
|
|
23912
|
+
m = "GFS4: " + m.split(/\n/).join(`
|
|
23913
|
+
GFS4: `);
|
|
23914
|
+
console.error(m);
|
|
23915
|
+
};
|
|
23916
|
+
if (!fs[gracefulQueue]) {
|
|
23917
|
+
queue = global[gracefulQueue] || [];
|
|
23918
|
+
publishQueue(fs, queue);
|
|
23919
|
+
fs.close = function(fs$close) {
|
|
23920
|
+
function close(fd, cb) {
|
|
23921
|
+
return fs$close.call(fs, fd, function(err) {
|
|
23922
|
+
if (!err) {
|
|
23923
|
+
resetQueue();
|
|
23924
|
+
}
|
|
23925
|
+
if (typeof cb === "function")
|
|
23926
|
+
cb.apply(this, arguments);
|
|
23927
|
+
});
|
|
23928
|
+
}
|
|
23929
|
+
Object.defineProperty(close, previousSymbol, {
|
|
23930
|
+
value: fs$close
|
|
23931
|
+
});
|
|
23932
|
+
return close;
|
|
23933
|
+
}(fs.close);
|
|
23934
|
+
fs.closeSync = function(fs$closeSync) {
|
|
23935
|
+
function closeSync(fd) {
|
|
23936
|
+
fs$closeSync.apply(fs, arguments);
|
|
23937
|
+
resetQueue();
|
|
23938
|
+
}
|
|
23939
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
23940
|
+
value: fs$closeSync
|
|
23941
|
+
});
|
|
23942
|
+
return closeSync;
|
|
23943
|
+
}(fs.closeSync);
|
|
23944
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
23945
|
+
process.on("exit", function() {
|
|
23946
|
+
debug(fs[gracefulQueue]);
|
|
23947
|
+
__require("assert").equal(fs[gracefulQueue].length, 0);
|
|
23948
|
+
});
|
|
23949
|
+
}
|
|
23950
|
+
}
|
|
23951
|
+
var queue;
|
|
23952
|
+
if (!global[gracefulQueue]) {
|
|
23953
|
+
publishQueue(global, fs[gracefulQueue]);
|
|
23954
|
+
}
|
|
23955
|
+
module.exports = patch(clone(fs));
|
|
23956
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
|
|
23957
|
+
module.exports = patch(fs);
|
|
23958
|
+
fs.__patched = true;
|
|
23959
|
+
}
|
|
23960
|
+
function patch(fs2) {
|
|
23961
|
+
polyfills(fs2);
|
|
23962
|
+
fs2.gracefulify = patch;
|
|
23963
|
+
fs2.createReadStream = createReadStream;
|
|
23964
|
+
fs2.createWriteStream = createWriteStream;
|
|
23965
|
+
var fs$readFile = fs2.readFile;
|
|
23966
|
+
fs2.readFile = readFile;
|
|
23967
|
+
function readFile(path, options, cb) {
|
|
23968
|
+
if (typeof options === "function")
|
|
23969
|
+
cb = options, options = null;
|
|
23970
|
+
return go$readFile(path, options, cb);
|
|
23971
|
+
function go$readFile(path2, options2, cb2, startTime) {
|
|
23972
|
+
return fs$readFile(path2, options2, function(err) {
|
|
23973
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
23974
|
+
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
23975
|
+
else {
|
|
23976
|
+
if (typeof cb2 === "function")
|
|
23977
|
+
cb2.apply(this, arguments);
|
|
23978
|
+
}
|
|
23979
|
+
});
|
|
23980
|
+
}
|
|
23981
|
+
}
|
|
23982
|
+
var fs$writeFile = fs2.writeFile;
|
|
23983
|
+
fs2.writeFile = writeFile;
|
|
23984
|
+
function writeFile(path, data, options, cb) {
|
|
23985
|
+
if (typeof options === "function")
|
|
23986
|
+
cb = options, options = null;
|
|
23987
|
+
return go$writeFile(path, data, options, cb);
|
|
23988
|
+
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
|
23989
|
+
return fs$writeFile(path2, data2, options2, function(err) {
|
|
23990
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
23991
|
+
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
23992
|
+
else {
|
|
23993
|
+
if (typeof cb2 === "function")
|
|
23994
|
+
cb2.apply(this, arguments);
|
|
23995
|
+
}
|
|
23996
|
+
});
|
|
23997
|
+
}
|
|
23998
|
+
}
|
|
23999
|
+
var fs$appendFile = fs2.appendFile;
|
|
24000
|
+
if (fs$appendFile)
|
|
24001
|
+
fs2.appendFile = appendFile;
|
|
24002
|
+
function appendFile(path, data, options, cb) {
|
|
24003
|
+
if (typeof options === "function")
|
|
24004
|
+
cb = options, options = null;
|
|
24005
|
+
return go$appendFile(path, data, options, cb);
|
|
24006
|
+
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
|
24007
|
+
return fs$appendFile(path2, data2, options2, function(err) {
|
|
24008
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
24009
|
+
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
24010
|
+
else {
|
|
24011
|
+
if (typeof cb2 === "function")
|
|
24012
|
+
cb2.apply(this, arguments);
|
|
24013
|
+
}
|
|
24014
|
+
});
|
|
24015
|
+
}
|
|
24016
|
+
}
|
|
24017
|
+
var fs$copyFile = fs2.copyFile;
|
|
24018
|
+
if (fs$copyFile)
|
|
24019
|
+
fs2.copyFile = copyFile;
|
|
24020
|
+
function copyFile(src, dest, flags, cb) {
|
|
24021
|
+
if (typeof flags === "function") {
|
|
24022
|
+
cb = flags;
|
|
24023
|
+
flags = 0;
|
|
24024
|
+
}
|
|
24025
|
+
return go$copyFile(src, dest, flags, cb);
|
|
24026
|
+
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
|
|
24027
|
+
return fs$copyFile(src2, dest2, flags2, function(err) {
|
|
24028
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
24029
|
+
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
24030
|
+
else {
|
|
24031
|
+
if (typeof cb2 === "function")
|
|
24032
|
+
cb2.apply(this, arguments);
|
|
24033
|
+
}
|
|
24034
|
+
});
|
|
24035
|
+
}
|
|
24036
|
+
}
|
|
24037
|
+
var fs$readdir = fs2.readdir;
|
|
24038
|
+
fs2.readdir = readdir;
|
|
24039
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
24040
|
+
function readdir(path, options, cb) {
|
|
24041
|
+
if (typeof options === "function")
|
|
24042
|
+
cb = options, options = null;
|
|
24043
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
|
|
24044
|
+
return fs$readdir(path2, fs$readdirCallback(path2, options2, cb2, startTime));
|
|
24045
|
+
} : function go$readdir2(path2, options2, cb2, startTime) {
|
|
24046
|
+
return fs$readdir(path2, options2, fs$readdirCallback(path2, options2, cb2, startTime));
|
|
24047
|
+
};
|
|
24048
|
+
return go$readdir(path, options, cb);
|
|
24049
|
+
function fs$readdirCallback(path2, options2, cb2, startTime) {
|
|
24050
|
+
return function(err, files) {
|
|
24051
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
24052
|
+
enqueue([
|
|
24053
|
+
go$readdir,
|
|
24054
|
+
[path2, options2, cb2],
|
|
24055
|
+
err,
|
|
24056
|
+
startTime || Date.now(),
|
|
24057
|
+
Date.now()
|
|
24058
|
+
]);
|
|
24059
|
+
else {
|
|
24060
|
+
if (files && files.sort)
|
|
24061
|
+
files.sort();
|
|
24062
|
+
if (typeof cb2 === "function")
|
|
24063
|
+
cb2.call(this, err, files);
|
|
24064
|
+
}
|
|
24065
|
+
};
|
|
24066
|
+
}
|
|
24067
|
+
}
|
|
24068
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
24069
|
+
var legStreams = legacy(fs2);
|
|
24070
|
+
ReadStream = legStreams.ReadStream;
|
|
24071
|
+
WriteStream = legStreams.WriteStream;
|
|
24072
|
+
}
|
|
24073
|
+
var fs$ReadStream = fs2.ReadStream;
|
|
24074
|
+
if (fs$ReadStream) {
|
|
24075
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
24076
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
24077
|
+
}
|
|
24078
|
+
var fs$WriteStream = fs2.WriteStream;
|
|
24079
|
+
if (fs$WriteStream) {
|
|
24080
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
24081
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
24082
|
+
}
|
|
24083
|
+
Object.defineProperty(fs2, "ReadStream", {
|
|
24084
|
+
get: function() {
|
|
24085
|
+
return ReadStream;
|
|
24086
|
+
},
|
|
24087
|
+
set: function(val) {
|
|
24088
|
+
ReadStream = val;
|
|
24089
|
+
},
|
|
24090
|
+
enumerable: true,
|
|
24091
|
+
configurable: true
|
|
24092
|
+
});
|
|
24093
|
+
Object.defineProperty(fs2, "WriteStream", {
|
|
24094
|
+
get: function() {
|
|
24095
|
+
return WriteStream;
|
|
24096
|
+
},
|
|
24097
|
+
set: function(val) {
|
|
24098
|
+
WriteStream = val;
|
|
24099
|
+
},
|
|
24100
|
+
enumerable: true,
|
|
24101
|
+
configurable: true
|
|
24102
|
+
});
|
|
24103
|
+
var FileReadStream = ReadStream;
|
|
24104
|
+
Object.defineProperty(fs2, "FileReadStream", {
|
|
24105
|
+
get: function() {
|
|
24106
|
+
return FileReadStream;
|
|
24107
|
+
},
|
|
24108
|
+
set: function(val) {
|
|
24109
|
+
FileReadStream = val;
|
|
24110
|
+
},
|
|
24111
|
+
enumerable: true,
|
|
24112
|
+
configurable: true
|
|
24113
|
+
});
|
|
24114
|
+
var FileWriteStream = WriteStream;
|
|
24115
|
+
Object.defineProperty(fs2, "FileWriteStream", {
|
|
24116
|
+
get: function() {
|
|
24117
|
+
return FileWriteStream;
|
|
24118
|
+
},
|
|
24119
|
+
set: function(val) {
|
|
24120
|
+
FileWriteStream = val;
|
|
24121
|
+
},
|
|
24122
|
+
enumerable: true,
|
|
24123
|
+
configurable: true
|
|
24124
|
+
});
|
|
24125
|
+
function ReadStream(path, options) {
|
|
24126
|
+
if (this instanceof ReadStream)
|
|
24127
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
24128
|
+
else
|
|
24129
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
24130
|
+
}
|
|
24131
|
+
function ReadStream$open() {
|
|
24132
|
+
var that = this;
|
|
24133
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
24134
|
+
if (err) {
|
|
24135
|
+
if (that.autoClose)
|
|
24136
|
+
that.destroy();
|
|
24137
|
+
that.emit("error", err);
|
|
24138
|
+
} else {
|
|
24139
|
+
that.fd = fd;
|
|
24140
|
+
that.emit("open", fd);
|
|
24141
|
+
that.read();
|
|
24142
|
+
}
|
|
24143
|
+
});
|
|
24144
|
+
}
|
|
24145
|
+
function WriteStream(path, options) {
|
|
24146
|
+
if (this instanceof WriteStream)
|
|
24147
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
24148
|
+
else
|
|
24149
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
24150
|
+
}
|
|
24151
|
+
function WriteStream$open() {
|
|
24152
|
+
var that = this;
|
|
24153
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
24154
|
+
if (err) {
|
|
24155
|
+
that.destroy();
|
|
24156
|
+
that.emit("error", err);
|
|
24157
|
+
} else {
|
|
24158
|
+
that.fd = fd;
|
|
24159
|
+
that.emit("open", fd);
|
|
24160
|
+
}
|
|
24161
|
+
});
|
|
24162
|
+
}
|
|
24163
|
+
function createReadStream(path, options) {
|
|
24164
|
+
return new fs2.ReadStream(path, options);
|
|
24165
|
+
}
|
|
24166
|
+
function createWriteStream(path, options) {
|
|
24167
|
+
return new fs2.WriteStream(path, options);
|
|
24168
|
+
}
|
|
24169
|
+
var fs$open = fs2.open;
|
|
24170
|
+
fs2.open = open;
|
|
24171
|
+
function open(path, flags, mode, cb) {
|
|
24172
|
+
if (typeof mode === "function")
|
|
24173
|
+
cb = mode, mode = null;
|
|
24174
|
+
return go$open(path, flags, mode, cb);
|
|
24175
|
+
function go$open(path2, flags2, mode2, cb2, startTime) {
|
|
24176
|
+
return fs$open(path2, flags2, mode2, function(err, fd) {
|
|
24177
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
24178
|
+
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
24179
|
+
else {
|
|
24180
|
+
if (typeof cb2 === "function")
|
|
24181
|
+
cb2.apply(this, arguments);
|
|
24182
|
+
}
|
|
24183
|
+
});
|
|
24184
|
+
}
|
|
24185
|
+
}
|
|
24186
|
+
return fs2;
|
|
24187
|
+
}
|
|
24188
|
+
function enqueue(elem) {
|
|
24189
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
24190
|
+
fs[gracefulQueue].push(elem);
|
|
24191
|
+
retry();
|
|
24192
|
+
}
|
|
24193
|
+
var retryTimer;
|
|
24194
|
+
function resetQueue() {
|
|
24195
|
+
var now = Date.now();
|
|
24196
|
+
for (var i = 0;i < fs[gracefulQueue].length; ++i) {
|
|
24197
|
+
if (fs[gracefulQueue][i].length > 2) {
|
|
24198
|
+
fs[gracefulQueue][i][3] = now;
|
|
24199
|
+
fs[gracefulQueue][i][4] = now;
|
|
24200
|
+
}
|
|
24201
|
+
}
|
|
24202
|
+
retry();
|
|
24203
|
+
}
|
|
24204
|
+
function retry() {
|
|
24205
|
+
clearTimeout(retryTimer);
|
|
24206
|
+
retryTimer = undefined;
|
|
24207
|
+
if (fs[gracefulQueue].length === 0)
|
|
24208
|
+
return;
|
|
24209
|
+
var elem = fs[gracefulQueue].shift();
|
|
24210
|
+
var fn = elem[0];
|
|
24211
|
+
var args = elem[1];
|
|
24212
|
+
var err = elem[2];
|
|
24213
|
+
var startTime = elem[3];
|
|
24214
|
+
var lastTime = elem[4];
|
|
24215
|
+
if (startTime === undefined) {
|
|
24216
|
+
debug("RETRY", fn.name, args);
|
|
24217
|
+
fn.apply(null, args);
|
|
24218
|
+
} else if (Date.now() - startTime >= 60000) {
|
|
24219
|
+
debug("TIMEOUT", fn.name, args);
|
|
24220
|
+
var cb = args.pop();
|
|
24221
|
+
if (typeof cb === "function")
|
|
24222
|
+
cb.call(null, err);
|
|
24223
|
+
} else {
|
|
24224
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
24225
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
24226
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
24227
|
+
if (sinceAttempt >= desiredDelay) {
|
|
24228
|
+
debug("RETRY", fn.name, args);
|
|
24229
|
+
fn.apply(null, args.concat([startTime]));
|
|
24230
|
+
} else {
|
|
24231
|
+
fs[gracefulQueue].push(elem);
|
|
24232
|
+
}
|
|
24233
|
+
}
|
|
24234
|
+
if (retryTimer === undefined) {
|
|
24235
|
+
retryTimer = setTimeout(retry, 0);
|
|
24236
|
+
}
|
|
24237
|
+
}
|
|
24238
|
+
});
|
|
24239
|
+
|
|
24240
|
+
// ../node_modules/.bun/retry@0.12.0/node_modules/retry/lib/retry_operation.js
|
|
24241
|
+
var require_retry_operation = __commonJS((exports, module) => {
|
|
24242
|
+
function RetryOperation(timeouts, options) {
|
|
24243
|
+
if (typeof options === "boolean") {
|
|
24244
|
+
options = { forever: options };
|
|
24245
|
+
}
|
|
24246
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
24247
|
+
this._timeouts = timeouts;
|
|
24248
|
+
this._options = options || {};
|
|
24249
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
24250
|
+
this._fn = null;
|
|
24251
|
+
this._errors = [];
|
|
24252
|
+
this._attempts = 1;
|
|
24253
|
+
this._operationTimeout = null;
|
|
24254
|
+
this._operationTimeoutCb = null;
|
|
24255
|
+
this._timeout = null;
|
|
24256
|
+
this._operationStart = null;
|
|
24257
|
+
if (this._options.forever) {
|
|
24258
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
24259
|
+
}
|
|
24260
|
+
}
|
|
24261
|
+
module.exports = RetryOperation;
|
|
24262
|
+
RetryOperation.prototype.reset = function() {
|
|
24263
|
+
this._attempts = 1;
|
|
24264
|
+
this._timeouts = this._originalTimeouts;
|
|
24265
|
+
};
|
|
24266
|
+
RetryOperation.prototype.stop = function() {
|
|
24267
|
+
if (this._timeout) {
|
|
24268
|
+
clearTimeout(this._timeout);
|
|
24269
|
+
}
|
|
24270
|
+
this._timeouts = [];
|
|
24271
|
+
this._cachedTimeouts = null;
|
|
24272
|
+
};
|
|
24273
|
+
RetryOperation.prototype.retry = function(err) {
|
|
24274
|
+
if (this._timeout) {
|
|
24275
|
+
clearTimeout(this._timeout);
|
|
24276
|
+
}
|
|
24277
|
+
if (!err) {
|
|
24278
|
+
return false;
|
|
24279
|
+
}
|
|
24280
|
+
var currentTime = new Date().getTime();
|
|
24281
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
24282
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
24283
|
+
return false;
|
|
24284
|
+
}
|
|
24285
|
+
this._errors.push(err);
|
|
24286
|
+
var timeout = this._timeouts.shift();
|
|
24287
|
+
if (timeout === undefined) {
|
|
24288
|
+
if (this._cachedTimeouts) {
|
|
24289
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
24290
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
24291
|
+
timeout = this._timeouts.shift();
|
|
24292
|
+
} else {
|
|
24293
|
+
return false;
|
|
24294
|
+
}
|
|
24295
|
+
}
|
|
24296
|
+
var self = this;
|
|
24297
|
+
var timer = setTimeout(function() {
|
|
24298
|
+
self._attempts++;
|
|
24299
|
+
if (self._operationTimeoutCb) {
|
|
24300
|
+
self._timeout = setTimeout(function() {
|
|
24301
|
+
self._operationTimeoutCb(self._attempts);
|
|
24302
|
+
}, self._operationTimeout);
|
|
24303
|
+
if (self._options.unref) {
|
|
24304
|
+
self._timeout.unref();
|
|
24305
|
+
}
|
|
24306
|
+
}
|
|
24307
|
+
self._fn(self._attempts);
|
|
24308
|
+
}, timeout);
|
|
24309
|
+
if (this._options.unref) {
|
|
24310
|
+
timer.unref();
|
|
24311
|
+
}
|
|
24312
|
+
return true;
|
|
24313
|
+
};
|
|
24314
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
24315
|
+
this._fn = fn;
|
|
24316
|
+
if (timeoutOps) {
|
|
24317
|
+
if (timeoutOps.timeout) {
|
|
24318
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
24319
|
+
}
|
|
24320
|
+
if (timeoutOps.cb) {
|
|
24321
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
24322
|
+
}
|
|
24323
|
+
}
|
|
24324
|
+
var self = this;
|
|
24325
|
+
if (this._operationTimeoutCb) {
|
|
24326
|
+
this._timeout = setTimeout(function() {
|
|
24327
|
+
self._operationTimeoutCb();
|
|
24328
|
+
}, self._operationTimeout);
|
|
24329
|
+
}
|
|
24330
|
+
this._operationStart = new Date().getTime();
|
|
24331
|
+
this._fn(this._attempts);
|
|
24332
|
+
};
|
|
24333
|
+
RetryOperation.prototype.try = function(fn) {
|
|
24334
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
24335
|
+
this.attempt(fn);
|
|
24336
|
+
};
|
|
24337
|
+
RetryOperation.prototype.start = function(fn) {
|
|
24338
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
24339
|
+
this.attempt(fn);
|
|
24340
|
+
};
|
|
24341
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
24342
|
+
RetryOperation.prototype.errors = function() {
|
|
24343
|
+
return this._errors;
|
|
24344
|
+
};
|
|
24345
|
+
RetryOperation.prototype.attempts = function() {
|
|
24346
|
+
return this._attempts;
|
|
24347
|
+
};
|
|
24348
|
+
RetryOperation.prototype.mainError = function() {
|
|
24349
|
+
if (this._errors.length === 0) {
|
|
24350
|
+
return null;
|
|
24351
|
+
}
|
|
24352
|
+
var counts = {};
|
|
24353
|
+
var mainError = null;
|
|
24354
|
+
var mainErrorCount = 0;
|
|
24355
|
+
for (var i = 0;i < this._errors.length; i++) {
|
|
24356
|
+
var error = this._errors[i];
|
|
24357
|
+
var message = error.message;
|
|
24358
|
+
var count = (counts[message] || 0) + 1;
|
|
24359
|
+
counts[message] = count;
|
|
24360
|
+
if (count >= mainErrorCount) {
|
|
24361
|
+
mainError = error;
|
|
24362
|
+
mainErrorCount = count;
|
|
24363
|
+
}
|
|
24364
|
+
}
|
|
24365
|
+
return mainError;
|
|
24366
|
+
};
|
|
24367
|
+
});
|
|
24368
|
+
|
|
24369
|
+
// ../node_modules/.bun/retry@0.12.0/node_modules/retry/lib/retry.js
|
|
24370
|
+
var require_retry = __commonJS((exports) => {
|
|
24371
|
+
var RetryOperation = require_retry_operation();
|
|
24372
|
+
exports.operation = function(options) {
|
|
24373
|
+
var timeouts = exports.timeouts(options);
|
|
24374
|
+
return new RetryOperation(timeouts, {
|
|
24375
|
+
forever: options && options.forever,
|
|
24376
|
+
unref: options && options.unref,
|
|
24377
|
+
maxRetryTime: options && options.maxRetryTime
|
|
24378
|
+
});
|
|
24379
|
+
};
|
|
24380
|
+
exports.timeouts = function(options) {
|
|
24381
|
+
if (options instanceof Array) {
|
|
24382
|
+
return [].concat(options);
|
|
24383
|
+
}
|
|
24384
|
+
var opts = {
|
|
24385
|
+
retries: 10,
|
|
24386
|
+
factor: 2,
|
|
24387
|
+
minTimeout: 1 * 1000,
|
|
24388
|
+
maxTimeout: Infinity,
|
|
24389
|
+
randomize: false
|
|
24390
|
+
};
|
|
24391
|
+
for (var key in options) {
|
|
24392
|
+
opts[key] = options[key];
|
|
24393
|
+
}
|
|
24394
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
24395
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
24396
|
+
}
|
|
24397
|
+
var timeouts = [];
|
|
24398
|
+
for (var i = 0;i < opts.retries; i++) {
|
|
24399
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
24400
|
+
}
|
|
24401
|
+
if (options && options.forever && !timeouts.length) {
|
|
24402
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
24403
|
+
}
|
|
24404
|
+
timeouts.sort(function(a, b) {
|
|
24405
|
+
return a - b;
|
|
24406
|
+
});
|
|
24407
|
+
return timeouts;
|
|
24408
|
+
};
|
|
24409
|
+
exports.createTimeout = function(attempt, opts) {
|
|
24410
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
24411
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
24412
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
24413
|
+
return timeout;
|
|
24414
|
+
};
|
|
24415
|
+
exports.wrap = function(obj, options, methods) {
|
|
24416
|
+
if (options instanceof Array) {
|
|
24417
|
+
methods = options;
|
|
24418
|
+
options = null;
|
|
24419
|
+
}
|
|
24420
|
+
if (!methods) {
|
|
24421
|
+
methods = [];
|
|
24422
|
+
for (var key in obj) {
|
|
24423
|
+
if (typeof obj[key] === "function") {
|
|
24424
|
+
methods.push(key);
|
|
24425
|
+
}
|
|
24426
|
+
}
|
|
24427
|
+
}
|
|
24428
|
+
for (var i = 0;i < methods.length; i++) {
|
|
24429
|
+
var method = methods[i];
|
|
24430
|
+
var original = obj[method];
|
|
24431
|
+
obj[method] = function retryWrapper(original2) {
|
|
24432
|
+
var op = exports.operation(options);
|
|
24433
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
24434
|
+
var callback = args.pop();
|
|
24435
|
+
args.push(function(err) {
|
|
24436
|
+
if (op.retry(err)) {
|
|
24437
|
+
return;
|
|
24438
|
+
}
|
|
24439
|
+
if (err) {
|
|
24440
|
+
arguments[0] = op.mainError();
|
|
24441
|
+
}
|
|
24442
|
+
callback.apply(this, arguments);
|
|
24443
|
+
});
|
|
24444
|
+
op.attempt(function() {
|
|
24445
|
+
original2.apply(obj, args);
|
|
24446
|
+
});
|
|
24447
|
+
}.bind(obj, original);
|
|
24448
|
+
obj[method].options = options;
|
|
24449
|
+
}
|
|
24450
|
+
};
|
|
24451
|
+
});
|
|
24452
|
+
|
|
24453
|
+
// ../node_modules/.bun/signal-exit@3.0.7/node_modules/signal-exit/signals.js
|
|
24454
|
+
var require_signals = __commonJS((exports, module) => {
|
|
24455
|
+
module.exports = [
|
|
24456
|
+
"SIGABRT",
|
|
24457
|
+
"SIGALRM",
|
|
24458
|
+
"SIGHUP",
|
|
24459
|
+
"SIGINT",
|
|
24460
|
+
"SIGTERM"
|
|
24461
|
+
];
|
|
24462
|
+
if (process.platform !== "win32") {
|
|
24463
|
+
module.exports.push("SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
24464
|
+
}
|
|
24465
|
+
if (process.platform === "linux") {
|
|
24466
|
+
module.exports.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
|
|
24467
|
+
}
|
|
24468
|
+
});
|
|
24469
|
+
|
|
24470
|
+
// ../node_modules/.bun/signal-exit@3.0.7/node_modules/signal-exit/index.js
|
|
24471
|
+
var require_signal_exit = __commonJS((exports, module) => {
|
|
24472
|
+
var process3 = global.process;
|
|
24473
|
+
var processOk = function(process4) {
|
|
24474
|
+
return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
|
|
24475
|
+
};
|
|
24476
|
+
if (!processOk(process3)) {
|
|
24477
|
+
module.exports = function() {
|
|
24478
|
+
return function() {};
|
|
24479
|
+
};
|
|
24480
|
+
} else {
|
|
24481
|
+
assert = __require("assert");
|
|
24482
|
+
signals = require_signals();
|
|
24483
|
+
isWin = /^win/i.test(process3.platform);
|
|
24484
|
+
EE = __require("events");
|
|
24485
|
+
if (typeof EE !== "function") {
|
|
24486
|
+
EE = EE.EventEmitter;
|
|
24487
|
+
}
|
|
24488
|
+
if (process3.__signal_exit_emitter__) {
|
|
24489
|
+
emitter = process3.__signal_exit_emitter__;
|
|
24490
|
+
} else {
|
|
24491
|
+
emitter = process3.__signal_exit_emitter__ = new EE;
|
|
24492
|
+
emitter.count = 0;
|
|
24493
|
+
emitter.emitted = {};
|
|
24494
|
+
}
|
|
24495
|
+
if (!emitter.infinite) {
|
|
24496
|
+
emitter.setMaxListeners(Infinity);
|
|
24497
|
+
emitter.infinite = true;
|
|
24498
|
+
}
|
|
24499
|
+
module.exports = function(cb, opts) {
|
|
24500
|
+
if (!processOk(global.process)) {
|
|
24501
|
+
return function() {};
|
|
24502
|
+
}
|
|
24503
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
24504
|
+
if (loaded === false) {
|
|
24505
|
+
load();
|
|
24506
|
+
}
|
|
24507
|
+
var ev = "exit";
|
|
24508
|
+
if (opts && opts.alwaysLast) {
|
|
24509
|
+
ev = "afterexit";
|
|
24510
|
+
}
|
|
24511
|
+
var remove = function() {
|
|
24512
|
+
emitter.removeListener(ev, cb);
|
|
24513
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
24514
|
+
unload();
|
|
24515
|
+
}
|
|
24516
|
+
};
|
|
24517
|
+
emitter.on(ev, cb);
|
|
24518
|
+
return remove;
|
|
24519
|
+
};
|
|
24520
|
+
unload = function unload2() {
|
|
24521
|
+
if (!loaded || !processOk(global.process)) {
|
|
24522
|
+
return;
|
|
24523
|
+
}
|
|
24524
|
+
loaded = false;
|
|
24525
|
+
signals.forEach(function(sig) {
|
|
24526
|
+
try {
|
|
24527
|
+
process3.removeListener(sig, sigListeners[sig]);
|
|
24528
|
+
} catch (er) {}
|
|
24529
|
+
});
|
|
24530
|
+
process3.emit = originalProcessEmit;
|
|
24531
|
+
process3.reallyExit = originalProcessReallyExit;
|
|
24532
|
+
emitter.count -= 1;
|
|
24533
|
+
};
|
|
24534
|
+
module.exports.unload = unload;
|
|
24535
|
+
emit = function emit2(event, code, signal) {
|
|
24536
|
+
if (emitter.emitted[event]) {
|
|
24537
|
+
return;
|
|
24538
|
+
}
|
|
24539
|
+
emitter.emitted[event] = true;
|
|
24540
|
+
emitter.emit(event, code, signal);
|
|
24541
|
+
};
|
|
24542
|
+
sigListeners = {};
|
|
24543
|
+
signals.forEach(function(sig) {
|
|
24544
|
+
sigListeners[sig] = function listener() {
|
|
24545
|
+
if (!processOk(global.process)) {
|
|
24546
|
+
return;
|
|
24547
|
+
}
|
|
24548
|
+
var listeners = process3.listeners(sig);
|
|
24549
|
+
if (listeners.length === emitter.count) {
|
|
24550
|
+
unload();
|
|
24551
|
+
emit("exit", null, sig);
|
|
24552
|
+
emit("afterexit", null, sig);
|
|
24553
|
+
if (isWin && sig === "SIGHUP") {
|
|
24554
|
+
sig = "SIGINT";
|
|
24555
|
+
}
|
|
24556
|
+
process3.kill(process3.pid, sig);
|
|
24557
|
+
}
|
|
24558
|
+
};
|
|
24559
|
+
});
|
|
24560
|
+
module.exports.signals = function() {
|
|
24561
|
+
return signals;
|
|
24562
|
+
};
|
|
24563
|
+
loaded = false;
|
|
24564
|
+
load = function load2() {
|
|
24565
|
+
if (loaded || !processOk(global.process)) {
|
|
24566
|
+
return;
|
|
24567
|
+
}
|
|
24568
|
+
loaded = true;
|
|
24569
|
+
emitter.count += 1;
|
|
24570
|
+
signals = signals.filter(function(sig) {
|
|
24571
|
+
try {
|
|
24572
|
+
process3.on(sig, sigListeners[sig]);
|
|
24573
|
+
return true;
|
|
24574
|
+
} catch (er) {
|
|
24575
|
+
return false;
|
|
24576
|
+
}
|
|
24577
|
+
});
|
|
24578
|
+
process3.emit = processEmit;
|
|
24579
|
+
process3.reallyExit = processReallyExit;
|
|
24580
|
+
};
|
|
24581
|
+
module.exports.load = load;
|
|
24582
|
+
originalProcessReallyExit = process3.reallyExit;
|
|
24583
|
+
processReallyExit = function processReallyExit2(code) {
|
|
24584
|
+
if (!processOk(global.process)) {
|
|
24585
|
+
return;
|
|
24586
|
+
}
|
|
24587
|
+
process3.exitCode = code || 0;
|
|
24588
|
+
emit("exit", process3.exitCode, null);
|
|
24589
|
+
emit("afterexit", process3.exitCode, null);
|
|
24590
|
+
originalProcessReallyExit.call(process3, process3.exitCode);
|
|
24591
|
+
};
|
|
24592
|
+
originalProcessEmit = process3.emit;
|
|
24593
|
+
processEmit = function processEmit2(ev, arg) {
|
|
24594
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
24595
|
+
if (arg !== undefined) {
|
|
24596
|
+
process3.exitCode = arg;
|
|
24597
|
+
}
|
|
24598
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
24599
|
+
emit("exit", process3.exitCode, null);
|
|
24600
|
+
emit("afterexit", process3.exitCode, null);
|
|
24601
|
+
return ret;
|
|
24602
|
+
} else {
|
|
24603
|
+
return originalProcessEmit.apply(this, arguments);
|
|
24604
|
+
}
|
|
24605
|
+
};
|
|
24606
|
+
}
|
|
24607
|
+
var assert;
|
|
24608
|
+
var signals;
|
|
24609
|
+
var isWin;
|
|
24610
|
+
var EE;
|
|
24611
|
+
var emitter;
|
|
24612
|
+
var unload;
|
|
24613
|
+
var emit;
|
|
24614
|
+
var sigListeners;
|
|
24615
|
+
var loaded;
|
|
24616
|
+
var load;
|
|
24617
|
+
var originalProcessReallyExit;
|
|
24618
|
+
var processReallyExit;
|
|
24619
|
+
var originalProcessEmit;
|
|
24620
|
+
var processEmit;
|
|
24621
|
+
});
|
|
24622
|
+
|
|
24623
|
+
// ../node_modules/.bun/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js
|
|
24624
|
+
var require_mtime_precision = __commonJS((exports, module) => {
|
|
24625
|
+
var cacheSymbol = Symbol();
|
|
24626
|
+
function probe(file, fs, callback) {
|
|
24627
|
+
const cachedPrecision = fs[cacheSymbol];
|
|
24628
|
+
if (cachedPrecision) {
|
|
24629
|
+
return fs.stat(file, (err, stat) => {
|
|
24630
|
+
if (err) {
|
|
24631
|
+
return callback(err);
|
|
24632
|
+
}
|
|
24633
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
24634
|
+
});
|
|
24635
|
+
}
|
|
24636
|
+
const mtime = new Date(Math.ceil(Date.now() / 1000) * 1000 + 5);
|
|
24637
|
+
fs.utimes(file, mtime, mtime, (err) => {
|
|
24638
|
+
if (err) {
|
|
24639
|
+
return callback(err);
|
|
24640
|
+
}
|
|
24641
|
+
fs.stat(file, (err2, stat) => {
|
|
24642
|
+
if (err2) {
|
|
24643
|
+
return callback(err2);
|
|
24644
|
+
}
|
|
24645
|
+
const precision = stat.mtime.getTime() % 1000 === 0 ? "s" : "ms";
|
|
24646
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
24647
|
+
callback(null, stat.mtime, precision);
|
|
24648
|
+
});
|
|
24649
|
+
});
|
|
24650
|
+
}
|
|
24651
|
+
function getMtime(precision) {
|
|
24652
|
+
let now = Date.now();
|
|
24653
|
+
if (precision === "s") {
|
|
24654
|
+
now = Math.ceil(now / 1000) * 1000;
|
|
24655
|
+
}
|
|
24656
|
+
return new Date(now);
|
|
24657
|
+
}
|
|
24658
|
+
exports.probe = probe;
|
|
24659
|
+
exports.getMtime = getMtime;
|
|
24660
|
+
});
|
|
24661
|
+
|
|
24662
|
+
// ../node_modules/.bun/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js
|
|
24663
|
+
var require_lockfile = __commonJS((exports, module) => {
|
|
24664
|
+
var path = __require("path");
|
|
24665
|
+
var fs = require_graceful_fs();
|
|
24666
|
+
var retry = require_retry();
|
|
24667
|
+
var onExit = require_signal_exit();
|
|
24668
|
+
var mtimePrecision = require_mtime_precision();
|
|
24669
|
+
var locks = {};
|
|
24670
|
+
function getLockFile(file, options) {
|
|
24671
|
+
return options.lockfilePath || `${file}.lock`;
|
|
24672
|
+
}
|
|
24673
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
24674
|
+
if (!options.realpath) {
|
|
24675
|
+
return callback(null, path.resolve(file));
|
|
24676
|
+
}
|
|
24677
|
+
options.fs.realpath(file, callback);
|
|
24678
|
+
}
|
|
24679
|
+
function acquireLock(file, options, callback) {
|
|
24680
|
+
const lockfilePath = getLockFile(file, options);
|
|
24681
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
24682
|
+
if (!err) {
|
|
24683
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
|
|
24684
|
+
if (err2) {
|
|
24685
|
+
options.fs.rmdir(lockfilePath, () => {});
|
|
24686
|
+
return callback(err2);
|
|
24687
|
+
}
|
|
24688
|
+
callback(null, mtime, mtimePrecision2);
|
|
24689
|
+
});
|
|
24690
|
+
}
|
|
24691
|
+
if (err.code !== "EEXIST") {
|
|
24692
|
+
return callback(err);
|
|
24693
|
+
}
|
|
24694
|
+
if (options.stale <= 0) {
|
|
24695
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
24696
|
+
}
|
|
24697
|
+
options.fs.stat(lockfilePath, (err2, stat) => {
|
|
24698
|
+
if (err2) {
|
|
24699
|
+
if (err2.code === "ENOENT") {
|
|
24700
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
24701
|
+
}
|
|
24702
|
+
return callback(err2);
|
|
24703
|
+
}
|
|
24704
|
+
if (!isLockStale(stat, options)) {
|
|
24705
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
24706
|
+
}
|
|
24707
|
+
removeLock(file, options, (err3) => {
|
|
24708
|
+
if (err3) {
|
|
24709
|
+
return callback(err3);
|
|
24710
|
+
}
|
|
24711
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
24712
|
+
});
|
|
24713
|
+
});
|
|
24714
|
+
});
|
|
24715
|
+
}
|
|
24716
|
+
function isLockStale(stat, options) {
|
|
24717
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
24718
|
+
}
|
|
24719
|
+
function removeLock(file, options, callback) {
|
|
24720
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
24721
|
+
if (err && err.code !== "ENOENT") {
|
|
24722
|
+
return callback(err);
|
|
24723
|
+
}
|
|
24724
|
+
callback();
|
|
24725
|
+
});
|
|
24726
|
+
}
|
|
24727
|
+
function updateLock(file, options) {
|
|
24728
|
+
const lock2 = locks[file];
|
|
24729
|
+
if (lock2.updateTimeout) {
|
|
24730
|
+
return;
|
|
24731
|
+
}
|
|
24732
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
24733
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
24734
|
+
lock2.updateTimeout = null;
|
|
24735
|
+
options.fs.stat(lock2.lockfilePath, (err, stat) => {
|
|
24736
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
24737
|
+
if (err) {
|
|
24738
|
+
if (err.code === "ENOENT" || isOverThreshold) {
|
|
24739
|
+
return setLockAsCompromised(file, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
24740
|
+
}
|
|
24741
|
+
lock2.updateDelay = 1000;
|
|
24742
|
+
return updateLock(file, options);
|
|
24743
|
+
}
|
|
24744
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
24745
|
+
if (!isMtimeOurs) {
|
|
24746
|
+
return setLockAsCompromised(file, lock2, Object.assign(new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
|
|
24747
|
+
}
|
|
24748
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
24749
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
|
|
24750
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
24751
|
+
if (lock2.released) {
|
|
24752
|
+
return;
|
|
24753
|
+
}
|
|
24754
|
+
if (err2) {
|
|
24755
|
+
if (err2.code === "ENOENT" || isOverThreshold2) {
|
|
24756
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
24757
|
+
}
|
|
24758
|
+
lock2.updateDelay = 1000;
|
|
24759
|
+
return updateLock(file, options);
|
|
24760
|
+
}
|
|
24761
|
+
lock2.mtime = mtime;
|
|
24762
|
+
lock2.lastUpdate = Date.now();
|
|
24763
|
+
lock2.updateDelay = null;
|
|
24764
|
+
updateLock(file, options);
|
|
24765
|
+
});
|
|
24766
|
+
});
|
|
24767
|
+
}, lock2.updateDelay);
|
|
24768
|
+
if (lock2.updateTimeout.unref) {
|
|
24769
|
+
lock2.updateTimeout.unref();
|
|
24770
|
+
}
|
|
24771
|
+
}
|
|
24772
|
+
function setLockAsCompromised(file, lock2, err) {
|
|
24773
|
+
lock2.released = true;
|
|
24774
|
+
if (lock2.updateTimeout) {
|
|
24775
|
+
clearTimeout(lock2.updateTimeout);
|
|
24776
|
+
}
|
|
24777
|
+
if (locks[file] === lock2) {
|
|
24778
|
+
delete locks[file];
|
|
24779
|
+
}
|
|
24780
|
+
lock2.options.onCompromised(err);
|
|
24781
|
+
}
|
|
24782
|
+
function lock(file, options, callback) {
|
|
24783
|
+
options = {
|
|
24784
|
+
stale: 1e4,
|
|
24785
|
+
update: null,
|
|
24786
|
+
realpath: true,
|
|
24787
|
+
retries: 0,
|
|
24788
|
+
fs,
|
|
24789
|
+
onCompromised: (err) => {
|
|
24790
|
+
throw err;
|
|
24791
|
+
},
|
|
24792
|
+
...options
|
|
24793
|
+
};
|
|
24794
|
+
options.retries = options.retries || 0;
|
|
24795
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
24796
|
+
options.stale = Math.max(options.stale || 0, 2000);
|
|
24797
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
24798
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1000);
|
|
24799
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
24800
|
+
if (err) {
|
|
24801
|
+
return callback(err);
|
|
24802
|
+
}
|
|
24803
|
+
const operation = retry.operation(options.retries);
|
|
24804
|
+
operation.attempt(() => {
|
|
24805
|
+
acquireLock(file2, options, (err2, mtime, mtimePrecision2) => {
|
|
24806
|
+
if (operation.retry(err2)) {
|
|
24807
|
+
return;
|
|
24808
|
+
}
|
|
24809
|
+
if (err2) {
|
|
24810
|
+
return callback(operation.mainError());
|
|
24811
|
+
}
|
|
24812
|
+
const lock2 = locks[file2] = {
|
|
24813
|
+
lockfilePath: getLockFile(file2, options),
|
|
24814
|
+
mtime,
|
|
24815
|
+
mtimePrecision: mtimePrecision2,
|
|
24816
|
+
options,
|
|
24817
|
+
lastUpdate: Date.now()
|
|
24818
|
+
};
|
|
24819
|
+
updateLock(file2, options);
|
|
24820
|
+
callback(null, (releasedCallback) => {
|
|
24821
|
+
if (lock2.released) {
|
|
24822
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
24823
|
+
}
|
|
24824
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
24825
|
+
});
|
|
24826
|
+
});
|
|
24827
|
+
});
|
|
24828
|
+
});
|
|
24829
|
+
}
|
|
24830
|
+
function unlock(file, options, callback) {
|
|
24831
|
+
options = {
|
|
24832
|
+
fs,
|
|
24833
|
+
realpath: true,
|
|
24834
|
+
...options
|
|
24835
|
+
};
|
|
24836
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
24837
|
+
if (err) {
|
|
24838
|
+
return callback(err);
|
|
24839
|
+
}
|
|
24840
|
+
const lock2 = locks[file2];
|
|
24841
|
+
if (!lock2) {
|
|
24842
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
24843
|
+
}
|
|
24844
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
24845
|
+
lock2.released = true;
|
|
24846
|
+
delete locks[file2];
|
|
24847
|
+
removeLock(file2, options, callback);
|
|
24848
|
+
});
|
|
24849
|
+
}
|
|
24850
|
+
function check(file, options, callback) {
|
|
24851
|
+
options = {
|
|
24852
|
+
stale: 1e4,
|
|
24853
|
+
realpath: true,
|
|
24854
|
+
fs,
|
|
24855
|
+
...options
|
|
24856
|
+
};
|
|
24857
|
+
options.stale = Math.max(options.stale || 0, 2000);
|
|
24858
|
+
resolveCanonicalPath(file, options, (err, file2) => {
|
|
24859
|
+
if (err) {
|
|
24860
|
+
return callback(err);
|
|
24861
|
+
}
|
|
24862
|
+
options.fs.stat(getLockFile(file2, options), (err2, stat) => {
|
|
24863
|
+
if (err2) {
|
|
24864
|
+
return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
|
|
24865
|
+
}
|
|
24866
|
+
return callback(null, !isLockStale(stat, options));
|
|
24867
|
+
});
|
|
24868
|
+
});
|
|
24869
|
+
}
|
|
24870
|
+
function getLocks() {
|
|
24871
|
+
return locks;
|
|
24872
|
+
}
|
|
24873
|
+
onExit(() => {
|
|
24874
|
+
for (const file in locks) {
|
|
24875
|
+
const options = locks[file].options;
|
|
24876
|
+
try {
|
|
24877
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
24878
|
+
} catch (e) {}
|
|
24879
|
+
}
|
|
24880
|
+
});
|
|
24881
|
+
exports.lock = lock;
|
|
24882
|
+
exports.unlock = unlock;
|
|
24883
|
+
exports.check = check;
|
|
24884
|
+
exports.getLocks = getLocks;
|
|
24885
|
+
});
|
|
24886
|
+
|
|
24887
|
+
// ../node_modules/.bun/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js
|
|
24888
|
+
var require_adapter = __commonJS((exports, module) => {
|
|
24889
|
+
var fs = require_graceful_fs();
|
|
24890
|
+
function createSyncFs(fs2) {
|
|
24891
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
24892
|
+
const newFs = { ...fs2 };
|
|
24893
|
+
methods.forEach((method) => {
|
|
24894
|
+
newFs[method] = (...args) => {
|
|
24895
|
+
const callback = args.pop();
|
|
24896
|
+
let ret;
|
|
24897
|
+
try {
|
|
24898
|
+
ret = fs2[`${method}Sync`](...args);
|
|
24899
|
+
} catch (err) {
|
|
24900
|
+
return callback(err);
|
|
24901
|
+
}
|
|
24902
|
+
callback(null, ret);
|
|
24903
|
+
};
|
|
24904
|
+
});
|
|
24905
|
+
return newFs;
|
|
24906
|
+
}
|
|
24907
|
+
function toPromise(method) {
|
|
24908
|
+
return (...args) => new Promise((resolve8, reject) => {
|
|
24909
|
+
args.push((err, result) => {
|
|
24910
|
+
if (err) {
|
|
24911
|
+
reject(err);
|
|
24912
|
+
} else {
|
|
24913
|
+
resolve8(result);
|
|
24914
|
+
}
|
|
24915
|
+
});
|
|
24916
|
+
method(...args);
|
|
24917
|
+
});
|
|
24918
|
+
}
|
|
24919
|
+
function toSync(method) {
|
|
24920
|
+
return (...args) => {
|
|
24921
|
+
let err;
|
|
24922
|
+
let result;
|
|
24923
|
+
args.push((_err, _result) => {
|
|
24924
|
+
err = _err;
|
|
24925
|
+
result = _result;
|
|
24926
|
+
});
|
|
24927
|
+
method(...args);
|
|
24928
|
+
if (err) {
|
|
24929
|
+
throw err;
|
|
24930
|
+
}
|
|
24931
|
+
return result;
|
|
24932
|
+
};
|
|
24933
|
+
}
|
|
24934
|
+
function toSyncOptions(options) {
|
|
24935
|
+
options = { ...options };
|
|
24936
|
+
options.fs = createSyncFs(options.fs || fs);
|
|
24937
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
24938
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
24939
|
+
}
|
|
24940
|
+
return options;
|
|
24941
|
+
}
|
|
24942
|
+
module.exports = {
|
|
24943
|
+
toPromise,
|
|
24944
|
+
toSync,
|
|
24945
|
+
toSyncOptions
|
|
24946
|
+
};
|
|
24947
|
+
});
|
|
24948
|
+
|
|
24949
|
+
// ../node_modules/.bun/proper-lockfile@4.1.2/node_modules/proper-lockfile/index.js
|
|
24950
|
+
var require_proper_lockfile = __commonJS((exports, module) => {
|
|
24951
|
+
var lockfile = require_lockfile();
|
|
24952
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
24953
|
+
async function lock(file, options) {
|
|
24954
|
+
const release = await toPromise(lockfile.lock)(file, options);
|
|
24955
|
+
return toPromise(release);
|
|
24956
|
+
}
|
|
24957
|
+
function lockSync(file, options) {
|
|
24958
|
+
const release = toSync(lockfile.lock)(file, toSyncOptions(options));
|
|
24959
|
+
return toSync(release);
|
|
24960
|
+
}
|
|
24961
|
+
function unlock(file, options) {
|
|
24962
|
+
return toPromise(lockfile.unlock)(file, options);
|
|
24963
|
+
}
|
|
24964
|
+
function unlockSync(file, options) {
|
|
24965
|
+
return toSync(lockfile.unlock)(file, toSyncOptions(options));
|
|
24966
|
+
}
|
|
24967
|
+
function check(file, options) {
|
|
24968
|
+
return toPromise(lockfile.check)(file, options);
|
|
24969
|
+
}
|
|
24970
|
+
function checkSync(file, options) {
|
|
24971
|
+
return toSync(lockfile.check)(file, toSyncOptions(options));
|
|
24972
|
+
}
|
|
24973
|
+
module.exports = lock;
|
|
24974
|
+
module.exports.lock = lock;
|
|
24975
|
+
module.exports.unlock = unlock;
|
|
24976
|
+
module.exports.lockSync = lockSync;
|
|
24977
|
+
module.exports.unlockSync = unlockSync;
|
|
24978
|
+
module.exports.check = check;
|
|
24979
|
+
module.exports.checkSync = checkSync;
|
|
24980
|
+
});
|
|
24981
|
+
|
|
23462
24982
|
// ../src/vault/vault.ts
|
|
23463
24983
|
import { randomBytes, scryptSync, createCipheriv, createDecipheriv } from "node:crypto";
|
|
23464
24984
|
import {
|
|
@@ -23526,8 +25046,16 @@ function openVault(passphrase, vaultPath) {
|
|
|
23526
25046
|
}
|
|
23527
25047
|
return normalizeSecrets(vaultData.secrets ?? {});
|
|
23528
25048
|
}
|
|
23529
|
-
var SCRYPT_N = 32768, SCRYPT_R = 8, SCRYPT_P = 1, SCRYPT_MAXMEM, VaultError, LEGACY_SCRYPT_N = 16384;
|
|
25049
|
+
var import_proper_lockfile, KNOWN_VAULT_ARTIFACT_NAMES, SCRYPT_N = 32768, SCRYPT_R = 8, SCRYPT_P = 1, SCRYPT_MAXMEM, VaultError, LEGACY_SCRYPT_N = 16384;
|
|
23530
25050
|
var init_vault = __esm(() => {
|
|
25051
|
+
import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
25052
|
+
KNOWN_VAULT_ARTIFACT_NAMES = new Set([
|
|
25053
|
+
"vault.enc",
|
|
25054
|
+
"vault.enc.bak",
|
|
25055
|
+
"vault.enc.tmp",
|
|
25056
|
+
"vault.enc.lock",
|
|
25057
|
+
".vault.enc.symlink-tmp"
|
|
25058
|
+
]);
|
|
23531
25059
|
SCRYPT_MAXMEM = 128 * 1024 * 1024;
|
|
23532
25060
|
VaultError = class VaultError extends Error {
|
|
23533
25061
|
constructor(message) {
|
|
@@ -23920,10 +25448,10 @@ var init_client = __esm(() => {
|
|
|
23920
25448
|
// ../src/vault/resolver.ts
|
|
23921
25449
|
import {
|
|
23922
25450
|
chmodSync as chmodSync2,
|
|
23923
|
-
closeSync,
|
|
25451
|
+
closeSync as closeSync2,
|
|
23924
25452
|
mkdirSync as mkdirSync9,
|
|
23925
25453
|
mkdtempSync,
|
|
23926
|
-
openSync,
|
|
25454
|
+
openSync as openSync2,
|
|
23927
25455
|
rmSync as rmSync2,
|
|
23928
25456
|
statSync as statSync4,
|
|
23929
25457
|
writeSync
|
|
@@ -23991,11 +25519,11 @@ function materializationRoot() {
|
|
|
23991
25519
|
}
|
|
23992
25520
|
function writeFileExclusive(filePath, content) {
|
|
23993
25521
|
const buf = typeof content === "string" ? Buffer.from(content, "utf8") : content;
|
|
23994
|
-
const fd =
|
|
25522
|
+
const fd = openSync2(filePath, fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL, 384);
|
|
23995
25523
|
try {
|
|
23996
25524
|
writeSync(fd, buf);
|
|
23997
25525
|
} finally {
|
|
23998
|
-
|
|
25526
|
+
closeSync2(fd);
|
|
23999
25527
|
}
|
|
24000
25528
|
}
|
|
24001
25529
|
function materializeFilesEntry(key, files) {
|