@mnemonik/cli 7.104.9 → 7.104.11
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/digests.json +68 -68
- package/dist/humanReason.d.ts +2 -0
- package/dist/humanReason.d.ts.map +1 -1
- package/dist/humanReason.js +18 -3
- package/dist/humanReason.js.map +1 -1
- package/dist/install/journal.d.ts +1 -1
- package/dist/install/journal.d.ts.map +1 -1
- package/dist/install/journal.js +2 -0
- package/dist/install/journal.js.map +1 -1
- package/dist/install/journey.d.ts.map +1 -1
- package/dist/install/journey.js +50 -20
- package/dist/install/journey.js.map +1 -1
- package/dist/install/transaction.d.ts.map +1 -1
- package/dist/install/transaction.js +6 -11
- package/dist/install/transaction.js.map +1 -1
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/dist/preflight.js +2 -3
- package/dist/project/eligibility.d.ts +0 -1
- package/dist/project/eligibility.d.ts.map +1 -1
- package/dist/project/eligibility.js +9 -6
- package/dist/project/eligibility.js.map +1 -1
- package/dist/project.d.ts +4 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +109 -58
- package/dist/project.js.map +1 -1
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +121 -33
- package/dist/router.js.map +1 -1
- package/dist/runtime/signers.js +6 -3
- package/dist/runtime/store.d.ts +2 -1
- package/dist/runtime/store.d.ts.map +1 -1
- package/dist/runtime/store.js +9 -1
- package/dist/runtime/store.js.map +1 -1
- package/dist/sbom.json +21 -21
- package/dist/scanner/control.d.ts +3 -0
- package/dist/scanner/control.d.ts.map +1 -1
- package/dist/scanner/control.js.map +1 -1
- package/dist/scanner/discover.d.ts +2 -1
- package/dist/scanner/discover.d.ts.map +1 -1
- package/dist/scanner/discover.js +8 -12
- package/dist/scanner/discover.js.map +1 -1
- package/dist/scanner/enable.d.ts +1 -1
- package/dist/scanner/enable.d.ts.map +1 -1
- package/dist/scanner/enable.js +153 -44
- package/dist/scanner/enable.js.map +1 -1
- package/dist/scanner/picker.d.ts +1 -2
- package/dist/scanner/picker.d.ts.map +1 -1
- package/dist/scanner/picker.js +11 -34
- package/dist/scanner/picker.js.map +1 -1
- package/dist/scanner/service.d.ts +21 -3
- package/dist/scanner/service.d.ts.map +1 -1
- package/dist/scanner/service.js +2353 -118
- package/dist/scanner/service.js.map +1 -1
- package/dist/scanner/update.d.ts.map +1 -1
- package/dist/scanner/update.js +55 -128
- package/dist/scanner/update.js.map +1 -1
- package/dist/scanner-release.json +29 -29
- package/dist/screens/journey.d.ts +4 -0
- package/dist/screens/journey.d.ts.map +1 -1
- package/dist/screens/journey.js +10 -4
- package/dist/screens/journey.js.map +1 -1
- package/dist/status.d.ts +2 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +78 -6
- package/dist/status.js.map +1 -1
- package/dist/vendor/local-setup.js +21 -25
- package/dist/vendor/shared/runtimeReader.js +4 -0
- package/package.json +31 -31
package/dist/scanner/service.js
CHANGED
|
@@ -5,7 +5,21 @@ 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
|
|
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
|
+
});
|
|
14
|
+
var __esm = (fn, res, err2) => function __init() {
|
|
15
|
+
if (err2) throw err2[0];
|
|
16
|
+
try {
|
|
17
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw err2 = [e], e;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
23
|
try {
|
|
10
24
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
25
|
} catch (e) {
|
|
@@ -400,90 +414,1742 @@ var require_ignore = __commonJS({
|
|
|
400
414
|
}
|
|
401
415
|
return this;
|
|
402
416
|
}
|
|
403
|
-
// legacy
|
|
404
|
-
addPattern(pattern) {
|
|
405
|
-
return this.add(pattern);
|
|
417
|
+
// legacy
|
|
418
|
+
addPattern(pattern) {
|
|
419
|
+
return this.add(pattern);
|
|
420
|
+
}
|
|
421
|
+
// @returns {TestResult}
|
|
422
|
+
_test(originalPath, cache, checkUnignored, slices) {
|
|
423
|
+
const path = originalPath && checkPath.convert(originalPath);
|
|
424
|
+
checkPath(
|
|
425
|
+
path,
|
|
426
|
+
originalPath,
|
|
427
|
+
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
428
|
+
);
|
|
429
|
+
return this._t(path, cache, checkUnignored, slices);
|
|
430
|
+
}
|
|
431
|
+
checkIgnore(path) {
|
|
432
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
|
|
433
|
+
return this.test(path);
|
|
434
|
+
}
|
|
435
|
+
const slices = path.split(SLASH).filter(Boolean);
|
|
436
|
+
slices.pop();
|
|
437
|
+
if (slices.length) {
|
|
438
|
+
const parent = this._t(
|
|
439
|
+
slices.join(SLASH) + SLASH,
|
|
440
|
+
this._testCache,
|
|
441
|
+
true,
|
|
442
|
+
slices
|
|
443
|
+
);
|
|
444
|
+
if (parent.ignored) {
|
|
445
|
+
return parent;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return this._rules.test(path, false, MODE_CHECK_IGNORE);
|
|
449
|
+
}
|
|
450
|
+
_t(path, cache, checkUnignored, slices) {
|
|
451
|
+
if (path in cache) {
|
|
452
|
+
return cache[path];
|
|
453
|
+
}
|
|
454
|
+
if (!slices) {
|
|
455
|
+
slices = path.split(SLASH).filter(Boolean);
|
|
456
|
+
}
|
|
457
|
+
slices.pop();
|
|
458
|
+
if (!slices.length) {
|
|
459
|
+
return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
460
|
+
}
|
|
461
|
+
const parent = this._t(
|
|
462
|
+
slices.join(SLASH) + SLASH,
|
|
463
|
+
cache,
|
|
464
|
+
checkUnignored,
|
|
465
|
+
slices
|
|
466
|
+
);
|
|
467
|
+
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
468
|
+
}
|
|
469
|
+
ignores(path) {
|
|
470
|
+
return this._test(path, this._ignoreCache, false).ignored;
|
|
471
|
+
}
|
|
472
|
+
createFilter() {
|
|
473
|
+
return (path) => !this.ignores(path);
|
|
474
|
+
}
|
|
475
|
+
filter(paths) {
|
|
476
|
+
return makeArray(paths).filter(this.createFilter());
|
|
477
|
+
}
|
|
478
|
+
// @returns {TestResult}
|
|
479
|
+
test(path) {
|
|
480
|
+
return this._test(path, this._testCache, true);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
var factory = (options) => new Ignore(options);
|
|
484
|
+
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
485
|
+
var setupWindows = () => {
|
|
486
|
+
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
487
|
+
checkPath.convert = makePosix;
|
|
488
|
+
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
489
|
+
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
490
|
+
};
|
|
491
|
+
if (
|
|
492
|
+
// Detect `process` so that it can run in browsers.
|
|
493
|
+
typeof process !== "undefined" && process.platform === "win32"
|
|
494
|
+
) {
|
|
495
|
+
setupWindows();
|
|
496
|
+
}
|
|
497
|
+
module2.exports = factory;
|
|
498
|
+
factory.default = factory;
|
|
499
|
+
module2.exports.isPathValid = isPathValid;
|
|
500
|
+
define(module2.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// packages/shared/dist/runtimeSigners.js
|
|
505
|
+
var ttl;
|
|
506
|
+
var init_runtimeSigners = __esm({
|
|
507
|
+
"packages/shared/dist/runtimeSigners.js"() {
|
|
508
|
+
"use strict";
|
|
509
|
+
ttl = 10 * 6e4;
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// packages/shared/dist/repositoryFingerprint.js
|
|
514
|
+
var REPOSITORY_PROVIDER_RULES, controls;
|
|
515
|
+
var init_repositoryFingerprint = __esm({
|
|
516
|
+
"packages/shared/dist/repositoryFingerprint.js"() {
|
|
517
|
+
"use strict";
|
|
518
|
+
REPOSITORY_PROVIDER_RULES = Object.freeze([
|
|
519
|
+
Object.freeze({ name: "github", host: "github.com", sshUser: "git", removeTerminalDotGit: true })
|
|
520
|
+
]);
|
|
521
|
+
controls = new RegExp("\\p{Cc}", "u");
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
// packages/shared/dist/projectIdentityFile.js
|
|
526
|
+
var init_projectIdentityFile = __esm({
|
|
527
|
+
"packages/shared/dist/projectIdentityFile.js"() {
|
|
528
|
+
"use strict";
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
// packages/shared/dist/repositoryRoot.js
|
|
533
|
+
var init_repositoryRoot = __esm({
|
|
534
|
+
"packages/shared/dist/repositoryRoot.js"() {
|
|
535
|
+
"use strict";
|
|
536
|
+
init_projectIdentityFile();
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
// packages/shared/dist/runtimeReader.js
|
|
541
|
+
var RuntimeError;
|
|
542
|
+
var init_runtimeReader = __esm({
|
|
543
|
+
"packages/shared/dist/runtimeReader.js"() {
|
|
544
|
+
"use strict";
|
|
545
|
+
init_runtimeSigners();
|
|
546
|
+
init_runtimeSigners();
|
|
547
|
+
RuntimeError = class extends Error {
|
|
548
|
+
reason;
|
|
549
|
+
constructor(reason) {
|
|
550
|
+
super(reason);
|
|
551
|
+
this.reason = reason;
|
|
552
|
+
this.name = "RuntimeError";
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
// packages/shared/dist/projectSetupHandoff.js
|
|
559
|
+
var init_projectSetupHandoff = __esm({
|
|
560
|
+
"packages/shared/dist/projectSetupHandoff.js"() {
|
|
561
|
+
"use strict";
|
|
562
|
+
init_runtimeSigners();
|
|
563
|
+
init_runtimeReader();
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
// packages/shared/dist/hookRuntime.js
|
|
568
|
+
var init_hookRuntime = __esm({
|
|
569
|
+
"packages/shared/dist/hookRuntime.js"() {
|
|
570
|
+
"use strict";
|
|
571
|
+
init_runtimeSigners();
|
|
572
|
+
init_repositoryRoot();
|
|
573
|
+
init_runtimeReader();
|
|
574
|
+
init_runtimeSigners();
|
|
575
|
+
init_projectSetupHandoff();
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// node_modules/graceful-fs/polyfills.js
|
|
580
|
+
var require_polyfills = __commonJS({
|
|
581
|
+
"node_modules/graceful-fs/polyfills.js"(exports, module2) {
|
|
582
|
+
var constants = __require("constants");
|
|
583
|
+
var origCwd = process.cwd;
|
|
584
|
+
var cwd = null;
|
|
585
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
586
|
+
process.cwd = function() {
|
|
587
|
+
if (!cwd)
|
|
588
|
+
cwd = origCwd.call(process);
|
|
589
|
+
return cwd;
|
|
590
|
+
};
|
|
591
|
+
try {
|
|
592
|
+
process.cwd();
|
|
593
|
+
} catch (er) {
|
|
594
|
+
}
|
|
595
|
+
if (typeof process.chdir === "function") {
|
|
596
|
+
chdir = process.chdir;
|
|
597
|
+
process.chdir = function(d) {
|
|
598
|
+
cwd = null;
|
|
599
|
+
chdir.call(process, d);
|
|
600
|
+
};
|
|
601
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
602
|
+
}
|
|
603
|
+
var chdir;
|
|
604
|
+
module2.exports = patch;
|
|
605
|
+
function patch(fs3) {
|
|
606
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
607
|
+
patchLchmod(fs3);
|
|
608
|
+
}
|
|
609
|
+
if (!fs3.lutimes) {
|
|
610
|
+
patchLutimes(fs3);
|
|
611
|
+
}
|
|
612
|
+
fs3.chown = chownFix(fs3.chown);
|
|
613
|
+
fs3.fchown = chownFix(fs3.fchown);
|
|
614
|
+
fs3.lchown = chownFix(fs3.lchown);
|
|
615
|
+
fs3.chmod = chmodFix(fs3.chmod);
|
|
616
|
+
fs3.fchmod = chmodFix(fs3.fchmod);
|
|
617
|
+
fs3.lchmod = chmodFix(fs3.lchmod);
|
|
618
|
+
fs3.chownSync = chownFixSync(fs3.chownSync);
|
|
619
|
+
fs3.fchownSync = chownFixSync(fs3.fchownSync);
|
|
620
|
+
fs3.lchownSync = chownFixSync(fs3.lchownSync);
|
|
621
|
+
fs3.chmodSync = chmodFixSync(fs3.chmodSync);
|
|
622
|
+
fs3.fchmodSync = chmodFixSync(fs3.fchmodSync);
|
|
623
|
+
fs3.lchmodSync = chmodFixSync(fs3.lchmodSync);
|
|
624
|
+
fs3.stat = statFix(fs3.stat);
|
|
625
|
+
fs3.fstat = statFix(fs3.fstat);
|
|
626
|
+
fs3.lstat = statFix(fs3.lstat);
|
|
627
|
+
fs3.statSync = statFixSync(fs3.statSync);
|
|
628
|
+
fs3.fstatSync = statFixSync(fs3.fstatSync);
|
|
629
|
+
fs3.lstatSync = statFixSync(fs3.lstatSync);
|
|
630
|
+
if (fs3.chmod && !fs3.lchmod) {
|
|
631
|
+
fs3.lchmod = function(path, mode, cb) {
|
|
632
|
+
if (cb) process.nextTick(cb);
|
|
633
|
+
};
|
|
634
|
+
fs3.lchmodSync = function() {
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
if (fs3.chown && !fs3.lchown) {
|
|
638
|
+
fs3.lchown = function(path, uid, gid, cb) {
|
|
639
|
+
if (cb) process.nextTick(cb);
|
|
640
|
+
};
|
|
641
|
+
fs3.lchownSync = function() {
|
|
642
|
+
};
|
|
643
|
+
}
|
|
644
|
+
if (platform === "win32") {
|
|
645
|
+
fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : (function(fs$rename) {
|
|
646
|
+
function rename2(from, to, cb) {
|
|
647
|
+
var start2 = Date.now();
|
|
648
|
+
var backoff = 0;
|
|
649
|
+
fs$rename(from, to, function CB(er) {
|
|
650
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
|
|
651
|
+
setTimeout(function() {
|
|
652
|
+
fs3.stat(to, function(stater, st) {
|
|
653
|
+
if (stater && stater.code === "ENOENT")
|
|
654
|
+
fs$rename(from, to, CB);
|
|
655
|
+
else
|
|
656
|
+
cb(er);
|
|
657
|
+
});
|
|
658
|
+
}, backoff);
|
|
659
|
+
if (backoff < 100)
|
|
660
|
+
backoff += 10;
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
if (cb) cb(er);
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename2, fs$rename);
|
|
667
|
+
return rename2;
|
|
668
|
+
})(fs3.rename);
|
|
669
|
+
}
|
|
670
|
+
fs3.read = typeof fs3.read !== "function" ? fs3.read : (function(fs$read) {
|
|
671
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
672
|
+
var callback;
|
|
673
|
+
if (callback_ && typeof callback_ === "function") {
|
|
674
|
+
var eagCounter = 0;
|
|
675
|
+
callback = function(er, _, __) {
|
|
676
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
677
|
+
eagCounter++;
|
|
678
|
+
return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
|
|
679
|
+
}
|
|
680
|
+
callback_.apply(this, arguments);
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
|
|
684
|
+
}
|
|
685
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
686
|
+
return read;
|
|
687
|
+
})(fs3.read);
|
|
688
|
+
fs3.readSync = typeof fs3.readSync !== "function" ? fs3.readSync : /* @__PURE__ */ (function(fs$readSync) {
|
|
689
|
+
return function(fd, buffer, offset, length, position) {
|
|
690
|
+
var eagCounter = 0;
|
|
691
|
+
while (true) {
|
|
692
|
+
try {
|
|
693
|
+
return fs$readSync.call(fs3, fd, buffer, offset, length, position);
|
|
694
|
+
} catch (er) {
|
|
695
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
696
|
+
eagCounter++;
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
throw er;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
})(fs3.readSync);
|
|
704
|
+
function patchLchmod(fs4) {
|
|
705
|
+
fs4.lchmod = function(path, mode, callback) {
|
|
706
|
+
fs4.open(
|
|
707
|
+
path,
|
|
708
|
+
constants.O_WRONLY | constants.O_SYMLINK,
|
|
709
|
+
mode,
|
|
710
|
+
function(err2, fd) {
|
|
711
|
+
if (err2) {
|
|
712
|
+
if (callback) callback(err2);
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
fs4.fchmod(fd, mode, function(err3) {
|
|
716
|
+
fs4.close(fd, function(err22) {
|
|
717
|
+
if (callback) callback(err3 || err22);
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
);
|
|
722
|
+
};
|
|
723
|
+
fs4.lchmodSync = function(path, mode) {
|
|
724
|
+
var fd = fs4.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
725
|
+
var threw = true;
|
|
726
|
+
var ret;
|
|
727
|
+
try {
|
|
728
|
+
ret = fs4.fchmodSync(fd, mode);
|
|
729
|
+
threw = false;
|
|
730
|
+
} finally {
|
|
731
|
+
if (threw) {
|
|
732
|
+
try {
|
|
733
|
+
fs4.closeSync(fd);
|
|
734
|
+
} catch (er) {
|
|
735
|
+
}
|
|
736
|
+
} else {
|
|
737
|
+
fs4.closeSync(fd);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
return ret;
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
function patchLutimes(fs4) {
|
|
744
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs4.futimes) {
|
|
745
|
+
fs4.lutimes = function(path, at, mt, cb) {
|
|
746
|
+
fs4.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
747
|
+
if (er) {
|
|
748
|
+
if (cb) cb(er);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
fs4.futimes(fd, at, mt, function(er2) {
|
|
752
|
+
fs4.close(fd, function(er22) {
|
|
753
|
+
if (cb) cb(er2 || er22);
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
};
|
|
758
|
+
fs4.lutimesSync = function(path, at, mt) {
|
|
759
|
+
var fd = fs4.openSync(path, constants.O_SYMLINK);
|
|
760
|
+
var ret;
|
|
761
|
+
var threw = true;
|
|
762
|
+
try {
|
|
763
|
+
ret = fs4.futimesSync(fd, at, mt);
|
|
764
|
+
threw = false;
|
|
765
|
+
} finally {
|
|
766
|
+
if (threw) {
|
|
767
|
+
try {
|
|
768
|
+
fs4.closeSync(fd);
|
|
769
|
+
} catch (er) {
|
|
770
|
+
}
|
|
771
|
+
} else {
|
|
772
|
+
fs4.closeSync(fd);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
return ret;
|
|
776
|
+
};
|
|
777
|
+
} else if (fs4.futimes) {
|
|
778
|
+
fs4.lutimes = function(_a, _b, _c, cb) {
|
|
779
|
+
if (cb) process.nextTick(cb);
|
|
780
|
+
};
|
|
781
|
+
fs4.lutimesSync = function() {
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function chmodFix(orig) {
|
|
786
|
+
if (!orig) return orig;
|
|
787
|
+
return function(target, mode, cb) {
|
|
788
|
+
return orig.call(fs3, target, mode, function(er) {
|
|
789
|
+
if (chownErOk(er)) er = null;
|
|
790
|
+
if (cb) cb.apply(this, arguments);
|
|
791
|
+
});
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
function chmodFixSync(orig) {
|
|
795
|
+
if (!orig) return orig;
|
|
796
|
+
return function(target, mode) {
|
|
797
|
+
try {
|
|
798
|
+
return orig.call(fs3, target, mode);
|
|
799
|
+
} catch (er) {
|
|
800
|
+
if (!chownErOk(er)) throw er;
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
function chownFix(orig) {
|
|
805
|
+
if (!orig) return orig;
|
|
806
|
+
return function(target, uid, gid, cb) {
|
|
807
|
+
return orig.call(fs3, target, uid, gid, function(er) {
|
|
808
|
+
if (chownErOk(er)) er = null;
|
|
809
|
+
if (cb) cb.apply(this, arguments);
|
|
810
|
+
});
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function chownFixSync(orig) {
|
|
814
|
+
if (!orig) return orig;
|
|
815
|
+
return function(target, uid, gid) {
|
|
816
|
+
try {
|
|
817
|
+
return orig.call(fs3, target, uid, gid);
|
|
818
|
+
} catch (er) {
|
|
819
|
+
if (!chownErOk(er)) throw er;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
function statFix(orig) {
|
|
824
|
+
if (!orig) return orig;
|
|
825
|
+
return function(target, options, cb) {
|
|
826
|
+
if (typeof options === "function") {
|
|
827
|
+
cb = options;
|
|
828
|
+
options = null;
|
|
829
|
+
}
|
|
830
|
+
function callback(er, stats) {
|
|
831
|
+
if (stats) {
|
|
832
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
833
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
834
|
+
}
|
|
835
|
+
if (cb) cb.apply(this, arguments);
|
|
836
|
+
}
|
|
837
|
+
return options ? orig.call(fs3, target, options, callback) : orig.call(fs3, target, callback);
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
function statFixSync(orig) {
|
|
841
|
+
if (!orig) return orig;
|
|
842
|
+
return function(target, options) {
|
|
843
|
+
var stats = options ? orig.call(fs3, target, options) : orig.call(fs3, target);
|
|
844
|
+
if (stats) {
|
|
845
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
846
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
847
|
+
}
|
|
848
|
+
return stats;
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function chownErOk(er) {
|
|
852
|
+
if (!er)
|
|
853
|
+
return true;
|
|
854
|
+
if (er.code === "ENOSYS")
|
|
855
|
+
return true;
|
|
856
|
+
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
857
|
+
if (nonroot) {
|
|
858
|
+
if (er.code === "EINVAL" || er.code === "EPERM")
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
861
|
+
return false;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
// node_modules/graceful-fs/legacy-streams.js
|
|
868
|
+
var require_legacy_streams = __commonJS({
|
|
869
|
+
"node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
|
|
870
|
+
var Stream = __require("stream").Stream;
|
|
871
|
+
module2.exports = legacy;
|
|
872
|
+
function legacy(fs3) {
|
|
873
|
+
return {
|
|
874
|
+
ReadStream,
|
|
875
|
+
WriteStream
|
|
876
|
+
};
|
|
877
|
+
function ReadStream(path, options) {
|
|
878
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
879
|
+
Stream.call(this);
|
|
880
|
+
var self = this;
|
|
881
|
+
this.path = path;
|
|
882
|
+
this.fd = null;
|
|
883
|
+
this.readable = true;
|
|
884
|
+
this.paused = false;
|
|
885
|
+
this.flags = "r";
|
|
886
|
+
this.mode = 438;
|
|
887
|
+
this.bufferSize = 64 * 1024;
|
|
888
|
+
options = options || {};
|
|
889
|
+
var keys = Object.keys(options);
|
|
890
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
891
|
+
var key = keys[index];
|
|
892
|
+
this[key] = options[key];
|
|
893
|
+
}
|
|
894
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
895
|
+
if (this.start !== void 0) {
|
|
896
|
+
if ("number" !== typeof this.start) {
|
|
897
|
+
throw TypeError("start must be a Number");
|
|
898
|
+
}
|
|
899
|
+
if (this.end === void 0) {
|
|
900
|
+
this.end = Infinity;
|
|
901
|
+
} else if ("number" !== typeof this.end) {
|
|
902
|
+
throw TypeError("end must be a Number");
|
|
903
|
+
}
|
|
904
|
+
if (this.start > this.end) {
|
|
905
|
+
throw new Error("start must be <= end");
|
|
906
|
+
}
|
|
907
|
+
this.pos = this.start;
|
|
908
|
+
}
|
|
909
|
+
if (this.fd !== null) {
|
|
910
|
+
process.nextTick(function() {
|
|
911
|
+
self._read();
|
|
912
|
+
});
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
fs3.open(this.path, this.flags, this.mode, function(err2, fd) {
|
|
916
|
+
if (err2) {
|
|
917
|
+
self.emit("error", err2);
|
|
918
|
+
self.readable = false;
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
self.fd = fd;
|
|
922
|
+
self.emit("open", fd);
|
|
923
|
+
self._read();
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
function WriteStream(path, options) {
|
|
927
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
928
|
+
Stream.call(this);
|
|
929
|
+
this.path = path;
|
|
930
|
+
this.fd = null;
|
|
931
|
+
this.writable = true;
|
|
932
|
+
this.flags = "w";
|
|
933
|
+
this.encoding = "binary";
|
|
934
|
+
this.mode = 438;
|
|
935
|
+
this.bytesWritten = 0;
|
|
936
|
+
options = options || {};
|
|
937
|
+
var keys = Object.keys(options);
|
|
938
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
939
|
+
var key = keys[index];
|
|
940
|
+
this[key] = options[key];
|
|
941
|
+
}
|
|
942
|
+
if (this.start !== void 0) {
|
|
943
|
+
if ("number" !== typeof this.start) {
|
|
944
|
+
throw TypeError("start must be a Number");
|
|
945
|
+
}
|
|
946
|
+
if (this.start < 0) {
|
|
947
|
+
throw new Error("start must be >= zero");
|
|
948
|
+
}
|
|
949
|
+
this.pos = this.start;
|
|
950
|
+
}
|
|
951
|
+
this.busy = false;
|
|
952
|
+
this._queue = [];
|
|
953
|
+
if (this.fd === null) {
|
|
954
|
+
this._open = fs3.open;
|
|
955
|
+
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
956
|
+
this.flush();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
// node_modules/graceful-fs/clone.js
|
|
964
|
+
var require_clone = __commonJS({
|
|
965
|
+
"node_modules/graceful-fs/clone.js"(exports, module2) {
|
|
966
|
+
"use strict";
|
|
967
|
+
module2.exports = clone;
|
|
968
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
969
|
+
return obj.__proto__;
|
|
970
|
+
};
|
|
971
|
+
function clone(obj) {
|
|
972
|
+
if (obj === null || typeof obj !== "object")
|
|
973
|
+
return obj;
|
|
974
|
+
if (obj instanceof Object)
|
|
975
|
+
var copy = { __proto__: getPrototypeOf(obj) };
|
|
976
|
+
else
|
|
977
|
+
var copy = /* @__PURE__ */ Object.create(null);
|
|
978
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
979
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
980
|
+
});
|
|
981
|
+
return copy;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
// node_modules/graceful-fs/graceful-fs.js
|
|
987
|
+
var require_graceful_fs = __commonJS({
|
|
988
|
+
"node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
|
|
989
|
+
var fs3 = __require("fs");
|
|
990
|
+
var polyfills = require_polyfills();
|
|
991
|
+
var legacy = require_legacy_streams();
|
|
992
|
+
var clone = require_clone();
|
|
993
|
+
var util = __require("util");
|
|
994
|
+
var gracefulQueue;
|
|
995
|
+
var previousSymbol;
|
|
996
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
997
|
+
gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
|
|
998
|
+
previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
|
|
999
|
+
} else {
|
|
1000
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
1001
|
+
previousSymbol = "___graceful-fs.previous";
|
|
1002
|
+
}
|
|
1003
|
+
function noop() {
|
|
1004
|
+
}
|
|
1005
|
+
function publishQueue(context, queue2) {
|
|
1006
|
+
Object.defineProperty(context, gracefulQueue, {
|
|
1007
|
+
get: function() {
|
|
1008
|
+
return queue2;
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
var debug2 = noop;
|
|
1013
|
+
if (util.debuglog)
|
|
1014
|
+
debug2 = util.debuglog("gfs4");
|
|
1015
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
1016
|
+
debug2 = function() {
|
|
1017
|
+
var m = util.format.apply(util, arguments);
|
|
1018
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
1019
|
+
console.error(m);
|
|
1020
|
+
};
|
|
1021
|
+
if (!fs3[gracefulQueue]) {
|
|
1022
|
+
queue = global[gracefulQueue] || [];
|
|
1023
|
+
publishQueue(fs3, queue);
|
|
1024
|
+
fs3.close = (function(fs$close) {
|
|
1025
|
+
function close(fd, cb) {
|
|
1026
|
+
return fs$close.call(fs3, fd, function(err2) {
|
|
1027
|
+
if (!err2) {
|
|
1028
|
+
resetQueue();
|
|
1029
|
+
}
|
|
1030
|
+
if (typeof cb === "function")
|
|
1031
|
+
cb.apply(this, arguments);
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
Object.defineProperty(close, previousSymbol, {
|
|
1035
|
+
value: fs$close
|
|
1036
|
+
});
|
|
1037
|
+
return close;
|
|
1038
|
+
})(fs3.close);
|
|
1039
|
+
fs3.closeSync = (function(fs$closeSync) {
|
|
1040
|
+
function closeSync(fd) {
|
|
1041
|
+
fs$closeSync.apply(fs3, arguments);
|
|
1042
|
+
resetQueue();
|
|
1043
|
+
}
|
|
1044
|
+
Object.defineProperty(closeSync, previousSymbol, {
|
|
1045
|
+
value: fs$closeSync
|
|
1046
|
+
});
|
|
1047
|
+
return closeSync;
|
|
1048
|
+
})(fs3.closeSync);
|
|
1049
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
1050
|
+
process.on("exit", function() {
|
|
1051
|
+
debug2(fs3[gracefulQueue]);
|
|
1052
|
+
__require("assert").equal(fs3[gracefulQueue].length, 0);
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
var queue;
|
|
1057
|
+
if (!global[gracefulQueue]) {
|
|
1058
|
+
publishQueue(global, fs3[gracefulQueue]);
|
|
1059
|
+
}
|
|
1060
|
+
module2.exports = patch(clone(fs3));
|
|
1061
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs3.__patched) {
|
|
1062
|
+
module2.exports = patch(fs3);
|
|
1063
|
+
fs3.__patched = true;
|
|
1064
|
+
}
|
|
1065
|
+
function patch(fs4) {
|
|
1066
|
+
polyfills(fs4);
|
|
1067
|
+
fs4.gracefulify = patch;
|
|
1068
|
+
fs4.createReadStream = createReadStream;
|
|
1069
|
+
fs4.createWriteStream = createWriteStream;
|
|
1070
|
+
var fs$readFile = fs4.readFile;
|
|
1071
|
+
fs4.readFile = readFile4;
|
|
1072
|
+
function readFile4(path, options, cb) {
|
|
1073
|
+
if (typeof options === "function")
|
|
1074
|
+
cb = options, options = null;
|
|
1075
|
+
return go$readFile(path, options, cb);
|
|
1076
|
+
function go$readFile(path2, options2, cb2, startTime) {
|
|
1077
|
+
return fs$readFile(path2, options2, function(err2) {
|
|
1078
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1079
|
+
enqueue([go$readFile, [path2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1080
|
+
else {
|
|
1081
|
+
if (typeof cb2 === "function")
|
|
1082
|
+
cb2.apply(this, arguments);
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
var fs$writeFile = fs4.writeFile;
|
|
1088
|
+
fs4.writeFile = writeFile3;
|
|
1089
|
+
function writeFile3(path, data, options, cb) {
|
|
1090
|
+
if (typeof options === "function")
|
|
1091
|
+
cb = options, options = null;
|
|
1092
|
+
return go$writeFile(path, data, options, cb);
|
|
1093
|
+
function go$writeFile(path2, data2, options2, cb2, startTime) {
|
|
1094
|
+
return fs$writeFile(path2, data2, options2, function(err2) {
|
|
1095
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1096
|
+
enqueue([go$writeFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1097
|
+
else {
|
|
1098
|
+
if (typeof cb2 === "function")
|
|
1099
|
+
cb2.apply(this, arguments);
|
|
1100
|
+
}
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
var fs$appendFile = fs4.appendFile;
|
|
1105
|
+
if (fs$appendFile)
|
|
1106
|
+
fs4.appendFile = appendFile;
|
|
1107
|
+
function appendFile(path, data, options, cb) {
|
|
1108
|
+
if (typeof options === "function")
|
|
1109
|
+
cb = options, options = null;
|
|
1110
|
+
return go$appendFile(path, data, options, cb);
|
|
1111
|
+
function go$appendFile(path2, data2, options2, cb2, startTime) {
|
|
1112
|
+
return fs$appendFile(path2, data2, options2, function(err2) {
|
|
1113
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1114
|
+
enqueue([go$appendFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1115
|
+
else {
|
|
1116
|
+
if (typeof cb2 === "function")
|
|
1117
|
+
cb2.apply(this, arguments);
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
var fs$copyFile = fs4.copyFile;
|
|
1123
|
+
if (fs$copyFile)
|
|
1124
|
+
fs4.copyFile = copyFile;
|
|
1125
|
+
function copyFile(src, dest, flags2, cb) {
|
|
1126
|
+
if (typeof flags2 === "function") {
|
|
1127
|
+
cb = flags2;
|
|
1128
|
+
flags2 = 0;
|
|
1129
|
+
}
|
|
1130
|
+
return go$copyFile(src, dest, flags2, cb);
|
|
1131
|
+
function go$copyFile(src2, dest2, flags3, cb2, startTime) {
|
|
1132
|
+
return fs$copyFile(src2, dest2, flags3, function(err2) {
|
|
1133
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1134
|
+
enqueue([go$copyFile, [src2, dest2, flags3, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1135
|
+
else {
|
|
1136
|
+
if (typeof cb2 === "function")
|
|
1137
|
+
cb2.apply(this, arguments);
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
var fs$readdir = fs4.readdir;
|
|
1143
|
+
fs4.readdir = readdir;
|
|
1144
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
1145
|
+
function readdir(path, options, cb) {
|
|
1146
|
+
if (typeof options === "function")
|
|
1147
|
+
cb = options, options = null;
|
|
1148
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
|
|
1149
|
+
return fs$readdir(path2, fs$readdirCallback(
|
|
1150
|
+
path2,
|
|
1151
|
+
options2,
|
|
1152
|
+
cb2,
|
|
1153
|
+
startTime
|
|
1154
|
+
));
|
|
1155
|
+
} : function go$readdir2(path2, options2, cb2, startTime) {
|
|
1156
|
+
return fs$readdir(path2, options2, fs$readdirCallback(
|
|
1157
|
+
path2,
|
|
1158
|
+
options2,
|
|
1159
|
+
cb2,
|
|
1160
|
+
startTime
|
|
1161
|
+
));
|
|
1162
|
+
};
|
|
1163
|
+
return go$readdir(path, options, cb);
|
|
1164
|
+
function fs$readdirCallback(path2, options2, cb2, startTime) {
|
|
1165
|
+
return function(err2, files) {
|
|
1166
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1167
|
+
enqueue([
|
|
1168
|
+
go$readdir,
|
|
1169
|
+
[path2, options2, cb2],
|
|
1170
|
+
err2,
|
|
1171
|
+
startTime || Date.now(),
|
|
1172
|
+
Date.now()
|
|
1173
|
+
]);
|
|
1174
|
+
else {
|
|
1175
|
+
if (files && files.sort)
|
|
1176
|
+
files.sort();
|
|
1177
|
+
if (typeof cb2 === "function")
|
|
1178
|
+
cb2.call(this, err2, files);
|
|
1179
|
+
}
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
1184
|
+
var legStreams = legacy(fs4);
|
|
1185
|
+
ReadStream = legStreams.ReadStream;
|
|
1186
|
+
WriteStream = legStreams.WriteStream;
|
|
1187
|
+
}
|
|
1188
|
+
var fs$ReadStream = fs4.ReadStream;
|
|
1189
|
+
if (fs$ReadStream) {
|
|
1190
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
1191
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
1192
|
+
}
|
|
1193
|
+
var fs$WriteStream = fs4.WriteStream;
|
|
1194
|
+
if (fs$WriteStream) {
|
|
1195
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
1196
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
1197
|
+
}
|
|
1198
|
+
Object.defineProperty(fs4, "ReadStream", {
|
|
1199
|
+
get: function() {
|
|
1200
|
+
return ReadStream;
|
|
1201
|
+
},
|
|
1202
|
+
set: function(val) {
|
|
1203
|
+
ReadStream = val;
|
|
1204
|
+
},
|
|
1205
|
+
enumerable: true,
|
|
1206
|
+
configurable: true
|
|
1207
|
+
});
|
|
1208
|
+
Object.defineProperty(fs4, "WriteStream", {
|
|
1209
|
+
get: function() {
|
|
1210
|
+
return WriteStream;
|
|
1211
|
+
},
|
|
1212
|
+
set: function(val) {
|
|
1213
|
+
WriteStream = val;
|
|
1214
|
+
},
|
|
1215
|
+
enumerable: true,
|
|
1216
|
+
configurable: true
|
|
1217
|
+
});
|
|
1218
|
+
var FileReadStream = ReadStream;
|
|
1219
|
+
Object.defineProperty(fs4, "FileReadStream", {
|
|
1220
|
+
get: function() {
|
|
1221
|
+
return FileReadStream;
|
|
1222
|
+
},
|
|
1223
|
+
set: function(val) {
|
|
1224
|
+
FileReadStream = val;
|
|
1225
|
+
},
|
|
1226
|
+
enumerable: true,
|
|
1227
|
+
configurable: true
|
|
1228
|
+
});
|
|
1229
|
+
var FileWriteStream = WriteStream;
|
|
1230
|
+
Object.defineProperty(fs4, "FileWriteStream", {
|
|
1231
|
+
get: function() {
|
|
1232
|
+
return FileWriteStream;
|
|
1233
|
+
},
|
|
1234
|
+
set: function(val) {
|
|
1235
|
+
FileWriteStream = val;
|
|
1236
|
+
},
|
|
1237
|
+
enumerable: true,
|
|
1238
|
+
configurable: true
|
|
1239
|
+
});
|
|
1240
|
+
function ReadStream(path, options) {
|
|
1241
|
+
if (this instanceof ReadStream)
|
|
1242
|
+
return fs$ReadStream.apply(this, arguments), this;
|
|
1243
|
+
else
|
|
1244
|
+
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
1245
|
+
}
|
|
1246
|
+
function ReadStream$open() {
|
|
1247
|
+
var that = this;
|
|
1248
|
+
open2(that.path, that.flags, that.mode, function(err2, fd) {
|
|
1249
|
+
if (err2) {
|
|
1250
|
+
if (that.autoClose)
|
|
1251
|
+
that.destroy();
|
|
1252
|
+
that.emit("error", err2);
|
|
1253
|
+
} else {
|
|
1254
|
+
that.fd = fd;
|
|
1255
|
+
that.emit("open", fd);
|
|
1256
|
+
that.read();
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
function WriteStream(path, options) {
|
|
1261
|
+
if (this instanceof WriteStream)
|
|
1262
|
+
return fs$WriteStream.apply(this, arguments), this;
|
|
1263
|
+
else
|
|
1264
|
+
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
1265
|
+
}
|
|
1266
|
+
function WriteStream$open() {
|
|
1267
|
+
var that = this;
|
|
1268
|
+
open2(that.path, that.flags, that.mode, function(err2, fd) {
|
|
1269
|
+
if (err2) {
|
|
1270
|
+
that.destroy();
|
|
1271
|
+
that.emit("error", err2);
|
|
1272
|
+
} else {
|
|
1273
|
+
that.fd = fd;
|
|
1274
|
+
that.emit("open", fd);
|
|
1275
|
+
}
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
function createReadStream(path, options) {
|
|
1279
|
+
return new fs4.ReadStream(path, options);
|
|
1280
|
+
}
|
|
1281
|
+
function createWriteStream(path, options) {
|
|
1282
|
+
return new fs4.WriteStream(path, options);
|
|
1283
|
+
}
|
|
1284
|
+
var fs$open = fs4.open;
|
|
1285
|
+
fs4.open = open2;
|
|
1286
|
+
function open2(path, flags2, mode, cb) {
|
|
1287
|
+
if (typeof mode === "function")
|
|
1288
|
+
cb = mode, mode = null;
|
|
1289
|
+
return go$open(path, flags2, mode, cb);
|
|
1290
|
+
function go$open(path2, flags3, mode2, cb2, startTime) {
|
|
1291
|
+
return fs$open(path2, flags3, mode2, function(err2, fd) {
|
|
1292
|
+
if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
|
|
1293
|
+
enqueue([go$open, [path2, flags3, mode2, cb2], err2, startTime || Date.now(), Date.now()]);
|
|
1294
|
+
else {
|
|
1295
|
+
if (typeof cb2 === "function")
|
|
1296
|
+
cb2.apply(this, arguments);
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
return fs4;
|
|
1302
|
+
}
|
|
1303
|
+
function enqueue(elem) {
|
|
1304
|
+
debug2("ENQUEUE", elem[0].name, elem[1]);
|
|
1305
|
+
fs3[gracefulQueue].push(elem);
|
|
1306
|
+
retry();
|
|
1307
|
+
}
|
|
1308
|
+
var retryTimer;
|
|
1309
|
+
function resetQueue() {
|
|
1310
|
+
var now = Date.now();
|
|
1311
|
+
for (var i2 = 0; i2 < fs3[gracefulQueue].length; ++i2) {
|
|
1312
|
+
if (fs3[gracefulQueue][i2].length > 2) {
|
|
1313
|
+
fs3[gracefulQueue][i2][3] = now;
|
|
1314
|
+
fs3[gracefulQueue][i2][4] = now;
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
retry();
|
|
1318
|
+
}
|
|
1319
|
+
function retry() {
|
|
1320
|
+
clearTimeout(retryTimer);
|
|
1321
|
+
retryTimer = void 0;
|
|
1322
|
+
if (fs3[gracefulQueue].length === 0)
|
|
1323
|
+
return;
|
|
1324
|
+
var elem = fs3[gracefulQueue].shift();
|
|
1325
|
+
var fn = elem[0];
|
|
1326
|
+
var args2 = elem[1];
|
|
1327
|
+
var err2 = elem[2];
|
|
1328
|
+
var startTime = elem[3];
|
|
1329
|
+
var lastTime = elem[4];
|
|
1330
|
+
if (startTime === void 0) {
|
|
1331
|
+
debug2("RETRY", fn.name, args2);
|
|
1332
|
+
fn.apply(null, args2);
|
|
1333
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
1334
|
+
debug2("TIMEOUT", fn.name, args2);
|
|
1335
|
+
var cb = args2.pop();
|
|
1336
|
+
if (typeof cb === "function")
|
|
1337
|
+
cb.call(null, err2);
|
|
1338
|
+
} else {
|
|
1339
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
1340
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
1341
|
+
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
1342
|
+
if (sinceAttempt >= desiredDelay) {
|
|
1343
|
+
debug2("RETRY", fn.name, args2);
|
|
1344
|
+
fn.apply(null, args2.concat([startTime]));
|
|
1345
|
+
} else {
|
|
1346
|
+
fs3[gracefulQueue].push(elem);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
if (retryTimer === void 0) {
|
|
1350
|
+
retryTimer = setTimeout(retry, 0);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
// node_modules/retry/lib/retry_operation.js
|
|
1357
|
+
var require_retry_operation = __commonJS({
|
|
1358
|
+
"node_modules/retry/lib/retry_operation.js"(exports, module2) {
|
|
1359
|
+
function RetryOperation(timeouts, options) {
|
|
1360
|
+
if (typeof options === "boolean") {
|
|
1361
|
+
options = { forever: options };
|
|
1362
|
+
}
|
|
1363
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
1364
|
+
this._timeouts = timeouts;
|
|
1365
|
+
this._options = options || {};
|
|
1366
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
1367
|
+
this._fn = null;
|
|
1368
|
+
this._errors = [];
|
|
1369
|
+
this._attempts = 1;
|
|
1370
|
+
this._operationTimeout = null;
|
|
1371
|
+
this._operationTimeoutCb = null;
|
|
1372
|
+
this._timeout = null;
|
|
1373
|
+
this._operationStart = null;
|
|
1374
|
+
if (this._options.forever) {
|
|
1375
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
module2.exports = RetryOperation;
|
|
1379
|
+
RetryOperation.prototype.reset = function() {
|
|
1380
|
+
this._attempts = 1;
|
|
1381
|
+
this._timeouts = this._originalTimeouts;
|
|
1382
|
+
};
|
|
1383
|
+
RetryOperation.prototype.stop = function() {
|
|
1384
|
+
if (this._timeout) {
|
|
1385
|
+
clearTimeout(this._timeout);
|
|
1386
|
+
}
|
|
1387
|
+
this._timeouts = [];
|
|
1388
|
+
this._cachedTimeouts = null;
|
|
1389
|
+
};
|
|
1390
|
+
RetryOperation.prototype.retry = function(err2) {
|
|
1391
|
+
if (this._timeout) {
|
|
1392
|
+
clearTimeout(this._timeout);
|
|
1393
|
+
}
|
|
1394
|
+
if (!err2) {
|
|
1395
|
+
return false;
|
|
1396
|
+
}
|
|
1397
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1398
|
+
if (err2 && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
1399
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
1400
|
+
return false;
|
|
1401
|
+
}
|
|
1402
|
+
this._errors.push(err2);
|
|
1403
|
+
var timeout = this._timeouts.shift();
|
|
1404
|
+
if (timeout === void 0) {
|
|
1405
|
+
if (this._cachedTimeouts) {
|
|
1406
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
1407
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
1408
|
+
timeout = this._timeouts.shift();
|
|
1409
|
+
} else {
|
|
1410
|
+
return false;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
var self = this;
|
|
1414
|
+
var timer = setTimeout(function() {
|
|
1415
|
+
self._attempts++;
|
|
1416
|
+
if (self._operationTimeoutCb) {
|
|
1417
|
+
self._timeout = setTimeout(function() {
|
|
1418
|
+
self._operationTimeoutCb(self._attempts);
|
|
1419
|
+
}, self._operationTimeout);
|
|
1420
|
+
if (self._options.unref) {
|
|
1421
|
+
self._timeout.unref();
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
self._fn(self._attempts);
|
|
1425
|
+
}, timeout);
|
|
1426
|
+
if (this._options.unref) {
|
|
1427
|
+
timer.unref();
|
|
1428
|
+
}
|
|
1429
|
+
return true;
|
|
1430
|
+
};
|
|
1431
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
1432
|
+
this._fn = fn;
|
|
1433
|
+
if (timeoutOps) {
|
|
1434
|
+
if (timeoutOps.timeout) {
|
|
1435
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
1436
|
+
}
|
|
1437
|
+
if (timeoutOps.cb) {
|
|
1438
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
var self = this;
|
|
1442
|
+
if (this._operationTimeoutCb) {
|
|
1443
|
+
this._timeout = setTimeout(function() {
|
|
1444
|
+
self._operationTimeoutCb();
|
|
1445
|
+
}, self._operationTimeout);
|
|
1446
|
+
}
|
|
1447
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
1448
|
+
this._fn(this._attempts);
|
|
1449
|
+
};
|
|
1450
|
+
RetryOperation.prototype.try = function(fn) {
|
|
1451
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
1452
|
+
this.attempt(fn);
|
|
1453
|
+
};
|
|
1454
|
+
RetryOperation.prototype.start = function(fn) {
|
|
1455
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
1456
|
+
this.attempt(fn);
|
|
1457
|
+
};
|
|
1458
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
1459
|
+
RetryOperation.prototype.errors = function() {
|
|
1460
|
+
return this._errors;
|
|
1461
|
+
};
|
|
1462
|
+
RetryOperation.prototype.attempts = function() {
|
|
1463
|
+
return this._attempts;
|
|
1464
|
+
};
|
|
1465
|
+
RetryOperation.prototype.mainError = function() {
|
|
1466
|
+
if (this._errors.length === 0) {
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
var counts = {};
|
|
1470
|
+
var mainError = null;
|
|
1471
|
+
var mainErrorCount = 0;
|
|
1472
|
+
for (var i2 = 0; i2 < this._errors.length; i2++) {
|
|
1473
|
+
var error = this._errors[i2];
|
|
1474
|
+
var message = error.message;
|
|
1475
|
+
var count = (counts[message] || 0) + 1;
|
|
1476
|
+
counts[message] = count;
|
|
1477
|
+
if (count >= mainErrorCount) {
|
|
1478
|
+
mainError = error;
|
|
1479
|
+
mainErrorCount = count;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
return mainError;
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
// node_modules/retry/lib/retry.js
|
|
1488
|
+
var require_retry = __commonJS({
|
|
1489
|
+
"node_modules/retry/lib/retry.js"(exports) {
|
|
1490
|
+
var RetryOperation = require_retry_operation();
|
|
1491
|
+
exports.operation = function(options) {
|
|
1492
|
+
var timeouts = exports.timeouts(options);
|
|
1493
|
+
return new RetryOperation(timeouts, {
|
|
1494
|
+
forever: options && options.forever,
|
|
1495
|
+
unref: options && options.unref,
|
|
1496
|
+
maxRetryTime: options && options.maxRetryTime
|
|
1497
|
+
});
|
|
1498
|
+
};
|
|
1499
|
+
exports.timeouts = function(options) {
|
|
1500
|
+
if (options instanceof Array) {
|
|
1501
|
+
return [].concat(options);
|
|
1502
|
+
}
|
|
1503
|
+
var opts = {
|
|
1504
|
+
retries: 10,
|
|
1505
|
+
factor: 2,
|
|
1506
|
+
minTimeout: 1 * 1e3,
|
|
1507
|
+
maxTimeout: Infinity,
|
|
1508
|
+
randomize: false
|
|
1509
|
+
};
|
|
1510
|
+
for (var key in options) {
|
|
1511
|
+
opts[key] = options[key];
|
|
1512
|
+
}
|
|
1513
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
1514
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
1515
|
+
}
|
|
1516
|
+
var timeouts = [];
|
|
1517
|
+
for (var i2 = 0; i2 < opts.retries; i2++) {
|
|
1518
|
+
timeouts.push(this.createTimeout(i2, opts));
|
|
1519
|
+
}
|
|
1520
|
+
if (options && options.forever && !timeouts.length) {
|
|
1521
|
+
timeouts.push(this.createTimeout(i2, opts));
|
|
1522
|
+
}
|
|
1523
|
+
timeouts.sort(function(a, b) {
|
|
1524
|
+
return a - b;
|
|
1525
|
+
});
|
|
1526
|
+
return timeouts;
|
|
1527
|
+
};
|
|
1528
|
+
exports.createTimeout = function(attempt, opts) {
|
|
1529
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
1530
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
1531
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
1532
|
+
return timeout;
|
|
1533
|
+
};
|
|
1534
|
+
exports.wrap = function(obj, options, methods) {
|
|
1535
|
+
if (options instanceof Array) {
|
|
1536
|
+
methods = options;
|
|
1537
|
+
options = null;
|
|
1538
|
+
}
|
|
1539
|
+
if (!methods) {
|
|
1540
|
+
methods = [];
|
|
1541
|
+
for (var key in obj) {
|
|
1542
|
+
if (typeof obj[key] === "function") {
|
|
1543
|
+
methods.push(key);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
for (var i2 = 0; i2 < methods.length; i2++) {
|
|
1548
|
+
var method = methods[i2];
|
|
1549
|
+
var original = obj[method];
|
|
1550
|
+
obj[method] = function retryWrapper(original2) {
|
|
1551
|
+
var op = exports.operation(options);
|
|
1552
|
+
var args2 = Array.prototype.slice.call(arguments, 1);
|
|
1553
|
+
var callback = args2.pop();
|
|
1554
|
+
args2.push(function(err2) {
|
|
1555
|
+
if (op.retry(err2)) {
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
if (err2) {
|
|
1559
|
+
arguments[0] = op.mainError();
|
|
1560
|
+
}
|
|
1561
|
+
callback.apply(this, arguments);
|
|
1562
|
+
});
|
|
1563
|
+
op.attempt(function() {
|
|
1564
|
+
original2.apply(obj, args2);
|
|
1565
|
+
});
|
|
1566
|
+
}.bind(obj, original);
|
|
1567
|
+
obj[method].options = options;
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
|
|
1573
|
+
// node_modules/retry/index.js
|
|
1574
|
+
var require_retry2 = __commonJS({
|
|
1575
|
+
"node_modules/retry/index.js"(exports, module2) {
|
|
1576
|
+
module2.exports = require_retry();
|
|
1577
|
+
}
|
|
1578
|
+
});
|
|
1579
|
+
|
|
1580
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/signals.js
|
|
1581
|
+
var require_signals = __commonJS({
|
|
1582
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module2) {
|
|
1583
|
+
module2.exports = [
|
|
1584
|
+
"SIGABRT",
|
|
1585
|
+
"SIGALRM",
|
|
1586
|
+
"SIGHUP",
|
|
1587
|
+
"SIGINT",
|
|
1588
|
+
"SIGTERM"
|
|
1589
|
+
];
|
|
1590
|
+
if (process.platform !== "win32") {
|
|
1591
|
+
module2.exports.push(
|
|
1592
|
+
"SIGVTALRM",
|
|
1593
|
+
"SIGXCPU",
|
|
1594
|
+
"SIGXFSZ",
|
|
1595
|
+
"SIGUSR2",
|
|
1596
|
+
"SIGTRAP",
|
|
1597
|
+
"SIGSYS",
|
|
1598
|
+
"SIGQUIT",
|
|
1599
|
+
"SIGIOT"
|
|
1600
|
+
// should detect profiler and enable/disable accordingly.
|
|
1601
|
+
// see #21
|
|
1602
|
+
// 'SIGPROF'
|
|
1603
|
+
);
|
|
1604
|
+
}
|
|
1605
|
+
if (process.platform === "linux") {
|
|
1606
|
+
module2.exports.push(
|
|
1607
|
+
"SIGIO",
|
|
1608
|
+
"SIGPOLL",
|
|
1609
|
+
"SIGPWR",
|
|
1610
|
+
"SIGSTKFLT",
|
|
1611
|
+
"SIGUNUSED"
|
|
1612
|
+
);
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
|
|
1617
|
+
// node_modules/proper-lockfile/node_modules/signal-exit/index.js
|
|
1618
|
+
var require_signal_exit = __commonJS({
|
|
1619
|
+
"node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module2) {
|
|
1620
|
+
var process2 = global.process;
|
|
1621
|
+
var processOk = function(process3) {
|
|
1622
|
+
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";
|
|
1623
|
+
};
|
|
1624
|
+
if (!processOk(process2)) {
|
|
1625
|
+
module2.exports = function() {
|
|
1626
|
+
return function() {
|
|
1627
|
+
};
|
|
1628
|
+
};
|
|
1629
|
+
} else {
|
|
1630
|
+
assert = __require("assert");
|
|
1631
|
+
signals = require_signals();
|
|
1632
|
+
isWin = /^win/i.test(process2.platform);
|
|
1633
|
+
EE = __require("events");
|
|
1634
|
+
if (typeof EE !== "function") {
|
|
1635
|
+
EE = EE.EventEmitter;
|
|
1636
|
+
}
|
|
1637
|
+
if (process2.__signal_exit_emitter__) {
|
|
1638
|
+
emitter = process2.__signal_exit_emitter__;
|
|
1639
|
+
} else {
|
|
1640
|
+
emitter = process2.__signal_exit_emitter__ = new EE();
|
|
1641
|
+
emitter.count = 0;
|
|
1642
|
+
emitter.emitted = {};
|
|
1643
|
+
}
|
|
1644
|
+
if (!emitter.infinite) {
|
|
1645
|
+
emitter.setMaxListeners(Infinity);
|
|
1646
|
+
emitter.infinite = true;
|
|
1647
|
+
}
|
|
1648
|
+
module2.exports = function(cb, opts) {
|
|
1649
|
+
if (!processOk(global.process)) {
|
|
1650
|
+
return function() {
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
1654
|
+
if (loaded === false) {
|
|
1655
|
+
load();
|
|
1656
|
+
}
|
|
1657
|
+
var ev = "exit";
|
|
1658
|
+
if (opts && opts.alwaysLast) {
|
|
1659
|
+
ev = "afterexit";
|
|
1660
|
+
}
|
|
1661
|
+
var remove = function() {
|
|
1662
|
+
emitter.removeListener(ev, cb);
|
|
1663
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
|
|
1664
|
+
unload();
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
emitter.on(ev, cb);
|
|
1668
|
+
return remove;
|
|
1669
|
+
};
|
|
1670
|
+
unload = function unload2() {
|
|
1671
|
+
if (!loaded || !processOk(global.process)) {
|
|
1672
|
+
return;
|
|
1673
|
+
}
|
|
1674
|
+
loaded = false;
|
|
1675
|
+
signals.forEach(function(sig) {
|
|
1676
|
+
try {
|
|
1677
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
1678
|
+
} catch (er) {
|
|
1679
|
+
}
|
|
1680
|
+
});
|
|
1681
|
+
process2.emit = originalProcessEmit;
|
|
1682
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
1683
|
+
emitter.count -= 1;
|
|
1684
|
+
};
|
|
1685
|
+
module2.exports.unload = unload;
|
|
1686
|
+
emit = function emit2(event, code, signal) {
|
|
1687
|
+
if (emitter.emitted[event]) {
|
|
1688
|
+
return;
|
|
1689
|
+
}
|
|
1690
|
+
emitter.emitted[event] = true;
|
|
1691
|
+
emitter.emit(event, code, signal);
|
|
1692
|
+
};
|
|
1693
|
+
sigListeners = {};
|
|
1694
|
+
signals.forEach(function(sig) {
|
|
1695
|
+
sigListeners[sig] = function listener() {
|
|
1696
|
+
if (!processOk(global.process)) {
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1699
|
+
var listeners = process2.listeners(sig);
|
|
1700
|
+
if (listeners.length === emitter.count) {
|
|
1701
|
+
unload();
|
|
1702
|
+
emit("exit", null, sig);
|
|
1703
|
+
emit("afterexit", null, sig);
|
|
1704
|
+
if (isWin && sig === "SIGHUP") {
|
|
1705
|
+
sig = "SIGINT";
|
|
1706
|
+
}
|
|
1707
|
+
process2.kill(process2.pid, sig);
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
});
|
|
1711
|
+
module2.exports.signals = function() {
|
|
1712
|
+
return signals;
|
|
1713
|
+
};
|
|
1714
|
+
loaded = false;
|
|
1715
|
+
load = function load2() {
|
|
1716
|
+
if (loaded || !processOk(global.process)) {
|
|
1717
|
+
return;
|
|
1718
|
+
}
|
|
1719
|
+
loaded = true;
|
|
1720
|
+
emitter.count += 1;
|
|
1721
|
+
signals = signals.filter(function(sig) {
|
|
1722
|
+
try {
|
|
1723
|
+
process2.on(sig, sigListeners[sig]);
|
|
1724
|
+
return true;
|
|
1725
|
+
} catch (er) {
|
|
1726
|
+
return false;
|
|
1727
|
+
}
|
|
1728
|
+
});
|
|
1729
|
+
process2.emit = processEmit;
|
|
1730
|
+
process2.reallyExit = processReallyExit;
|
|
1731
|
+
};
|
|
1732
|
+
module2.exports.load = load;
|
|
1733
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
1734
|
+
processReallyExit = function processReallyExit2(code) {
|
|
1735
|
+
if (!processOk(global.process)) {
|
|
1736
|
+
return;
|
|
1737
|
+
}
|
|
1738
|
+
process2.exitCode = code || /* istanbul ignore next */
|
|
1739
|
+
0;
|
|
1740
|
+
emit("exit", process2.exitCode, null);
|
|
1741
|
+
emit("afterexit", process2.exitCode, null);
|
|
1742
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
1743
|
+
};
|
|
1744
|
+
originalProcessEmit = process2.emit;
|
|
1745
|
+
processEmit = function processEmit2(ev, arg) {
|
|
1746
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1747
|
+
if (arg !== void 0) {
|
|
1748
|
+
process2.exitCode = arg;
|
|
1749
|
+
}
|
|
1750
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1751
|
+
emit("exit", process2.exitCode, null);
|
|
1752
|
+
emit("afterexit", process2.exitCode, null);
|
|
1753
|
+
return ret;
|
|
1754
|
+
} else {
|
|
1755
|
+
return originalProcessEmit.apply(this, arguments);
|
|
1756
|
+
}
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
var assert;
|
|
1760
|
+
var signals;
|
|
1761
|
+
var isWin;
|
|
1762
|
+
var EE;
|
|
1763
|
+
var emitter;
|
|
1764
|
+
var unload;
|
|
1765
|
+
var emit;
|
|
1766
|
+
var sigListeners;
|
|
1767
|
+
var loaded;
|
|
1768
|
+
var load;
|
|
1769
|
+
var originalProcessReallyExit;
|
|
1770
|
+
var processReallyExit;
|
|
1771
|
+
var originalProcessEmit;
|
|
1772
|
+
var processEmit;
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
|
|
1776
|
+
// node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1777
|
+
var require_mtime_precision = __commonJS({
|
|
1778
|
+
"node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module2) {
|
|
1779
|
+
"use strict";
|
|
1780
|
+
var cacheSymbol = /* @__PURE__ */ Symbol();
|
|
1781
|
+
function probe(file, fs3, callback) {
|
|
1782
|
+
const cachedPrecision = fs3[cacheSymbol];
|
|
1783
|
+
if (cachedPrecision) {
|
|
1784
|
+
return fs3.stat(file, (err2, stat) => {
|
|
1785
|
+
if (err2) {
|
|
1786
|
+
return callback(err2);
|
|
1787
|
+
}
|
|
1788
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1792
|
+
fs3.utimes(file, mtime, mtime, (err2) => {
|
|
1793
|
+
if (err2) {
|
|
1794
|
+
return callback(err2);
|
|
1795
|
+
}
|
|
1796
|
+
fs3.stat(file, (err3, stat) => {
|
|
1797
|
+
if (err3) {
|
|
1798
|
+
return callback(err3);
|
|
1799
|
+
}
|
|
1800
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1801
|
+
Object.defineProperty(fs3, cacheSymbol, { value: precision });
|
|
1802
|
+
callback(null, stat.mtime, precision);
|
|
1803
|
+
});
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
function getMtime(precision) {
|
|
1807
|
+
let now = Date.now();
|
|
1808
|
+
if (precision === "s") {
|
|
1809
|
+
now = Math.ceil(now / 1e3) * 1e3;
|
|
1810
|
+
}
|
|
1811
|
+
return new Date(now);
|
|
1812
|
+
}
|
|
1813
|
+
module2.exports.probe = probe;
|
|
1814
|
+
module2.exports.getMtime = getMtime;
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
|
|
1818
|
+
// node_modules/proper-lockfile/lib/lockfile.js
|
|
1819
|
+
var require_lockfile = __commonJS({
|
|
1820
|
+
"node_modules/proper-lockfile/lib/lockfile.js"(exports, module2) {
|
|
1821
|
+
"use strict";
|
|
1822
|
+
var path = __require("path");
|
|
1823
|
+
var fs3 = require_graceful_fs();
|
|
1824
|
+
var retry = require_retry2();
|
|
1825
|
+
var onExit = require_signal_exit();
|
|
1826
|
+
var mtimePrecision = require_mtime_precision();
|
|
1827
|
+
var locks = {};
|
|
1828
|
+
function getLockFile(file, options) {
|
|
1829
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1830
|
+
}
|
|
1831
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1832
|
+
if (!options.realpath) {
|
|
1833
|
+
return callback(null, path.resolve(file));
|
|
1834
|
+
}
|
|
1835
|
+
options.fs.realpath(file, callback);
|
|
1836
|
+
}
|
|
1837
|
+
function acquireLock(file, options, callback) {
|
|
1838
|
+
const lockfilePath = getLockFile(file, options);
|
|
1839
|
+
options.fs.mkdir(lockfilePath, (err2) => {
|
|
1840
|
+
if (!err2) {
|
|
1841
|
+
return mtimePrecision.probe(lockfilePath, options.fs, (err3, mtime, mtimePrecision2) => {
|
|
1842
|
+
if (err3) {
|
|
1843
|
+
options.fs.rmdir(lockfilePath, () => {
|
|
1844
|
+
});
|
|
1845
|
+
return callback(err3);
|
|
1846
|
+
}
|
|
1847
|
+
callback(null, mtime, mtimePrecision2);
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
if (err2.code !== "EEXIST") {
|
|
1851
|
+
return callback(err2);
|
|
1852
|
+
}
|
|
1853
|
+
if (options.stale <= 0) {
|
|
1854
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1855
|
+
}
|
|
1856
|
+
options.fs.stat(lockfilePath, (err3, stat) => {
|
|
1857
|
+
if (err3) {
|
|
1858
|
+
if (err3.code === "ENOENT") {
|
|
1859
|
+
return acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1860
|
+
}
|
|
1861
|
+
return callback(err3);
|
|
1862
|
+
}
|
|
1863
|
+
if (!isLockStale(stat, options)) {
|
|
1864
|
+
return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
|
|
1865
|
+
}
|
|
1866
|
+
removeLock(file, options, (err4) => {
|
|
1867
|
+
if (err4) {
|
|
1868
|
+
return callback(err4);
|
|
1869
|
+
}
|
|
1870
|
+
acquireLock(file, { ...options, stale: 0 }, callback);
|
|
1871
|
+
});
|
|
1872
|
+
});
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1875
|
+
function isLockStale(stat, options) {
|
|
1876
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
1877
|
+
}
|
|
1878
|
+
function removeLock(file, options, callback) {
|
|
1879
|
+
options.fs.rmdir(getLockFile(file, options), (err2) => {
|
|
1880
|
+
if (err2 && err2.code !== "ENOENT") {
|
|
1881
|
+
return callback(err2);
|
|
1882
|
+
}
|
|
1883
|
+
callback();
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
function updateLock(file, options) {
|
|
1887
|
+
const lock2 = locks[file];
|
|
1888
|
+
if (lock2.updateTimeout) {
|
|
1889
|
+
return;
|
|
1890
|
+
}
|
|
1891
|
+
lock2.updateDelay = lock2.updateDelay || options.update;
|
|
1892
|
+
lock2.updateTimeout = setTimeout(() => {
|
|
1893
|
+
lock2.updateTimeout = null;
|
|
1894
|
+
options.fs.stat(lock2.lockfilePath, (err2, stat) => {
|
|
1895
|
+
const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
|
|
1896
|
+
if (err2) {
|
|
1897
|
+
if (err2.code === "ENOENT" || isOverThreshold) {
|
|
1898
|
+
return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
|
|
1899
|
+
}
|
|
1900
|
+
lock2.updateDelay = 1e3;
|
|
1901
|
+
return updateLock(file, options);
|
|
1902
|
+
}
|
|
1903
|
+
const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
|
|
1904
|
+
if (!isMtimeOurs) {
|
|
1905
|
+
return setLockAsCompromised(
|
|
1906
|
+
file,
|
|
1907
|
+
lock2,
|
|
1908
|
+
Object.assign(
|
|
1909
|
+
new Error("Unable to update lock within the stale threshold"),
|
|
1910
|
+
{ code: "ECOMPROMISED" }
|
|
1911
|
+
)
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1914
|
+
const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
|
|
1915
|
+
options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err3) => {
|
|
1916
|
+
const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
|
|
1917
|
+
if (lock2.released) {
|
|
1918
|
+
return;
|
|
1919
|
+
}
|
|
1920
|
+
if (err3) {
|
|
1921
|
+
if (err3.code === "ENOENT" || isOverThreshold2) {
|
|
1922
|
+
return setLockAsCompromised(file, lock2, Object.assign(err3, { code: "ECOMPROMISED" }));
|
|
1923
|
+
}
|
|
1924
|
+
lock2.updateDelay = 1e3;
|
|
1925
|
+
return updateLock(file, options);
|
|
1926
|
+
}
|
|
1927
|
+
lock2.mtime = mtime;
|
|
1928
|
+
lock2.lastUpdate = Date.now();
|
|
1929
|
+
lock2.updateDelay = null;
|
|
1930
|
+
updateLock(file, options);
|
|
1931
|
+
});
|
|
1932
|
+
});
|
|
1933
|
+
}, lock2.updateDelay);
|
|
1934
|
+
if (lock2.updateTimeout.unref) {
|
|
1935
|
+
lock2.updateTimeout.unref();
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
function setLockAsCompromised(file, lock2, err2) {
|
|
1939
|
+
lock2.released = true;
|
|
1940
|
+
if (lock2.updateTimeout) {
|
|
1941
|
+
clearTimeout(lock2.updateTimeout);
|
|
406
1942
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
const path = originalPath && checkPath.convert(originalPath);
|
|
410
|
-
checkPath(
|
|
411
|
-
path,
|
|
412
|
-
originalPath,
|
|
413
|
-
this._strictPathCheck ? throwError : RETURN_FALSE
|
|
414
|
-
);
|
|
415
|
-
return this._t(path, cache, checkUnignored, slices);
|
|
1943
|
+
if (locks[file] === lock2) {
|
|
1944
|
+
delete locks[file];
|
|
416
1945
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
1946
|
+
lock2.options.onCompromised(err2);
|
|
1947
|
+
}
|
|
1948
|
+
function lock(file, options, callback) {
|
|
1949
|
+
options = {
|
|
1950
|
+
stale: 1e4,
|
|
1951
|
+
update: null,
|
|
1952
|
+
realpath: true,
|
|
1953
|
+
retries: 0,
|
|
1954
|
+
fs: fs3,
|
|
1955
|
+
onCompromised: (err2) => {
|
|
1956
|
+
throw err2;
|
|
1957
|
+
},
|
|
1958
|
+
...options
|
|
1959
|
+
};
|
|
1960
|
+
options.retries = options.retries || 0;
|
|
1961
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1962
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1963
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1964
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1965
|
+
resolveCanonicalPath(file, options, (err2, file2) => {
|
|
1966
|
+
if (err2) {
|
|
1967
|
+
return callback(err2);
|
|
420
1968
|
}
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
1969
|
+
const operation = retry.operation(options.retries);
|
|
1970
|
+
operation.attempt(() => {
|
|
1971
|
+
acquireLock(file2, options, (err3, mtime, mtimePrecision2) => {
|
|
1972
|
+
if (operation.retry(err3)) {
|
|
1973
|
+
return;
|
|
1974
|
+
}
|
|
1975
|
+
if (err3) {
|
|
1976
|
+
return callback(operation.mainError());
|
|
1977
|
+
}
|
|
1978
|
+
const lock2 = locks[file2] = {
|
|
1979
|
+
lockfilePath: getLockFile(file2, options),
|
|
1980
|
+
mtime,
|
|
1981
|
+
mtimePrecision: mtimePrecision2,
|
|
1982
|
+
options,
|
|
1983
|
+
lastUpdate: Date.now()
|
|
1984
|
+
};
|
|
1985
|
+
updateLock(file2, options);
|
|
1986
|
+
callback(null, (releasedCallback) => {
|
|
1987
|
+
if (lock2.released) {
|
|
1988
|
+
return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1989
|
+
}
|
|
1990
|
+
unlock(file2, { ...options, realpath: false }, releasedCallback);
|
|
1991
|
+
});
|
|
1992
|
+
});
|
|
1993
|
+
});
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
function unlock(file, options, callback) {
|
|
1997
|
+
options = {
|
|
1998
|
+
fs: fs3,
|
|
1999
|
+
realpath: true,
|
|
2000
|
+
...options
|
|
2001
|
+
};
|
|
2002
|
+
resolveCanonicalPath(file, options, (err2, file2) => {
|
|
2003
|
+
if (err2) {
|
|
2004
|
+
return callback(err2);
|
|
433
2005
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
if (path in cache) {
|
|
438
|
-
return cache[path];
|
|
2006
|
+
const lock2 = locks[file2];
|
|
2007
|
+
if (!lock2) {
|
|
2008
|
+
return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
439
2009
|
}
|
|
440
|
-
|
|
441
|
-
|
|
2010
|
+
lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
|
|
2011
|
+
lock2.released = true;
|
|
2012
|
+
delete locks[file2];
|
|
2013
|
+
removeLock(file2, options, callback);
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
function check(file, options, callback) {
|
|
2017
|
+
options = {
|
|
2018
|
+
stale: 1e4,
|
|
2019
|
+
realpath: true,
|
|
2020
|
+
fs: fs3,
|
|
2021
|
+
...options
|
|
2022
|
+
};
|
|
2023
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
2024
|
+
resolveCanonicalPath(file, options, (err2, file2) => {
|
|
2025
|
+
if (err2) {
|
|
2026
|
+
return callback(err2);
|
|
442
2027
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
2028
|
+
options.fs.stat(getLockFile(file2, options), (err3, stat) => {
|
|
2029
|
+
if (err3) {
|
|
2030
|
+
return err3.code === "ENOENT" ? callback(null, false) : callback(err3);
|
|
2031
|
+
}
|
|
2032
|
+
return callback(null, !isLockStale(stat, options));
|
|
2033
|
+
});
|
|
2034
|
+
});
|
|
2035
|
+
}
|
|
2036
|
+
function getLocks() {
|
|
2037
|
+
return locks;
|
|
2038
|
+
}
|
|
2039
|
+
onExit(() => {
|
|
2040
|
+
for (const file in locks) {
|
|
2041
|
+
const options = locks[file].options;
|
|
2042
|
+
try {
|
|
2043
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
2044
|
+
} catch (e) {
|
|
446
2045
|
}
|
|
447
|
-
const parent = this._t(
|
|
448
|
-
slices.join(SLASH) + SLASH,
|
|
449
|
-
cache,
|
|
450
|
-
checkUnignored,
|
|
451
|
-
slices
|
|
452
|
-
);
|
|
453
|
-
return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
|
|
454
|
-
}
|
|
455
|
-
ignores(path) {
|
|
456
|
-
return this._test(path, this._ignoreCache, false).ignored;
|
|
457
|
-
}
|
|
458
|
-
createFilter() {
|
|
459
|
-
return (path) => !this.ignores(path);
|
|
460
|
-
}
|
|
461
|
-
filter(paths) {
|
|
462
|
-
return makeArray(paths).filter(this.createFilter());
|
|
463
2046
|
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
2047
|
+
});
|
|
2048
|
+
module2.exports.lock = lock;
|
|
2049
|
+
module2.exports.unlock = unlock;
|
|
2050
|
+
module2.exports.check = check;
|
|
2051
|
+
module2.exports.getLocks = getLocks;
|
|
2052
|
+
}
|
|
2053
|
+
});
|
|
2054
|
+
|
|
2055
|
+
// node_modules/proper-lockfile/lib/adapter.js
|
|
2056
|
+
var require_adapter = __commonJS({
|
|
2057
|
+
"node_modules/proper-lockfile/lib/adapter.js"(exports, module2) {
|
|
2058
|
+
"use strict";
|
|
2059
|
+
var fs3 = require_graceful_fs();
|
|
2060
|
+
function createSyncFs(fs4) {
|
|
2061
|
+
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
2062
|
+
const newFs = { ...fs4 };
|
|
2063
|
+
methods.forEach((method) => {
|
|
2064
|
+
newFs[method] = (...args2) => {
|
|
2065
|
+
const callback = args2.pop();
|
|
2066
|
+
let ret;
|
|
2067
|
+
try {
|
|
2068
|
+
ret = fs4[`${method}Sync`](...args2);
|
|
2069
|
+
} catch (err2) {
|
|
2070
|
+
return callback(err2);
|
|
2071
|
+
}
|
|
2072
|
+
callback(null, ret);
|
|
2073
|
+
};
|
|
2074
|
+
});
|
|
2075
|
+
return newFs;
|
|
2076
|
+
}
|
|
2077
|
+
function toPromise(method) {
|
|
2078
|
+
return (...args2) => new Promise((resolve, reject) => {
|
|
2079
|
+
args2.push((err2, result) => {
|
|
2080
|
+
if (err2) {
|
|
2081
|
+
reject(err2);
|
|
2082
|
+
} else {
|
|
2083
|
+
resolve(result);
|
|
2084
|
+
}
|
|
2085
|
+
});
|
|
2086
|
+
method(...args2);
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
function toSync(method) {
|
|
2090
|
+
return (...args2) => {
|
|
2091
|
+
let err2;
|
|
2092
|
+
let result;
|
|
2093
|
+
args2.push((_err, _result) => {
|
|
2094
|
+
err2 = _err;
|
|
2095
|
+
result = _result;
|
|
2096
|
+
});
|
|
2097
|
+
method(...args2);
|
|
2098
|
+
if (err2) {
|
|
2099
|
+
throw err2;
|
|
2100
|
+
}
|
|
2101
|
+
return result;
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
2104
|
+
function toSyncOptions(options) {
|
|
2105
|
+
options = { ...options };
|
|
2106
|
+
options.fs = createSyncFs(options.fs || fs3);
|
|
2107
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
2108
|
+
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
467
2109
|
}
|
|
468
|
-
|
|
469
|
-
var factory = (options) => new Ignore(options);
|
|
470
|
-
var isPathValid = (path) => checkPath(path && checkPath.convert(path), path, RETURN_FALSE);
|
|
471
|
-
var setupWindows = () => {
|
|
472
|
-
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
473
|
-
checkPath.convert = makePosix;
|
|
474
|
-
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
475
|
-
checkPath.isNotRelative = (path) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path) || isNotRelative(path);
|
|
476
|
-
};
|
|
477
|
-
if (
|
|
478
|
-
// Detect `process` so that it can run in browsers.
|
|
479
|
-
typeof process !== "undefined" && process.platform === "win32"
|
|
480
|
-
) {
|
|
481
|
-
setupWindows();
|
|
2110
|
+
return options;
|
|
482
2111
|
}
|
|
483
|
-
module2.exports =
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
2112
|
+
module2.exports = {
|
|
2113
|
+
toPromise,
|
|
2114
|
+
toSync,
|
|
2115
|
+
toSyncOptions
|
|
2116
|
+
};
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
|
|
2120
|
+
// node_modules/proper-lockfile/index.js
|
|
2121
|
+
var require_proper_lockfile = __commonJS({
|
|
2122
|
+
"node_modules/proper-lockfile/index.js"(exports, module2) {
|
|
2123
|
+
"use strict";
|
|
2124
|
+
var lockfile = require_lockfile();
|
|
2125
|
+
var { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
2126
|
+
async function lock(file, options) {
|
|
2127
|
+
const release = await toPromise(lockfile.lock)(file, options);
|
|
2128
|
+
return toPromise(release);
|
|
2129
|
+
}
|
|
2130
|
+
function lockSync(file, options) {
|
|
2131
|
+
const release = toSync(lockfile.lock)(file, toSyncOptions(options));
|
|
2132
|
+
return toSync(release);
|
|
2133
|
+
}
|
|
2134
|
+
function unlock(file, options) {
|
|
2135
|
+
return toPromise(lockfile.unlock)(file, options);
|
|
2136
|
+
}
|
|
2137
|
+
function unlockSync(file, options) {
|
|
2138
|
+
return toSync(lockfile.unlock)(file, toSyncOptions(options));
|
|
2139
|
+
}
|
|
2140
|
+
function check(file, options) {
|
|
2141
|
+
return toPromise(lockfile.check)(file, options);
|
|
2142
|
+
}
|
|
2143
|
+
function checkSync(file, options) {
|
|
2144
|
+
return toSync(lockfile.check)(file, toSyncOptions(options));
|
|
2145
|
+
}
|
|
2146
|
+
module2.exports = lock;
|
|
2147
|
+
module2.exports.lock = lock;
|
|
2148
|
+
module2.exports.unlock = unlock;
|
|
2149
|
+
module2.exports.lockSync = lockSync;
|
|
2150
|
+
module2.exports.unlockSync = unlockSync;
|
|
2151
|
+
module2.exports.check = check;
|
|
2152
|
+
module2.exports.checkSync = checkSync;
|
|
487
2153
|
}
|
|
488
2154
|
});
|
|
489
2155
|
|
|
@@ -1994,8 +3660,8 @@ var Language = class _Language {
|
|
|
1994
3660
|
if (input instanceof Uint8Array) {
|
|
1995
3661
|
binary2 = input;
|
|
1996
3662
|
} else if (globalThis.process?.versions.node) {
|
|
1997
|
-
const
|
|
1998
|
-
binary2 = await
|
|
3663
|
+
const fs22 = await import("fs/promises");
|
|
3664
|
+
binary2 = await fs22.readFile(input);
|
|
1999
3665
|
} else {
|
|
2000
3666
|
const response = await fetch(input);
|
|
2001
3667
|
if (!response.ok) {
|
|
@@ -4396,14 +6062,14 @@ var Query = class {
|
|
|
4396
6062
|
captures.length = captureCount;
|
|
4397
6063
|
address = unmarshalCaptures(this, node.tree, address, patternIndex, captures);
|
|
4398
6064
|
if (this.textPredicates[patternIndex].every((p) => p(captures))) {
|
|
4399
|
-
const
|
|
6065
|
+
const capture2 = captures[captureIndex];
|
|
4400
6066
|
const setProperties = this.setProperties[patternIndex];
|
|
4401
|
-
|
|
6067
|
+
capture2.setProperties = setProperties;
|
|
4402
6068
|
const assertedProperties = this.assertedProperties[patternIndex];
|
|
4403
|
-
|
|
6069
|
+
capture2.assertedProperties = assertedProperties;
|
|
4404
6070
|
const refutedProperties = this.refutedProperties[patternIndex];
|
|
4405
|
-
|
|
4406
|
-
result.push(
|
|
6071
|
+
capture2.refutedProperties = refutedProperties;
|
|
6072
|
+
result.push(capture2);
|
|
4407
6073
|
}
|
|
4408
6074
|
}
|
|
4409
6075
|
C._free(startAddress);
|
|
@@ -4669,25 +6335,428 @@ var DEFAULT_OPTIONS = {
|
|
|
4669
6335
|
};
|
|
4670
6336
|
var BUILT_IN_IGNORE_DIR_SET = new Set(BUILT_IN_IGNORE_DIRS);
|
|
4671
6337
|
|
|
4672
|
-
// packages/shared/dist/
|
|
4673
|
-
|
|
6338
|
+
// packages/shared/dist/jitDeliveryAck.js
|
|
6339
|
+
init_runtimeSigners();
|
|
4674
6340
|
|
|
4675
|
-
// packages/shared/dist/
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
var controls = new RegExp("\\p{Cc}", "u");
|
|
6341
|
+
// packages/shared/dist/index.js
|
|
6342
|
+
init_repositoryFingerprint();
|
|
6343
|
+
init_projectIdentityFile();
|
|
6344
|
+
init_repositoryRoot();
|
|
4680
6345
|
|
|
4681
6346
|
// packages/shared/dist/scannerSupervisor.js
|
|
4682
6347
|
var WINDOWS_SERVICE_BUDGET_MS = 12e4;
|
|
6348
|
+
var SCANNER_STARTUP_BUDGET_MS = 6e4;
|
|
6349
|
+
var SCANNER_HANDOFF_BUDGET_MS = 15e4;
|
|
6350
|
+
var SCANNER_RECEIPT_STALE_MS = 36e4;
|
|
6351
|
+
var SCANNER_MAC_COMMAND_BUDGET_MS = 36e4;
|
|
6352
|
+
var SCANNER_STOP_BUDGET_MS = 1e4;
|
|
6353
|
+
var SCANNER_REMOVAL_BUDGET_MS = 18e4;
|
|
6354
|
+
function scannerAttemptHealthy(receipt, attempt, paused = false) {
|
|
6355
|
+
const life = receipt?.snapshot?.lifecycle;
|
|
6356
|
+
const readyAt = receipt?.snapshot?.startupTimings?.localReadyAt;
|
|
6357
|
+
const state = life?.state;
|
|
6358
|
+
return !!receipt && !!attempt && (receipt.recordedAt ?? 0) > attempt.startedAt && (attempt.version === void 0 || receipt.snapshot?.version === attempt.version) && (life?.pid === attempt.pid || state === "stopped") && (paused && state === "paused" || (readyAt ?? 0) > attempt.startedAt && (state === "running" || state === "starting" || state === "stopped") || readyAt === void 0 && state === "running");
|
|
6359
|
+
}
|
|
6360
|
+
|
|
6361
|
+
// packages/shared/dist/launchdControl.js
|
|
6362
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
6363
|
+
import { mkdir, readFile, rm, writeFile, lstat } from "node:fs/promises";
|
|
6364
|
+
import { join as join2 } from "node:path";
|
|
6365
|
+
async function printLaunchdRegistration(domain, label, run2) {
|
|
6366
|
+
try {
|
|
6367
|
+
return await run2("launchctl", ["print", `${domain}/${label}`]);
|
|
6368
|
+
} catch (error) {
|
|
6369
|
+
const failure = error;
|
|
6370
|
+
if (/Could not find (?:service|domain)\b/i.test(failure.message))
|
|
6371
|
+
return null;
|
|
6372
|
+
const unsupportedDomain = /Could not print domain:\s*125:\s*Domain does not support specified action\s*$/.test(failure.message);
|
|
6373
|
+
if (domain.startsWith("gui/") && unsupportedDomain && (failure.code === 125 && !failure.killed && !failure.signal || /^supervisor_command_failed killed=false code=125 signal=null:/.test(failure.message)))
|
|
6374
|
+
return null;
|
|
6375
|
+
throw error;
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
async function processesAlive(pids, run2) {
|
|
6379
|
+
const list = [...pids];
|
|
6380
|
+
if (!list.length)
|
|
6381
|
+
return false;
|
|
6382
|
+
try {
|
|
6383
|
+
return (await run2("ps", ["-p", list.join(","), "-o", "pid="])).trim() !== "";
|
|
6384
|
+
} catch (error) {
|
|
6385
|
+
const failure = error;
|
|
6386
|
+
if (failure.code === 1 && !failure.killed && !failure.signal || /^supervisor_command_failed killed=false code=1 signal=null:/.test(failure.message))
|
|
6387
|
+
return false;
|
|
6388
|
+
throw error;
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6391
|
+
var macScannerLauncher = "/Library/Application Support/Mnemonik/scanner-launcher";
|
|
6392
|
+
var macScannerPlist = "/Library/LaunchDaemons/ai.mnemonik.scanner.plist";
|
|
6393
|
+
async function authorizeMacService(run2, env = process.env) {
|
|
6394
|
+
let interrupted = false;
|
|
6395
|
+
const interrupt = () => {
|
|
6396
|
+
interrupted = true;
|
|
6397
|
+
};
|
|
6398
|
+
process.on("SIGINT", interrupt);
|
|
6399
|
+
try {
|
|
6400
|
+
await run2("sudo", [...env.SUDO_ASKPASS ? ["-A"] : [], "-v"]);
|
|
6401
|
+
} catch (error) {
|
|
6402
|
+
throw new Error(!interrupted && /terminal is required|a password is required|no tty present|no askpass program/iu.test(error.message) ? "mac_authorization_required" : "mac_authorization_failed");
|
|
6403
|
+
} finally {
|
|
6404
|
+
process.removeListener("SIGINT", interrupt);
|
|
6405
|
+
}
|
|
6406
|
+
}
|
|
6407
|
+
async function removeMacScanner(state, home, uid, run2, options = {}) {
|
|
6408
|
+
const exists = (path) => lstat(path).then(() => true, (error) => {
|
|
6409
|
+
if (error.code === "ENOENT")
|
|
6410
|
+
return false;
|
|
6411
|
+
throw error;
|
|
6412
|
+
});
|
|
6413
|
+
const receipt = await readFile(join2(state, "scanner/status.json"), "utf8").catch((error) => {
|
|
6414
|
+
if (error.code === "ENOENT")
|
|
6415
|
+
return null;
|
|
6416
|
+
throw error;
|
|
6417
|
+
});
|
|
6418
|
+
const recordedPid = receipt ? JSON.parse(receipt).snapshot?.lifecycle?.pid : void 0;
|
|
6419
|
+
const system = await printLaunchdRegistration("system", "ai.mnemonik.scanner", run2) !== null;
|
|
6420
|
+
const plist = options.plist ?? macScannerPlist;
|
|
6421
|
+
const present = await exists(plist);
|
|
6422
|
+
const launcher = options.launcher ?? macScannerLauncher;
|
|
6423
|
+
const launcherPresent = await exists(launcher);
|
|
6424
|
+
if (system || present || launcherPresent)
|
|
6425
|
+
await authorizeMacService(run2, options.environment);
|
|
6426
|
+
const privileged = (file, args2) => file === "launchctl" && args2[0] === "bootout" ? run2("sudo", ["-n", "/bin/launchctl", ...args2]) : run2(file, args2);
|
|
6427
|
+
await stopLaunchdRegistrations(["system"], "ai.mnemonik.scanner", privileged, {
|
|
6428
|
+
...options
|
|
6429
|
+
});
|
|
6430
|
+
const legacy = [`user/${uid}`, `gui/${uid}`];
|
|
6431
|
+
await stopLaunchdRegistrations(legacy, "ai.mnemonik.scanner.replacement", run2, options);
|
|
6432
|
+
await stopLaunchdRegistrations(legacy, "ai.mnemonik.scanner", run2, { ...options, recordedPid });
|
|
6433
|
+
await rm(join2(state, "scanner/service-replacement"), { recursive: true, force: true });
|
|
6434
|
+
if (options.remove === false) {
|
|
6435
|
+
await mkdir(join2(state, "scanner/service-replacement"), { recursive: true });
|
|
6436
|
+
await writeFile(join2(state, "scanner/service-replacement/result.json"), JSON.stringify({ stopped: true }));
|
|
6437
|
+
return;
|
|
6438
|
+
}
|
|
6439
|
+
if (present || launcherPresent)
|
|
6440
|
+
await run2("sudo", ["-n", "/bin/rm", "-f", plist, launcher]);
|
|
6441
|
+
for (const label of ["ai.mnemonik.scanner", "ai.mnemonik.scanner.replacement"])
|
|
6442
|
+
await rm(join2(home, "Library/LaunchAgents", `${label}.plist`), { force: true });
|
|
6443
|
+
await rm(join2(state, "scanner/assets"), { recursive: true, force: true });
|
|
6444
|
+
await rm(join2(state, "scanner/service-supervisor.json"), { force: true });
|
|
6445
|
+
await rm(join2(state, "scanner/service-migrated"), { force: true });
|
|
6446
|
+
await rm(join2(state, "scanner/system-service.plist"), { force: true });
|
|
6447
|
+
}
|
|
6448
|
+
async function stopLaunchdRegistrations(domains, label, run2, options = {}) {
|
|
6449
|
+
const now = options.now ?? Date.now;
|
|
6450
|
+
const sleep = options.sleep ?? delay;
|
|
6451
|
+
const inspect = (domain) => printLaunchdRegistration(domain, label, run2);
|
|
6452
|
+
const pids = /* @__PURE__ */ new Set();
|
|
6453
|
+
const recordedPid = options.recordedPid;
|
|
6454
|
+
if (typeof recordedPid === "number" && Number.isInteger(recordedPid) && recordedPid > 0)
|
|
6455
|
+
pids.add(recordedPid);
|
|
6456
|
+
const registrations = [];
|
|
6457
|
+
for (const domain of domains) {
|
|
6458
|
+
const output = await inspect(domain);
|
|
6459
|
+
if (output === null)
|
|
6460
|
+
continue;
|
|
6461
|
+
const pid = Number(/\bpid = (\d+)/.exec(output)?.[1]);
|
|
6462
|
+
if (pid)
|
|
6463
|
+
pids.add(pid);
|
|
6464
|
+
registrations.push(domain);
|
|
6465
|
+
}
|
|
6466
|
+
for (const domain of registrations)
|
|
6467
|
+
await run2("launchctl", ["bootout", `${domain}/${label}`]);
|
|
6468
|
+
const deadline = now() + SCANNER_STOP_BUDGET_MS;
|
|
6469
|
+
do {
|
|
6470
|
+
let registered = false;
|
|
6471
|
+
for (const domain of domains) {
|
|
6472
|
+
const output = await inspect(domain);
|
|
6473
|
+
if (output !== null) {
|
|
6474
|
+
registered = true;
|
|
6475
|
+
const pid = Number(/\bpid = (\d+)/.exec(output)?.[1]);
|
|
6476
|
+
if (pid)
|
|
6477
|
+
pids.add(pid);
|
|
6478
|
+
}
|
|
6479
|
+
}
|
|
6480
|
+
if (!registered && !await processesAlive(pids, run2))
|
|
6481
|
+
return;
|
|
6482
|
+
await sleep(100);
|
|
6483
|
+
} while (now() <= deadline);
|
|
6484
|
+
throw new Error("scanner_stop_failed");
|
|
6485
|
+
}
|
|
6486
|
+
|
|
6487
|
+
// packages/shared/dist/systemdControl.js
|
|
6488
|
+
import { existsSync } from "node:fs";
|
|
6489
|
+
import { rm as rm2 } from "node:fs/promises";
|
|
6490
|
+
import { basename, dirname as dirname2, join as join3 } from "node:path";
|
|
6491
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
6492
|
+
async function uninstallSystemdUnit(unitPath, run2, options = {}) {
|
|
6493
|
+
try {
|
|
6494
|
+
const unit = basename(unitPath);
|
|
6495
|
+
if (!/^mnemonik-scanner(?:-test-[0-9]+)?\.service$/.test(unit))
|
|
6496
|
+
throw new Error("invalid_test_unit");
|
|
6497
|
+
const command = (args2) => run2("systemctl", ["--user", ...args2]);
|
|
6498
|
+
const inspect = async () => {
|
|
6499
|
+
const output = await command([
|
|
6500
|
+
"show",
|
|
6501
|
+
unit,
|
|
6502
|
+
"--property=LoadState,ActiveState,MainPID,UnitFileState"
|
|
6503
|
+
]);
|
|
6504
|
+
const state = Object.fromEntries(output.trim().split("\n").map((line) => {
|
|
6505
|
+
const split = line.indexOf("=");
|
|
6506
|
+
return [line.slice(0, split), line.slice(split + 1)];
|
|
6507
|
+
}));
|
|
6508
|
+
if (!state.LoadState || !state.ActiveState || !/^\d+$/.test(state.MainPID) || state.UnitFileState === void 0)
|
|
6509
|
+
throw new Error("systemd_inspection_failed");
|
|
6510
|
+
return state;
|
|
6511
|
+
};
|
|
6512
|
+
const before = await inspect();
|
|
6513
|
+
const pids = /* @__PURE__ */ new Set();
|
|
6514
|
+
if (Number(before.MainPID))
|
|
6515
|
+
pids.add(Number(before.MainPID));
|
|
6516
|
+
const recordedPid = options.recordedPid;
|
|
6517
|
+
if (typeof recordedPid === "number" && Number.isInteger(recordedPid) && recordedPid > 0)
|
|
6518
|
+
pids.add(recordedPid);
|
|
6519
|
+
if (before.LoadState !== "not-found" || before.ActiveState !== "inactive" || Number(before.MainPID))
|
|
6520
|
+
await command(["stop", unit]);
|
|
6521
|
+
try {
|
|
6522
|
+
await command(["disable", "--now", unit]);
|
|
6523
|
+
} catch (error) {
|
|
6524
|
+
if (existsSync(unitPath) || !new RegExp(`Unit file ${unit.replaceAll(".", "\\.")} does not exist\\.?\\s*$`).test(error.message))
|
|
6525
|
+
throw error;
|
|
6526
|
+
await rm2(join3(dirname2(unitPath), "default.target.wants", unit), { force: true });
|
|
6527
|
+
await command(["daemon-reload"]);
|
|
6528
|
+
}
|
|
6529
|
+
if ((await inspect()).ActiveState === "failed")
|
|
6530
|
+
await command(["reset-failed", unit]);
|
|
6531
|
+
const now = options.now ?? Date.now;
|
|
6532
|
+
const wait = async (removed) => {
|
|
6533
|
+
const deadline = now() + SCANNER_STOP_BUDGET_MS;
|
|
6534
|
+
do {
|
|
6535
|
+
const state = await inspect();
|
|
6536
|
+
if (Number(state.MainPID))
|
|
6537
|
+
pids.add(Number(state.MainPID));
|
|
6538
|
+
const alive = await processesAlive(pids, run2);
|
|
6539
|
+
if (state.ActiveState === "inactive" && Number(state.MainPID) === 0 && !alive && ["", "disabled", "static", "indirect", "not-found"].includes(state.UnitFileState) && (!removed || state.LoadState === "not-found"))
|
|
6540
|
+
return;
|
|
6541
|
+
await (options.sleep ?? delay2)(100);
|
|
6542
|
+
} while (now() <= deadline);
|
|
6543
|
+
throw new Error("systemd_stop_unverified");
|
|
6544
|
+
};
|
|
6545
|
+
await wait(false);
|
|
6546
|
+
await rm2(unitPath, { force: true });
|
|
6547
|
+
await command(["daemon-reload"]);
|
|
6548
|
+
await wait(true);
|
|
6549
|
+
} catch (cause) {
|
|
6550
|
+
throw new Error("scanner_stop_failed", { cause });
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
|
|
6554
|
+
// packages/shared/dist/scannerPid.js
|
|
6555
|
+
import { execFileSync } from "node:child_process";
|
|
6556
|
+
import { readFileSync } from "node:fs";
|
|
6557
|
+
var SCANNER_CMD_PATTERN = /(mnemonik-scanner|scanner[\\/]dist[\\/]index\.js)/;
|
|
6558
|
+
var capture = {
|
|
6559
|
+
encoding: "utf-8",
|
|
6560
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
6561
|
+
timeout: 5e3
|
|
6562
|
+
};
|
|
6563
|
+
function processCmdline(pid, platform, exec = execFileSync) {
|
|
6564
|
+
if (!Number.isSafeInteger(pid) || pid <= 0)
|
|
6565
|
+
return null;
|
|
6566
|
+
if (platform === "win32") {
|
|
6567
|
+
try {
|
|
6568
|
+
return exec("powershell.exe", [
|
|
6569
|
+
"-NoProfile",
|
|
6570
|
+
"-NonInteractive",
|
|
6571
|
+
"-Command",
|
|
6572
|
+
`(Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}").CommandLine`
|
|
6573
|
+
], capture).trim();
|
|
6574
|
+
} catch {
|
|
6575
|
+
return null;
|
|
6576
|
+
}
|
|
6577
|
+
}
|
|
6578
|
+
if (platform === "linux") {
|
|
6579
|
+
try {
|
|
6580
|
+
return readFileSync(`/proc/${pid}/cmdline`, "utf-8").replace(/\0/g, " ").trim();
|
|
6581
|
+
} catch {
|
|
6582
|
+
}
|
|
6583
|
+
}
|
|
6584
|
+
try {
|
|
6585
|
+
return exec("ps", ["-o", "args=", "-p", String(pid)], capture).trim();
|
|
6586
|
+
} catch {
|
|
6587
|
+
return null;
|
|
6588
|
+
}
|
|
6589
|
+
}
|
|
6590
|
+
function pidIsScanner(pid, platform = process.platform, exec = execFileSync, identity) {
|
|
6591
|
+
const cmdline = processCmdline(pid, platform, exec);
|
|
6592
|
+
if (cmdline === null)
|
|
6593
|
+
return false;
|
|
6594
|
+
if (!identity)
|
|
6595
|
+
return SCANNER_CMD_PATTERN.test(cmdline);
|
|
6596
|
+
if (cmdline !== `${identity.binaryPath} start`)
|
|
6597
|
+
return false;
|
|
6598
|
+
try {
|
|
6599
|
+
return exec("ps", ["-o", "uid=", "-p", String(pid)], capture).trim() === String(identity.uid);
|
|
6600
|
+
} catch {
|
|
6601
|
+
return false;
|
|
6602
|
+
}
|
|
6603
|
+
}
|
|
6604
|
+
|
|
6605
|
+
// packages/local-setup/dist/storage.js
|
|
6606
|
+
init_hookRuntime();
|
|
6607
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
6608
|
+
import fs2 from "node:fs";
|
|
6609
|
+
import { open, rename, readFile as readFile2, mkdir as mkdir2, lstat as lstat2, chmod, writeFile as writeFile2, unlink, rmdir } from "node:fs/promises";
|
|
6610
|
+
init_hookRuntime();
|
|
6611
|
+
import { dirname as dirname3, join as join4, win32, posix } from "node:path";
|
|
6612
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
6613
|
+
var lockfileKey = /* @__PURE__ */ Symbol.for("mnemonik.proper-lockfile");
|
|
6614
|
+
function sharedLockfile() {
|
|
6615
|
+
const shared = globalThis;
|
|
6616
|
+
return shared[lockfileKey] ??= Promise.resolve().then(() => __toESM(require_proper_lockfile(), 1)).then((module2) => module2.default);
|
|
6617
|
+
}
|
|
6618
|
+
var codeIs = (error, code) => error.code === code;
|
|
6619
|
+
async function readBytes(path) {
|
|
6620
|
+
try {
|
|
6621
|
+
if (!(await lstat2(path)).isFile())
|
|
6622
|
+
throw new Error("setup_requires_regular_file");
|
|
6623
|
+
return await readFile2(path);
|
|
6624
|
+
} catch (error) {
|
|
6625
|
+
if (codeIs(error, "ENOENT"))
|
|
6626
|
+
return null;
|
|
6627
|
+
throw error;
|
|
6628
|
+
}
|
|
6629
|
+
}
|
|
6630
|
+
async function withLock(path, waitMs, work) {
|
|
6631
|
+
const lockfile = await sharedLockfile();
|
|
6632
|
+
await mkdir2(dirname3(path), { recursive: true, mode: 448 });
|
|
6633
|
+
const generation = randomUUID();
|
|
6634
|
+
const owner = join4(`${path}.lock`, "owner");
|
|
6635
|
+
let compromised = false;
|
|
6636
|
+
let acquired = false;
|
|
6637
|
+
const assertOwned = async () => {
|
|
6638
|
+
if (compromised || (await readBytes(owner).catch(() => null))?.toString() !== generation) {
|
|
6639
|
+
compromised = true;
|
|
6640
|
+
throw new Error("lock_lost");
|
|
6641
|
+
}
|
|
6642
|
+
};
|
|
6643
|
+
const leaseFs = {
|
|
6644
|
+
...fs2,
|
|
6645
|
+
mkdir: (dir, callback) => {
|
|
6646
|
+
void mkdir2(dir).then(() => writeFile2(owner, generation, { mode: 384, flag: "wx" })).then(() => callback(), callback);
|
|
6647
|
+
},
|
|
6648
|
+
rmdir: (dir, callback) => {
|
|
6649
|
+
void unlink(join4(dir, "owner")).catch((error) => {
|
|
6650
|
+
if (!codeIs(error, "ENOENT"))
|
|
6651
|
+
throw error;
|
|
6652
|
+
}).then(() => rmdir(dir)).then(() => callback(), callback);
|
|
6653
|
+
},
|
|
6654
|
+
rmdirSync: (dir) => {
|
|
6655
|
+
try {
|
|
6656
|
+
fs2.unlinkSync(join4(dir, "owner"));
|
|
6657
|
+
} catch (error) {
|
|
6658
|
+
if (!codeIs(error, "ENOENT"))
|
|
6659
|
+
throw error;
|
|
6660
|
+
}
|
|
6661
|
+
fs2.rmdirSync(dir);
|
|
6662
|
+
},
|
|
6663
|
+
stat: (file, callback) => {
|
|
6664
|
+
void (acquired ? assertOwned() : Promise.resolve()).then(() => fs2.stat(file, callback), () => callback(Object.assign(new Error("lock_lost"), { code: "ENOENT" })));
|
|
6665
|
+
}
|
|
6666
|
+
};
|
|
6667
|
+
const deadline = performance.now() + waitMs;
|
|
6668
|
+
let release;
|
|
6669
|
+
while (!release) {
|
|
6670
|
+
try {
|
|
6671
|
+
release = await lockfile.lock(path, {
|
|
6672
|
+
realpath: false,
|
|
6673
|
+
stale: 3e4,
|
|
6674
|
+
update: 5e3,
|
|
6675
|
+
retries: 0,
|
|
6676
|
+
fs: leaseFs,
|
|
6677
|
+
onCompromised: () => {
|
|
6678
|
+
compromised = true;
|
|
6679
|
+
}
|
|
6680
|
+
});
|
|
6681
|
+
} catch (error) {
|
|
6682
|
+
if (!codeIs(error, "ELOCKED"))
|
|
6683
|
+
throw error;
|
|
6684
|
+
if (performance.now() >= deadline)
|
|
6685
|
+
throw new RuntimeError("lock_held");
|
|
6686
|
+
await delay3(Math.min(100, Math.max(1, deadline - performance.now())));
|
|
6687
|
+
}
|
|
6688
|
+
}
|
|
6689
|
+
acquired = true;
|
|
6690
|
+
try {
|
|
6691
|
+
return await work(assertOwned);
|
|
6692
|
+
} finally {
|
|
6693
|
+
if (await assertOwned().then(() => true, () => false))
|
|
6694
|
+
await release();
|
|
6695
|
+
}
|
|
6696
|
+
}
|
|
6697
|
+
|
|
6698
|
+
// packages/local-setup/dist/index.js
|
|
6699
|
+
var MAX_ORIGINAL_BYTES = 64 * 1024;
|
|
4683
6700
|
|
|
4684
6701
|
// packages/cli/src/scanner/service.ts
|
|
4685
6702
|
import { execFile } from "node:child_process";
|
|
4686
|
-
import { readFile, rm } from "node:fs/promises";
|
|
4687
|
-
import { join as
|
|
6703
|
+
import { readFile as readFile3, rm as rm3, lstat as lstat3 } from "node:fs/promises";
|
|
6704
|
+
import { join as join5, dirname as dirname4 } from "node:path";
|
|
6705
|
+
import { homedir } from "node:os";
|
|
4688
6706
|
import { promisify } from "node:util";
|
|
4689
|
-
import { setTimeout as
|
|
6707
|
+
import { setTimeout as delay4 } from "node:timers/promises";
|
|
4690
6708
|
import { RuntimeStore } from "../runtime/store.js";
|
|
6709
|
+
import { scannerReceipt } from "./control.js";
|
|
6710
|
+
var SCANNER_RESTART_MESSAGE = "Background indexing stopped responding. Mnemonik restarted it.";
|
|
6711
|
+
var SCANNER_RESTART_ACTION = "Run mnemonik status after indexing starts.";
|
|
6712
|
+
var SCANNER_LIMITED_SENTENCE = "Background indexing could not be started.";
|
|
6713
|
+
var SCANNER_LIMITED_ACTION = "Run mnemonik install to try again.";
|
|
6714
|
+
var SCANNER_SENTENCES = {
|
|
6715
|
+
systemd_linger_required: [
|
|
6716
|
+
"Background indexing needs permission to keep running after you log out.",
|
|
6717
|
+
"Run sudo loginctl enable-linger $USER, then run mnemonik install."
|
|
6718
|
+
],
|
|
6719
|
+
systemd_session_unavailable: [
|
|
6720
|
+
"This server cannot keep background indexing running.",
|
|
6721
|
+
"Ask the server administrator to enable systemd user services, then run mnemonik install."
|
|
6722
|
+
],
|
|
6723
|
+
mac_authorization_required: [
|
|
6724
|
+
"Mnemonik needs your Mac password to set up background indexing.",
|
|
6725
|
+
"Run mnemonik install in a terminal and enter your Mac password."
|
|
6726
|
+
],
|
|
6727
|
+
mac_authorization_failed: [
|
|
6728
|
+
"Background indexing was not set up because the password was not accepted.",
|
|
6729
|
+
SCANNER_LIMITED_ACTION
|
|
6730
|
+
],
|
|
6731
|
+
scanner_replacement_rolled_back: [
|
|
6732
|
+
"Background indexing went back to the previous version.",
|
|
6733
|
+
SCANNER_LIMITED_ACTION
|
|
6734
|
+
],
|
|
6735
|
+
scanner_stop_failed: [
|
|
6736
|
+
"Background indexing could not be stopped.",
|
|
6737
|
+
"Restart this computer, then run mnemonik uninstall again."
|
|
6738
|
+
],
|
|
6739
|
+
scanner_other_account: [
|
|
6740
|
+
"Background indexing is already set up for another account on this Mac.",
|
|
6741
|
+
""
|
|
6742
|
+
],
|
|
6743
|
+
scanner_stopped: [
|
|
6744
|
+
"Background indexing is stopped on this computer.",
|
|
6745
|
+
"Run mnemonik scanner start and enter your Mac password to start it again."
|
|
6746
|
+
],
|
|
6747
|
+
scanner_replacement_failed: [
|
|
6748
|
+
"Background indexing could not be started. Mnemonik tried the new version and the last working one.",
|
|
6749
|
+
SCANNER_LIMITED_ACTION
|
|
6750
|
+
],
|
|
6751
|
+
scanner_replacement_pending: [
|
|
6752
|
+
"Background indexing is restarting with a new version.",
|
|
6753
|
+
"Wait a minute, then run mnemonik status."
|
|
6754
|
+
],
|
|
6755
|
+
heartbeat_timeout: [
|
|
6756
|
+
"Background indexing started but has not reported yet.",
|
|
6757
|
+
"Wait a minute, then run mnemonik status."
|
|
6758
|
+
]
|
|
6759
|
+
};
|
|
4691
6760
|
var ScannerServiceLimited = class extends Error {
|
|
4692
6761
|
constructor(reason, message = reason) {
|
|
4693
6762
|
super(message);
|
|
@@ -4695,14 +6764,21 @@ var ScannerServiceLimited = class extends Error {
|
|
|
4695
6764
|
}
|
|
4696
6765
|
reason;
|
|
4697
6766
|
status = "LIMITED";
|
|
4698
|
-
|
|
6767
|
+
get summary() {
|
|
6768
|
+
return SCANNER_SENTENCES[this.reason]?.[0] ?? SCANNER_LIMITED_SENTENCE;
|
|
6769
|
+
}
|
|
6770
|
+
get action() {
|
|
6771
|
+
if (this.reason.startsWith("scanner_replacement_") && /ENOSPC|no space left/iu.test(this.message))
|
|
6772
|
+
return "Free disk space on this computer, then run mnemonik install.";
|
|
6773
|
+
return SCANNER_SENTENCES[this.reason]?.[1] ?? SCANNER_LIMITED_ACTION;
|
|
6774
|
+
}
|
|
4699
6775
|
};
|
|
4700
6776
|
function scannerService(options) {
|
|
4701
6777
|
let store = options.store ?? new RuntimeStore(options.stateDir);
|
|
4702
|
-
const
|
|
6778
|
+
const configureStore = async () => {
|
|
4703
6779
|
if (!options.store) {
|
|
4704
6780
|
const saved = JSON.parse(
|
|
4705
|
-
await new RuntimeStore(options.stateDir).bytes(
|
|
6781
|
+
await new RuntimeStore(options.stateDir).bytes(join5(options.stateDir, "scanner/state.json")).then((bytes) => bytes.toString()).catch((error) => {
|
|
4706
6782
|
if (error.code === "ENOENT") return "null";
|
|
4707
6783
|
throw error;
|
|
4708
6784
|
})
|
|
@@ -4711,19 +6787,30 @@ function scannerService(options) {
|
|
|
4711
6787
|
allowUnsigned: saved?.devReleaseSource === true
|
|
4712
6788
|
});
|
|
4713
6789
|
}
|
|
6790
|
+
};
|
|
6791
|
+
const verify = async () => {
|
|
6792
|
+
await configureStore();
|
|
4714
6793
|
return store.verifyRuntime("scanner");
|
|
4715
6794
|
};
|
|
4716
6795
|
const now = options.now ?? Date.now;
|
|
4717
|
-
const sleep = options.sleep ??
|
|
6796
|
+
const sleep = options.sleep ?? delay4;
|
|
4718
6797
|
let verified = false;
|
|
6798
|
+
let replacementRuntime;
|
|
4719
6799
|
const command = options.command ?? (async (operation, definition) => {
|
|
4720
|
-
const
|
|
6800
|
+
const retained = replacementRuntime ?? options.supervisorRuntime;
|
|
6801
|
+
const fixed = !replacementRuntime && (options.platform ?? process.platform) === "darwin" ? await lstat3(macScannerLauncher).catch((error) => {
|
|
6802
|
+
if (error.code === "ENOENT") return null;
|
|
6803
|
+
throw error;
|
|
6804
|
+
}) : null;
|
|
6805
|
+
if (fixed && (!fixed.isFile() || fixed.uid !== 0 || fixed.mode & 18))
|
|
6806
|
+
throw new Error("service_runtime_permission");
|
|
6807
|
+
const entry = fixed ? macScannerLauncher : (retained ? await store.verifyRetainedRuntime("scanner", retained.reference) : await verify()).entry;
|
|
4721
6808
|
return new Promise((resolve, reject) => {
|
|
4722
6809
|
const child = execFile(
|
|
4723
|
-
|
|
6810
|
+
entry,
|
|
4724
6811
|
["service", operation, "--json"],
|
|
4725
6812
|
{
|
|
4726
|
-
timeout: process.platform === "win32" ? WINDOWS_SERVICE_BUDGET_MS : 3e4,
|
|
6813
|
+
timeout: (options.platform ?? process.platform) === "darwin" ? SCANNER_MAC_COMMAND_BUDGET_MS : process.platform === "win32" ? WINDOWS_SERVICE_BUDGET_MS : 3e4,
|
|
4727
6814
|
encoding: "utf8",
|
|
4728
6815
|
env: {
|
|
4729
6816
|
...process.env,
|
|
@@ -4753,10 +6840,16 @@ function scannerService(options) {
|
|
|
4753
6840
|
});
|
|
4754
6841
|
const invoke = async (operation, definition) => {
|
|
4755
6842
|
let result;
|
|
6843
|
+
const interrupt = () => {
|
|
6844
|
+
};
|
|
6845
|
+
const terminalAuthentication = (options.platform ?? process.platform) === "darwin" && operation === "install";
|
|
6846
|
+
if (terminalAuthentication) process.on("SIGINT", interrupt);
|
|
4756
6847
|
try {
|
|
4757
6848
|
result = await command(operation, definition);
|
|
4758
6849
|
} catch (error) {
|
|
4759
6850
|
throw new ScannerServiceLimited("scanner_service_unavailable", error.message);
|
|
6851
|
+
} finally {
|
|
6852
|
+
if (terminalAuthentication) process.removeListener("SIGINT", interrupt);
|
|
4760
6853
|
}
|
|
4761
6854
|
if (result.status === "LIMITED") throw new ScannerServiceLimited(result.reason, result.detail);
|
|
4762
6855
|
return result.supervisor;
|
|
@@ -4779,15 +6872,14 @@ function scannerService(options) {
|
|
|
4779
6872
|
}
|
|
4780
6873
|
};
|
|
4781
6874
|
const heartbeat = async (since, pid) => {
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
await readFile(join2(options.stateDir, "scanner/status.json"), "utf8")
|
|
4785
|
-
);
|
|
4786
|
-
return pid !== null && receipt.snapshot.lifecycle.pid === pid && typeof receipt.snapshot.heartbeat.lastSuccess === "number" && receipt.snapshot.heartbeat.lastSuccess > since;
|
|
4787
|
-
} catch {
|
|
4788
|
-
return false;
|
|
4789
|
-
}
|
|
6875
|
+
const snapshot = (await scannerReceipt(options.stateDir).catch(() => null))?.snapshot;
|
|
6876
|
+
return pid !== null && snapshot?.lifecycle.pid === pid && (snapshot.heartbeat.lastSuccess ?? 0) > since;
|
|
4790
6877
|
};
|
|
6878
|
+
const locallyReady = async (since, pid, paused = false) => scannerAttemptHealthy(
|
|
6879
|
+
await scannerReceipt(options.stateDir).catch(() => null),
|
|
6880
|
+
{ pid, startedAt: since },
|
|
6881
|
+
paused
|
|
6882
|
+
);
|
|
4791
6883
|
const describe = async () => {
|
|
4792
6884
|
const runtime = await verify();
|
|
4793
6885
|
return options.describe ? await options.describe() : JSON.parse(
|
|
@@ -4803,6 +6895,52 @@ function scannerService(options) {
|
|
|
4803
6895
|
};
|
|
4804
6896
|
return {
|
|
4805
6897
|
status: () => invoke("status"),
|
|
6898
|
+
async recover() {
|
|
6899
|
+
if ((options.platform ?? process.platform) !== "darwin") return false;
|
|
6900
|
+
return withLock(
|
|
6901
|
+
join5(options.stateDir, "scanner/launchd-replacement-control"),
|
|
6902
|
+
5e3,
|
|
6903
|
+
async () => {
|
|
6904
|
+
const receipt = await scannerReceipt(options.stateDir);
|
|
6905
|
+
const snapshot = receipt?.snapshot;
|
|
6906
|
+
const attempt = await readFile3(
|
|
6907
|
+
join5(options.stateDir, "scanner/service-replacement/result.json"),
|
|
6908
|
+
"utf8"
|
|
6909
|
+
).then((text) => JSON.parse(text)).catch(() => null);
|
|
6910
|
+
const age = now() - Number(attempt?.startedAt);
|
|
6911
|
+
if (attempt?.pid && age <= SCANNER_HANDOFF_BUDGET_MS) return false;
|
|
6912
|
+
const stalledStart = attempt?.pid && Number.isFinite(age) && age > SCANNER_HANDOFF_BUDGET_MS;
|
|
6913
|
+
const staleReceipt = snapshot && receipt && snapshot.heartbeat.lastSuccess && ["running", "starting"].includes(snapshot.lifecycle.state) && now() - snapshot.heartbeat.lastSuccess > SCANNER_RECEIPT_STALE_MS && now() - receipt.recordedAt > SCANNER_RECEIPT_STALE_MS;
|
|
6914
|
+
const pid = stalledStart ? attempt.pid : snapshot?.lifecycle.pid;
|
|
6915
|
+
if (!pid || !stalledStart && !staleReceipt) return false;
|
|
6916
|
+
if (receipt && snapshot?.lifecycle.pid === pid && (snapshot.lifecycle.state === "paused" || now() - receipt.recordedAt <= SCANNER_RECEIPT_STALE_MS))
|
|
6917
|
+
return false;
|
|
6918
|
+
const state = JSON.parse(
|
|
6919
|
+
await readFile3(join5(options.stateDir, "scanner/state.json"), "utf8")
|
|
6920
|
+
);
|
|
6921
|
+
if (state.paused) return false;
|
|
6922
|
+
let runtime = await verify();
|
|
6923
|
+
const service = await invoke("status");
|
|
6924
|
+
if (service.binaryPath !== runtime.entry) {
|
|
6925
|
+
const pointer = JSON.parse(
|
|
6926
|
+
(await store.bytes(store.pointerPath("scanner"))).toString()
|
|
6927
|
+
);
|
|
6928
|
+
if (!pointer.previous) return false;
|
|
6929
|
+
runtime = await store.verifyRetainedRuntime("scanner", pointer.previous);
|
|
6930
|
+
}
|
|
6931
|
+
if (service.kind !== "launchd" || !service.installed || !service.running || service.pid !== pid || service.binaryPath !== runtime.entry || !process.getuid)
|
|
6932
|
+
return false;
|
|
6933
|
+
if (!(options.pidIdentity ?? pidIsScanner)(pid, "darwin", void 0, {
|
|
6934
|
+
binaryPath: runtime.entry,
|
|
6935
|
+
uid: process.getuid()
|
|
6936
|
+
}))
|
|
6937
|
+
return false;
|
|
6938
|
+
(options.signal ?? process.kill)(pid, "SIGKILL");
|
|
6939
|
+
options.onScannerRestartRequested?.();
|
|
6940
|
+
return true;
|
|
6941
|
+
}
|
|
6942
|
+
);
|
|
6943
|
+
},
|
|
4806
6944
|
get verified() {
|
|
4807
6945
|
return verified;
|
|
4808
6946
|
},
|
|
@@ -4823,7 +6961,7 @@ function scannerService(options) {
|
|
|
4823
6961
|
return [{ id: "scanner", before: "unknown" }];
|
|
4824
6962
|
}
|
|
4825
6963
|
},
|
|
4826
|
-
async start(_id = "scanner") {
|
|
6964
|
+
async start(_id = "scanner", heartbeatAfter) {
|
|
4827
6965
|
verified = false;
|
|
4828
6966
|
let state = await invoke("status");
|
|
4829
6967
|
const alreadyRunning = state.running;
|
|
@@ -4839,8 +6977,8 @@ function scannerService(options) {
|
|
|
4839
6977
|
});
|
|
4840
6978
|
await waitFor(
|
|
4841
6979
|
"heartbeat",
|
|
4842
|
-
|
|
4843
|
-
() => heartbeat(alreadyRunning ? startedAt - 3e5 : startedAt, state.pid)
|
|
6980
|
+
SCANNER_STARTUP_BUDGET_MS,
|
|
6981
|
+
() => heartbeat(heartbeatAfter ?? (alreadyRunning ? startedAt - 3e5 : startedAt), state.pid)
|
|
4844
6982
|
);
|
|
4845
6983
|
verified = true;
|
|
4846
6984
|
return alreadyRunning ? { started: false, alreadyRunning: true } : { started: true, alreadyRunning: false };
|
|
@@ -4856,33 +6994,130 @@ function scannerService(options) {
|
|
|
4856
6994
|
}
|
|
4857
6995
|
});
|
|
4858
6996
|
},
|
|
6997
|
+
async replace(runtime, replacement) {
|
|
6998
|
+
replacementRuntime = runtime;
|
|
6999
|
+
verified = false;
|
|
7000
|
+
const saved = JSON.parse(
|
|
7001
|
+
replacement.state?.after ?? await readFile3(join5(options.stateDir, "scanner/state.json"), "utf8")
|
|
7002
|
+
);
|
|
7003
|
+
const startedAt = now();
|
|
7004
|
+
await invoke("install", {
|
|
7005
|
+
binaryPath: runtime.entry,
|
|
7006
|
+
arguments: ["start"],
|
|
7007
|
+
workingDirectory: runtime.directory,
|
|
7008
|
+
environment: { MNEMONIK_STATE_DIR: options.stateDir },
|
|
7009
|
+
credentialFamilyId: saved.config?.credentialFamilyId,
|
|
7010
|
+
runAtLogin: true,
|
|
7011
|
+
restart: { policy: "on-failure", delayMs: 3e3 },
|
|
7012
|
+
logDestination: join5(options.stateDir, "scanner/scanner.log"),
|
|
7013
|
+
replacement
|
|
7014
|
+
});
|
|
7015
|
+
const deadline = now() + SCANNER_HANDOFF_BUDGET_MS;
|
|
7016
|
+
while (now() < deadline) {
|
|
7017
|
+
const attempt = await readFile3(
|
|
7018
|
+
join5(options.stateDir, "scanner/service-replacement/result.json"),
|
|
7019
|
+
"utf8"
|
|
7020
|
+
).then(JSON.parse).catch(() => null);
|
|
7021
|
+
if (attempt && attempt.startedAt >= startedAt) {
|
|
7022
|
+
if (attempt.candidateError === "scanner_configuration_changed")
|
|
7023
|
+
throw new ScannerServiceLimited("scanner_replacement_interrupted");
|
|
7024
|
+
if (attempt.fallbackError)
|
|
7025
|
+
throw new ScannerServiceLimited(
|
|
7026
|
+
attempt.fallbackError === "scanner_fallback_missing" ? "scanner_replacement_candidate_failed" : "scanner_replacement_failed",
|
|
7027
|
+
[attempt.candidateError, attempt.fallbackError].filter(Boolean).join("; ")
|
|
7028
|
+
);
|
|
7029
|
+
const active = await invoke("status");
|
|
7030
|
+
if (active.running && active.pid === attempt.pid && await locallyReady(attempt.startedAt, active.pid, saved.paused)) {
|
|
7031
|
+
if (attempt.fallback)
|
|
7032
|
+
throw new ScannerServiceLimited(
|
|
7033
|
+
"scanner_replacement_rolled_back",
|
|
7034
|
+
attempt.candidateError
|
|
7035
|
+
);
|
|
7036
|
+
verified = true;
|
|
7037
|
+
return;
|
|
7038
|
+
}
|
|
7039
|
+
}
|
|
7040
|
+
await sleep(1e3);
|
|
7041
|
+
}
|
|
7042
|
+
throw new ScannerServiceLimited("scanner_replacement_interrupted");
|
|
7043
|
+
},
|
|
4859
7044
|
async restart() {
|
|
4860
|
-
await
|
|
4861
|
-
|
|
4862
|
-
|
|
7045
|
+
const definition = await describe();
|
|
7046
|
+
const startedAt = now();
|
|
7047
|
+
await invoke("install", definition);
|
|
7048
|
+
return this.start("scanner", startedAt);
|
|
4863
7049
|
},
|
|
4864
7050
|
async stop() {
|
|
4865
7051
|
await invoke("stop");
|
|
4866
7052
|
},
|
|
4867
7053
|
async uninstall() {
|
|
4868
|
-
await
|
|
4869
|
-
|
|
4870
|
-
|
|
7054
|
+
const native = (timeout) => options.supervisorRun ?? (async (file, args2) => (await promisify(execFile)(file, args2, { encoding: "utf8", timeout })).stdout);
|
|
7055
|
+
try {
|
|
7056
|
+
if ((options.platform ?? process.platform) === "darwin") {
|
|
7057
|
+
return await withLock(
|
|
7058
|
+
join5(options.stateDir, "scanner/launchd-replacement-control"),
|
|
7059
|
+
SCANNER_REMOVAL_BUDGET_MS,
|
|
7060
|
+
async () => {
|
|
7061
|
+
await removeMacScanner(
|
|
7062
|
+
options.stateDir,
|
|
7063
|
+
options.home ?? homedir(),
|
|
7064
|
+
options.uid ?? process.getuid?.() ?? -1,
|
|
7065
|
+
native(SCANNER_REMOVAL_BUDGET_MS),
|
|
7066
|
+
{ now, sleep, plist: options.systemPlist }
|
|
7067
|
+
);
|
|
7068
|
+
await rm3(dirname4(store.pointerPath("scanner")), { recursive: true, force: true });
|
|
7069
|
+
}
|
|
7070
|
+
);
|
|
7071
|
+
}
|
|
7072
|
+
if ((options.platform ?? process.platform) === "linux") {
|
|
7073
|
+
const recordedPid = await readFile3(join5(options.stateDir, "scanner/status.json"), "utf8").then(
|
|
7074
|
+
(text) => JSON.parse(text).snapshot?.lifecycle?.pid
|
|
7075
|
+
).catch((error) => {
|
|
7076
|
+
if (error.code === "ENOENT") return void 0;
|
|
7077
|
+
throw error;
|
|
7078
|
+
});
|
|
7079
|
+
await uninstallSystemdUnit(
|
|
7080
|
+
join5(
|
|
7081
|
+
process.env.XDG_CONFIG_HOME ?? join5(options.home ?? homedir(), ".config"),
|
|
7082
|
+
"systemd/user/mnemonik-scanner.service"
|
|
7083
|
+
),
|
|
7084
|
+
native(SCANNER_STOP_BUDGET_MS),
|
|
7085
|
+
{ now, sleep, recordedPid }
|
|
7086
|
+
);
|
|
7087
|
+
} else {
|
|
7088
|
+
await invoke("stop");
|
|
7089
|
+
await invoke("uninstall");
|
|
7090
|
+
}
|
|
7091
|
+
await rm3(dirname4(store.pointerPath("scanner")), { recursive: true, force: true });
|
|
7092
|
+
} catch (error) {
|
|
7093
|
+
const cause = error.cause;
|
|
7094
|
+
throw new ScannerServiceLimited(
|
|
7095
|
+
"scanner_stop_failed",
|
|
7096
|
+
[error.message, cause instanceof Error ? cause.message : void 0].filter(Boolean).join(": ")
|
|
7097
|
+
);
|
|
7098
|
+
}
|
|
4871
7099
|
},
|
|
4872
7100
|
async restore(_id, before) {
|
|
4873
7101
|
if (before === "unknown") return;
|
|
7102
|
+
const restoredAt = now();
|
|
4874
7103
|
const previous = JSON.parse(before);
|
|
4875
7104
|
if (previous.installed && previous.definition) {
|
|
4876
7105
|
await invoke("install", previous.definition);
|
|
4877
|
-
|
|
7106
|
+
if (previous.running) await this.start("scanner", restoredAt);
|
|
7107
|
+
else await invoke("stop");
|
|
4878
7108
|
return;
|
|
4879
7109
|
}
|
|
4880
7110
|
if (!previous.installed) await invoke("uninstall");
|
|
4881
|
-
else if (
|
|
7111
|
+
else if (previous.running) await this.start("scanner", restoredAt);
|
|
7112
|
+
else await invoke("stop");
|
|
4882
7113
|
}
|
|
4883
7114
|
};
|
|
4884
7115
|
}
|
|
4885
7116
|
export {
|
|
7117
|
+
SCANNER_LIMITED_ACTION,
|
|
7118
|
+
SCANNER_LIMITED_SENTENCE,
|
|
7119
|
+
SCANNER_RESTART_ACTION,
|
|
7120
|
+
SCANNER_RESTART_MESSAGE,
|
|
4886
7121
|
ScannerServiceLimited,
|
|
4887
7122
|
scannerService
|
|
4888
7123
|
};
|