cmux/node_modules/@vercel/ruby/dist/index.js
2026-01-29 17:36:26 -08:00

7660 lines
249 KiB
JavaScript

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// ../../node_modules/.pnpm/nice-try@1.0.5/node_modules/nice-try/src/index.js
var require_src = __commonJS({
"../../node_modules/.pnpm/nice-try@1.0.5/node_modules/nice-try/src/index.js"(exports, module2) {
"use strict";
module2.exports = function(fn) {
try {
return fn();
} catch (e) {
}
};
}
});
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js
var require_windows = __commonJS({
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs = require("fs");
function checkPathExt(path, options) {
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
if (!pathext) {
return true;
}
pathext = pathext.split(";");
if (pathext.indexOf("") !== -1) {
return true;
}
for (var i = 0; i < pathext.length; i++) {
var p = pathext[i].toLowerCase();
if (p && path.substr(-p.length).toLowerCase() === p) {
return true;
}
}
return false;
}
function checkStat(stat, path, options) {
if (!stat.isSymbolicLink() && !stat.isFile()) {
return false;
}
return checkPathExt(path, options);
}
function isexe(path, options, cb) {
fs.stat(path, function(er, stat) {
cb(er, er ? false : checkStat(stat, path, options));
});
}
function sync(path, options) {
return checkStat(fs.statSync(path), path, options);
}
}
});
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js
var require_mode = __commonJS({
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports, module2) {
module2.exports = isexe;
isexe.sync = sync;
var fs = require("fs");
function isexe(path, options, cb) {
fs.stat(path, function(er, stat) {
cb(er, er ? false : checkStat(stat, options));
});
}
function sync(path, options) {
return checkStat(fs.statSync(path), options);
}
function checkStat(stat, options) {
return stat.isFile() && checkMode(stat, options);
}
function checkMode(stat, options) {
var mod = stat.mode;
var uid = stat.uid;
var gid = stat.gid;
var myUid = options.uid !== void 0 ? options.uid : process.getuid && process.getuid();
var myGid = options.gid !== void 0 ? options.gid : process.getgid && process.getgid();
var u = parseInt("100", 8);
var g = parseInt("010", 8);
var o = parseInt("001", 8);
var ug = u | g;
var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
return ret;
}
}
});
// ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
var require_isexe = __commonJS({
"../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module2) {
var fs = require("fs");
var core;
if (process.platform === "win32" || global.TESTING_WINDOWS) {
core = require_windows();
} else {
core = require_mode();
}
module2.exports = isexe;
isexe.sync = sync;
function isexe(path, options, cb) {
if (typeof options === "function") {
cb = options;
options = {};
}
if (!cb) {
if (typeof Promise !== "function") {
throw new TypeError("callback not provided");
}
return new Promise(function(resolve, reject) {
isexe(path, options || {}, function(er, is) {
if (er) {
reject(er);
} else {
resolve(is);
}
});
});
}
core(path, options || {}, function(er, is) {
if (er) {
if (er.code === "EACCES" || options && options.ignoreErrors) {
er = null;
is = false;
}
}
cb(er, is);
});
}
function sync(path, options) {
try {
return core.sync(path, options || {});
} catch (er) {
if (options && options.ignoreErrors || er.code === "EACCES") {
return false;
} else {
throw er;
}
}
}
}
});
// ../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js
var require_which = __commonJS({
"../../node_modules/.pnpm/which@1.3.1/node_modules/which/which.js"(exports, module2) {
module2.exports = which3;
which3.sync = whichSync;
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
var path = require("path");
var COLON = isWindows ? ";" : ":";
var isexe = require_isexe();
function getNotFoundError(cmd) {
var er = new Error("not found: " + cmd);
er.code = "ENOENT";
return er;
}
function getPathInfo(cmd, opt) {
var colon = opt.colon || COLON;
var pathEnv = opt.path || process.env.PATH || "";
var pathExt = [""];
pathEnv = pathEnv.split(colon);
var pathExtExe = "";
if (isWindows) {
pathEnv.unshift(process.cwd());
pathExtExe = opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM";
pathExt = pathExtExe.split(colon);
if (cmd.indexOf(".") !== -1 && pathExt[0] !== "")
pathExt.unshift("");
}
if (cmd.match(/\//) || isWindows && cmd.match(/\\/))
pathEnv = [""];
return {
env: pathEnv,
ext: pathExt,
extExe: pathExtExe
};
}
function which3(cmd, opt, cb) {
if (typeof opt === "function") {
cb = opt;
opt = {};
}
var info = getPathInfo(cmd, opt);
var pathEnv = info.env;
var pathExt = info.ext;
var pathExtExe = info.extExe;
var found = [];
(function F(i, l) {
if (i === l) {
if (opt.all && found.length)
return cb(null, found);
else
return cb(getNotFoundError(cmd));
}
var pathPart = pathEnv[i];
if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
pathPart = pathPart.slice(1, -1);
var p = path.join(pathPart, cmd);
if (!pathPart && /^\.[\\\/]/.test(cmd)) {
p = cmd.slice(0, 2) + p;
}
;
(function E(ii, ll) {
if (ii === ll)
return F(i + 1, l);
var ext = pathExt[ii];
isexe(p + ext, { pathExt: pathExtExe }, function(er, is) {
if (!er && is) {
if (opt.all)
found.push(p + ext);
else
return cb(null, p + ext);
}
return E(ii + 1, ll);
});
})(0, pathExt.length);
})(0, pathEnv.length);
}
function whichSync(cmd, opt) {
opt = opt || {};
var info = getPathInfo(cmd, opt);
var pathEnv = info.env;
var pathExt = info.ext;
var pathExtExe = info.extExe;
var found = [];
for (var i = 0, l = pathEnv.length; i < l; i++) {
var pathPart = pathEnv[i];
if (pathPart.charAt(0) === '"' && pathPart.slice(-1) === '"')
pathPart = pathPart.slice(1, -1);
var p = path.join(pathPart, cmd);
if (!pathPart && /^\.[\\\/]/.test(cmd)) {
p = cmd.slice(0, 2) + p;
}
for (var j = 0, ll = pathExt.length; j < ll; j++) {
var cur = p + pathExt[j];
var is;
try {
is = isexe.sync(cur, { pathExt: pathExtExe });
if (is) {
if (opt.all)
found.push(cur);
else
return cur;
}
} catch (ex) {
}
}
}
if (opt.all && found.length)
return found;
if (opt.nothrow)
return null;
throw getNotFoundError(cmd);
}
}
});
// ../../node_modules/.pnpm/path-key@2.0.1/node_modules/path-key/index.js
var require_path_key = __commonJS({
"../../node_modules/.pnpm/path-key@2.0.1/node_modules/path-key/index.js"(exports, module2) {
"use strict";
module2.exports = (opts) => {
opts = opts || {};
const env = opts.env || process.env;
const platform = opts.platform || process.platform;
if (platform !== "win32") {
return "PATH";
}
return Object.keys(env).find((x) => x.toUpperCase() === "PATH") || "Path";
};
}
});
// ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/resolveCommand.js
var require_resolveCommand = __commonJS({
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports, module2) {
"use strict";
var path = require("path");
var which3 = require_which();
var pathKey = require_path_key()();
function resolveCommandAttempt(parsed, withoutPathExt) {
const cwd = process.cwd();
const hasCustomCwd = parsed.options.cwd != null;
if (hasCustomCwd) {
try {
process.chdir(parsed.options.cwd);
} catch (err) {
}
}
let resolved;
try {
resolved = which3.sync(parsed.command, {
path: (parsed.options.env || process.env)[pathKey],
pathExt: withoutPathExt ? path.delimiter : void 0
});
} catch (e) {
} finally {
process.chdir(cwd);
}
if (resolved) {
resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
}
return resolved;
}
function resolveCommand(parsed) {
return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
}
module2.exports = resolveCommand;
}
});
// ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/escape.js
var require_escape = __commonJS({
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/escape.js"(exports, module2) {
"use strict";
var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
function escapeCommand(arg) {
arg = arg.replace(metaCharsRegExp, "^$1");
return arg;
}
function escapeArgument(arg, doubleEscapeMetaChars) {
arg = `${arg}`;
arg = arg.replace(/(\\*)"/g, '$1$1\\"');
arg = arg.replace(/(\\*)$/, "$1$1");
arg = `"${arg}"`;
arg = arg.replace(metaCharsRegExp, "^$1");
if (doubleEscapeMetaChars) {
arg = arg.replace(metaCharsRegExp, "^$1");
}
return arg;
}
module2.exports.command = escapeCommand;
module2.exports.argument = escapeArgument;
}
});
// ../../node_modules/.pnpm/shebang-regex@1.0.0/node_modules/shebang-regex/index.js
var require_shebang_regex = __commonJS({
"../../node_modules/.pnpm/shebang-regex@1.0.0/node_modules/shebang-regex/index.js"(exports, module2) {
"use strict";
module2.exports = /^#!.*/;
}
});
// ../../node_modules/.pnpm/shebang-command@1.2.0/node_modules/shebang-command/index.js
var require_shebang_command = __commonJS({
"../../node_modules/.pnpm/shebang-command@1.2.0/node_modules/shebang-command/index.js"(exports, module2) {
"use strict";
var shebangRegex = require_shebang_regex();
module2.exports = function(str) {
var match = str.match(shebangRegex);
if (!match) {
return null;
}
var arr = match[0].replace(/#! ?/, "").split(" ");
var bin = arr[0].split("/").pop();
var arg = arr[1];
return bin === "env" ? arg : bin + (arg ? " " + arg : "");
};
}
});
// ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js
var require_readShebang = __commonJS({
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/util/readShebang.js"(exports, module2) {
"use strict";
var fs = require("fs");
var shebangCommand = require_shebang_command();
function readShebang(command) {
const size = 150;
let buffer;
if (Buffer.alloc) {
buffer = Buffer.alloc(size);
} else {
buffer = new Buffer(size);
buffer.fill(0);
}
let fd;
try {
fd = fs.openSync(command, "r");
fs.readSync(fd, buffer, 0, size, 0);
fs.closeSync(fd);
} catch (e) {
}
return shebangCommand(buffer.toString());
}
module2.exports = readShebang;
}
});
// ../../node_modules/.pnpm/semver@5.7.2/node_modules/semver/semver.js
var require_semver = __commonJS({
"../../node_modules/.pnpm/semver@5.7.2/node_modules/semver/semver.js"(exports, module2) {
exports = module2.exports = SemVer;
var debug4;
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
debug4 = function() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift("SEMVER");
console.log.apply(console, args);
};
} else {
debug4 = function() {
};
}
exports.SEMVER_SPEC_VERSION = "2.0.0";
var MAX_LENGTH = 256;
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
9007199254740991;
var MAX_SAFE_COMPONENT_LENGTH = 16;
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
var re = exports.re = [];
var safeRe = exports.safeRe = [];
var src = exports.src = [];
var R = 0;
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
var safeRegexReplacements = [
["\\s", 1],
["\\d", MAX_LENGTH],
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
];
function makeSafeRe(value) {
for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) {
var token = safeRegexReplacements[i2][0];
var max = safeRegexReplacements[i2][1];
value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}");
}
return value;
}
var NUMERICIDENTIFIER = R++;
src[NUMERICIDENTIFIER] = "0|[1-9]\\d*";
var NUMERICIDENTIFIERLOOSE = R++;
src[NUMERICIDENTIFIERLOOSE] = "\\d+";
var NONNUMERICIDENTIFIER = R++;
src[NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*";
var MAINVERSION = R++;
src[MAINVERSION] = "(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")\\.(" + src[NUMERICIDENTIFIER] + ")";
var MAINVERSIONLOOSE = R++;
src[MAINVERSIONLOOSE] = "(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[NUMERICIDENTIFIERLOOSE] + ")";
var PRERELEASEIDENTIFIER = R++;
src[PRERELEASEIDENTIFIER] = "(?:" + src[NUMERICIDENTIFIER] + "|" + src[NONNUMERICIDENTIFIER] + ")";
var PRERELEASEIDENTIFIERLOOSE = R++;
src[PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[NUMERICIDENTIFIERLOOSE] + "|" + src[NONNUMERICIDENTIFIER] + ")";
var PRERELEASE = R++;
src[PRERELEASE] = "(?:-(" + src[PRERELEASEIDENTIFIER] + "(?:\\." + src[PRERELEASEIDENTIFIER] + ")*))";
var PRERELEASELOOSE = R++;
src[PRERELEASELOOSE] = "(?:-?(" + src[PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[PRERELEASEIDENTIFIERLOOSE] + ")*))";
var BUILDIDENTIFIER = R++;
src[BUILDIDENTIFIER] = LETTERDASHNUMBER + "+";
var BUILD = R++;
src[BUILD] = "(?:\\+(" + src[BUILDIDENTIFIER] + "(?:\\." + src[BUILDIDENTIFIER] + ")*))";
var FULL = R++;
var FULLPLAIN = "v?" + src[MAINVERSION] + src[PRERELEASE] + "?" + src[BUILD] + "?";
src[FULL] = "^" + FULLPLAIN + "$";
var LOOSEPLAIN = "[v=\\s]*" + src[MAINVERSIONLOOSE] + src[PRERELEASELOOSE] + "?" + src[BUILD] + "?";
var LOOSE = R++;
src[LOOSE] = "^" + LOOSEPLAIN + "$";
var GTLT = R++;
src[GTLT] = "((?:<|>)?=?)";
var XRANGEIDENTIFIERLOOSE = R++;
src[XRANGEIDENTIFIERLOOSE] = src[NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
var XRANGEIDENTIFIER = R++;
src[XRANGEIDENTIFIER] = src[NUMERICIDENTIFIER] + "|x|X|\\*";
var XRANGEPLAIN = R++;
src[XRANGEPLAIN] = "[v=\\s]*(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:\\.(" + src[XRANGEIDENTIFIER] + ")(?:" + src[PRERELEASE] + ")?" + src[BUILD] + "?)?)?";
var XRANGEPLAINLOOSE = R++;
src[XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[XRANGEIDENTIFIERLOOSE] + ")(?:" + src[PRERELEASELOOSE] + ")?" + src[BUILD] + "?)?)?";
var XRANGE = R++;
src[XRANGE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAIN] + "$";
var XRANGELOOSE = R++;
src[XRANGELOOSE] = "^" + src[GTLT] + "\\s*" + src[XRANGEPLAINLOOSE] + "$";
var COERCE = R++;
src[COERCE] = "(?:^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])";
var LONETILDE = R++;
src[LONETILDE] = "(?:~>?)";
var TILDETRIM = R++;
src[TILDETRIM] = "(\\s*)" + src[LONETILDE] + "\\s+";
re[TILDETRIM] = new RegExp(src[TILDETRIM], "g");
safeRe[TILDETRIM] = new RegExp(makeSafeRe(src[TILDETRIM]), "g");
var tildeTrimReplace = "$1~";
var TILDE = R++;
src[TILDE] = "^" + src[LONETILDE] + src[XRANGEPLAIN] + "$";
var TILDELOOSE = R++;
src[TILDELOOSE] = "^" + src[LONETILDE] + src[XRANGEPLAINLOOSE] + "$";
var LONECARET = R++;
src[LONECARET] = "(?:\\^)";
var CARETTRIM = R++;
src[CARETTRIM] = "(\\s*)" + src[LONECARET] + "\\s+";
re[CARETTRIM] = new RegExp(src[CARETTRIM], "g");
safeRe[CARETTRIM] = new RegExp(makeSafeRe(src[CARETTRIM]), "g");
var caretTrimReplace = "$1^";
var CARET = R++;
src[CARET] = "^" + src[LONECARET] + src[XRANGEPLAIN] + "$";
var CARETLOOSE = R++;
src[CARETLOOSE] = "^" + src[LONECARET] + src[XRANGEPLAINLOOSE] + "$";
var COMPARATORLOOSE = R++;
src[COMPARATORLOOSE] = "^" + src[GTLT] + "\\s*(" + LOOSEPLAIN + ")$|^$";
var COMPARATOR = R++;
src[COMPARATOR] = "^" + src[GTLT] + "\\s*(" + FULLPLAIN + ")$|^$";
var COMPARATORTRIM = R++;
src[COMPARATORTRIM] = "(\\s*)" + src[GTLT] + "\\s*(" + LOOSEPLAIN + "|" + src[XRANGEPLAIN] + ")";
re[COMPARATORTRIM] = new RegExp(src[COMPARATORTRIM], "g");
safeRe[COMPARATORTRIM] = new RegExp(makeSafeRe(src[COMPARATORTRIM]), "g");
var comparatorTrimReplace = "$1$2$3";
var HYPHENRANGE = R++;
src[HYPHENRANGE] = "^\\s*(" + src[XRANGEPLAIN] + ")\\s+-\\s+(" + src[XRANGEPLAIN] + ")\\s*$";
var HYPHENRANGELOOSE = R++;
src[HYPHENRANGELOOSE] = "^\\s*(" + src[XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[XRANGEPLAINLOOSE] + ")\\s*$";
var STAR = R++;
src[STAR] = "(<|>)?=?\\s*\\*";
for (i = 0; i < R; i++) {
debug4(i, src[i]);
if (!re[i]) {
re[i] = new RegExp(src[i]);
safeRe[i] = new RegExp(makeSafeRe(src[i]));
}
}
var i;
exports.parse = parse;
function parse(version2, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version2 instanceof SemVer) {
return version2;
}
if (typeof version2 !== "string") {
return null;
}
if (version2.length > MAX_LENGTH) {
return null;
}
var r = options.loose ? safeRe[LOOSE] : safeRe[FULL];
if (!r.test(version2)) {
return null;
}
try {
return new SemVer(version2, options);
} catch (er) {
return null;
}
}
exports.valid = valid;
function valid(version2, options) {
var v = parse(version2, options);
return v ? v.version : null;
}
exports.clean = clean;
function clean(version2, options) {
var s = parse(version2.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
}
exports.SemVer = SemVer;
function SemVer(version2, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version2 instanceof SemVer) {
if (version2.loose === options.loose) {
return version2;
} else {
version2 = version2.version;
}
} else if (typeof version2 !== "string") {
throw new TypeError("Invalid Version: " + version2);
}
if (version2.length > MAX_LENGTH) {
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
}
if (!(this instanceof SemVer)) {
return new SemVer(version2, options);
}
debug4("SemVer", version2, options);
this.options = options;
this.loose = !!options.loose;
var m = version2.trim().match(options.loose ? safeRe[LOOSE] : safeRe[FULL]);
if (!m) {
throw new TypeError("Invalid Version: " + version2);
}
this.raw = version2;
this.major = +m[1];
this.minor = +m[2];
this.patch = +m[3];
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError("Invalid major version");
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError("Invalid minor version");
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError("Invalid patch version");
}
if (!m[4]) {
this.prerelease = [];
} else {
this.prerelease = m[4].split(".").map(function(id) {
if (/^[0-9]+$/.test(id)) {
var num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
}
this.build = m[5] ? m[5].split(".") : [];
this.format();
}
SemVer.prototype.format = function() {
this.version = this.major + "." + this.minor + "." + this.patch;
if (this.prerelease.length) {
this.version += "-" + this.prerelease.join(".");
}
return this.version;
};
SemVer.prototype.toString = function() {
return this.version;
};
SemVer.prototype.compare = function(other) {
debug4("SemVer.compare", this.version, this.options, other);
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return this.compareMain(other) || this.comparePre(other);
};
SemVer.prototype.compareMain = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
};
SemVer.prototype.comparePre = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
if (this.prerelease.length && !other.prerelease.length) {
return -1;
} else if (!this.prerelease.length && other.prerelease.length) {
return 1;
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
var i2 = 0;
do {
var a = this.prerelease[i2];
var b = other.prerelease[i2];
debug4("prerelease compare", i2, a, b);
if (a === void 0 && b === void 0) {
return 0;
} else if (b === void 0) {
return 1;
} else if (a === void 0) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i2);
};
SemVer.prototype.inc = function(release2, identifier) {
switch (release2) {
case "premajor":
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc("pre", identifier);
break;
case "preminor":
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc("pre", identifier);
break;
case "prepatch":
this.prerelease.length = 0;
this.inc("patch", identifier);
this.inc("pre", identifier);
break;
case "prerelease":
if (this.prerelease.length === 0) {
this.inc("patch", identifier);
}
this.inc("pre", identifier);
break;
case "major":
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
this.major++;
}
this.minor = 0;
this.patch = 0;
this.prerelease = [];
break;
case "minor":
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++;
}
this.patch = 0;
this.prerelease = [];
break;
case "patch":
if (this.prerelease.length === 0) {
this.patch++;
}
this.prerelease = [];
break;
case "pre":
if (this.prerelease.length === 0) {
this.prerelease = [0];
} else {
var i2 = this.prerelease.length;
while (--i2 >= 0) {
if (typeof this.prerelease[i2] === "number") {
this.prerelease[i2]++;
i2 = -2;
}
}
if (i2 === -1) {
this.prerelease.push(0);
}
}
if (identifier) {
if (this.prerelease[0] === identifier) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, 0];
}
} else {
this.prerelease = [identifier, 0];
}
}
break;
default:
throw new Error("invalid increment argument: " + release2);
}
this.format();
this.raw = this.version;
return this;
};
exports.inc = inc;
function inc(version2, release2, loose, identifier) {
if (typeof loose === "string") {
identifier = loose;
loose = void 0;
}
try {
return new SemVer(version2, loose).inc(release2, identifier).version;
} catch (er) {
return null;
}
}
exports.diff = diff;
function diff(version1, version2) {
if (eq(version1, version2)) {
return null;
} else {
var v1 = parse(version1);
var v2 = parse(version2);
var prefix = "";
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
var defaultResult = "prerelease";
}
for (var key in v1) {
if (key === "major" || key === "minor" || key === "patch") {
if (v1[key] !== v2[key]) {
return prefix + key;
}
}
}
return defaultResult;
}
}
exports.compareIdentifiers = compareIdentifiers;
var numeric = /^[0-9]+$/;
function compareIdentifiers(a, b) {
var anum = numeric.test(a);
var bnum = numeric.test(b);
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
}
exports.rcompareIdentifiers = rcompareIdentifiers;
function rcompareIdentifiers(a, b) {
return compareIdentifiers(b, a);
}
exports.major = major;
function major(a, loose) {
return new SemVer(a, loose).major;
}
exports.minor = minor;
function minor(a, loose) {
return new SemVer(a, loose).minor;
}
exports.patch = patch;
function patch(a, loose) {
return new SemVer(a, loose).patch;
}
exports.compare = compare;
function compare(a, b, loose) {
return new SemVer(a, loose).compare(new SemVer(b, loose));
}
exports.compareLoose = compareLoose;
function compareLoose(a, b) {
return compare(a, b, true);
}
exports.rcompare = rcompare;
function rcompare(a, b, loose) {
return compare(b, a, loose);
}
exports.sort = sort;
function sort(list, loose) {
return list.sort(function(a, b) {
return exports.compare(a, b, loose);
});
}
exports.rsort = rsort;
function rsort(list, loose) {
return list.sort(function(a, b) {
return exports.rcompare(a, b, loose);
});
}
exports.gt = gt;
function gt(a, b, loose) {
return compare(a, b, loose) > 0;
}
exports.lt = lt;
function lt(a, b, loose) {
return compare(a, b, loose) < 0;
}
exports.eq = eq;
function eq(a, b, loose) {
return compare(a, b, loose) === 0;
}
exports.neq = neq;
function neq(a, b, loose) {
return compare(a, b, loose) !== 0;
}
exports.gte = gte;
function gte(a, b, loose) {
return compare(a, b, loose) >= 0;
}
exports.lte = lte;
function lte(a, b, loose) {
return compare(a, b, loose) <= 0;
}
exports.cmp = cmp;
function cmp(a, op, b, loose) {
switch (op) {
case "===":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a === b;
case "!==":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a !== b;
case "":
case "=":
case "==":
return eq(a, b, loose);
case "!=":
return neq(a, b, loose);
case ">":
return gt(a, b, loose);
case ">=":
return gte(a, b, loose);
case "<":
return lt(a, b, loose);
case "<=":
return lte(a, b, loose);
default:
throw new TypeError("Invalid operator: " + op);
}
}
exports.Comparator = Comparator;
function Comparator(comp, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (comp instanceof Comparator) {
if (comp.loose === !!options.loose) {
return comp;
} else {
comp = comp.value;
}
}
if (!(this instanceof Comparator)) {
return new Comparator(comp, options);
}
comp = comp.trim().split(/\s+/).join(" ");
debug4("comparator", comp, options);
this.options = options;
this.loose = !!options.loose;
this.parse(comp);
if (this.semver === ANY) {
this.value = "";
} else {
this.value = this.operator + this.semver.version;
}
debug4("comp", this);
}
var ANY = {};
Comparator.prototype.parse = function(comp) {
var r = this.options.loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
var m = comp.match(r);
if (!m) {
throw new TypeError("Invalid comparator: " + comp);
}
this.operator = m[1];
if (this.operator === "=") {
this.operator = "";
}
if (!m[2]) {
this.semver = ANY;
} else {
this.semver = new SemVer(m[2], this.options.loose);
}
};
Comparator.prototype.toString = function() {
return this.value;
};
Comparator.prototype.test = function(version2) {
debug4("Comparator.test", version2, this.options.loose);
if (this.semver === ANY) {
return true;
}
if (typeof version2 === "string") {
version2 = new SemVer(version2, this.options);
}
return cmp(version2, this.operator, this.semver, this.options);
};
Comparator.prototype.intersects = function(comp, options) {
if (!(comp instanceof Comparator)) {
throw new TypeError("a Comparator is required");
}
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
var rangeTmp;
if (this.operator === "") {
rangeTmp = new Range(comp.value, options);
return satisfies(this.value, rangeTmp, options);
} else if (comp.operator === "") {
rangeTmp = new Range(this.value, options);
return satisfies(comp.semver, rangeTmp, options);
}
var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
var sameSemVer = this.semver.version === comp.semver.version;
var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<"));
var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">"));
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
};
exports.Range = Range;
function Range(range, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (range instanceof Range) {
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
return range;
} else {
return new Range(range.raw, options);
}
}
if (range instanceof Comparator) {
return new Range(range.value, options);
}
if (!(this instanceof Range)) {
return new Range(range, options);
}
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease;
this.raw = range.trim().split(/\s+/).join(" ");
this.set = this.raw.split("||").map(function(range2) {
return this.parseRange(range2.trim());
}, this).filter(function(c) {
return c.length;
});
if (!this.set.length) {
throw new TypeError("Invalid SemVer Range: " + this.raw);
}
this.format();
}
Range.prototype.format = function() {
this.range = this.set.map(function(comps) {
return comps.join(" ").trim();
}).join("||").trim();
return this.range;
};
Range.prototype.toString = function() {
return this.range;
};
Range.prototype.parseRange = function(range) {
var loose = this.options.loose;
var hr = loose ? safeRe[HYPHENRANGELOOSE] : safeRe[HYPHENRANGE];
range = range.replace(hr, hyphenReplace);
debug4("hyphen replace", range);
range = range.replace(safeRe[COMPARATORTRIM], comparatorTrimReplace);
debug4("comparator trim", range, safeRe[COMPARATORTRIM]);
range = range.replace(safeRe[TILDETRIM], tildeTrimReplace);
range = range.replace(safeRe[CARETTRIM], caretTrimReplace);
var compRe = loose ? safeRe[COMPARATORLOOSE] : safeRe[COMPARATOR];
var set = range.split(" ").map(function(comp) {
return parseComparator(comp, this.options);
}, this).join(" ").split(/\s+/);
if (this.options.loose) {
set = set.filter(function(comp) {
return !!comp.match(compRe);
});
}
set = set.map(function(comp) {
return new Comparator(comp, this.options);
}, this);
return set;
};
Range.prototype.intersects = function(range, options) {
if (!(range instanceof Range)) {
throw new TypeError("a Range is required");
}
return this.set.some(function(thisComparators) {
return thisComparators.every(function(thisComparator) {
return range.set.some(function(rangeComparators) {
return rangeComparators.every(function(rangeComparator) {
return thisComparator.intersects(rangeComparator, options);
});
});
});
});
};
exports.toComparators = toComparators;
function toComparators(range, options) {
return new Range(range, options).set.map(function(comp) {
return comp.map(function(c) {
return c.value;
}).join(" ").trim().split(" ");
});
}
function parseComparator(comp, options) {
debug4("comp", comp, options);
comp = replaceCarets(comp, options);
debug4("caret", comp);
comp = replaceTildes(comp, options);
debug4("tildes", comp);
comp = replaceXRanges(comp, options);
debug4("xrange", comp);
comp = replaceStars(comp, options);
debug4("stars", comp);
return comp;
}
function isX(id) {
return !id || id.toLowerCase() === "x" || id === "*";
}
function replaceTildes(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceTilde(comp2, options);
}).join(" ");
}
function replaceTilde(comp, options) {
var r = options.loose ? safeRe[TILDELOOSE] : safeRe[TILDE];
return comp.replace(r, function(_, M, m, p, pr) {
debug4("tilde", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else if (pr) {
debug4("replaceTilde pr", pr);
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
debug4("tilde return", ret);
return ret;
});
}
function replaceCarets(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceCaret(comp2, options);
}).join(" ");
}
function replaceCaret(comp, options) {
debug4("caret", comp, options);
var r = options.loose ? safeRe[CARETLOOSE] : safeRe[CARET];
return comp.replace(r, function(_, M, m, p, pr) {
debug4("caret", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
if (M === "0") {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
}
} else if (pr) {
debug4("replaceCaret pr", pr);
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
}
} else {
debug4("no pr");
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
}
}
debug4("caret return", ret);
return ret;
});
}
function replaceXRanges(comp, options) {
debug4("replaceXRanges", comp, options);
return comp.split(/\s+/).map(function(comp2) {
return replaceXRange(comp2, options);
}).join(" ");
}
function replaceXRange(comp, options) {
comp = comp.trim();
var r = options.loose ? safeRe[XRANGELOOSE] : safeRe[XRANGE];
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
debug4("xRange", comp, ret, gtlt, M, m, p, pr);
var xM = isX(M);
var xm = xM || isX(m);
var xp = xm || isX(p);
var anyX = xp;
if (gtlt === "=" && anyX) {
gtlt = "";
}
if (xM) {
if (gtlt === ">" || gtlt === "<") {
ret = "<0.0.0";
} else {
ret = "*";
}
} else if (gtlt && anyX) {
if (xm) {
m = 0;
}
p = 0;
if (gtlt === ">") {
gtlt = ">=";
if (xm) {
M = +M + 1;
m = 0;
p = 0;
} else {
m = +m + 1;
p = 0;
}
} else if (gtlt === "<=") {
gtlt = "<";
if (xm) {
M = +M + 1;
} else {
m = +m + 1;
}
}
ret = gtlt + M + "." + m + "." + p;
} else if (xm) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (xp) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
}
debug4("xRange return", ret);
return ret;
});
}
function replaceStars(comp, options) {
debug4("replaceStars", comp, options);
return comp.trim().replace(safeRe[STAR], "");
}
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
if (isX(fM)) {
from = "";
} else if (isX(fm)) {
from = ">=" + fM + ".0.0";
} else if (isX(fp)) {
from = ">=" + fM + "." + fm + ".0";
} else {
from = ">=" + from;
}
if (isX(tM)) {
to = "";
} else if (isX(tm)) {
to = "<" + (+tM + 1) + ".0.0";
} else if (isX(tp)) {
to = "<" + tM + "." + (+tm + 1) + ".0";
} else if (tpr) {
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
} else {
to = "<=" + to;
}
return (from + " " + to).trim();
}
Range.prototype.test = function(version2) {
if (!version2) {
return false;
}
if (typeof version2 === "string") {
version2 = new SemVer(version2, this.options);
}
for (var i2 = 0; i2 < this.set.length; i2++) {
if (testSet(this.set[i2], version2, this.options)) {
return true;
}
}
return false;
};
function testSet(set, version2, options) {
for (var i2 = 0; i2 < set.length; i2++) {
if (!set[i2].test(version2)) {
return false;
}
}
if (version2.prerelease.length && !options.includePrerelease) {
for (i2 = 0; i2 < set.length; i2++) {
debug4(set[i2].semver);
if (set[i2].semver === ANY) {
continue;
}
if (set[i2].semver.prerelease.length > 0) {
var allowed = set[i2].semver;
if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
return true;
}
}
}
return false;
}
return true;
}
exports.satisfies = satisfies;
function satisfies(version2, range, options) {
try {
range = new Range(range, options);
} catch (er) {
return false;
}
return range.test(version2);
}
exports.maxSatisfying = maxSatisfying;
function maxSatisfying(versions, range, options) {
var max = null;
var maxSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!max || maxSV.compare(v) === -1) {
max = v;
maxSV = new SemVer(max, options);
}
}
});
return max;
}
exports.minSatisfying = minSatisfying;
function minSatisfying(versions, range, options) {
var min = null;
var minSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!min || minSV.compare(v) === 1) {
min = v;
minSV = new SemVer(min, options);
}
}
});
return min;
}
exports.minVersion = minVersion;
function minVersion(range, loose) {
range = new Range(range, loose);
var minver = new SemVer("0.0.0");
if (range.test(minver)) {
return minver;
}
minver = new SemVer("0.0.0-0");
if (range.test(minver)) {
return minver;
}
minver = null;
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
comparators.forEach(function(comparator) {
var compver = new SemVer(comparator.semver.version);
switch (comparator.operator) {
case ">":
if (compver.prerelease.length === 0) {
compver.patch++;
} else {
compver.prerelease.push(0);
}
compver.raw = compver.format();
case "":
case ">=":
if (!minver || gt(minver, compver)) {
minver = compver;
}
break;
case "<":
case "<=":
break;
default:
throw new Error("Unexpected operation: " + comparator.operator);
}
});
}
if (minver && range.test(minver)) {
return minver;
}
return null;
}
exports.validRange = validRange;
function validRange(range, options) {
try {
return new Range(range, options).range || "*";
} catch (er) {
return null;
}
}
exports.ltr = ltr;
function ltr(version2, range, options) {
return outside(version2, range, "<", options);
}
exports.gtr = gtr;
function gtr(version2, range, options) {
return outside(version2, range, ">", options);
}
exports.outside = outside;
function outside(version2, range, hilo, options) {
version2 = new SemVer(version2, options);
range = new Range(range, options);
var gtfn, ltefn, ltfn, comp, ecomp;
switch (hilo) {
case ">":
gtfn = gt;
ltefn = lte;
ltfn = lt;
comp = ">";
ecomp = ">=";
break;
case "<":
gtfn = lt;
ltefn = gte;
ltfn = gt;
comp = "<";
ecomp = "<=";
break;
default:
throw new TypeError('Must provide a hilo val of "<" or ">"');
}
if (satisfies(version2, range, options)) {
return false;
}
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
var high = null;
var low = null;
comparators.forEach(function(comparator) {
if (comparator.semver === ANY) {
comparator = new Comparator(">=0.0.0");
}
high = high || comparator;
low = low || comparator;
if (gtfn(comparator.semver, high.semver, options)) {
high = comparator;
} else if (ltfn(comparator.semver, low.semver, options)) {
low = comparator;
}
});
if (high.operator === comp || high.operator === ecomp) {
return false;
}
if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
return false;
} else if (low.operator === ecomp && ltfn(version2, low.semver)) {
return false;
}
}
return true;
}
exports.prerelease = prerelease;
function prerelease(version2, options) {
var parsed = parse(version2, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
exports.intersects = intersects2;
function intersects2(r1, r2, options) {
r1 = new Range(r1, options);
r2 = new Range(r2, options);
return r1.intersects(r2);
}
exports.coerce = coerce;
function coerce(version2) {
if (version2 instanceof SemVer) {
return version2;
}
if (typeof version2 !== "string") {
return null;
}
var match = version2.match(safeRe[COERCE]);
if (match == null) {
return null;
}
return parse(match[1] + "." + (match[2] || "0") + "." + (match[3] || "0"));
}
}
});
// ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/parse.js
var require_parse = __commonJS({
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/parse.js"(exports, module2) {
"use strict";
var path = require("path");
var niceTry = require_src();
var resolveCommand = require_resolveCommand();
var escape = require_escape();
var readShebang = require_readShebang();
var semver = require_semver();
var isWin = process.platform === "win32";
var isExecutableRegExp = /\.(?:com|exe)$/i;
var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
var supportsShellOption = niceTry(() => semver.satisfies(process.version, "^4.8.0 || ^5.7.0 || >= 6.0.0", true)) || false;
function detectShebang(parsed) {
parsed.file = resolveCommand(parsed);
const shebang = parsed.file && readShebang(parsed.file);
if (shebang) {
parsed.args.unshift(parsed.file);
parsed.command = shebang;
return resolveCommand(parsed);
}
return parsed.file;
}
function parseNonShell(parsed) {
if (!isWin) {
return parsed;
}
const commandFile = detectShebang(parsed);
const needsShell = !isExecutableRegExp.test(commandFile);
if (parsed.options.forceShell || needsShell) {
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
parsed.command = path.normalize(parsed.command);
parsed.command = escape.command(parsed.command);
parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
parsed.command = process.env.comspec || "cmd.exe";
parsed.options.windowsVerbatimArguments = true;
}
return parsed;
}
function parseShell(parsed) {
if (supportsShellOption) {
return parsed;
}
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
if (isWin) {
parsed.command = typeof parsed.options.shell === "string" ? parsed.options.shell : process.env.comspec || "cmd.exe";
parsed.args = ["/d", "/s", "/c", `"${shellCommand}"`];
parsed.options.windowsVerbatimArguments = true;
} else {
if (typeof parsed.options.shell === "string") {
parsed.command = parsed.options.shell;
} else if (process.platform === "android") {
parsed.command = "/system/bin/sh";
} else {
parsed.command = "/bin/sh";
}
parsed.args = ["-c", shellCommand];
}
return parsed;
}
function parse(command, args, options) {
if (args && !Array.isArray(args)) {
options = args;
args = null;
}
args = args ? args.slice(0) : [];
options = Object.assign({}, options);
const parsed = {
command,
args,
options,
file: void 0,
original: {
command,
args
}
};
return options.shell ? parseShell(parsed) : parseNonShell(parsed);
}
module2.exports = parse;
}
});
// ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/enoent.js
var require_enoent = __commonJS({
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/lib/enoent.js"(exports, module2) {
"use strict";
var isWin = process.platform === "win32";
function notFoundError(original, syscall) {
return Object.assign(new Error(`${syscall} ${original.command} ENOENT`), {
code: "ENOENT",
errno: "ENOENT",
syscall: `${syscall} ${original.command}`,
path: original.command,
spawnargs: original.args
});
}
function hookChildProcess(cp, parsed) {
if (!isWin) {
return;
}
const originalEmit = cp.emit;
cp.emit = function(name, arg1) {
if (name === "exit") {
const err = verifyENOENT(arg1, parsed, "spawn");
if (err) {
return originalEmit.call(cp, "error", err);
}
}
return originalEmit.apply(cp, arguments);
};
}
function verifyENOENT(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, "spawn");
}
return null;
}
function verifyENOENTSync(status, parsed) {
if (isWin && status === 1 && !parsed.file) {
return notFoundError(parsed.original, "spawnSync");
}
return null;
}
module2.exports = {
hookChildProcess,
verifyENOENT,
verifyENOENTSync,
notFoundError
};
}
});
// ../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/index.js
var require_cross_spawn = __commonJS({
"../../node_modules/.pnpm/cross-spawn@6.0.5/node_modules/cross-spawn/index.js"(exports, module2) {
"use strict";
var cp = require("child_process");
var parse = require_parse();
var enoent = require_enoent();
function spawn2(command, args, options) {
const parsed = parse(command, args, options);
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
enoent.hookChildProcess(spawned, parsed);
return spawned;
}
function spawnSync2(command, args, options) {
const parsed = parse(command, args, options);
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
return result;
}
module2.exports = spawn2;
module2.exports.spawn = spawn2;
module2.exports.sync = spawnSync2;
module2.exports._parse = parse;
module2.exports._enoent = enoent;
}
});
// ../../node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js
var require_strip_final_newline = __commonJS({
"../../node_modules/.pnpm/strip-final-newline@2.0.0/node_modules/strip-final-newline/index.js"(exports, module2) {
"use strict";
module2.exports = (input) => {
const LF = typeof input === "string" ? "\n" : "\n".charCodeAt();
const CR = typeof input === "string" ? "\r" : "\r".charCodeAt();
if (input[input.length - 1] === LF) {
input = input.slice(0, input.length - 1);
}
if (input[input.length - 1] === CR) {
input = input.slice(0, input.length - 1);
}
return input;
};
}
});
// ../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js
var require_path_key2 = __commonJS({
"../../node_modules/.pnpm/path-key@3.1.1/node_modules/path-key/index.js"(exports, module2) {
"use strict";
var pathKey = (options = {}) => {
const environment = options.env || process.env;
const platform = options.platform || process.platform;
if (platform !== "win32") {
return "PATH";
}
return Object.keys(environment).reverse().find((key) => key.toUpperCase() === "PATH") || "Path";
};
module2.exports = pathKey;
module2.exports.default = pathKey;
}
});
// ../../node_modules/.pnpm/npm-run-path@3.1.0/node_modules/npm-run-path/index.js
var require_npm_run_path = __commonJS({
"../../node_modules/.pnpm/npm-run-path@3.1.0/node_modules/npm-run-path/index.js"(exports, module2) {
"use strict";
var path = require("path");
var pathKey = require_path_key2();
var npmRunPath = (options) => {
options = {
cwd: process.cwd(),
path: process.env[pathKey()],
...options
};
let previous;
let cwdPath = path.resolve(options.cwd);
const result = [];
while (previous !== cwdPath) {
result.push(path.join(cwdPath, "node_modules/.bin"));
previous = cwdPath;
cwdPath = path.resolve(cwdPath, "..");
}
result.push(path.dirname(process.execPath));
return result.concat(options.path).join(path.delimiter);
};
module2.exports = npmRunPath;
module2.exports.default = npmRunPath;
module2.exports.env = (options) => {
options = {
env: process.env,
...options
};
const env = { ...options.env };
const path2 = pathKey({ env });
options.path = env[path2];
env[path2] = module2.exports(options);
return env;
};
}
});
// ../../node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js
var require_mimic_fn = __commonJS({
"../../node_modules/.pnpm/mimic-fn@2.1.0/node_modules/mimic-fn/index.js"(exports, module2) {
"use strict";
var mimicFn = (to, from) => {
for (const prop of Reflect.ownKeys(from)) {
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
}
return to;
};
module2.exports = mimicFn;
module2.exports.default = mimicFn;
}
});
// ../../node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js
var require_onetime = __commonJS({
"../../node_modules/.pnpm/onetime@5.1.2/node_modules/onetime/index.js"(exports, module2) {
"use strict";
var mimicFn = require_mimic_fn();
var calledFunctions = /* @__PURE__ */ new WeakMap();
var onetime = (function_, options = {}) => {
if (typeof function_ !== "function") {
throw new TypeError("Expected a function");
}
let returnValue;
let callCount = 0;
const functionName = function_.displayName || function_.name || "<anonymous>";
const onetime2 = function(...arguments_) {
calledFunctions.set(onetime2, ++callCount);
if (callCount === 1) {
returnValue = function_.apply(this, arguments_);
function_ = null;
} else if (options.throw === true) {
throw new Error(`Function \`${functionName}\` can only be called once`);
}
return returnValue;
};
mimicFn(onetime2, function_);
calledFunctions.set(onetime2, callCount);
return onetime2;
};
module2.exports = onetime;
module2.exports.default = onetime;
module2.exports.callCount = (function_) => {
if (!calledFunctions.has(function_)) {
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
}
return calledFunctions.get(function_);
};
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/error.js
var require_error = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/error.js"(exports, module2) {
"use strict";
var os = require("os");
var util = require("util");
var getCode = (error, code) => {
if (error && error.code) {
return [error.code, os.constants.errno[error.code]];
}
if (Number.isInteger(code)) {
return [util.getSystemErrorName(-code), code];
}
return [];
};
var getErrorPrefix = ({ timedOut, timeout, signal, exitCodeName, exitCode, isCanceled }) => {
if (timedOut) {
return `timed out after ${timeout} milliseconds`;
}
if (isCanceled) {
return "was canceled";
}
if (signal) {
return `was killed with ${signal}`;
}
if (exitCode !== void 0) {
return `failed with exit code ${exitCode} (${exitCodeName})`;
}
return "failed";
};
var makeError = ({
stdout,
stderr,
all,
error,
signal,
code,
command,
timedOut,
isCanceled,
killed,
parsed: { options: { timeout } }
}) => {
const [exitCodeName, exitCode] = getCode(error, code);
const prefix = getErrorPrefix({ timedOut, timeout, signal, exitCodeName, exitCode, isCanceled });
const message = `Command ${prefix}: ${command}`;
if (error instanceof Error) {
error.message = `${message}
${error.message}`;
} else {
error = new Error(message);
}
error.command = command;
delete error.code;
error.exitCode = exitCode;
error.exitCodeName = exitCodeName;
error.stdout = stdout;
error.stderr = stderr;
if (all !== void 0) {
error.all = all;
}
if ("bufferedData" in error) {
delete error.bufferedData;
}
error.failed = true;
error.timedOut = Boolean(timedOut);
error.isCanceled = isCanceled;
error.killed = killed && !timedOut;
error.signal = signal || void 0;
return error;
};
module2.exports = makeError;
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/stdio.js
var require_stdio = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/stdio.js"(exports, module2) {
"use strict";
var aliases = ["stdin", "stdout", "stderr"];
var hasAlias = (opts) => aliases.some((alias) => opts[alias] !== void 0);
var normalizeStdio = (opts) => {
if (!opts) {
return;
}
const { stdio } = opts;
if (stdio === void 0) {
return aliases.map((alias) => opts[alias]);
}
if (hasAlias(opts)) {
throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${aliases.map((alias) => `\`${alias}\``).join(", ")}`);
}
if (typeof stdio === "string") {
return stdio;
}
if (!Array.isArray(stdio)) {
throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof stdio}\``);
}
const length = Math.max(stdio.length, aliases.length);
return Array.from({ length }, (value, index) => stdio[index]);
};
module2.exports = normalizeStdio;
module2.exports.node = (opts) => {
const stdio = normalizeStdio(opts);
if (stdio === "ipc") {
return "ipc";
}
if (stdio === void 0 || typeof stdio === "string") {
return [stdio, stdio, stdio, "ipc"];
}
if (stdio.includes("ipc")) {
return stdio;
}
return [...stdio, "ipc"];
};
}
});
// ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js
var require_signals = __commonJS({
"../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports, module2) {
module2.exports = [
"SIGABRT",
"SIGALRM",
"SIGHUP",
"SIGINT",
"SIGTERM"
];
if (process.platform !== "win32") {
module2.exports.push(
"SIGVTALRM",
"SIGXCPU",
"SIGXFSZ",
"SIGUSR2",
"SIGTRAP",
"SIGSYS",
"SIGQUIT",
"SIGIOT"
// should detect profiler and enable/disable accordingly.
// see #21
// 'SIGPROF'
);
}
if (process.platform === "linux") {
module2.exports.push(
"SIGIO",
"SIGPOLL",
"SIGPWR",
"SIGSTKFLT",
"SIGUNUSED"
);
}
}
});
// ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
var require_signal_exit = __commonJS({
"../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports, module2) {
var process2 = global.process;
var processOk = function(process3) {
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";
};
if (!processOk(process2)) {
module2.exports = function() {
return function() {
};
};
} else {
assert = require("assert");
signals = require_signals();
isWin = /^win/i.test(process2.platform);
EE = require("events");
if (typeof EE !== "function") {
EE = EE.EventEmitter;
}
if (process2.__signal_exit_emitter__) {
emitter = process2.__signal_exit_emitter__;
} else {
emitter = process2.__signal_exit_emitter__ = new EE();
emitter.count = 0;
emitter.emitted = {};
}
if (!emitter.infinite) {
emitter.setMaxListeners(Infinity);
emitter.infinite = true;
}
module2.exports = function(cb, opts) {
if (!processOk(global.process)) {
return function() {
};
}
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
if (loaded === false) {
load();
}
var ev = "exit";
if (opts && opts.alwaysLast) {
ev = "afterexit";
}
var remove2 = function() {
emitter.removeListener(ev, cb);
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
unload();
}
};
emitter.on(ev, cb);
return remove2;
};
unload = function unload2() {
if (!loaded || !processOk(global.process)) {
return;
}
loaded = false;
signals.forEach(function(sig) {
try {
process2.removeListener(sig, sigListeners[sig]);
} catch (er) {
}
});
process2.emit = originalProcessEmit;
process2.reallyExit = originalProcessReallyExit;
emitter.count -= 1;
};
module2.exports.unload = unload;
emit = function emit2(event, code, signal) {
if (emitter.emitted[event]) {
return;
}
emitter.emitted[event] = true;
emitter.emit(event, code, signal);
};
sigListeners = {};
signals.forEach(function(sig) {
sigListeners[sig] = function listener() {
if (!processOk(global.process)) {
return;
}
var listeners = process2.listeners(sig);
if (listeners.length === emitter.count) {
unload();
emit("exit", null, sig);
emit("afterexit", null, sig);
if (isWin && sig === "SIGHUP") {
sig = "SIGINT";
}
process2.kill(process2.pid, sig);
}
};
});
module2.exports.signals = function() {
return signals;
};
loaded = false;
load = function load2() {
if (loaded || !processOk(global.process)) {
return;
}
loaded = true;
emitter.count += 1;
signals = signals.filter(function(sig) {
try {
process2.on(sig, sigListeners[sig]);
return true;
} catch (er) {
return false;
}
});
process2.emit = processEmit;
process2.reallyExit = processReallyExit;
};
module2.exports.load = load;
originalProcessReallyExit = process2.reallyExit;
processReallyExit = function processReallyExit2(code) {
if (!processOk(global.process)) {
return;
}
process2.exitCode = code || /* istanbul ignore next */
0;
emit("exit", process2.exitCode, null);
emit("afterexit", process2.exitCode, null);
originalProcessReallyExit.call(process2, process2.exitCode);
};
originalProcessEmit = process2.emit;
processEmit = function processEmit2(ev, arg) {
if (ev === "exit" && processOk(global.process)) {
if (arg !== void 0) {
process2.exitCode = arg;
}
var ret = originalProcessEmit.apply(this, arguments);
emit("exit", process2.exitCode, null);
emit("afterexit", process2.exitCode, null);
return ret;
} else {
return originalProcessEmit.apply(this, arguments);
}
};
}
var assert;
var signals;
var isWin;
var EE;
var emitter;
var unload;
var emit;
var sigListeners;
var loaded;
var load;
var originalProcessReallyExit;
var processReallyExit;
var originalProcessEmit;
var processEmit;
}
});
// ../../node_modules/.pnpm/p-finally@2.0.1/node_modules/p-finally/index.js
var require_p_finally = __commonJS({
"../../node_modules/.pnpm/p-finally@2.0.1/node_modules/p-finally/index.js"(exports, module2) {
"use strict";
module2.exports = async (promise, onFinally = () => {
}) => {
let value;
try {
value = await promise;
} catch (error) {
await onFinally();
throw error;
}
await onFinally();
return value;
};
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/kill.js
var require_kill = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/kill.js"(exports, module2) {
"use strict";
var os = require("os");
var onExit = require_signal_exit();
var pFinally = require_p_finally();
var DEFAULT_FORCE_KILL_TIMEOUT = 1e3 * 5;
var spawnedKill = (kill, signal = "SIGTERM", options = {}) => {
const killResult = kill(signal);
setKillTimeout(kill, signal, options, killResult);
return killResult;
};
var setKillTimeout = (kill, signal, options, killResult) => {
if (!shouldForceKill(signal, options, killResult)) {
return;
}
const timeout = getForceKillAfterTimeout(options);
setTimeout(() => {
kill("SIGKILL");
}, timeout).unref();
};
var shouldForceKill = (signal, { forceKillAfterTimeout }, killResult) => {
return isSigterm(signal) && forceKillAfterTimeout !== false && killResult;
};
var isSigterm = (signal) => {
return signal === os.constants.signals.SIGTERM || typeof signal === "string" && signal.toUpperCase() === "SIGTERM";
};
var getForceKillAfterTimeout = ({ forceKillAfterTimeout = true }) => {
if (forceKillAfterTimeout === true) {
return DEFAULT_FORCE_KILL_TIMEOUT;
}
if (!Number.isInteger(forceKillAfterTimeout) || forceKillAfterTimeout < 0) {
throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${forceKillAfterTimeout}\` (${typeof forceKillAfterTimeout})`);
}
return forceKillAfterTimeout;
};
var spawnedCancel = (spawned, context) => {
const killResult = spawned.kill();
if (killResult) {
context.isCanceled = true;
}
};
var timeoutKill = (spawned, signal, reject) => {
spawned.kill(signal);
reject(Object.assign(new Error("Timed out"), { timedOut: true, signal }));
};
var setupTimeout = (spawned, { timeout, killSignal = "SIGTERM" }, spawnedPromise) => {
if (timeout === 0 || timeout === void 0) {
return spawnedPromise;
}
if (!Number.isInteger(timeout) || timeout < 0) {
throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${timeout}\` (${typeof timeout})`);
}
let timeoutId;
const timeoutPromise = new Promise((resolve, reject) => {
timeoutId = setTimeout(() => {
timeoutKill(spawned, killSignal, reject);
}, timeout);
});
const safeSpawnedPromise = pFinally(spawnedPromise, () => {
clearTimeout(timeoutId);
});
return Promise.race([timeoutPromise, safeSpawnedPromise]);
};
var setExitHandler = (spawned, { cleanup, detached }, timedPromise) => {
if (!cleanup || detached) {
return timedPromise;
}
const removeExitHandler = onExit(() => {
spawned.kill();
});
return pFinally(timedPromise, removeExitHandler);
};
module2.exports = {
spawnedKill,
spawnedCancel,
setupTimeout,
setExitHandler
};
}
});
// ../../node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js
var require_is_stream = __commonJS({
"../../node_modules/.pnpm/is-stream@2.0.1/node_modules/is-stream/index.js"(exports, module2) {
"use strict";
var isStream = (stream) => stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
isStream.writable = (stream) => isStream(stream) && stream.writable !== false && typeof stream._write === "function" && typeof stream._writableState === "object";
isStream.readable = (stream) => isStream(stream) && stream.readable !== false && typeof stream._read === "function" && typeof stream._readableState === "object";
isStream.duplex = (stream) => isStream.writable(stream) && isStream.readable(stream);
isStream.transform = (stream) => isStream.duplex(stream) && typeof stream._transform === "function";
module2.exports = isStream;
}
});
// ../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js
var require_wrappy = __commonJS({
"../../node_modules/.pnpm/wrappy@1.0.2/node_modules/wrappy/wrappy.js"(exports, module2) {
module2.exports = wrappy;
function wrappy(fn, cb) {
if (fn && cb)
return wrappy(fn)(cb);
if (typeof fn !== "function")
throw new TypeError("need wrapper function");
Object.keys(fn).forEach(function(k) {
wrapper[k] = fn[k];
});
return wrapper;
function wrapper() {
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
var ret = fn.apply(this, args);
var cb2 = args[args.length - 1];
if (typeof ret === "function" && ret !== cb2) {
Object.keys(cb2).forEach(function(k) {
ret[k] = cb2[k];
});
}
return ret;
}
}
}
});
// ../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js
var require_once = __commonJS({
"../../node_modules/.pnpm/once@1.4.0/node_modules/once/once.js"(exports, module2) {
var wrappy = require_wrappy();
module2.exports = wrappy(once);
module2.exports.strict = wrappy(onceStrict);
once.proto = once(function() {
Object.defineProperty(Function.prototype, "once", {
value: function() {
return once(this);
},
configurable: true
});
Object.defineProperty(Function.prototype, "onceStrict", {
value: function() {
return onceStrict(this);
},
configurable: true
});
});
function once(fn) {
var f = function() {
if (f.called)
return f.value;
f.called = true;
return f.value = fn.apply(this, arguments);
};
f.called = false;
return f;
}
function onceStrict(fn) {
var f = function() {
if (f.called)
throw new Error(f.onceError);
f.called = true;
return f.value = fn.apply(this, arguments);
};
var name = fn.name || "Function wrapped with `once`";
f.onceError = name + " shouldn't be called more than once";
f.called = false;
return f;
}
}
});
// ../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js
var require_end_of_stream = __commonJS({
"../../node_modules/.pnpm/end-of-stream@1.4.1/node_modules/end-of-stream/index.js"(exports, module2) {
var once = require_once();
var noop = function() {
};
var isRequest = function(stream) {
return stream.setHeader && typeof stream.abort === "function";
};
var isChildProcess = function(stream) {
return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3;
};
var eos = function(stream, opts, callback) {
if (typeof opts === "function")
return eos(stream, null, opts);
if (!opts)
opts = {};
callback = once(callback || noop);
var ws = stream._writableState;
var rs = stream._readableState;
var readable = opts.readable || opts.readable !== false && stream.readable;
var writable = opts.writable || opts.writable !== false && stream.writable;
var onlegacyfinish = function() {
if (!stream.writable)
onfinish();
};
var onfinish = function() {
writable = false;
if (!readable)
callback.call(stream);
};
var onend = function() {
readable = false;
if (!writable)
callback.call(stream);
};
var onexit = function(exitCode) {
callback.call(stream, exitCode ? new Error("exited with error code: " + exitCode) : null);
};
var onerror = function(err) {
callback.call(stream, err);
};
var onclose = function() {
if (readable && !(rs && rs.ended))
return callback.call(stream, new Error("premature close"));
if (writable && !(ws && ws.ended))
return callback.call(stream, new Error("premature close"));
};
var onrequest = function() {
stream.req.on("finish", onfinish);
};
if (isRequest(stream)) {
stream.on("complete", onfinish);
stream.on("abort", onclose);
if (stream.req)
onrequest();
else
stream.on("request", onrequest);
} else if (writable && !ws) {
stream.on("end", onlegacyfinish);
stream.on("close", onlegacyfinish);
}
if (isChildProcess(stream))
stream.on("exit", onexit);
stream.on("end", onend);
stream.on("finish", onfinish);
if (opts.error !== false)
stream.on("error", onerror);
stream.on("close", onclose);
return function() {
stream.removeListener("complete", onfinish);
stream.removeListener("abort", onclose);
stream.removeListener("request", onrequest);
if (stream.req)
stream.req.removeListener("finish", onfinish);
stream.removeListener("end", onlegacyfinish);
stream.removeListener("close", onlegacyfinish);
stream.removeListener("finish", onfinish);
stream.removeListener("exit", onexit);
stream.removeListener("end", onend);
stream.removeListener("error", onerror);
stream.removeListener("close", onclose);
};
};
module2.exports = eos;
}
});
// ../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js
var require_pump = __commonJS({
"../../node_modules/.pnpm/pump@3.0.2/node_modules/pump/index.js"(exports, module2) {
var once = require_once();
var eos = require_end_of_stream();
var fs;
try {
fs = require("fs");
} catch (e) {
}
var noop = function() {
};
var ancient = /^v?\.0/.test(process.version);
var isFn = function(fn) {
return typeof fn === "function";
};
var isFS = function(stream) {
if (!ancient)
return false;
if (!fs)
return false;
return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close);
};
var isRequest = function(stream) {
return stream.setHeader && isFn(stream.abort);
};
var destroyer = function(stream, reading, writing, callback) {
callback = once(callback);
var closed = false;
stream.on("close", function() {
closed = true;
});
eos(stream, { readable: reading, writable: writing }, function(err) {
if (err)
return callback(err);
closed = true;
callback();
});
var destroyed = false;
return function(err) {
if (closed)
return;
if (destroyed)
return;
destroyed = true;
if (isFS(stream))
return stream.close(noop);
if (isRequest(stream))
return stream.abort();
if (isFn(stream.destroy))
return stream.destroy();
callback(err || new Error("stream was destroyed"));
};
};
var call = function(fn) {
fn();
};
var pipe = function(from, to) {
return from.pipe(to);
};
var pump = function() {
var streams = Array.prototype.slice.call(arguments);
var callback = isFn(streams[streams.length - 1] || noop) && streams.pop() || noop;
if (Array.isArray(streams[0]))
streams = streams[0];
if (streams.length < 2)
throw new Error("pump requires two streams per minimum");
var error;
var destroys = streams.map(function(stream, i) {
var reading = i < streams.length - 1;
var writing = i > 0;
return destroyer(stream, reading, writing, function(err) {
if (!error)
error = err;
if (err)
destroys.forEach(call);
if (reading)
return;
destroys.forEach(call);
callback(error);
});
});
return streams.reduce(pipe);
};
module2.exports = pump;
}
});
// ../../node_modules/.pnpm/get-stream@5.2.0/node_modules/get-stream/buffer-stream.js
var require_buffer_stream = __commonJS({
"../../node_modules/.pnpm/get-stream@5.2.0/node_modules/get-stream/buffer-stream.js"(exports, module2) {
"use strict";
var { PassThrough: PassThroughStream } = require("stream");
module2.exports = (options) => {
options = { ...options };
const { array } = options;
let { encoding } = options;
const isBuffer = encoding === "buffer";
let objectMode = false;
if (array) {
objectMode = !(encoding || isBuffer);
} else {
encoding = encoding || "utf8";
}
if (isBuffer) {
encoding = null;
}
const stream = new PassThroughStream({ objectMode });
if (encoding) {
stream.setEncoding(encoding);
}
let length = 0;
const chunks = [];
stream.on("data", (chunk) => {
chunks.push(chunk);
if (objectMode) {
length = chunks.length;
} else {
length += chunk.length;
}
});
stream.getBufferedValue = () => {
if (array) {
return chunks;
}
return isBuffer ? Buffer.concat(chunks, length) : chunks.join("");
};
stream.getBufferedLength = () => length;
return stream;
};
}
});
// ../../node_modules/.pnpm/get-stream@5.2.0/node_modules/get-stream/index.js
var require_get_stream = __commonJS({
"../../node_modules/.pnpm/get-stream@5.2.0/node_modules/get-stream/index.js"(exports, module2) {
"use strict";
var { constants: BufferConstants } = require("buffer");
var pump = require_pump();
var bufferStream = require_buffer_stream();
var MaxBufferError = class extends Error {
constructor() {
super("maxBuffer exceeded");
this.name = "MaxBufferError";
}
};
async function getStream(inputStream, options) {
if (!inputStream) {
return Promise.reject(new Error("Expected a stream"));
}
options = {
maxBuffer: Infinity,
...options
};
const { maxBuffer } = options;
let stream;
await new Promise((resolve, reject) => {
const rejectPromise = (error) => {
if (error && stream.getBufferedLength() <= BufferConstants.MAX_LENGTH) {
error.bufferedData = stream.getBufferedValue();
}
reject(error);
};
stream = pump(inputStream, bufferStream(options), (error) => {
if (error) {
rejectPromise(error);
return;
}
resolve();
});
stream.on("data", () => {
if (stream.getBufferedLength() > maxBuffer) {
rejectPromise(new MaxBufferError());
}
});
});
return stream.getBufferedValue();
}
module2.exports = getStream;
module2.exports.default = getStream;
module2.exports.buffer = (stream, options) => getStream(stream, { ...options, encoding: "buffer" });
module2.exports.array = (stream, options) => getStream(stream, { ...options, array: true });
module2.exports.MaxBufferError = MaxBufferError;
}
});
// ../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js
var require_merge_stream = __commonJS({
"../../node_modules/.pnpm/merge-stream@2.0.0/node_modules/merge-stream/index.js"(exports, module2) {
"use strict";
var { PassThrough } = require("stream");
module2.exports = function() {
var sources = [];
var output = new PassThrough({ objectMode: true });
output.setMaxListeners(0);
output.add = add;
output.isEmpty = isEmpty;
output.on("unpipe", remove2);
Array.prototype.slice.call(arguments).forEach(add);
return output;
function add(source) {
if (Array.isArray(source)) {
source.forEach(add);
return this;
}
sources.push(source);
source.once("end", remove2.bind(null, source));
source.once("error", output.emit.bind(output, "error"));
source.pipe(output, { end: false });
return this;
}
function isEmpty() {
return sources.length == 0;
}
function remove2(source) {
sources = sources.filter(function(it) {
return it !== source;
});
if (!sources.length && output.readable) {
output.end();
}
}
};
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/stream.js
var require_stream = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/stream.js"(exports, module2) {
"use strict";
var isStream = require_is_stream();
var getStream = require_get_stream();
var mergeStream = require_merge_stream();
var handleInput = (spawned, input) => {
if (input === void 0 || spawned.stdin === void 0) {
return;
}
if (isStream(input)) {
input.pipe(spawned.stdin);
} else {
spawned.stdin.end(input);
}
};
var makeAllStream = (spawned) => {
if (!spawned.stdout && !spawned.stderr) {
return;
}
const mixed = mergeStream();
if (spawned.stdout) {
mixed.add(spawned.stdout);
}
if (spawned.stderr) {
mixed.add(spawned.stderr);
}
return mixed;
};
var getBufferedData = async (stream, streamPromise) => {
if (!stream) {
return;
}
stream.destroy();
try {
return await streamPromise;
} catch (error) {
return error.bufferedData;
}
};
var getStreamPromise = (stream, { encoding, buffer, maxBuffer }) => {
if (!stream) {
return;
}
if (!buffer) {
return new Promise((resolve, reject) => {
stream.once("end", resolve).once("error", reject);
});
}
if (encoding) {
return getStream(stream, { encoding, maxBuffer });
}
return getStream.buffer(stream, { maxBuffer });
};
var getSpawnedResult = async ({ stdout, stderr, all }, { encoding, buffer, maxBuffer }, processDone) => {
const stdoutPromise = getStreamPromise(stdout, { encoding, buffer, maxBuffer });
const stderrPromise = getStreamPromise(stderr, { encoding, buffer, maxBuffer });
const allPromise = getStreamPromise(all, { encoding, buffer, maxBuffer: maxBuffer * 2 });
try {
return await Promise.all([processDone, stdoutPromise, stderrPromise, allPromise]);
} catch (error) {
return Promise.all([
{ error, code: error.code, signal: error.signal, timedOut: error.timedOut },
getBufferedData(stdout, stdoutPromise),
getBufferedData(stderr, stderrPromise),
getBufferedData(all, allPromise)
]);
}
};
var validateInputSync = ({ input }) => {
if (isStream(input)) {
throw new TypeError("The `input` option cannot be a stream in sync mode");
}
};
module2.exports = {
handleInput,
makeAllStream,
getSpawnedResult,
validateInputSync
};
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/promise.js
var require_promise = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/promise.js"(exports, module2) {
"use strict";
var mergePromiseProperty = (spawned, promise, property) => {
const value = typeof promise === "function" ? (...args) => promise()[property](...args) : promise[property].bind(promise);
Object.defineProperty(spawned, property, {
value,
writable: true,
enumerable: false,
configurable: true
});
};
var mergePromise = (spawned, promise) => {
mergePromiseProperty(spawned, promise, "then");
mergePromiseProperty(spawned, promise, "catch");
if (Promise.prototype.finally) {
mergePromiseProperty(spawned, promise, "finally");
}
return spawned;
};
var getSpawnedPromise = (spawned) => {
return new Promise((resolve, reject) => {
spawned.on("exit", (code, signal) => {
resolve({ code, signal });
});
spawned.on("error", (error) => {
reject(error);
});
if (spawned.stdin) {
spawned.stdin.on("error", (error) => {
reject(error);
});
}
});
};
module2.exports = {
mergePromise,
getSpawnedPromise
};
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/command.js
var require_command = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/lib/command.js"(exports, module2) {
"use strict";
var SPACES_REGEXP = / +/g;
var joinCommand = (file, args = []) => {
if (!Array.isArray(args)) {
return file;
}
return [file, ...args].join(" ");
};
var handleEscaping = (tokens, token, index) => {
if (index === 0) {
return [token];
}
const previousToken = tokens[tokens.length - 1];
if (previousToken.endsWith("\\")) {
return [...tokens.slice(0, -1), `${previousToken.slice(0, -1)} ${token}`];
}
return [...tokens, token];
};
var parseCommand = (command) => {
return command.trim().split(SPACES_REGEXP).reduce(handleEscaping, []);
};
module2.exports = {
joinCommand,
parseCommand
};
}
});
// ../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/index.js
var require_execa = __commonJS({
"../../node_modules/.pnpm/execa@2.0.4/node_modules/execa/index.js"(exports, module2) {
"use strict";
var path = require("path");
var childProcess = require("child_process");
var crossSpawn = require_cross_spawn();
var stripFinalNewline = require_strip_final_newline();
var npmRunPath = require_npm_run_path();
var onetime = require_onetime();
var makeError = require_error();
var normalizeStdio = require_stdio();
var { spawnedKill, spawnedCancel, setupTimeout, setExitHandler } = require_kill();
var { handleInput, getSpawnedResult, makeAllStream, validateInputSync } = require_stream();
var { mergePromise, getSpawnedPromise } = require_promise();
var { joinCommand, parseCommand } = require_command();
var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
var getEnv = ({ env: envOption, extendEnv, preferLocal, localDir }) => {
const env = extendEnv ? { ...process.env, ...envOption } : envOption;
if (preferLocal) {
return npmRunPath.env({ env, cwd: localDir });
}
return env;
};
var handleArgs = (file, args, options = {}) => {
const parsed = crossSpawn._parse(file, args, options);
file = parsed.command;
args = parsed.args;
options = parsed.options;
options = {
maxBuffer: DEFAULT_MAX_BUFFER,
buffer: true,
stripFinalNewline: true,
extendEnv: true,
preferLocal: false,
localDir: options.cwd || process.cwd(),
encoding: "utf8",
reject: true,
cleanup: true,
...options,
windowsHide: true
};
options.env = getEnv(options);
options.stdio = normalizeStdio(options);
if (process.platform === "win32" && path.basename(file, ".exe") === "cmd") {
args.unshift("/q");
}
return { file, args, options, parsed };
};
var handleOutput = (options, value, error) => {
if (typeof value !== "string" && !Buffer.isBuffer(value)) {
return error === void 0 ? void 0 : "";
}
if (options.stripFinalNewline) {
return stripFinalNewline(value);
}
return value;
};
var execa3 = (file, args, options) => {
const parsed = handleArgs(file, args, options);
const command = joinCommand(file, args);
let spawned;
try {
spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);
} catch (error) {
const dummySpawned = new childProcess.ChildProcess();
const errorPromise = Promise.reject(makeError({
error,
stdout: "",
stderr: "",
all: "",
command,
parsed,
timedOut: false,
isCanceled: false,
killed: false
}));
return mergePromise(dummySpawned, errorPromise);
}
const spawnedPromise = getSpawnedPromise(spawned);
const timedPromise = setupTimeout(spawned, parsed.options, spawnedPromise);
const processDone = setExitHandler(spawned, parsed.options, timedPromise);
const context = { isCanceled: false };
spawned.kill = spawnedKill.bind(null, spawned.kill.bind(spawned));
spawned.cancel = spawnedCancel.bind(null, spawned, context);
const handlePromise = async () => {
const [{ error, code, signal, timedOut }, stdoutResult, stderrResult, allResult] = await getSpawnedResult(spawned, parsed.options, processDone);
const stdout = handleOutput(parsed.options, stdoutResult);
const stderr = handleOutput(parsed.options, stderrResult);
const all = handleOutput(parsed.options, allResult);
if (error || code !== 0 || signal !== null) {
const returnedError = makeError({
error,
code,
signal,
stdout,
stderr,
all,
command,
parsed,
timedOut,
isCanceled: context.isCanceled,
killed: spawned.killed
});
if (!parsed.options.reject) {
return returnedError;
}
throw returnedError;
}
return {
command,
exitCode: 0,
exitCodeName: "SUCCESS",
stdout,
stderr,
all,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
};
};
const handlePromiseOnce = onetime(handlePromise);
crossSpawn._enoent.hookChildProcess(spawned, parsed.parsed);
handleInput(spawned, parsed.options.input);
spawned.all = makeAllStream(spawned);
return mergePromise(spawned, handlePromiseOnce);
};
module2.exports = execa3;
module2.exports.sync = (file, args, options) => {
const parsed = handleArgs(file, args, options);
const command = joinCommand(file, args);
validateInputSync(parsed.options);
let result;
try {
result = childProcess.spawnSync(parsed.file, parsed.args, parsed.options);
} catch (error) {
throw makeError({
error,
stdout: "",
stderr: "",
all: "",
command,
parsed,
timedOut: false,
isCanceled: false,
killed: false
});
}
result.stdout = handleOutput(parsed.options, result.stdout, result.error);
result.stderr = handleOutput(parsed.options, result.stderr, result.error);
if (result.error || result.status !== 0 || result.signal !== null) {
const error = makeError({
...result,
code: result.status,
command,
parsed,
timedOut: result.error && result.error.errno === "ETIMEDOUT",
isCanceled: false,
killed: result.signal !== null
});
if (!parsed.options.reject) {
return error;
}
throw error;
}
return {
command,
exitCode: 0,
exitCodeName: "SUCCESS",
stdout: result.stdout,
stderr: result.stderr,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
};
};
module2.exports.command = (command, options) => {
const [file, ...args] = parseCommand(command);
return execa3(file, args, options);
};
module2.exports.commandSync = (command, options) => {
const [file, ...args] = parseCommand(command);
return execa3.sync(file, args, options);
};
module2.exports.node = (scriptPath, args, options = {}) => {
if (args && !Array.isArray(args) && typeof args === "object") {
options = args;
args = [];
}
const stdio = normalizeStdio.node(options);
const { nodePath = process.execPath, nodeOptions = process.execArgv } = options;
return execa3(
nodePath,
[
...nodeOptions,
scriptPath,
...Array.isArray(args) ? args : []
],
{
...options,
stdin: void 0,
stdout: void 0,
stderr: void 0,
stdio,
shell: false
}
);
};
}
});
// ../../node_modules/.pnpm/universalify@0.1.2/node_modules/universalify/index.js
var require_universalify = __commonJS({
"../../node_modules/.pnpm/universalify@0.1.2/node_modules/universalify/index.js"(exports) {
"use strict";
exports.fromCallback = function(fn) {
return Object.defineProperty(function() {
if (typeof arguments[arguments.length - 1] === "function")
fn.apply(this, arguments);
else {
return new Promise((resolve, reject) => {
arguments[arguments.length] = (err, res) => {
if (err)
return reject(err);
resolve(res);
};
arguments.length++;
fn.apply(this, arguments);
});
}
}, "name", { value: fn.name });
};
exports.fromPromise = function(fn) {
return Object.defineProperty(function() {
const cb = arguments[arguments.length - 1];
if (typeof cb !== "function")
return fn.apply(this, arguments);
else
fn.apply(this, arguments).then((r) => cb(null, r), cb);
}, "name", { value: fn.name });
};
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
var require_polyfills = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports, module2) {
var constants = require("constants");
var origCwd = process.cwd;
var cwd = null;
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
process.cwd = function() {
if (!cwd)
cwd = origCwd.call(process);
return cwd;
};
try {
process.cwd();
} catch (er) {
}
if (typeof process.chdir === "function") {
chdir = process.chdir;
process.chdir = function(d) {
cwd = null;
chdir.call(process, d);
};
if (Object.setPrototypeOf)
Object.setPrototypeOf(process.chdir, chdir);
}
var chdir;
module2.exports = patch;
function patch(fs) {
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
patchLchmod(fs);
}
if (!fs.lutimes) {
patchLutimes(fs);
}
fs.chown = chownFix(fs.chown);
fs.fchown = chownFix(fs.fchown);
fs.lchown = chownFix(fs.lchown);
fs.chmod = chmodFix(fs.chmod);
fs.fchmod = chmodFix(fs.fchmod);
fs.lchmod = chmodFix(fs.lchmod);
fs.chownSync = chownFixSync(fs.chownSync);
fs.fchownSync = chownFixSync(fs.fchownSync);
fs.lchownSync = chownFixSync(fs.lchownSync);
fs.chmodSync = chmodFixSync(fs.chmodSync);
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
fs.stat = statFix(fs.stat);
fs.fstat = statFix(fs.fstat);
fs.lstat = statFix(fs.lstat);
fs.statSync = statFixSync(fs.statSync);
fs.fstatSync = statFixSync(fs.fstatSync);
fs.lstatSync = statFixSync(fs.lstatSync);
if (fs.chmod && !fs.lchmod) {
fs.lchmod = function(path, mode, cb) {
if (cb)
process.nextTick(cb);
};
fs.lchmodSync = function() {
};
}
if (fs.chown && !fs.lchown) {
fs.lchown = function(path, uid, gid, cb) {
if (cb)
process.nextTick(cb);
};
fs.lchownSync = function() {
};
}
if (platform === "win32") {
fs.rename = typeof fs.rename !== "function" ? fs.rename : function(fs$rename) {
function rename(from, to, cb) {
var start = Date.now();
var backoff = 0;
fs$rename(from, to, function CB(er) {
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
setTimeout(function() {
fs.stat(to, function(stater, st) {
if (stater && stater.code === "ENOENT")
fs$rename(from, to, CB);
else
cb(er);
});
}, backoff);
if (backoff < 100)
backoff += 10;
return;
}
if (cb)
cb(er);
});
}
if (Object.setPrototypeOf)
Object.setPrototypeOf(rename, fs$rename);
return rename;
}(fs.rename);
}
fs.read = typeof fs.read !== "function" ? fs.read : function(fs$read) {
function read(fd, buffer, offset, length, position, callback_) {
var callback;
if (callback_ && typeof callback_ === "function") {
var eagCounter = 0;
callback = function(er, _, __) {
if (er && er.code === "EAGAIN" && eagCounter < 10) {
eagCounter++;
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
}
callback_.apply(this, arguments);
};
}
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
}
if (Object.setPrototypeOf)
Object.setPrototypeOf(read, fs$read);
return read;
}(fs.read);
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : function(fs$readSync) {
return function(fd, buffer, offset, length, position) {
var eagCounter = 0;
while (true) {
try {
return fs$readSync.call(fs, fd, buffer, offset, length, position);
} catch (er) {
if (er.code === "EAGAIN" && eagCounter < 10) {
eagCounter++;
continue;
}
throw er;
}
}
};
}(fs.readSync);
function patchLchmod(fs2) {
fs2.lchmod = function(path, mode, callback) {
fs2.open(
path,
constants.O_WRONLY | constants.O_SYMLINK,
mode,
function(err, fd) {
if (err) {
if (callback)
callback(err);
return;
}
fs2.fchmod(fd, mode, function(err2) {
fs2.close(fd, function(err22) {
if (callback)
callback(err2 || err22);
});
});
}
);
};
fs2.lchmodSync = function(path, mode) {
var fd = fs2.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
var threw = true;
var ret;
try {
ret = fs2.fchmodSync(fd, mode);
threw = false;
} finally {
if (threw) {
try {
fs2.closeSync(fd);
} catch (er) {
}
} else {
fs2.closeSync(fd);
}
}
return ret;
};
}
function patchLutimes(fs2) {
if (constants.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
fs2.lutimes = function(path, at, mt, cb) {
fs2.open(path, constants.O_SYMLINK, function(er, fd) {
if (er) {
if (cb)
cb(er);
return;
}
fs2.futimes(fd, at, mt, function(er2) {
fs2.close(fd, function(er22) {
if (cb)
cb(er2 || er22);
});
});
});
};
fs2.lutimesSync = function(path, at, mt) {
var fd = fs2.openSync(path, constants.O_SYMLINK);
var ret;
var threw = true;
try {
ret = fs2.futimesSync(fd, at, mt);
threw = false;
} finally {
if (threw) {
try {
fs2.closeSync(fd);
} catch (er) {
}
} else {
fs2.closeSync(fd);
}
}
return ret;
};
} else if (fs2.futimes) {
fs2.lutimes = function(_a, _b, _c, cb) {
if (cb)
process.nextTick(cb);
};
fs2.lutimesSync = function() {
};
}
}
function chmodFix(orig) {
if (!orig)
return orig;
return function(target, mode, cb) {
return orig.call(fs, target, mode, function(er) {
if (chownErOk(er))
er = null;
if (cb)
cb.apply(this, arguments);
});
};
}
function chmodFixSync(orig) {
if (!orig)
return orig;
return function(target, mode) {
try {
return orig.call(fs, target, mode);
} catch (er) {
if (!chownErOk(er))
throw er;
}
};
}
function chownFix(orig) {
if (!orig)
return orig;
return function(target, uid, gid, cb) {
return orig.call(fs, target, uid, gid, function(er) {
if (chownErOk(er))
er = null;
if (cb)
cb.apply(this, arguments);
});
};
}
function chownFixSync(orig) {
if (!orig)
return orig;
return function(target, uid, gid) {
try {
return orig.call(fs, target, uid, gid);
} catch (er) {
if (!chownErOk(er))
throw er;
}
};
}
function statFix(orig) {
if (!orig)
return orig;
return function(target, options, cb) {
if (typeof options === "function") {
cb = options;
options = null;
}
function callback(er, stats) {
if (stats) {
if (stats.uid < 0)
stats.uid += 4294967296;
if (stats.gid < 0)
stats.gid += 4294967296;
}
if (cb)
cb.apply(this, arguments);
}
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
};
}
function statFixSync(orig) {
if (!orig)
return orig;
return function(target, options) {
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
if (stats) {
if (stats.uid < 0)
stats.uid += 4294967296;
if (stats.gid < 0)
stats.gid += 4294967296;
}
return stats;
};
}
function chownErOk(er) {
if (!er)
return true;
if (er.code === "ENOSYS")
return true;
var nonroot = !process.getuid || process.getuid() !== 0;
if (nonroot) {
if (er.code === "EINVAL" || er.code === "EPERM")
return true;
}
return false;
}
}
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
var require_legacy_streams = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
var Stream = require("stream").Stream;
module2.exports = legacy;
function legacy(fs) {
return {
ReadStream,
WriteStream
};
function ReadStream(path, options) {
if (!(this instanceof ReadStream))
return new ReadStream(path, options);
Stream.call(this);
var self = this;
this.path = path;
this.fd = null;
this.readable = true;
this.paused = false;
this.flags = "r";
this.mode = 438;
this.bufferSize = 64 * 1024;
options = options || {};
var keys = Object.keys(options);
for (var index = 0, length = keys.length; index < length; index++) {
var key = keys[index];
this[key] = options[key];
}
if (this.encoding)
this.setEncoding(this.encoding);
if (this.start !== void 0) {
if ("number" !== typeof this.start) {
throw TypeError("start must be a Number");
}
if (this.end === void 0) {
this.end = Infinity;
} else if ("number" !== typeof this.end) {
throw TypeError("end must be a Number");
}
if (this.start > this.end) {
throw new Error("start must be <= end");
}
this.pos = this.start;
}
if (this.fd !== null) {
process.nextTick(function() {
self._read();
});
return;
}
fs.open(this.path, this.flags, this.mode, function(err, fd) {
if (err) {
self.emit("error", err);
self.readable = false;
return;
}
self.fd = fd;
self.emit("open", fd);
self._read();
});
}
function WriteStream(path, options) {
if (!(this instanceof WriteStream))
return new WriteStream(path, options);
Stream.call(this);
this.path = path;
this.fd = null;
this.writable = true;
this.flags = "w";
this.encoding = "binary";
this.mode = 438;
this.bytesWritten = 0;
options = options || {};
var keys = Object.keys(options);
for (var index = 0, length = keys.length; index < length; index++) {
var key = keys[index];
this[key] = options[key];
}
if (this.start !== void 0) {
if ("number" !== typeof this.start) {
throw TypeError("start must be a Number");
}
if (this.start < 0) {
throw new Error("start must be >= zero");
}
this.pos = this.start;
}
this.busy = false;
this._queue = [];
if (this.fd === null) {
this._open = fs.open;
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
this.flush();
}
}
}
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
var require_clone = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js"(exports, module2) {
"use strict";
module2.exports = clone;
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
return obj.__proto__;
};
function clone(obj) {
if (obj === null || typeof obj !== "object")
return obj;
if (obj instanceof Object)
var copy = { __proto__: getPrototypeOf(obj) };
else
var copy = /* @__PURE__ */ Object.create(null);
Object.getOwnPropertyNames(obj).forEach(function(key) {
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
});
return copy;
}
}
});
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
var require_graceful_fs = __commonJS({
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
var fs = require("fs");
var polyfills = require_polyfills();
var legacy = require_legacy_streams();
var clone = require_clone();
var util = require("util");
var gracefulQueue;
var previousSymbol;
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
gracefulQueue = Symbol.for("graceful-fs.queue");
previousSymbol = Symbol.for("graceful-fs.previous");
} else {
gracefulQueue = "___graceful-fs.queue";
previousSymbol = "___graceful-fs.previous";
}
function noop() {
}
function publishQueue(context, queue2) {
Object.defineProperty(context, gracefulQueue, {
get: function() {
return queue2;
}
});
}
var debug4 = noop;
if (util.debuglog)
debug4 = util.debuglog("gfs4");
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
debug4 = function() {
var m = util.format.apply(util, arguments);
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
console.error(m);
};
if (!fs[gracefulQueue]) {
queue = global[gracefulQueue] || [];
publishQueue(fs, queue);
fs.close = function(fs$close) {
function close(fd, cb) {
return fs$close.call(fs, fd, function(err) {
if (!err) {
resetQueue();
}
if (typeof cb === "function")
cb.apply(this, arguments);
});
}
Object.defineProperty(close, previousSymbol, {
value: fs$close
});
return close;
}(fs.close);
fs.closeSync = function(fs$closeSync) {
function closeSync(fd) {
fs$closeSync.apply(fs, arguments);
resetQueue();
}
Object.defineProperty(closeSync, previousSymbol, {
value: fs$closeSync
});
return closeSync;
}(fs.closeSync);
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
process.on("exit", function() {
debug4(fs[gracefulQueue]);
require("assert").equal(fs[gracefulQueue].length, 0);
});
}
}
var queue;
if (!global[gracefulQueue]) {
publishQueue(global, fs[gracefulQueue]);
}
module2.exports = patch(clone(fs));
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
module2.exports = patch(fs);
fs.__patched = true;
}
function patch(fs2) {
polyfills(fs2);
fs2.gracefulify = patch;
fs2.createReadStream = createReadStream;
fs2.createWriteStream = createWriteStream;
var fs$readFile = fs2.readFile;
fs2.readFile = readFile2;
function readFile2(path, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$readFile(path, options, cb);
function go$readFile(path2, options2, cb2, startTime) {
return fs$readFile(path2, options2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$readFile, [path2, options2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$writeFile = fs2.writeFile;
fs2.writeFile = writeFile2;
function writeFile2(path, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$writeFile(path, data, options, cb);
function go$writeFile(path2, data2, options2, cb2, startTime) {
return fs$writeFile(path2, data2, options2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$writeFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$appendFile = fs2.appendFile;
if (fs$appendFile)
fs2.appendFile = appendFile;
function appendFile(path, data, options, cb) {
if (typeof options === "function")
cb = options, options = null;
return go$appendFile(path, data, options, cb);
function go$appendFile(path2, data2, options2, cb2, startTime) {
return fs$appendFile(path2, data2, options2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$appendFile, [path2, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$copyFile = fs2.copyFile;
if (fs$copyFile)
fs2.copyFile = copyFile;
function copyFile(src, dest, flags, cb) {
if (typeof flags === "function") {
cb = flags;
flags = 0;
}
return go$copyFile(src, dest, flags, cb);
function go$copyFile(src2, dest2, flags2, cb2, startTime) {
return fs$copyFile(src2, dest2, flags2, function(err) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
var fs$readdir = fs2.readdir;
fs2.readdir = readdir;
var noReaddirOptionVersions = /^v[0-5]\./;
function readdir(path, options, cb) {
if (typeof options === "function")
cb = options, options = null;
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
return fs$readdir(path2, fs$readdirCallback(
path2,
options2,
cb2,
startTime
));
} : function go$readdir2(path2, options2, cb2, startTime) {
return fs$readdir(path2, options2, fs$readdirCallback(
path2,
options2,
cb2,
startTime
));
};
return go$readdir(path, options, cb);
function fs$readdirCallback(path2, options2, cb2, startTime) {
return function(err, files) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([
go$readdir,
[path2, options2, cb2],
err,
startTime || Date.now(),
Date.now()
]);
else {
if (files && files.sort)
files.sort();
if (typeof cb2 === "function")
cb2.call(this, err, files);
}
};
}
}
if (process.version.substr(0, 4) === "v0.8") {
var legStreams = legacy(fs2);
ReadStream = legStreams.ReadStream;
WriteStream = legStreams.WriteStream;
}
var fs$ReadStream = fs2.ReadStream;
if (fs$ReadStream) {
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
ReadStream.prototype.open = ReadStream$open;
}
var fs$WriteStream = fs2.WriteStream;
if (fs$WriteStream) {
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
WriteStream.prototype.open = WriteStream$open;
}
Object.defineProperty(fs2, "ReadStream", {
get: function() {
return ReadStream;
},
set: function(val) {
ReadStream = val;
},
enumerable: true,
configurable: true
});
Object.defineProperty(fs2, "WriteStream", {
get: function() {
return WriteStream;
},
set: function(val) {
WriteStream = val;
},
enumerable: true,
configurable: true
});
var FileReadStream = ReadStream;
Object.defineProperty(fs2, "FileReadStream", {
get: function() {
return FileReadStream;
},
set: function(val) {
FileReadStream = val;
},
enumerable: true,
configurable: true
});
var FileWriteStream = WriteStream;
Object.defineProperty(fs2, "FileWriteStream", {
get: function() {
return FileWriteStream;
},
set: function(val) {
FileWriteStream = val;
},
enumerable: true,
configurable: true
});
function ReadStream(path, options) {
if (this instanceof ReadStream)
return fs$ReadStream.apply(this, arguments), this;
else
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
}
function ReadStream$open() {
var that = this;
open(that.path, that.flags, that.mode, function(err, fd) {
if (err) {
if (that.autoClose)
that.destroy();
that.emit("error", err);
} else {
that.fd = fd;
that.emit("open", fd);
that.read();
}
});
}
function WriteStream(path, options) {
if (this instanceof WriteStream)
return fs$WriteStream.apply(this, arguments), this;
else
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
}
function WriteStream$open() {
var that = this;
open(that.path, that.flags, that.mode, function(err, fd) {
if (err) {
that.destroy();
that.emit("error", err);
} else {
that.fd = fd;
that.emit("open", fd);
}
});
}
function createReadStream(path, options) {
return new fs2.ReadStream(path, options);
}
function createWriteStream(path, options) {
return new fs2.WriteStream(path, options);
}
var fs$open = fs2.open;
fs2.open = open;
function open(path, flags, mode, cb) {
if (typeof mode === "function")
cb = mode, mode = null;
return go$open(path, flags, mode, cb);
function go$open(path2, flags2, mode2, cb2, startTime) {
return fs$open(path2, flags2, mode2, function(err, fd) {
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
enqueue([go$open, [path2, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
else {
if (typeof cb2 === "function")
cb2.apply(this, arguments);
}
});
}
}
return fs2;
}
function enqueue(elem) {
debug4("ENQUEUE", elem[0].name, elem[1]);
fs[gracefulQueue].push(elem);
retry();
}
var retryTimer;
function resetQueue() {
var now = Date.now();
for (var i = 0; i < fs[gracefulQueue].length; ++i) {
if (fs[gracefulQueue][i].length > 2) {
fs[gracefulQueue][i][3] = now;
fs[gracefulQueue][i][4] = now;
}
}
retry();
}
function retry() {
clearTimeout(retryTimer);
retryTimer = void 0;
if (fs[gracefulQueue].length === 0)
return;
var elem = fs[gracefulQueue].shift();
var fn = elem[0];
var args = elem[1];
var err = elem[2];
var startTime = elem[3];
var lastTime = elem[4];
if (startTime === void 0) {
debug4("RETRY", fn.name, args);
fn.apply(null, args);
} else if (Date.now() - startTime >= 6e4) {
debug4("TIMEOUT", fn.name, args);
var cb = args.pop();
if (typeof cb === "function")
cb.call(null, err);
} else {
var sinceAttempt = Date.now() - lastTime;
var sinceStart = Math.max(lastTime - startTime, 1);
var desiredDelay = Math.min(sinceStart * 1.2, 100);
if (sinceAttempt >= desiredDelay) {
debug4("RETRY", fn.name, args);
fn.apply(null, args.concat([startTime]));
} else {
fs[gracefulQueue].push(elem);
}
}
if (retryTimer === void 0) {
retryTimer = setTimeout(retry, 0);
}
}
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/fs/index.js
var require_fs = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/fs/index.js"(exports) {
"use strict";
var u = require_universalify().fromCallback;
var fs = require_graceful_fs();
var api = [
"access",
"appendFile",
"chmod",
"chown",
"close",
"copyFile",
"fchmod",
"fchown",
"fdatasync",
"fstat",
"fsync",
"ftruncate",
"futimes",
"lchown",
"lchmod",
"link",
"lstat",
"mkdir",
"mkdtemp",
"open",
"readFile",
"readdir",
"readlink",
"realpath",
"rename",
"rmdir",
"stat",
"symlink",
"truncate",
"unlink",
"utimes",
"writeFile"
].filter((key) => {
return typeof fs[key] === "function";
});
Object.keys(fs).forEach((key) => {
if (key === "promises") {
return;
}
exports[key] = fs[key];
});
api.forEach((method) => {
exports[method] = u(fs[method]);
});
exports.exists = function(filename, callback) {
if (typeof callback === "function") {
return fs.exists(filename, callback);
}
return new Promise((resolve) => {
return fs.exists(filename, resolve);
});
};
exports.read = function(fd, buffer, offset, length, position, callback) {
if (typeof callback === "function") {
return fs.read(fd, buffer, offset, length, position, callback);
}
return new Promise((resolve, reject) => {
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
if (err)
return reject(err);
resolve({ bytesRead, buffer: buffer2 });
});
});
};
exports.write = function(fd, buffer, ...args) {
if (typeof args[args.length - 1] === "function") {
return fs.write(fd, buffer, ...args);
}
return new Promise((resolve, reject) => {
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
if (err)
return reject(err);
resolve({ bytesWritten, buffer: buffer2 });
});
});
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/win32.js
var require_win32 = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/win32.js"(exports, module2) {
"use strict";
var path = require("path");
function getRootPath(p) {
p = path.normalize(path.resolve(p)).split(path.sep);
if (p.length > 0)
return p[0];
return null;
}
var INVALID_PATH_CHARS = /[<>:"|?*]/;
function invalidWin32Path(p) {
const rp = getRootPath(p);
p = p.replace(rp, "");
return INVALID_PATH_CHARS.test(p);
}
module2.exports = {
getRootPath,
invalidWin32Path
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/mkdirs.js
var require_mkdirs = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/mkdirs.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var invalidWin32Path = require_win32().invalidWin32Path;
var o777 = parseInt("0777", 8);
function mkdirs(p, opts, callback, made) {
if (typeof opts === "function") {
callback = opts;
opts = {};
} else if (!opts || typeof opts !== "object") {
opts = { mode: opts };
}
if (process.platform === "win32" && invalidWin32Path(p)) {
const errInval = new Error(p + " contains invalid WIN32 path characters.");
errInval.code = "EINVAL";
return callback(errInval);
}
let mode = opts.mode;
const xfs = opts.fs || fs;
if (mode === void 0) {
mode = o777 & ~process.umask();
}
if (!made)
made = null;
callback = callback || function() {
};
p = path.resolve(p);
xfs.mkdir(p, mode, (er) => {
if (!er) {
made = made || p;
return callback(null, made);
}
switch (er.code) {
case "ENOENT":
if (path.dirname(p) === p)
return callback(er);
mkdirs(path.dirname(p), opts, (er2, made2) => {
if (er2)
callback(er2, made2);
else
mkdirs(p, opts, callback, made2);
});
break;
default:
xfs.stat(p, (er2, stat) => {
if (er2 || !stat.isDirectory())
callback(er, made);
else
callback(null, made);
});
break;
}
});
}
module2.exports = mkdirs;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js
var require_mkdirs_sync = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var invalidWin32Path = require_win32().invalidWin32Path;
var o777 = parseInt("0777", 8);
function mkdirsSync(p, opts, made) {
if (!opts || typeof opts !== "object") {
opts = { mode: opts };
}
let mode = opts.mode;
const xfs = opts.fs || fs;
if (process.platform === "win32" && invalidWin32Path(p)) {
const errInval = new Error(p + " contains invalid WIN32 path characters.");
errInval.code = "EINVAL";
throw errInval;
}
if (mode === void 0) {
mode = o777 & ~process.umask();
}
if (!made)
made = null;
p = path.resolve(p);
try {
xfs.mkdirSync(p, mode);
made = made || p;
} catch (err0) {
if (err0.code === "ENOENT") {
if (path.dirname(p) === p)
throw err0;
made = mkdirsSync(path.dirname(p), opts, made);
mkdirsSync(p, opts, made);
} else {
let stat;
try {
stat = xfs.statSync(p);
} catch (err1) {
throw err0;
}
if (!stat.isDirectory())
throw err0;
}
}
return made;
}
module2.exports = mkdirsSync;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/index.js
var require_mkdirs2 = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/mkdirs/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var mkdirs = u(require_mkdirs());
var mkdirsSync = require_mkdirs_sync();
module2.exports = {
mkdirs,
mkdirsSync,
// alias
mkdirp: mkdirs,
mkdirpSync: mkdirsSync,
ensureDir: mkdirs,
ensureDirSync: mkdirsSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/util/utimes.js
var require_utimes = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/util/utimes.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var os = require("os");
var path = require("path");
function hasMillisResSync() {
let tmpfile = path.join("millis-test-sync" + Date.now().toString() + Math.random().toString().slice(2));
tmpfile = path.join(os.tmpdir(), tmpfile);
const d = /* @__PURE__ */ new Date(1435410243862);
fs.writeFileSync(tmpfile, "https://github.com/jprichardson/node-fs-extra/pull/141");
const fd = fs.openSync(tmpfile, "r+");
fs.futimesSync(fd, d, d);
fs.closeSync(fd);
return fs.statSync(tmpfile).mtime > 1435410243e3;
}
function hasMillisRes(callback) {
let tmpfile = path.join("millis-test" + Date.now().toString() + Math.random().toString().slice(2));
tmpfile = path.join(os.tmpdir(), tmpfile);
const d = /* @__PURE__ */ new Date(1435410243862);
fs.writeFile(tmpfile, "https://github.com/jprichardson/node-fs-extra/pull/141", (err) => {
if (err)
return callback(err);
fs.open(tmpfile, "r+", (err2, fd) => {
if (err2)
return callback(err2);
fs.futimes(fd, d, d, (err3) => {
if (err3)
return callback(err3);
fs.close(fd, (err4) => {
if (err4)
return callback(err4);
fs.stat(tmpfile, (err5, stats) => {
if (err5)
return callback(err5);
callback(null, stats.mtime > 1435410243e3);
});
});
});
});
});
}
function timeRemoveMillis(timestamp) {
if (typeof timestamp === "number") {
return Math.floor(timestamp / 1e3) * 1e3;
} else if (timestamp instanceof Date) {
return new Date(Math.floor(timestamp.getTime() / 1e3) * 1e3);
} else {
throw new Error("fs-extra: timeRemoveMillis() unknown parameter type");
}
}
function utimesMillis(path2, atime, mtime, callback) {
fs.open(path2, "r+", (err, fd) => {
if (err)
return callback(err);
fs.futimes(fd, atime, mtime, (futimesErr) => {
fs.close(fd, (closeErr) => {
if (callback)
callback(futimesErr || closeErr);
});
});
});
}
function utimesMillisSync(path2, atime, mtime) {
const fd = fs.openSync(path2, "r+");
fs.futimesSync(fd, atime, mtime);
return fs.closeSync(fd);
}
module2.exports = {
hasMillisRes,
hasMillisResSync,
timeRemoveMillis,
utimesMillis,
utimesMillisSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/util/buffer.js
var require_buffer = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/util/buffer.js"(exports, module2) {
"use strict";
module2.exports = function(size) {
if (typeof Buffer.allocUnsafe === "function") {
try {
return Buffer.allocUnsafe(size);
} catch (e) {
return new Buffer(size);
}
}
return new Buffer(size);
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy-sync/copy-sync.js
var require_copy_sync = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy-sync/copy-sync.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var mkdirpSync = require_mkdirs2().mkdirsSync;
var utimesSync = require_utimes().utimesMillisSync;
var notExist = Symbol("notExist");
function copySync(src, dest, opts) {
if (typeof opts === "function") {
opts = { filter: opts };
}
opts = opts || {};
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
if (opts.preserveTimestamps && process.arch === "ia32") {
console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;
see https://github.com/jprichardson/node-fs-extra/issues/269`);
}
const destStat = checkPaths(src, dest);
if (opts.filter && !opts.filter(src, dest))
return;
const destParent = path.dirname(dest);
if (!fs.existsSync(destParent))
mkdirpSync(destParent);
return startCopy(destStat, src, dest, opts);
}
function startCopy(destStat, src, dest, opts) {
if (opts.filter && !opts.filter(src, dest))
return;
return getStats(destStat, src, dest, opts);
}
function getStats(destStat, src, dest, opts) {
const statSync = opts.dereference ? fs.statSync : fs.lstatSync;
const srcStat = statSync(src);
if (srcStat.isDirectory())
return onDir(srcStat, destStat, src, dest, opts);
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
return onFile(srcStat, destStat, src, dest, opts);
else if (srcStat.isSymbolicLink())
return onLink(destStat, src, dest, opts);
}
function onFile(srcStat, destStat, src, dest, opts) {
if (destStat === notExist)
return copyFile(srcStat, src, dest, opts);
return mayCopyFile(srcStat, src, dest, opts);
}
function mayCopyFile(srcStat, src, dest, opts) {
if (opts.overwrite) {
fs.unlinkSync(dest);
return copyFile(srcStat, src, dest, opts);
} else if (opts.errorOnExist) {
throw new Error(`'${dest}' already exists`);
}
}
function copyFile(srcStat, src, dest, opts) {
if (typeof fs.copyFileSync === "function") {
fs.copyFileSync(src, dest);
fs.chmodSync(dest, srcStat.mode);
if (opts.preserveTimestamps) {
return utimesSync(dest, srcStat.atime, srcStat.mtime);
}
return;
}
return copyFileFallback(srcStat, src, dest, opts);
}
function copyFileFallback(srcStat, src, dest, opts) {
const BUF_LENGTH = 64 * 1024;
const _buff = require_buffer()(BUF_LENGTH);
const fdr = fs.openSync(src, "r");
const fdw = fs.openSync(dest, "w", srcStat.mode);
let pos = 0;
while (pos < srcStat.size) {
const bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos);
fs.writeSync(fdw, _buff, 0, bytesRead);
pos += bytesRead;
}
if (opts.preserveTimestamps)
fs.futimesSync(fdw, srcStat.atime, srcStat.mtime);
fs.closeSync(fdr);
fs.closeSync(fdw);
}
function onDir(srcStat, destStat, src, dest, opts) {
if (destStat === notExist)
return mkDirAndCopy(srcStat, src, dest, opts);
if (destStat && !destStat.isDirectory()) {
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
}
return copyDir(src, dest, opts);
}
function mkDirAndCopy(srcStat, src, dest, opts) {
fs.mkdirSync(dest);
copyDir(src, dest, opts);
return fs.chmodSync(dest, srcStat.mode);
}
function copyDir(src, dest, opts) {
fs.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
}
function copyDirItem(item, src, dest, opts) {
const srcItem = path.join(src, item);
const destItem = path.join(dest, item);
const destStat = checkPaths(srcItem, destItem);
return startCopy(destStat, srcItem, destItem, opts);
}
function onLink(destStat, src, dest, opts) {
let resolvedSrc = fs.readlinkSync(src);
if (opts.dereference) {
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
}
if (destStat === notExist) {
return fs.symlinkSync(resolvedSrc, dest);
} else {
let resolvedDest;
try {
resolvedDest = fs.readlinkSync(dest);
} catch (err) {
if (err.code === "EINVAL" || err.code === "UNKNOWN")
return fs.symlinkSync(resolvedSrc, dest);
throw err;
}
if (opts.dereference) {
resolvedDest = path.resolve(process.cwd(), resolvedDest);
}
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
}
if (fs.statSync(dest).isDirectory() && isSrcSubdir(resolvedDest, resolvedSrc)) {
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
}
return copyLink(resolvedSrc, dest);
}
}
function copyLink(resolvedSrc, dest) {
fs.unlinkSync(dest);
return fs.symlinkSync(resolvedSrc, dest);
}
function isSrcSubdir(src, dest) {
const srcArray = path.resolve(src).split(path.sep);
const destArray = path.resolve(dest).split(path.sep);
return srcArray.reduce((acc, current, i) => acc && destArray[i] === current, true);
}
function checkStats(src, dest) {
const srcStat = fs.statSync(src);
let destStat;
try {
destStat = fs.statSync(dest);
} catch (err) {
if (err.code === "ENOENT")
return { srcStat, destStat: notExist };
throw err;
}
return { srcStat, destStat };
}
function checkPaths(src, dest) {
const { srcStat, destStat } = checkStats(src, dest);
if (destStat.ino && destStat.ino === srcStat.ino) {
throw new Error("Source and destination must not be the same.");
}
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
throw new Error(`Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`);
}
return destStat;
}
module2.exports = copySync;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy-sync/index.js
var require_copy_sync2 = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy-sync/index.js"(exports, module2) {
"use strict";
module2.exports = {
copySync: require_copy_sync()
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/path-exists/index.js
var require_path_exists = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/path-exists/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromPromise;
var fs = require_fs();
function pathExists2(path) {
return fs.access(path).then(() => true).catch(() => false);
}
module2.exports = {
pathExists: u(pathExists2),
pathExistsSync: fs.existsSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy/copy.js
var require_copy = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy/copy.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var mkdirp = require_mkdirs2().mkdirs;
var pathExists2 = require_path_exists().pathExists;
var utimes = require_utimes().utimesMillis;
var notExist = Symbol("notExist");
function copy(src, dest, opts, cb) {
if (typeof opts === "function" && !cb) {
cb = opts;
opts = {};
} else if (typeof opts === "function") {
opts = { filter: opts };
}
cb = cb || function() {
};
opts = opts || {};
opts.clobber = "clobber" in opts ? !!opts.clobber : true;
opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
if (opts.preserveTimestamps && process.arch === "ia32") {
console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;
see https://github.com/jprichardson/node-fs-extra/issues/269`);
}
checkPaths(src, dest, (err, destStat) => {
if (err)
return cb(err);
if (opts.filter)
return handleFilter(checkParentDir, destStat, src, dest, opts, cb);
return checkParentDir(destStat, src, dest, opts, cb);
});
}
function checkParentDir(destStat, src, dest, opts, cb) {
const destParent = path.dirname(dest);
pathExists2(destParent, (err, dirExists) => {
if (err)
return cb(err);
if (dirExists)
return startCopy(destStat, src, dest, opts, cb);
mkdirp(destParent, (err2) => {
if (err2)
return cb(err2);
return startCopy(destStat, src, dest, opts, cb);
});
});
}
function handleFilter(onInclude, destStat, src, dest, opts, cb) {
Promise.resolve(opts.filter(src, dest)).then((include) => {
if (include) {
if (destStat)
return onInclude(destStat, src, dest, opts, cb);
return onInclude(src, dest, opts, cb);
}
return cb();
}, (error) => cb(error));
}
function startCopy(destStat, src, dest, opts, cb) {
if (opts.filter)
return handleFilter(getStats, destStat, src, dest, opts, cb);
return getStats(destStat, src, dest, opts, cb);
}
function getStats(destStat, src, dest, opts, cb) {
const stat = opts.dereference ? fs.stat : fs.lstat;
stat(src, (err, srcStat) => {
if (err)
return cb(err);
if (srcStat.isDirectory())
return onDir(srcStat, destStat, src, dest, opts, cb);
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
return onFile(srcStat, destStat, src, dest, opts, cb);
else if (srcStat.isSymbolicLink())
return onLink(destStat, src, dest, opts, cb);
});
}
function onFile(srcStat, destStat, src, dest, opts, cb) {
if (destStat === notExist)
return copyFile(srcStat, src, dest, opts, cb);
return mayCopyFile(srcStat, src, dest, opts, cb);
}
function mayCopyFile(srcStat, src, dest, opts, cb) {
if (opts.overwrite) {
fs.unlink(dest, (err) => {
if (err)
return cb(err);
return copyFile(srcStat, src, dest, opts, cb);
});
} else if (opts.errorOnExist) {
return cb(new Error(`'${dest}' already exists`));
} else
return cb();
}
function copyFile(srcStat, src, dest, opts, cb) {
if (typeof fs.copyFile === "function") {
return fs.copyFile(src, dest, (err) => {
if (err)
return cb(err);
return setDestModeAndTimestamps(srcStat, dest, opts, cb);
});
}
return copyFileFallback(srcStat, src, dest, opts, cb);
}
function copyFileFallback(srcStat, src, dest, opts, cb) {
const rs = fs.createReadStream(src);
rs.on("error", (err) => cb(err)).once("open", () => {
const ws = fs.createWriteStream(dest, { mode: srcStat.mode });
ws.on("error", (err) => cb(err)).on("open", () => rs.pipe(ws)).once("close", () => setDestModeAndTimestamps(srcStat, dest, opts, cb));
});
}
function setDestModeAndTimestamps(srcStat, dest, opts, cb) {
fs.chmod(dest, srcStat.mode, (err) => {
if (err)
return cb(err);
if (opts.preserveTimestamps) {
return utimes(dest, srcStat.atime, srcStat.mtime, cb);
}
return cb();
});
}
function onDir(srcStat, destStat, src, dest, opts, cb) {
if (destStat === notExist)
return mkDirAndCopy(srcStat, src, dest, opts, cb);
if (destStat && !destStat.isDirectory()) {
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`));
}
return copyDir(src, dest, opts, cb);
}
function mkDirAndCopy(srcStat, src, dest, opts, cb) {
fs.mkdir(dest, (err) => {
if (err)
return cb(err);
copyDir(src, dest, opts, (err2) => {
if (err2)
return cb(err2);
return fs.chmod(dest, srcStat.mode, cb);
});
});
}
function copyDir(src, dest, opts, cb) {
fs.readdir(src, (err, items) => {
if (err)
return cb(err);
return copyDirItems(items, src, dest, opts, cb);
});
}
function copyDirItems(items, src, dest, opts, cb) {
const item = items.pop();
if (!item)
return cb();
return copyDirItem(items, item, src, dest, opts, cb);
}
function copyDirItem(items, item, src, dest, opts, cb) {
const srcItem = path.join(src, item);
const destItem = path.join(dest, item);
checkPaths(srcItem, destItem, (err, destStat) => {
if (err)
return cb(err);
startCopy(destStat, srcItem, destItem, opts, (err2) => {
if (err2)
return cb(err2);
return copyDirItems(items, src, dest, opts, cb);
});
});
}
function onLink(destStat, src, dest, opts, cb) {
fs.readlink(src, (err, resolvedSrc) => {
if (err)
return cb(err);
if (opts.dereference) {
resolvedSrc = path.resolve(process.cwd(), resolvedSrc);
}
if (destStat === notExist) {
return fs.symlink(resolvedSrc, dest, cb);
} else {
fs.readlink(dest, (err2, resolvedDest) => {
if (err2) {
if (err2.code === "EINVAL" || err2.code === "UNKNOWN")
return fs.symlink(resolvedSrc, dest, cb);
return cb(err2);
}
if (opts.dereference) {
resolvedDest = path.resolve(process.cwd(), resolvedDest);
}
if (isSrcSubdir(resolvedSrc, resolvedDest)) {
return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
}
if (destStat.isDirectory() && isSrcSubdir(resolvedDest, resolvedSrc)) {
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
}
return copyLink(resolvedSrc, dest, cb);
});
}
});
}
function copyLink(resolvedSrc, dest, cb) {
fs.unlink(dest, (err) => {
if (err)
return cb(err);
return fs.symlink(resolvedSrc, dest, cb);
});
}
function isSrcSubdir(src, dest) {
const srcArray = path.resolve(src).split(path.sep);
const destArray = path.resolve(dest).split(path.sep);
return srcArray.reduce((acc, current, i) => acc && destArray[i] === current, true);
}
function checkStats(src, dest, cb) {
fs.stat(src, (err, srcStat) => {
if (err)
return cb(err);
fs.stat(dest, (err2, destStat) => {
if (err2) {
if (err2.code === "ENOENT")
return cb(null, { srcStat, destStat: notExist });
return cb(err2);
}
return cb(null, { srcStat, destStat });
});
});
}
function checkPaths(src, dest, cb) {
checkStats(src, dest, (err, stats) => {
if (err)
return cb(err);
const { srcStat, destStat } = stats;
if (destStat.ino && destStat.ino === srcStat.ino) {
return cb(new Error("Source and destination must not be the same."));
}
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
return cb(new Error(`Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`));
}
return cb(null, destStat);
});
}
module2.exports = copy;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy/index.js
var require_copy2 = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/copy/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
module2.exports = {
copy: u(require_copy())
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/remove/rimraf.js
var require_rimraf = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/remove/rimraf.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var assert = require("assert");
var isWindows = process.platform === "win32";
function defaults(options) {
const methods = [
"unlink",
"chmod",
"stat",
"lstat",
"rmdir",
"readdir"
];
methods.forEach((m) => {
options[m] = options[m] || fs[m];
m = m + "Sync";
options[m] = options[m] || fs[m];
});
options.maxBusyTries = options.maxBusyTries || 3;
}
function rimraf(p, options, cb) {
let busyTries = 0;
if (typeof options === "function") {
cb = options;
options = {};
}
assert(p, "rimraf: missing path");
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
assert.strictEqual(typeof cb, "function", "rimraf: callback function required");
assert(options, "rimraf: invalid options argument provided");
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
defaults(options);
rimraf_(p, options, function CB(er) {
if (er) {
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
busyTries++;
const time = busyTries * 100;
return setTimeout(() => rimraf_(p, options, CB), time);
}
if (er.code === "ENOENT")
er = null;
}
cb(er);
});
}
function rimraf_(p, options, cb) {
assert(p);
assert(options);
assert(typeof cb === "function");
options.lstat(p, (er, st) => {
if (er && er.code === "ENOENT") {
return cb(null);
}
if (er && er.code === "EPERM" && isWindows) {
return fixWinEPERM(p, options, er, cb);
}
if (st && st.isDirectory()) {
return rmdir(p, options, er, cb);
}
options.unlink(p, (er2) => {
if (er2) {
if (er2.code === "ENOENT") {
return cb(null);
}
if (er2.code === "EPERM") {
return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
}
if (er2.code === "EISDIR") {
return rmdir(p, options, er2, cb);
}
}
return cb(er2);
});
});
}
function fixWinEPERM(p, options, er, cb) {
assert(p);
assert(options);
assert(typeof cb === "function");
if (er) {
assert(er instanceof Error);
}
options.chmod(p, 438, (er2) => {
if (er2) {
cb(er2.code === "ENOENT" ? null : er);
} else {
options.stat(p, (er3, stats) => {
if (er3) {
cb(er3.code === "ENOENT" ? null : er);
} else if (stats.isDirectory()) {
rmdir(p, options, er, cb);
} else {
options.unlink(p, cb);
}
});
}
});
}
function fixWinEPERMSync(p, options, er) {
let stats;
assert(p);
assert(options);
if (er) {
assert(er instanceof Error);
}
try {
options.chmodSync(p, 438);
} catch (er2) {
if (er2.code === "ENOENT") {
return;
} else {
throw er;
}
}
try {
stats = options.statSync(p);
} catch (er3) {
if (er3.code === "ENOENT") {
return;
} else {
throw er;
}
}
if (stats.isDirectory()) {
rmdirSync(p, options, er);
} else {
options.unlinkSync(p);
}
}
function rmdir(p, options, originalEr, cb) {
assert(p);
assert(options);
if (originalEr) {
assert(originalEr instanceof Error);
}
assert(typeof cb === "function");
options.rmdir(p, (er) => {
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) {
rmkids(p, options, cb);
} else if (er && er.code === "ENOTDIR") {
cb(originalEr);
} else {
cb(er);
}
});
}
function rmkids(p, options, cb) {
assert(p);
assert(options);
assert(typeof cb === "function");
options.readdir(p, (er, files) => {
if (er)
return cb(er);
let n = files.length;
let errState;
if (n === 0)
return options.rmdir(p, cb);
files.forEach((f) => {
rimraf(path.join(p, f), options, (er2) => {
if (errState) {
return;
}
if (er2)
return cb(errState = er2);
if (--n === 0) {
options.rmdir(p, cb);
}
});
});
});
}
function rimrafSync(p, options) {
let st;
options = options || {};
defaults(options);
assert(p, "rimraf: missing path");
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
assert(options, "rimraf: missing options");
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
try {
st = options.lstatSync(p);
} catch (er) {
if (er.code === "ENOENT") {
return;
}
if (er.code === "EPERM" && isWindows) {
fixWinEPERMSync(p, options, er);
}
}
try {
if (st && st.isDirectory()) {
rmdirSync(p, options, null);
} else {
options.unlinkSync(p);
}
} catch (er) {
if (er.code === "ENOENT") {
return;
} else if (er.code === "EPERM") {
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
} else if (er.code !== "EISDIR") {
throw er;
}
rmdirSync(p, options, er);
}
}
function rmdirSync(p, options, originalEr) {
assert(p);
assert(options);
if (originalEr) {
assert(originalEr instanceof Error);
}
try {
options.rmdirSync(p);
} catch (er) {
if (er.code === "ENOTDIR") {
throw originalEr;
} else if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") {
rmkidsSync(p, options);
} else if (er.code !== "ENOENT") {
throw er;
}
}
}
function rmkidsSync(p, options) {
assert(p);
assert(options);
options.readdirSync(p).forEach((f) => rimrafSync(path.join(p, f), options));
if (isWindows) {
const startTime = Date.now();
do {
try {
const ret = options.rmdirSync(p, options);
return ret;
} catch (er) {
}
} while (Date.now() - startTime < 500);
} else {
const ret = options.rmdirSync(p, options);
return ret;
}
}
module2.exports = rimraf;
rimraf.sync = rimrafSync;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/remove/index.js
var require_remove = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/remove/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var rimraf = require_rimraf();
module2.exports = {
remove: u(rimraf),
removeSync: rimraf.sync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/empty/index.js
var require_empty = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/empty/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var fs = require("fs");
var path = require("path");
var mkdir = require_mkdirs2();
var remove2 = require_remove();
var emptyDir = u(function emptyDir2(dir, callback) {
callback = callback || function() {
};
fs.readdir(dir, (err, items) => {
if (err)
return mkdir.mkdirs(dir, callback);
items = items.map((item) => path.join(dir, item));
deleteItem();
function deleteItem() {
const item = items.pop();
if (!item)
return callback();
remove2.remove(item, (err2) => {
if (err2)
return callback(err2);
deleteItem();
});
}
});
});
function emptyDirSync(dir) {
let items;
try {
items = fs.readdirSync(dir);
} catch (err) {
return mkdir.mkdirsSync(dir);
}
items.forEach((item) => {
item = path.join(dir, item);
remove2.removeSync(item);
});
}
module2.exports = {
emptyDirSync,
emptydirSync: emptyDirSync,
emptyDir,
emptydir: emptyDir
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/file.js
var require_file = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/file.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var path = require("path");
var fs = require_graceful_fs();
var mkdir = require_mkdirs2();
var pathExists2 = require_path_exists().pathExists;
function createFile(file, callback) {
function makeFile() {
fs.writeFile(file, "", (err) => {
if (err)
return callback(err);
callback();
});
}
fs.stat(file, (err, stats) => {
if (!err && stats.isFile())
return callback();
const dir = path.dirname(file);
pathExists2(dir, (err2, dirExists) => {
if (err2)
return callback(err2);
if (dirExists)
return makeFile();
mkdir.mkdirs(dir, (err3) => {
if (err3)
return callback(err3);
makeFile();
});
});
});
}
function createFileSync(file) {
let stats;
try {
stats = fs.statSync(file);
} catch (e) {
}
if (stats && stats.isFile())
return;
const dir = path.dirname(file);
if (!fs.existsSync(dir)) {
mkdir.mkdirsSync(dir);
}
fs.writeFileSync(file, "");
}
module2.exports = {
createFile: u(createFile),
createFileSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/link.js
var require_link = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/link.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var path = require("path");
var fs = require_graceful_fs();
var mkdir = require_mkdirs2();
var pathExists2 = require_path_exists().pathExists;
function createLink(srcpath, dstpath, callback) {
function makeLink(srcpath2, dstpath2) {
fs.link(srcpath2, dstpath2, (err) => {
if (err)
return callback(err);
callback(null);
});
}
pathExists2(dstpath, (err, destinationExists) => {
if (err)
return callback(err);
if (destinationExists)
return callback(null);
fs.lstat(srcpath, (err2) => {
if (err2) {
err2.message = err2.message.replace("lstat", "ensureLink");
return callback(err2);
}
const dir = path.dirname(dstpath);
pathExists2(dir, (err3, dirExists) => {
if (err3)
return callback(err3);
if (dirExists)
return makeLink(srcpath, dstpath);
mkdir.mkdirs(dir, (err4) => {
if (err4)
return callback(err4);
makeLink(srcpath, dstpath);
});
});
});
});
}
function createLinkSync(srcpath, dstpath) {
const destinationExists = fs.existsSync(dstpath);
if (destinationExists)
return void 0;
try {
fs.lstatSync(srcpath);
} catch (err) {
err.message = err.message.replace("lstat", "ensureLink");
throw err;
}
const dir = path.dirname(dstpath);
const dirExists = fs.existsSync(dir);
if (dirExists)
return fs.linkSync(srcpath, dstpath);
mkdir.mkdirsSync(dir);
return fs.linkSync(srcpath, dstpath);
}
module2.exports = {
createLink: u(createLink),
createLinkSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/symlink-paths.js
var require_symlink_paths = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports, module2) {
"use strict";
var path = require("path");
var fs = require_graceful_fs();
var pathExists2 = require_path_exists().pathExists;
function symlinkPaths(srcpath, dstpath, callback) {
if (path.isAbsolute(srcpath)) {
return fs.lstat(srcpath, (err) => {
if (err) {
err.message = err.message.replace("lstat", "ensureSymlink");
return callback(err);
}
return callback(null, {
"toCwd": srcpath,
"toDst": srcpath
});
});
} else {
const dstdir = path.dirname(dstpath);
const relativeToDst = path.join(dstdir, srcpath);
return pathExists2(relativeToDst, (err, exists) => {
if (err)
return callback(err);
if (exists) {
return callback(null, {
"toCwd": relativeToDst,
"toDst": srcpath
});
} else {
return fs.lstat(srcpath, (err2) => {
if (err2) {
err2.message = err2.message.replace("lstat", "ensureSymlink");
return callback(err2);
}
return callback(null, {
"toCwd": srcpath,
"toDst": path.relative(dstdir, srcpath)
});
});
}
});
}
}
function symlinkPathsSync(srcpath, dstpath) {
let exists;
if (path.isAbsolute(srcpath)) {
exists = fs.existsSync(srcpath);
if (!exists)
throw new Error("absolute srcpath does not exist");
return {
"toCwd": srcpath,
"toDst": srcpath
};
} else {
const dstdir = path.dirname(dstpath);
const relativeToDst = path.join(dstdir, srcpath);
exists = fs.existsSync(relativeToDst);
if (exists) {
return {
"toCwd": relativeToDst,
"toDst": srcpath
};
} else {
exists = fs.existsSync(srcpath);
if (!exists)
throw new Error("relative srcpath does not exist");
return {
"toCwd": srcpath,
"toDst": path.relative(dstdir, srcpath)
};
}
}
}
module2.exports = {
symlinkPaths,
symlinkPathsSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/symlink-type.js
var require_symlink_type = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/symlink-type.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
function symlinkType(srcpath, type, callback) {
callback = typeof type === "function" ? type : callback;
type = typeof type === "function" ? false : type;
if (type)
return callback(null, type);
fs.lstat(srcpath, (err, stats) => {
if (err)
return callback(null, "file");
type = stats && stats.isDirectory() ? "dir" : "file";
callback(null, type);
});
}
function symlinkTypeSync(srcpath, type) {
let stats;
if (type)
return type;
try {
stats = fs.lstatSync(srcpath);
} catch (e) {
return "file";
}
return stats && stats.isDirectory() ? "dir" : "file";
}
module2.exports = {
symlinkType,
symlinkTypeSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/symlink.js
var require_symlink = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/symlink.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var path = require("path");
var fs = require_graceful_fs();
var _mkdirs = require_mkdirs2();
var mkdirs = _mkdirs.mkdirs;
var mkdirsSync = _mkdirs.mkdirsSync;
var _symlinkPaths = require_symlink_paths();
var symlinkPaths = _symlinkPaths.symlinkPaths;
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync;
var _symlinkType = require_symlink_type();
var symlinkType = _symlinkType.symlinkType;
var symlinkTypeSync = _symlinkType.symlinkTypeSync;
var pathExists2 = require_path_exists().pathExists;
function createSymlink(srcpath, dstpath, type, callback) {
callback = typeof type === "function" ? type : callback;
type = typeof type === "function" ? false : type;
pathExists2(dstpath, (err, destinationExists) => {
if (err)
return callback(err);
if (destinationExists)
return callback(null);
symlinkPaths(srcpath, dstpath, (err2, relative) => {
if (err2)
return callback(err2);
srcpath = relative.toDst;
symlinkType(relative.toCwd, type, (err3, type2) => {
if (err3)
return callback(err3);
const dir = path.dirname(dstpath);
pathExists2(dir, (err4, dirExists) => {
if (err4)
return callback(err4);
if (dirExists)
return fs.symlink(srcpath, dstpath, type2, callback);
mkdirs(dir, (err5) => {
if (err5)
return callback(err5);
fs.symlink(srcpath, dstpath, type2, callback);
});
});
});
});
});
}
function createSymlinkSync(srcpath, dstpath, type) {
const destinationExists = fs.existsSync(dstpath);
if (destinationExists)
return void 0;
const relative = symlinkPathsSync(srcpath, dstpath);
srcpath = relative.toDst;
type = symlinkTypeSync(relative.toCwd, type);
const dir = path.dirname(dstpath);
const exists = fs.existsSync(dir);
if (exists)
return fs.symlinkSync(srcpath, dstpath, type);
mkdirsSync(dir);
return fs.symlinkSync(srcpath, dstpath, type);
}
module2.exports = {
createSymlink: u(createSymlink),
createSymlinkSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/index.js
var require_ensure = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/ensure/index.js"(exports, module2) {
"use strict";
var file = require_file();
var link = require_link();
var symlink = require_symlink();
module2.exports = {
// file
createFile: file.createFile,
createFileSync: file.createFileSync,
ensureFile: file.createFile,
ensureFileSync: file.createFileSync,
// link
createLink: link.createLink,
createLinkSync: link.createLinkSync,
ensureLink: link.createLink,
ensureLinkSync: link.createLinkSync,
// symlink
createSymlink: symlink.createSymlink,
createSymlinkSync: symlink.createSymlinkSync,
ensureSymlink: symlink.createSymlink,
ensureSymlinkSync: symlink.createSymlinkSync
};
}
});
// ../../node_modules/.pnpm/jsonfile@4.0.0/node_modules/jsonfile/index.js
var require_jsonfile = __commonJS({
"../../node_modules/.pnpm/jsonfile@4.0.0/node_modules/jsonfile/index.js"(exports, module2) {
var _fs;
try {
_fs = require_graceful_fs();
} catch (_) {
_fs = require("fs");
}
function readFile2(file, options, callback) {
if (callback == null) {
callback = options;
options = {};
}
if (typeof options === "string") {
options = { encoding: options };
}
options = options || {};
var fs = options.fs || _fs;
var shouldThrow = true;
if ("throws" in options) {
shouldThrow = options.throws;
}
fs.readFile(file, options, function(err, data) {
if (err)
return callback(err);
data = stripBom(data);
var obj;
try {
obj = JSON.parse(data, options ? options.reviver : null);
} catch (err2) {
if (shouldThrow) {
err2.message = file + ": " + err2.message;
return callback(err2);
} else {
return callback(null, null);
}
}
callback(null, obj);
});
}
function readFileSync2(file, options) {
options = options || {};
if (typeof options === "string") {
options = { encoding: options };
}
var fs = options.fs || _fs;
var shouldThrow = true;
if ("throws" in options) {
shouldThrow = options.throws;
}
try {
var content = fs.readFileSync(file, options);
content = stripBom(content);
return JSON.parse(content, options.reviver);
} catch (err) {
if (shouldThrow) {
err.message = file + ": " + err.message;
throw err;
} else {
return null;
}
}
}
function stringify(obj, options) {
var spaces;
var EOL2 = "\n";
if (typeof options === "object" && options !== null) {
if (options.spaces) {
spaces = options.spaces;
}
if (options.EOL) {
EOL2 = options.EOL;
}
}
var str = JSON.stringify(obj, options ? options.replacer : null, spaces);
return str.replace(/\n/g, EOL2) + EOL2;
}
function writeFile2(file, obj, options, callback) {
if (callback == null) {
callback = options;
options = {};
}
options = options || {};
var fs = options.fs || _fs;
var str = "";
try {
str = stringify(obj, options);
} catch (err) {
if (callback)
callback(err, null);
return;
}
fs.writeFile(file, str, options, callback);
}
function writeFileSync2(file, obj, options) {
options = options || {};
var fs = options.fs || _fs;
var str = stringify(obj, options);
return fs.writeFileSync(file, str, options);
}
function stripBom(content) {
if (Buffer.isBuffer(content))
content = content.toString("utf8");
content = content.replace(/^\uFEFF/, "");
return content;
}
var jsonfile = {
readFile: readFile2,
readFileSync: readFileSync2,
writeFile: writeFile2,
writeFileSync: writeFileSync2
};
module2.exports = jsonfile;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/jsonfile.js
var require_jsonfile2 = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/jsonfile.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var jsonFile = require_jsonfile();
module2.exports = {
// jsonfile exports
readJson: u(jsonFile.readFile),
readJsonSync: jsonFile.readFileSync,
writeJson: u(jsonFile.writeFile),
writeJsonSync: jsonFile.writeFileSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/output-json.js
var require_output_json = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/output-json.js"(exports, module2) {
"use strict";
var path = require("path");
var mkdir = require_mkdirs2();
var pathExists2 = require_path_exists().pathExists;
var jsonFile = require_jsonfile2();
function outputJson(file, data, options, callback) {
if (typeof options === "function") {
callback = options;
options = {};
}
const dir = path.dirname(file);
pathExists2(dir, (err, itDoes) => {
if (err)
return callback(err);
if (itDoes)
return jsonFile.writeJson(file, data, options, callback);
mkdir.mkdirs(dir, (err2) => {
if (err2)
return callback(err2);
jsonFile.writeJson(file, data, options, callback);
});
});
}
module2.exports = outputJson;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/output-json-sync.js
var require_output_json_sync = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/output-json-sync.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var mkdir = require_mkdirs2();
var jsonFile = require_jsonfile2();
function outputJsonSync(file, data, options) {
const dir = path.dirname(file);
if (!fs.existsSync(dir)) {
mkdir.mkdirsSync(dir);
}
jsonFile.writeJsonSync(file, data, options);
}
module2.exports = outputJsonSync;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/index.js
var require_json = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/json/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var jsonFile = require_jsonfile2();
jsonFile.outputJson = u(require_output_json());
jsonFile.outputJsonSync = require_output_json_sync();
jsonFile.outputJSON = jsonFile.outputJson;
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
jsonFile.writeJSON = jsonFile.writeJson;
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
jsonFile.readJSON = jsonFile.readJson;
jsonFile.readJSONSync = jsonFile.readJsonSync;
module2.exports = jsonFile;
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/move-sync/index.js
var require_move_sync = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/move-sync/index.js"(exports, module2) {
"use strict";
var fs = require_graceful_fs();
var path = require("path");
var copySync = require_copy_sync2().copySync;
var removeSync = require_remove().removeSync;
var mkdirpSync = require_mkdirs2().mkdirsSync;
var buffer = require_buffer();
function moveSync(src, dest, options) {
options = options || {};
const overwrite = options.overwrite || options.clobber || false;
src = path.resolve(src);
dest = path.resolve(dest);
if (src === dest)
return fs.accessSync(src);
if (isSrcSubdir(src, dest))
throw new Error(`Cannot move '${src}' into itself '${dest}'.`);
mkdirpSync(path.dirname(dest));
tryRenameSync();
function tryRenameSync() {
if (overwrite) {
try {
return fs.renameSync(src, dest);
} catch (err) {
if (err.code === "ENOTEMPTY" || err.code === "EEXIST" || err.code === "EPERM") {
removeSync(dest);
options.overwrite = false;
return moveSync(src, dest, options);
}
if (err.code !== "EXDEV")
throw err;
return moveSyncAcrossDevice(src, dest, overwrite);
}
} else {
try {
fs.linkSync(src, dest);
return fs.unlinkSync(src);
} catch (err) {
if (err.code === "EXDEV" || err.code === "EISDIR" || err.code === "EPERM" || err.code === "ENOTSUP") {
return moveSyncAcrossDevice(src, dest, overwrite);
}
throw err;
}
}
}
}
function moveSyncAcrossDevice(src, dest, overwrite) {
const stat = fs.statSync(src);
if (stat.isDirectory()) {
return moveDirSyncAcrossDevice(src, dest, overwrite);
} else {
return moveFileSyncAcrossDevice(src, dest, overwrite);
}
}
function moveFileSyncAcrossDevice(src, dest, overwrite) {
const BUF_LENGTH = 64 * 1024;
const _buff = buffer(BUF_LENGTH);
const flags = overwrite ? "w" : "wx";
const fdr = fs.openSync(src, "r");
const stat = fs.fstatSync(fdr);
const fdw = fs.openSync(dest, flags, stat.mode);
let pos = 0;
while (pos < stat.size) {
const bytesRead = fs.readSync(fdr, _buff, 0, BUF_LENGTH, pos);
fs.writeSync(fdw, _buff, 0, bytesRead);
pos += bytesRead;
}
fs.closeSync(fdr);
fs.closeSync(fdw);
return fs.unlinkSync(src);
}
function moveDirSyncAcrossDevice(src, dest, overwrite) {
const options = {
overwrite: false
};
if (overwrite) {
removeSync(dest);
tryCopySync();
} else {
tryCopySync();
}
function tryCopySync() {
copySync(src, dest, options);
return removeSync(src);
}
}
function isSrcSubdir(src, dest) {
try {
return fs.statSync(src).isDirectory() && src !== dest && dest.indexOf(src) > -1 && dest.split(path.dirname(src) + path.sep)[1].split(path.sep)[0] === path.basename(src);
} catch (e) {
return false;
}
}
module2.exports = {
moveSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/move/index.js
var require_move = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/move/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var fs = require_graceful_fs();
var path = require("path");
var copy = require_copy2().copy;
var remove2 = require_remove().remove;
var mkdirp = require_mkdirs2().mkdirp;
var pathExists2 = require_path_exists().pathExists;
function move2(src, dest, opts, cb) {
if (typeof opts === "function") {
cb = opts;
opts = {};
}
const overwrite = opts.overwrite || opts.clobber || false;
src = path.resolve(src);
dest = path.resolve(dest);
if (src === dest)
return fs.access(src, cb);
fs.stat(src, (err, st) => {
if (err)
return cb(err);
if (st.isDirectory() && isSrcSubdir(src, dest)) {
return cb(new Error(`Cannot move '${src}' to a subdirectory of itself, '${dest}'.`));
}
mkdirp(path.dirname(dest), (err2) => {
if (err2)
return cb(err2);
return doRename(src, dest, overwrite, cb);
});
});
}
function doRename(src, dest, overwrite, cb) {
if (overwrite) {
return remove2(dest, (err) => {
if (err)
return cb(err);
return rename(src, dest, overwrite, cb);
});
}
pathExists2(dest, (err, destExists) => {
if (err)
return cb(err);
if (destExists)
return cb(new Error("dest already exists."));
return rename(src, dest, overwrite, cb);
});
}
function rename(src, dest, overwrite, cb) {
fs.rename(src, dest, (err) => {
if (!err)
return cb();
if (err.code !== "EXDEV")
return cb(err);
return moveAcrossDevice(src, dest, overwrite, cb);
});
}
function moveAcrossDevice(src, dest, overwrite, cb) {
const opts = {
overwrite,
errorOnExist: true
};
copy(src, dest, opts, (err) => {
if (err)
return cb(err);
return remove2(src, cb);
});
}
function isSrcSubdir(src, dest) {
const srcArray = src.split(path.sep);
const destArray = dest.split(path.sep);
return srcArray.reduce((acc, current, i) => {
return acc && destArray[i] === current;
}, true);
}
module2.exports = {
move: u(move2)
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/output/index.js
var require_output = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/output/index.js"(exports, module2) {
"use strict";
var u = require_universalify().fromCallback;
var fs = require_graceful_fs();
var path = require("path");
var mkdir = require_mkdirs2();
var pathExists2 = require_path_exists().pathExists;
function outputFile(file, data, encoding, callback) {
if (typeof encoding === "function") {
callback = encoding;
encoding = "utf8";
}
const dir = path.dirname(file);
pathExists2(dir, (err, itDoes) => {
if (err)
return callback(err);
if (itDoes)
return fs.writeFile(file, data, encoding, callback);
mkdir.mkdirs(dir, (err2) => {
if (err2)
return callback(err2);
fs.writeFile(file, data, encoding, callback);
});
});
}
function outputFileSync(file, ...args) {
const dir = path.dirname(file);
if (fs.existsSync(dir)) {
return fs.writeFileSync(file, ...args);
}
mkdir.mkdirsSync(dir);
fs.writeFileSync(file, ...args);
}
module2.exports = {
outputFile: u(outputFile),
outputFileSync
};
}
});
// ../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/index.js
var require_lib = __commonJS({
"../../node_modules/.pnpm/fs-extra@7.0.1/node_modules/fs-extra/lib/index.js"(exports, module2) {
"use strict";
module2.exports = Object.assign(
{},
// Export promiseified graceful-fs:
require_fs(),
// Export extra methods:
require_copy_sync2(),
require_copy2(),
require_empty(),
require_ensure(),
require_json(),
require_mkdirs2(),
require_move_sync(),
require_move(),
require_output(),
require_path_exists(),
require_remove()
);
var fs = require("fs");
if (Object.getOwnPropertyDescriptor(fs, "promises")) {
Object.defineProperty(module2.exports, "promises", {
get() {
return fs.promises;
}
});
}
}
});
// ../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js
var require_lib2 = __commonJS({
"../../node_modules/.pnpm/which@3.0.0/node_modules/which/lib/index.js"(exports, module2) {
var isexe = require_isexe();
var { join: join4, delimiter, sep, posix } = require("path");
var isWindows = process.platform === "win32";
var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
var rRel = new RegExp(`^\\.${rSlash.source}`);
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
var getPathInfo = (cmd, {
path: optPath = process.env.PATH,
pathExt: optPathExt = process.env.PATHEXT,
delimiter: optDelimiter = delimiter
}) => {
const pathEnv = cmd.match(rSlash) ? [""] : [
// windows always checks the cwd first
...isWindows ? [process.cwd()] : [],
...(optPath || /* istanbul ignore next: very unusual */
"").split(optDelimiter)
];
if (isWindows) {
const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
const pathExt = pathExtExe.split(optDelimiter);
if (cmd.includes(".") && pathExt[0] !== "") {
pathExt.unshift("");
}
return { pathEnv, pathExt, pathExtExe };
}
return { pathEnv, pathExt: [""] };
};
var getPathPart = (raw, cmd) => {
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
return prefix + join4(pathPart, cmd);
};
var which3 = async (cmd, opt = {}) => {
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
const found = [];
for (const envPart of pathEnv) {
const p = getPathPart(envPart, cmd);
for (const ext of pathExt) {
const withExt = p + ext;
const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
if (is) {
if (!opt.all) {
return withExt;
}
found.push(withExt);
}
}
}
if (opt.all && found.length) {
return found;
}
if (opt.nothrow) {
return null;
}
throw getNotFoundError(cmd);
};
var whichSync = (cmd, opt = {}) => {
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
const found = [];
for (const pathEnvPart of pathEnv) {
const p = getPathPart(pathEnvPart, cmd);
for (const ext of pathExt) {
const withExt = p + ext;
const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
if (is) {
if (!opt.all) {
return withExt;
}
found.push(withExt);
}
}
}
if (opt.all && found.length) {
return found;
}
if (opt.nothrow) {
return null;
}
throw getNotFoundError(cmd);
};
module2.exports = which3;
which3.sync = whichSync;
}
});
// ../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js
var require_semver2 = __commonJS({
"../../node_modules/.pnpm/semver@6.3.1/node_modules/semver/semver.js"(exports, module2) {
exports = module2.exports = SemVer;
var debug4;
if (typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
debug4 = function() {
var args = Array.prototype.slice.call(arguments, 0);
args.unshift("SEMVER");
console.log.apply(console, args);
};
} else {
debug4 = function() {
};
}
exports.SEMVER_SPEC_VERSION = "2.0.0";
var MAX_LENGTH = 256;
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
9007199254740991;
var MAX_SAFE_COMPONENT_LENGTH = 16;
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
var re = exports.re = [];
var safeRe = exports.safeRe = [];
var src = exports.src = [];
var t = exports.tokens = {};
var R = 0;
function tok(n) {
t[n] = R++;
}
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
var safeRegexReplacements = [
["\\s", 1],
["\\d", MAX_LENGTH],
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
];
function makeSafeRe(value) {
for (var i2 = 0; i2 < safeRegexReplacements.length; i2++) {
var token = safeRegexReplacements[i2][0];
var max = safeRegexReplacements[i2][1];
value = value.split(token + "*").join(token + "{0," + max + "}").split(token + "+").join(token + "{1," + max + "}");
}
return value;
}
tok("NUMERICIDENTIFIER");
src[t.NUMERICIDENTIFIER] = "0|[1-9]\\d*";
tok("NUMERICIDENTIFIERLOOSE");
src[t.NUMERICIDENTIFIERLOOSE] = "\\d+";
tok("NONNUMERICIDENTIFIER");
src[t.NONNUMERICIDENTIFIER] = "\\d*[a-zA-Z-]" + LETTERDASHNUMBER + "*";
tok("MAINVERSION");
src[t.MAINVERSION] = "(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")\\.(" + src[t.NUMERICIDENTIFIER] + ")";
tok("MAINVERSIONLOOSE");
src[t.MAINVERSIONLOOSE] = "(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")\\.(" + src[t.NUMERICIDENTIFIERLOOSE] + ")";
tok("PRERELEASEIDENTIFIER");
src[t.PRERELEASEIDENTIFIER] = "(?:" + src[t.NUMERICIDENTIFIER] + "|" + src[t.NONNUMERICIDENTIFIER] + ")";
tok("PRERELEASEIDENTIFIERLOOSE");
src[t.PRERELEASEIDENTIFIERLOOSE] = "(?:" + src[t.NUMERICIDENTIFIERLOOSE] + "|" + src[t.NONNUMERICIDENTIFIER] + ")";
tok("PRERELEASE");
src[t.PRERELEASE] = "(?:-(" + src[t.PRERELEASEIDENTIFIER] + "(?:\\." + src[t.PRERELEASEIDENTIFIER] + ")*))";
tok("PRERELEASELOOSE");
src[t.PRERELEASELOOSE] = "(?:-?(" + src[t.PRERELEASEIDENTIFIERLOOSE] + "(?:\\." + src[t.PRERELEASEIDENTIFIERLOOSE] + ")*))";
tok("BUILDIDENTIFIER");
src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + "+";
tok("BUILD");
src[t.BUILD] = "(?:\\+(" + src[t.BUILDIDENTIFIER] + "(?:\\." + src[t.BUILDIDENTIFIER] + ")*))";
tok("FULL");
tok("FULLPLAIN");
src[t.FULLPLAIN] = "v?" + src[t.MAINVERSION] + src[t.PRERELEASE] + "?" + src[t.BUILD] + "?";
src[t.FULL] = "^" + src[t.FULLPLAIN] + "$";
tok("LOOSEPLAIN");
src[t.LOOSEPLAIN] = "[v=\\s]*" + src[t.MAINVERSIONLOOSE] + src[t.PRERELEASELOOSE] + "?" + src[t.BUILD] + "?";
tok("LOOSE");
src[t.LOOSE] = "^" + src[t.LOOSEPLAIN] + "$";
tok("GTLT");
src[t.GTLT] = "((?:<|>)?=?)";
tok("XRANGEIDENTIFIERLOOSE");
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + "|x|X|\\*";
tok("XRANGEIDENTIFIER");
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + "|x|X|\\*";
tok("XRANGEPLAIN");
src[t.XRANGEPLAIN] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:\\.(" + src[t.XRANGEIDENTIFIER] + ")(?:" + src[t.PRERELEASE] + ")?" + src[t.BUILD] + "?)?)?";
tok("XRANGEPLAINLOOSE");
src[t.XRANGEPLAINLOOSE] = "[v=\\s]*(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:\\.(" + src[t.XRANGEIDENTIFIERLOOSE] + ")(?:" + src[t.PRERELEASELOOSE] + ")?" + src[t.BUILD] + "?)?)?";
tok("XRANGE");
src[t.XRANGE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAIN] + "$";
tok("XRANGELOOSE");
src[t.XRANGELOOSE] = "^" + src[t.GTLT] + "\\s*" + src[t.XRANGEPLAINLOOSE] + "$";
tok("COERCE");
src[t.COERCE] = "(^|[^\\d])(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "})(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:\\.(\\d{1," + MAX_SAFE_COMPONENT_LENGTH + "}))?(?:$|[^\\d])";
tok("COERCERTL");
re[t.COERCERTL] = new RegExp(src[t.COERCE], "g");
safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), "g");
tok("LONETILDE");
src[t.LONETILDE] = "(?:~>?)";
tok("TILDETRIM");
src[t.TILDETRIM] = "(\\s*)" + src[t.LONETILDE] + "\\s+";
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], "g");
safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), "g");
var tildeTrimReplace = "$1~";
tok("TILDE");
src[t.TILDE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAIN] + "$";
tok("TILDELOOSE");
src[t.TILDELOOSE] = "^" + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + "$";
tok("LONECARET");
src[t.LONECARET] = "(?:\\^)";
tok("CARETTRIM");
src[t.CARETTRIM] = "(\\s*)" + src[t.LONECARET] + "\\s+";
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], "g");
safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), "g");
var caretTrimReplace = "$1^";
tok("CARET");
src[t.CARET] = "^" + src[t.LONECARET] + src[t.XRANGEPLAIN] + "$";
tok("CARETLOOSE");
src[t.CARETLOOSE] = "^" + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + "$";
tok("COMPARATORLOOSE");
src[t.COMPARATORLOOSE] = "^" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + ")$|^$";
tok("COMPARATOR");
src[t.COMPARATOR] = "^" + src[t.GTLT] + "\\s*(" + src[t.FULLPLAIN] + ")$|^$";
tok("COMPARATORTRIM");
src[t.COMPARATORTRIM] = "(\\s*)" + src[t.GTLT] + "\\s*(" + src[t.LOOSEPLAIN] + "|" + src[t.XRANGEPLAIN] + ")";
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], "g");
safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), "g");
var comparatorTrimReplace = "$1$2$3";
tok("HYPHENRANGE");
src[t.HYPHENRANGE] = "^\\s*(" + src[t.XRANGEPLAIN] + ")\\s+-\\s+(" + src[t.XRANGEPLAIN] + ")\\s*$";
tok("HYPHENRANGELOOSE");
src[t.HYPHENRANGELOOSE] = "^\\s*(" + src[t.XRANGEPLAINLOOSE] + ")\\s+-\\s+(" + src[t.XRANGEPLAINLOOSE] + ")\\s*$";
tok("STAR");
src[t.STAR] = "(<|>)?=?\\s*\\*";
for (i = 0; i < R; i++) {
debug4(i, src[i]);
if (!re[i]) {
re[i] = new RegExp(src[i]);
safeRe[i] = new RegExp(makeSafeRe(src[i]));
}
}
var i;
exports.parse = parse;
function parse(version2, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version2 instanceof SemVer) {
return version2;
}
if (typeof version2 !== "string") {
return null;
}
if (version2.length > MAX_LENGTH) {
return null;
}
var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL];
if (!r.test(version2)) {
return null;
}
try {
return new SemVer(version2, options);
} catch (er) {
return null;
}
}
exports.valid = valid;
function valid(version2, options) {
var v = parse(version2, options);
return v ? v.version : null;
}
exports.clean = clean;
function clean(version2, options) {
var s = parse(version2.trim().replace(/^[=v]+/, ""), options);
return s ? s.version : null;
}
exports.SemVer = SemVer;
function SemVer(version2, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (version2 instanceof SemVer) {
if (version2.loose === options.loose) {
return version2;
} else {
version2 = version2.version;
}
} else if (typeof version2 !== "string") {
throw new TypeError("Invalid Version: " + version2);
}
if (version2.length > MAX_LENGTH) {
throw new TypeError("version is longer than " + MAX_LENGTH + " characters");
}
if (!(this instanceof SemVer)) {
return new SemVer(version2, options);
}
debug4("SemVer", version2, options);
this.options = options;
this.loose = !!options.loose;
var m = version2.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]);
if (!m) {
throw new TypeError("Invalid Version: " + version2);
}
this.raw = version2;
this.major = +m[1];
this.minor = +m[2];
this.patch = +m[3];
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
throw new TypeError("Invalid major version");
}
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
throw new TypeError("Invalid minor version");
}
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
throw new TypeError("Invalid patch version");
}
if (!m[4]) {
this.prerelease = [];
} else {
this.prerelease = m[4].split(".").map(function(id) {
if (/^[0-9]+$/.test(id)) {
var num = +id;
if (num >= 0 && num < MAX_SAFE_INTEGER) {
return num;
}
}
return id;
});
}
this.build = m[5] ? m[5].split(".") : [];
this.format();
}
SemVer.prototype.format = function() {
this.version = this.major + "." + this.minor + "." + this.patch;
if (this.prerelease.length) {
this.version += "-" + this.prerelease.join(".");
}
return this.version;
};
SemVer.prototype.toString = function() {
return this.version;
};
SemVer.prototype.compare = function(other) {
debug4("SemVer.compare", this.version, this.options, other);
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return this.compareMain(other) || this.comparePre(other);
};
SemVer.prototype.compareMain = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
};
SemVer.prototype.comparePre = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
if (this.prerelease.length && !other.prerelease.length) {
return -1;
} else if (!this.prerelease.length && other.prerelease.length) {
return 1;
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
var i2 = 0;
do {
var a = this.prerelease[i2];
var b = other.prerelease[i2];
debug4("prerelease compare", i2, a, b);
if (a === void 0 && b === void 0) {
return 0;
} else if (b === void 0) {
return 1;
} else if (a === void 0) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i2);
};
SemVer.prototype.compareBuild = function(other) {
if (!(other instanceof SemVer)) {
other = new SemVer(other, this.options);
}
var i2 = 0;
do {
var a = this.build[i2];
var b = other.build[i2];
debug4("prerelease compare", i2, a, b);
if (a === void 0 && b === void 0) {
return 0;
} else if (b === void 0) {
return 1;
} else if (a === void 0) {
return -1;
} else if (a === b) {
continue;
} else {
return compareIdentifiers(a, b);
}
} while (++i2);
};
SemVer.prototype.inc = function(release2, identifier) {
switch (release2) {
case "premajor":
this.prerelease.length = 0;
this.patch = 0;
this.minor = 0;
this.major++;
this.inc("pre", identifier);
break;
case "preminor":
this.prerelease.length = 0;
this.patch = 0;
this.minor++;
this.inc("pre", identifier);
break;
case "prepatch":
this.prerelease.length = 0;
this.inc("patch", identifier);
this.inc("pre", identifier);
break;
case "prerelease":
if (this.prerelease.length === 0) {
this.inc("patch", identifier);
}
this.inc("pre", identifier);
break;
case "major":
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
this.major++;
}
this.minor = 0;
this.patch = 0;
this.prerelease = [];
break;
case "minor":
if (this.patch !== 0 || this.prerelease.length === 0) {
this.minor++;
}
this.patch = 0;
this.prerelease = [];
break;
case "patch":
if (this.prerelease.length === 0) {
this.patch++;
}
this.prerelease = [];
break;
case "pre":
if (this.prerelease.length === 0) {
this.prerelease = [0];
} else {
var i2 = this.prerelease.length;
while (--i2 >= 0) {
if (typeof this.prerelease[i2] === "number") {
this.prerelease[i2]++;
i2 = -2;
}
}
if (i2 === -1) {
this.prerelease.push(0);
}
}
if (identifier) {
if (this.prerelease[0] === identifier) {
if (isNaN(this.prerelease[1])) {
this.prerelease = [identifier, 0];
}
} else {
this.prerelease = [identifier, 0];
}
}
break;
default:
throw new Error("invalid increment argument: " + release2);
}
this.format();
this.raw = this.version;
return this;
};
exports.inc = inc;
function inc(version2, release2, loose, identifier) {
if (typeof loose === "string") {
identifier = loose;
loose = void 0;
}
try {
return new SemVer(version2, loose).inc(release2, identifier).version;
} catch (er) {
return null;
}
}
exports.diff = diff;
function diff(version1, version2) {
if (eq(version1, version2)) {
return null;
} else {
var v1 = parse(version1);
var v2 = parse(version2);
var prefix = "";
if (v1.prerelease.length || v2.prerelease.length) {
prefix = "pre";
var defaultResult = "prerelease";
}
for (var key in v1) {
if (key === "major" || key === "minor" || key === "patch") {
if (v1[key] !== v2[key]) {
return prefix + key;
}
}
}
return defaultResult;
}
}
exports.compareIdentifiers = compareIdentifiers;
var numeric = /^[0-9]+$/;
function compareIdentifiers(a, b) {
var anum = numeric.test(a);
var bnum = numeric.test(b);
if (anum && bnum) {
a = +a;
b = +b;
}
return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
}
exports.rcompareIdentifiers = rcompareIdentifiers;
function rcompareIdentifiers(a, b) {
return compareIdentifiers(b, a);
}
exports.major = major;
function major(a, loose) {
return new SemVer(a, loose).major;
}
exports.minor = minor;
function minor(a, loose) {
return new SemVer(a, loose).minor;
}
exports.patch = patch;
function patch(a, loose) {
return new SemVer(a, loose).patch;
}
exports.compare = compare;
function compare(a, b, loose) {
return new SemVer(a, loose).compare(new SemVer(b, loose));
}
exports.compareLoose = compareLoose;
function compareLoose(a, b) {
return compare(a, b, true);
}
exports.compareBuild = compareBuild;
function compareBuild(a, b, loose) {
var versionA = new SemVer(a, loose);
var versionB = new SemVer(b, loose);
return versionA.compare(versionB) || versionA.compareBuild(versionB);
}
exports.rcompare = rcompare;
function rcompare(a, b, loose) {
return compare(b, a, loose);
}
exports.sort = sort;
function sort(list, loose) {
return list.sort(function(a, b) {
return exports.compareBuild(a, b, loose);
});
}
exports.rsort = rsort;
function rsort(list, loose) {
return list.sort(function(a, b) {
return exports.compareBuild(b, a, loose);
});
}
exports.gt = gt;
function gt(a, b, loose) {
return compare(a, b, loose) > 0;
}
exports.lt = lt;
function lt(a, b, loose) {
return compare(a, b, loose) < 0;
}
exports.eq = eq;
function eq(a, b, loose) {
return compare(a, b, loose) === 0;
}
exports.neq = neq;
function neq(a, b, loose) {
return compare(a, b, loose) !== 0;
}
exports.gte = gte;
function gte(a, b, loose) {
return compare(a, b, loose) >= 0;
}
exports.lte = lte;
function lte(a, b, loose) {
return compare(a, b, loose) <= 0;
}
exports.cmp = cmp;
function cmp(a, op, b, loose) {
switch (op) {
case "===":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a === b;
case "!==":
if (typeof a === "object")
a = a.version;
if (typeof b === "object")
b = b.version;
return a !== b;
case "":
case "=":
case "==":
return eq(a, b, loose);
case "!=":
return neq(a, b, loose);
case ">":
return gt(a, b, loose);
case ">=":
return gte(a, b, loose);
case "<":
return lt(a, b, loose);
case "<=":
return lte(a, b, loose);
default:
throw new TypeError("Invalid operator: " + op);
}
}
exports.Comparator = Comparator;
function Comparator(comp, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (comp instanceof Comparator) {
if (comp.loose === !!options.loose) {
return comp;
} else {
comp = comp.value;
}
}
if (!(this instanceof Comparator)) {
return new Comparator(comp, options);
}
comp = comp.trim().split(/\s+/).join(" ");
debug4("comparator", comp, options);
this.options = options;
this.loose = !!options.loose;
this.parse(comp);
if (this.semver === ANY) {
this.value = "";
} else {
this.value = this.operator + this.semver.version;
}
debug4("comp", this);
}
var ANY = {};
Comparator.prototype.parse = function(comp) {
var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
var m = comp.match(r);
if (!m) {
throw new TypeError("Invalid comparator: " + comp);
}
this.operator = m[1] !== void 0 ? m[1] : "";
if (this.operator === "=") {
this.operator = "";
}
if (!m[2]) {
this.semver = ANY;
} else {
this.semver = new SemVer(m[2], this.options.loose);
}
};
Comparator.prototype.toString = function() {
return this.value;
};
Comparator.prototype.test = function(version2) {
debug4("Comparator.test", version2, this.options.loose);
if (this.semver === ANY || version2 === ANY) {
return true;
}
if (typeof version2 === "string") {
try {
version2 = new SemVer(version2, this.options);
} catch (er) {
return false;
}
}
return cmp(version2, this.operator, this.semver, this.options);
};
Comparator.prototype.intersects = function(comp, options) {
if (!(comp instanceof Comparator)) {
throw new TypeError("a Comparator is required");
}
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
var rangeTmp;
if (this.operator === "") {
if (this.value === "") {
return true;
}
rangeTmp = new Range(comp.value, options);
return satisfies(this.value, rangeTmp, options);
} else if (comp.operator === "") {
if (comp.value === "") {
return true;
}
rangeTmp = new Range(this.value, options);
return satisfies(comp.semver, rangeTmp, options);
}
var sameDirectionIncreasing = (this.operator === ">=" || this.operator === ">") && (comp.operator === ">=" || comp.operator === ">");
var sameDirectionDecreasing = (this.operator === "<=" || this.operator === "<") && (comp.operator === "<=" || comp.operator === "<");
var sameSemVer = this.semver.version === comp.semver.version;
var differentDirectionsInclusive = (this.operator === ">=" || this.operator === "<=") && (comp.operator === ">=" || comp.operator === "<=");
var oppositeDirectionsLessThan = cmp(this.semver, "<", comp.semver, options) && ((this.operator === ">=" || this.operator === ">") && (comp.operator === "<=" || comp.operator === "<"));
var oppositeDirectionsGreaterThan = cmp(this.semver, ">", comp.semver, options) && ((this.operator === "<=" || this.operator === "<") && (comp.operator === ">=" || comp.operator === ">"));
return sameDirectionIncreasing || sameDirectionDecreasing || sameSemVer && differentDirectionsInclusive || oppositeDirectionsLessThan || oppositeDirectionsGreaterThan;
};
exports.Range = Range;
function Range(range, options) {
if (!options || typeof options !== "object") {
options = {
loose: !!options,
includePrerelease: false
};
}
if (range instanceof Range) {
if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
return range;
} else {
return new Range(range.raw, options);
}
}
if (range instanceof Comparator) {
return new Range(range.value, options);
}
if (!(this instanceof Range)) {
return new Range(range, options);
}
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease;
this.raw = range.trim().split(/\s+/).join(" ");
this.set = this.raw.split("||").map(function(range2) {
return this.parseRange(range2.trim());
}, this).filter(function(c) {
return c.length;
});
if (!this.set.length) {
throw new TypeError("Invalid SemVer Range: " + this.raw);
}
this.format();
}
Range.prototype.format = function() {
this.range = this.set.map(function(comps) {
return comps.join(" ").trim();
}).join("||").trim();
return this.range;
};
Range.prototype.toString = function() {
return this.range;
};
Range.prototype.parseRange = function(range) {
var loose = this.options.loose;
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE];
range = range.replace(hr, hyphenReplace);
debug4("hyphen replace", range);
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace);
debug4("comparator trim", range, safeRe[t.COMPARATORTRIM]);
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace);
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace);
range = range.split(/\s+/).join(" ");
var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR];
var set = range.split(" ").map(function(comp) {
return parseComparator(comp, this.options);
}, this).join(" ").split(/\s+/);
if (this.options.loose) {
set = set.filter(function(comp) {
return !!comp.match(compRe);
});
}
set = set.map(function(comp) {
return new Comparator(comp, this.options);
}, this);
return set;
};
Range.prototype.intersects = function(range, options) {
if (!(range instanceof Range)) {
throw new TypeError("a Range is required");
}
return this.set.some(function(thisComparators) {
return isSatisfiable(thisComparators, options) && range.set.some(function(rangeComparators) {
return isSatisfiable(rangeComparators, options) && thisComparators.every(function(thisComparator) {
return rangeComparators.every(function(rangeComparator) {
return thisComparator.intersects(rangeComparator, options);
});
});
});
});
};
function isSatisfiable(comparators, options) {
var result = true;
var remainingComparators = comparators.slice();
var testComparator = remainingComparators.pop();
while (result && remainingComparators.length) {
result = remainingComparators.every(function(otherComparator) {
return testComparator.intersects(otherComparator, options);
});
testComparator = remainingComparators.pop();
}
return result;
}
exports.toComparators = toComparators;
function toComparators(range, options) {
return new Range(range, options).set.map(function(comp) {
return comp.map(function(c) {
return c.value;
}).join(" ").trim().split(" ");
});
}
function parseComparator(comp, options) {
debug4("comp", comp, options);
comp = replaceCarets(comp, options);
debug4("caret", comp);
comp = replaceTildes(comp, options);
debug4("tildes", comp);
comp = replaceXRanges(comp, options);
debug4("xrange", comp);
comp = replaceStars(comp, options);
debug4("stars", comp);
return comp;
}
function isX(id) {
return !id || id.toLowerCase() === "x" || id === "*";
}
function replaceTildes(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceTilde(comp2, options);
}).join(" ");
}
function replaceTilde(comp, options) {
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE];
return comp.replace(r, function(_, M, m, p, pr) {
debug4("tilde", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else if (pr) {
debug4("replaceTilde pr", pr);
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
debug4("tilde return", ret);
return ret;
});
}
function replaceCarets(comp, options) {
return comp.trim().split(/\s+/).map(function(comp2) {
return replaceCaret(comp2, options);
}).join(" ");
}
function replaceCaret(comp, options) {
debug4("caret", comp, options);
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET];
return comp.replace(r, function(_, M, m, p, pr) {
debug4("caret", comp, _, M, m, p, pr);
var ret;
if (isX(M)) {
ret = "";
} else if (isX(m)) {
ret = ">=" + M + ".0.0 <" + (+M + 1) + ".0.0";
} else if (isX(p)) {
if (M === "0") {
ret = ">=" + M + "." + m + ".0 <" + M + "." + (+m + 1) + ".0";
} else {
ret = ">=" + M + "." + m + ".0 <" + (+M + 1) + ".0.0";
}
} else if (pr) {
debug4("replaceCaret pr", pr);
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + "-" + pr + " <" + (+M + 1) + ".0.0";
}
} else {
debug4("no pr");
if (M === "0") {
if (m === "0") {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + m + "." + (+p + 1);
} else {
ret = ">=" + M + "." + m + "." + p + " <" + M + "." + (+m + 1) + ".0";
}
} else {
ret = ">=" + M + "." + m + "." + p + " <" + (+M + 1) + ".0.0";
}
}
debug4("caret return", ret);
return ret;
});
}
function replaceXRanges(comp, options) {
debug4("replaceXRanges", comp, options);
return comp.split(/\s+/).map(function(comp2) {
return replaceXRange(comp2, options);
}).join(" ");
}
function replaceXRange(comp, options) {
comp = comp.trim();
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE];
return comp.replace(r, function(ret, gtlt, M, m, p, pr) {
debug4("xRange", comp, ret, gtlt, M, m, p, pr);
var xM = isX(M);
var xm = xM || isX(m);
var xp = xm || isX(p);
var anyX = xp;
if (gtlt === "=" && anyX) {
gtlt = "";
}
pr = options.includePrerelease ? "-0" : "";
if (xM) {
if (gtlt === ">" || gtlt === "<") {
ret = "<0.0.0-0";
} else {
ret = "*";
}
} else if (gtlt && anyX) {
if (xm) {
m = 0;
}
p = 0;
if (gtlt === ">") {
gtlt = ">=";
if (xm) {
M = +M + 1;
m = 0;
p = 0;
} else {
m = +m + 1;
p = 0;
}
} else if (gtlt === "<=") {
gtlt = "<";
if (xm) {
M = +M + 1;
} else {
m = +m + 1;
}
}
ret = gtlt + M + "." + m + "." + p + pr;
} else if (xm) {
ret = ">=" + M + ".0.0" + pr + " <" + (+M + 1) + ".0.0" + pr;
} else if (xp) {
ret = ">=" + M + "." + m + ".0" + pr + " <" + M + "." + (+m + 1) + ".0" + pr;
}
debug4("xRange return", ret);
return ret;
});
}
function replaceStars(comp, options) {
debug4("replaceStars", comp, options);
return comp.trim().replace(safeRe[t.STAR], "");
}
function hyphenReplace($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) {
if (isX(fM)) {
from = "";
} else if (isX(fm)) {
from = ">=" + fM + ".0.0";
} else if (isX(fp)) {
from = ">=" + fM + "." + fm + ".0";
} else {
from = ">=" + from;
}
if (isX(tM)) {
to = "";
} else if (isX(tm)) {
to = "<" + (+tM + 1) + ".0.0";
} else if (isX(tp)) {
to = "<" + tM + "." + (+tm + 1) + ".0";
} else if (tpr) {
to = "<=" + tM + "." + tm + "." + tp + "-" + tpr;
} else {
to = "<=" + to;
}
return (from + " " + to).trim();
}
Range.prototype.test = function(version2) {
if (!version2) {
return false;
}
if (typeof version2 === "string") {
try {
version2 = new SemVer(version2, this.options);
} catch (er) {
return false;
}
}
for (var i2 = 0; i2 < this.set.length; i2++) {
if (testSet(this.set[i2], version2, this.options)) {
return true;
}
}
return false;
};
function testSet(set, version2, options) {
for (var i2 = 0; i2 < set.length; i2++) {
if (!set[i2].test(version2)) {
return false;
}
}
if (version2.prerelease.length && !options.includePrerelease) {
for (i2 = 0; i2 < set.length; i2++) {
debug4(set[i2].semver);
if (set[i2].semver === ANY) {
continue;
}
if (set[i2].semver.prerelease.length > 0) {
var allowed = set[i2].semver;
if (allowed.major === version2.major && allowed.minor === version2.minor && allowed.patch === version2.patch) {
return true;
}
}
}
return false;
}
return true;
}
exports.satisfies = satisfies;
function satisfies(version2, range, options) {
try {
range = new Range(range, options);
} catch (er) {
return false;
}
return range.test(version2);
}
exports.maxSatisfying = maxSatisfying;
function maxSatisfying(versions, range, options) {
var max = null;
var maxSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!max || maxSV.compare(v) === -1) {
max = v;
maxSV = new SemVer(max, options);
}
}
});
return max;
}
exports.minSatisfying = minSatisfying;
function minSatisfying(versions, range, options) {
var min = null;
var minSV = null;
try {
var rangeObj = new Range(range, options);
} catch (er) {
return null;
}
versions.forEach(function(v) {
if (rangeObj.test(v)) {
if (!min || minSV.compare(v) === 1) {
min = v;
minSV = new SemVer(min, options);
}
}
});
return min;
}
exports.minVersion = minVersion;
function minVersion(range, loose) {
range = new Range(range, loose);
var minver = new SemVer("0.0.0");
if (range.test(minver)) {
return minver;
}
minver = new SemVer("0.0.0-0");
if (range.test(minver)) {
return minver;
}
minver = null;
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
comparators.forEach(function(comparator) {
var compver = new SemVer(comparator.semver.version);
switch (comparator.operator) {
case ">":
if (compver.prerelease.length === 0) {
compver.patch++;
} else {
compver.prerelease.push(0);
}
compver.raw = compver.format();
case "":
case ">=":
if (!minver || gt(minver, compver)) {
minver = compver;
}
break;
case "<":
case "<=":
break;
default:
throw new Error("Unexpected operation: " + comparator.operator);
}
});
}
if (minver && range.test(minver)) {
return minver;
}
return null;
}
exports.validRange = validRange;
function validRange(range, options) {
try {
return new Range(range, options).range || "*";
} catch (er) {
return null;
}
}
exports.ltr = ltr;
function ltr(version2, range, options) {
return outside(version2, range, "<", options);
}
exports.gtr = gtr;
function gtr(version2, range, options) {
return outside(version2, range, ">", options);
}
exports.outside = outside;
function outside(version2, range, hilo, options) {
version2 = new SemVer(version2, options);
range = new Range(range, options);
var gtfn, ltefn, ltfn, comp, ecomp;
switch (hilo) {
case ">":
gtfn = gt;
ltefn = lte;
ltfn = lt;
comp = ">";
ecomp = ">=";
break;
case "<":
gtfn = lt;
ltefn = gte;
ltfn = gt;
comp = "<";
ecomp = "<=";
break;
default:
throw new TypeError('Must provide a hilo val of "<" or ">"');
}
if (satisfies(version2, range, options)) {
return false;
}
for (var i2 = 0; i2 < range.set.length; ++i2) {
var comparators = range.set[i2];
var high = null;
var low = null;
comparators.forEach(function(comparator) {
if (comparator.semver === ANY) {
comparator = new Comparator(">=0.0.0");
}
high = high || comparator;
low = low || comparator;
if (gtfn(comparator.semver, high.semver, options)) {
high = comparator;
} else if (ltfn(comparator.semver, low.semver, options)) {
low = comparator;
}
});
if (high.operator === comp || high.operator === ecomp) {
return false;
}
if ((!low.operator || low.operator === comp) && ltefn(version2, low.semver)) {
return false;
} else if (low.operator === ecomp && ltfn(version2, low.semver)) {
return false;
}
}
return true;
}
exports.prerelease = prerelease;
function prerelease(version2, options) {
var parsed = parse(version2, options);
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
}
exports.intersects = intersects2;
function intersects2(r1, r2, options) {
r1 = new Range(r1, options);
r2 = new Range(r2, options);
return r1.intersects(r2);
}
exports.coerce = coerce;
function coerce(version2, options) {
if (version2 instanceof SemVer) {
return version2;
}
if (typeof version2 === "number") {
version2 = String(version2);
}
if (typeof version2 !== "string") {
return null;
}
options = options || {};
var match = null;
if (!options.rtl) {
match = version2.match(safeRe[t.COERCE]);
} else {
var next;
while ((next = safeRe[t.COERCERTL].exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
if (!match || next.index + next[0].length !== match.index + match[0].length) {
match = next;
}
safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
}
safeRe[t.COERCERTL].lastIndex = -1;
}
if (match === null) {
return null;
}
return parse(match[2] + "." + (match[3] || "0") + "." + (match[4] || "0"), options);
}
}
});
// src/index.ts
var src_exports = {};
__export(src_exports, {
build: () => build,
shouldServe: () => shouldServe,
startDevServer: () => startDevServer,
version: () => version
});
module.exports = __toCommonJS(src_exports);
var import_os2 = require("os");
var import_path3 = require("path");
var import_execa2 = __toESM(require_execa());
var import_fs_extra = __toESM(require_lib());
var import_build_utils3 = require("@vercel/build-utils");
// src/install-ruby.ts
var import_execa = __toESM(require_execa());
var import_which = __toESM(require_lib2());
var import_path = require("path");
var import_semver = __toESM(require_semver2());
var import_build_utils = require("@vercel/build-utils");
var import_child_process = require("child_process");
var import_os = require("os");
var RubyVersion = class extends import_build_utils.Version {
};
var allOptions = [
new RubyVersion({
major: 3,
minor: 3,
range: "3.3.x",
runtime: "ruby3.3"
}),
new RubyVersion({
major: 3,
minor: 2,
range: "3.2.x",
runtime: "ruby3.2"
}),
new RubyVersion({
major: 2,
minor: 7,
range: "2.7.x",
runtime: "ruby2.7",
discontinueDate: /* @__PURE__ */ new Date("2023-12-07")
}),
new RubyVersion({
major: 2,
minor: 5,
range: "2.5.x",
runtime: "ruby2.5",
discontinueDate: /* @__PURE__ */ new Date("2021-11-30")
})
];
function getLatestRubyVersion() {
const selection = allOptions.find(isInstalled);
if (!selection) {
throw new import_build_utils.NowBuildError({
code: "RUBY_INVALID_VERSION",
link: "http://vercel.link/ruby-version",
message: `Unable to find any supported Ruby versions.`
});
}
return selection;
}
function resolveSystemRuby() {
const rubyPath = import_which.default.sync("ruby", { nothrow: true });
const gemPath = import_which.default.sync("gem", { nothrow: true });
if (!rubyPath || !gemPath)
return null;
const ver = (0, import_child_process.spawnSync)(rubyPath, ["-e", "print RUBY_VERSION"], {
encoding: "utf8"
});
if (ver.status !== 0 || !ver.stdout)
return null;
const [mj, mn] = String(ver.stdout).trim().split(".");
const major = Number(mj) ?? 3;
const minor = Number(mn) ?? 3;
return { rubyPath, gemPath, major, minor };
}
function makeLocalRubyEnv({
major,
minor,
rubyPath,
gemPath
}) {
const gemHome = (0, import_path.join)((0, import_os.tmpdir)(), `vercel-ruby-${major}${minor}-${process.pid}`);
const matchedOption = allOptions.find(
(o) => o.major === major && o.minor === minor && o.state !== "discontinued"
);
if (!matchedOption) {
throw new import_build_utils.NowBuildError({
code: "RUBY_INVALID_VERSION",
link: "http://vercel.link/ruby-version",
message: `Local Ruby ${major}.${minor} does not match any supported Vercel runtime. Supported: ${allOptions.filter((o) => o.state !== "discontinued").map((o) => `${o.major}.${o.minor}`).join(", ")}`
});
}
return {
major,
gemHome,
runtime: matchedOption.runtime,
rubyPath,
gemPath,
vendorPath: `vendor/bundle/ruby/${major}.${minor}.0`
};
}
function getRubyPath(meta, gemfileContents) {
let selection = null;
try {
selection = getLatestRubyVersion();
} catch {
selection = null;
}
if (meta.isDev) {
const sys2 = resolveSystemRuby();
if (sys2) {
const result = makeLocalRubyEnv(sys2);
(0, import_build_utils.debug)(
`ruby: using system ruby for local dev: ${JSON.stringify({ ruby: sys2.rubyPath, gem: sys2.gemPath, version: `${sys2.major}.${sys2.minor}` })}`
);
return result;
}
throw new import_build_utils.NowBuildError({
code: "RUBY_INVALID_VERSION",
link: "http://vercel.link/ruby-version",
message: "Unable to find any supported Ruby versions (local). Ensure ruby and gem are on PATH."
});
} else if (gemfileContents) {
const line = gemfileContents.split("\n").find((line2) => line2.startsWith("ruby"));
if (line) {
const strVersion = line.slice(4).trim().slice(1, -1).replace(/~>\s*/, "");
const found = allOptions.some((o) => {
selection = o;
return (0, import_semver.intersects)(o.range, strVersion);
});
if (!found) {
throw new import_build_utils.NowBuildError({
code: "RUBY_INVALID_VERSION",
message: `Found \`Gemfile\` with invalid Ruby version: \`${line}.\``,
link: "http://vercel.link/ruby-version"
});
}
if (!selection || selection.state === "discontinued" || !isInstalled(selection)) {
const sys2 = resolveSystemRuby();
if (sys2) {
const sysRange = `${sys2.major}.${sys2.minor}.x`;
if (!strVersion || (0, import_semver.intersects)(sysRange, strVersion)) {
const result = makeLocalRubyEnv(sys2);
(0, import_build_utils.debug)(
`ruby: using system ruby (Gemfile) version=${sys2.major}.${sys2.minor} ruby=${sys2.rubyPath}`
);
return result;
}
}
let latest = null;
try {
latest = getLatestRubyVersion();
} catch {
}
const intro = `Found \`Gemfile\` with ${selection && selection.state === "discontinued" ? "discontinued" : "invalid"} Ruby version: \`${line}.\``;
const hint = latest ? `Please set \`ruby "~> ${latest.range}"\` in your \`Gemfile\` to use Ruby ${latest.range}.` : "Please update your `Gemfile` to use a supported Ruby version.";
throw new import_build_utils.NowBuildError({
code: selection && selection.state === "discontinued" ? "RUBY_DISCONTINUED_VERSION" : "RUBY_INVALID_VERSION",
link: "http://vercel.link/ruby-version",
message: `${intro} ${hint}`
});
}
}
}
if (selection) {
const { major, minor, runtime } = selection;
const gemHome = "/ruby" + major + minor;
const result = {
major,
gemHome,
runtime,
rubyPath: (0, import_path.join)(gemHome, "bin", "ruby"),
gemPath: (0, import_path.join)(gemHome, "bin", "gem"),
vendorPath: `vendor/bundle/ruby/${major}.${minor}.0`
};
(0, import_build_utils.debug)(JSON.stringify(result, null, " "));
return result;
}
const sys = resolveSystemRuby();
if (sys) {
const result = makeLocalRubyEnv(sys);
(0, import_build_utils.debug)(
`ruby: using system ruby (fallback) version=${sys.major}.${sys.minor} ruby=${sys.rubyPath}`
);
return result;
}
throw new import_build_utils.NowBuildError({
code: "RUBY_INVALID_VERSION",
link: "http://vercel.link/ruby-version",
message: "Unable to find any supported Ruby versions."
});
}
async function installBundler(meta, gemfileContents) {
const { gemHome, rubyPath, gemPath, vendorPath, runtime, major } = getRubyPath(meta, gemfileContents);
(0, import_build_utils.debug)("installing bundler...");
await (0, import_execa.default)(gemPath, ["install", "bundler", "--no-document"], {
stdio: "pipe",
env: {
GEM_HOME: gemHome
}
});
return {
major,
gemHome,
rubyPath,
gemPath,
vendorPath,
runtime,
bundlerPath: (0, import_path.join)(gemHome, "bin", "bundler")
};
}
function isInstalled({ major, minor }) {
const gemHome = "/ruby" + major + minor;
return Boolean(import_which.default.sync((0, import_path.join)(gemHome, "bin/ruby"), { nothrow: true })) && Boolean(import_which.default.sync((0, import_path.join)(gemHome, "bin/gem"), { nothrow: true }));
}
// src/start-dev-server.ts
var import_child_process2 = require("child_process");
var import_fs = require("fs");
var import_path2 = require("path");
var import_which2 = __toESM(require_lib2());
var import_build_utils2 = require("@vercel/build-utils");
function silenceNodeWarnings() {
const original = process.emitWarning.bind(
process
);
let active = true;
const wrapped = (warning, ...args) => {
if (!active) {
return original(
warning,
...args
);
}
return;
};
process.emitWarning = wrapped;
return () => {
if (!active)
return;
active = false;
if (process.emitWarning === wrapped) {
process.emitWarning = original;
}
};
}
var PERSISTENT_SERVERS = /* @__PURE__ */ new Map();
var PENDING_STARTS = /* @__PURE__ */ new Map();
var restoreWarnings = null;
var cleanupHandlersInstalled = false;
function installGlobalCleanupHandlers() {
if (cleanupHandlersInstalled)
return;
cleanupHandlersInstalled = true;
const killAll = () => {
for (const [key, info] of PERSISTENT_SERVERS.entries()) {
try {
process.kill(info.pid, "SIGTERM");
} catch (err) {
(0, import_build_utils2.debug)(`Error sending SIGTERM to ${info.pid}: ${err}`);
}
try {
process.kill(info.pid, "SIGKILL");
} catch (err) {
(0, import_build_utils2.debug)(`Error sending SIGKILL to ${info.pid}: ${err}`);
}
PERSISTENT_SERVERS.delete(key);
}
if (restoreWarnings) {
try {
restoreWarnings();
} catch (err) {
(0, import_build_utils2.debug)(`Error restoring warnings: ${err}`);
}
restoreWarnings = null;
}
};
process.on("SIGINT", () => {
killAll();
process.exit(130);
});
process.on("SIGTERM", () => {
killAll();
process.exit(143);
});
process.on("exit", () => {
killAll();
});
}
function createDevRubyShim(workPath, entrypoint) {
try {
const vercelRubyDir = (0, import_path2.join)(workPath, ".vercel", "ruby");
(0, import_fs.mkdirSync)(vercelRubyDir, { recursive: true });
const shimPath = (0, import_path2.join)(vercelRubyDir, `vc_init_dev.rb`);
const templatePath = (0, import_path2.join)(__dirname, "..", "vc_init_dev.rb");
const template = (0, import_fs.readFileSync)(templatePath, "utf8");
const shimSource = template.replace(/__VC_DEV_ENTRYPOINT__/g, entrypoint);
(0, import_fs.writeFileSync)(shimPath, shimSource, "utf8");
(0, import_build_utils2.debug)(`Prepared Ruby dev shim at ${shimPath}`);
return shimPath;
} catch (err) {
(0, import_build_utils2.debug)(`Failed to prepare Ruby dev shim: ${err?.message || err}`);
return null;
}
}
function detectGemfile(workPath, entrypoint) {
const entryDir = (0, import_path2.dirname)(entrypoint);
const localGemfile = (0, import_path2.join)(workPath, entryDir, "Gemfile");
if ((0, import_fs.existsSync)(localGemfile))
return localGemfile;
const rootGemfile = (0, import_path2.join)(workPath, "Gemfile");
if ((0, import_fs.existsSync)(rootGemfile))
return rootGemfile;
return null;
}
async function run(cmd, args, opts) {
return await new Promise((resolve) => {
const child = (0, import_child_process2.spawn)(cmd, args, {
cwd: opts.cwd,
env: opts.env,
stdio: ["ignore", "pipe", "pipe"]
});
child.stdout?.on("data", (buf) => process.stdout.write(buf));
child.stderr?.on("data", (buf) => process.stderr.write(buf));
child.on("close", (code, signal) => resolve({ code, signal }));
});
}
var startDevServer = async (opts) => {
const { entrypoint: rawEntrypoint, workPath, meta = {} } = opts;
if (!rawEntrypoint.endsWith(".ru")) {
return null;
}
if (!restoreWarnings)
restoreWarnings = silenceNodeWarnings();
installGlobalCleanupHandlers();
const entrypoint = rawEntrypoint;
const env = { ...process.env, ...meta.env || {} };
const serverKey = `${workPath}::${entrypoint}::ruby`;
const existing = PERSISTENT_SERVERS.get(serverKey);
if (existing) {
return {
port: existing.port,
pid: existing.pid,
shutdown: async () => {
}
};
}
const pending = PENDING_STARTS.get(serverKey);
if (pending) {
const { port, pid } = await pending;
return { port, pid, shutdown: async () => {
} };
}
let childProcess = null;
let stdoutLogListener = null;
let stderrLogListener = null;
let resolveChildReady;
let rejectChildReady;
const childReady = new Promise(
(resolve, reject) => {
resolveChildReady = resolve;
rejectChildReady = reject;
}
);
PENDING_STARTS.set(serverKey, childReady);
try {
await new Promise((resolve, reject) => {
let resolved = false;
const shimPath = createDevRubyShim(workPath, entrypoint);
if (!shimPath) {
rejectChildReady(
new import_build_utils2.NowBuildError({
code: "RUBY_DEV_SHIM_ERROR",
message: "Failed to create Ruby dev shim."
})
);
return reject(new Error("Failed to create Ruby dev shim"));
}
const gemfile = detectGemfile(workPath, entrypoint);
const bundlePath = import_which2.default.sync("bundle", { nothrow: true });
const bundlerPath = bundlePath || import_which2.default.sync("bundler", { nothrow: true });
const projectDir = gemfile ? (0, import_path2.dirname)(gemfile) : workPath;
if (gemfile) {
env.BUNDLE_GEMFILE = gemfile;
}
const checkDeps = async () => {
if (gemfile && bundlerPath) {
(0, import_build_utils2.debug)(`Running "bundle check" for ${gemfile}`);
const check = await run(
bundlerPath,
["check", "--gemfile", gemfile],
{ cwd: projectDir, env }
);
if (check.code !== 0) {
return false;
}
}
return true;
};
checkDeps().then((ok) => {
if (!ok) {
const err = new import_build_utils2.NowBuildError({
code: "RUBY_GEMS_MISSING",
message: 'Required gems are not installed. Run "vercel build" and try again.'
});
rejectChildReady(err);
return reject(err);
}
let cmd = "ruby";
let args = [shimPath];
if (gemfile && bundlerPath) {
cmd = bundlerPath;
args = ["exec", "ruby", shimPath];
}
(0, import_build_utils2.debug)(`Starting Ruby dev server: ${cmd} ${args.join(" ")}`);
const child = (0, import_child_process2.spawn)(cmd, args, {
cwd: workPath,
env,
stdio: ["inherit", "pipe", "pipe"]
});
childProcess = child;
stdoutLogListener = (buf) => {
const s = buf.toString();
for (const line of s.split(/\r?\n/)) {
if (line)
process.stdout.write(line.endsWith("\n") ? line : line + "\n");
}
};
stderrLogListener = (buf) => {
const s = buf.toString();
for (const line of s.split(/\r?\n/)) {
if (line)
process.stderr.write(line.endsWith("\n") ? line : line + "\n");
}
};
child.stdout?.on("data", stdoutLogListener);
child.stderr?.on("data", stderrLogListener);
const readinessRegexes = [
/Serving on https?:\/\/(?:\[[^\]]+\]|[^:\s]+):(\d+)/i,
/WEBrick.*?listening on.*?:(\d+)/i
];
const onDetect = (chunk) => {
const text = chunk.toString();
let portMatch = null;
for (const rx of readinessRegexes) {
const m = text.match(rx);
if (m) {
portMatch = m;
break;
}
}
if (portMatch && child.pid) {
if (!resolved) {
resolved = true;
child.stdout?.removeListener("data", onDetect);
child.stderr?.removeListener("data", onDetect);
const port2 = Number(portMatch[1]);
resolveChildReady({ port: port2, pid: child.pid });
resolve();
}
}
};
child.stdout?.on("data", onDetect);
child.stderr?.on("data", onDetect);
child.once("error", (err) => {
if (!resolved) {
rejectChildReady(err);
reject(err);
}
});
child.once("exit", (code, signal) => {
if (!resolved) {
const err = new Error(
`Ruby dev server exited before binding (code=${code}, signal=${signal})`
);
rejectChildReady(err);
reject(err);
}
});
}).catch((err) => {
if (!resolved) {
rejectChildReady(err);
reject(err);
}
});
});
const { port, pid } = await childReady;
PERSISTENT_SERVERS.set(serverKey, {
port,
pid,
child: childProcess,
stdoutLogListener,
stderrLogListener
});
const shutdown = async () => {
};
return { port, pid, shutdown };
} finally {
PENDING_STARTS.delete(serverKey);
}
};
// src/index.ts
async function matchPaths(configPatterns, workPath) {
const patterns = typeof configPatterns === "string" ? [configPatterns] : configPatterns;
if (!patterns) {
return [];
}
const patternPaths = await Promise.all(
patterns.map(async (pattern) => {
const files = await (0, import_build_utils3.glob)(pattern, workPath);
return Object.keys(files);
})
);
return patternPaths.reduce((a, b) => a.concat(b), []);
}
async function prepareGemfile(gemfilePath, major) {
let gemfile = await (0, import_fs_extra.readFile)(gemfilePath, "utf8");
let modified = false;
const patchRuby = (from, to) => {
if (gemfile.includes(from)) {
gemfile = gemfile.replace(from, to);
modified = true;
}
};
patchRuby('ruby "~> 3.3.x"', 'ruby "~> 3.3.0"');
patchRuby('ruby "~> 3.2.x"', 'ruby "~> 3.2.0"');
patchRuby('ruby "~> 2.7.x"', 'ruby "~> 2.7.0"');
const containsWebrick = /^[^#]*\bgem\s+["']webrick["']/m.test(gemfile);
if (major >= 3 && !containsWebrick) {
gemfile += `${import_os2.EOL}gem "webrick"${import_os2.EOL}`;
modified = true;
}
if (modified) {
await (0, import_fs_extra.writeFile)(gemfilePath, gemfile);
}
return { modified };
}
async function bundleLock(bundlerPath, gemfilePath, rubyPath) {
const bundleAppConfig = await (0, import_build_utils3.getWriteableDirectory)();
const bundlerEnv = (0, import_build_utils3.cloneEnv)(process.env, {
PATH: `${(0, import_path3.dirname)(rubyPath)}:${(0, import_path3.dirname)(bundlerPath)}:${process.env.PATH}`,
BUNDLE_SILENCE_ROOT_WARNING: "1",
BUNDLE_APP_CONFIG: bundleAppConfig,
BUNDLE_JOBS: "4"
});
const archTokenLinux = process.arch === "arm64" ? "aarch64" : "x86_64";
const linuxPlatform = `${archTokenLinux}-linux`;
const platforms = [linuxPlatform];
if (process.platform === "darwin") {
const darwinArchToken = process.arch === "arm64" ? "arm64" : "x86_64";
const darwinMajor = Number((0, import_os2.release)().split(".")[0]) || void 0;
const darwinPlatform = darwinMajor ? `${darwinArchToken}-darwin-${darwinMajor}` : `${darwinArchToken}-darwin`;
platforms.push(darwinPlatform);
}
(0, import_build_utils3.debug)(`ruby: ensuring Gemfile.lock has platforms ${platforms.join(", ")}`);
const lockArgs = ["lock"];
for (const platform of platforms) {
lockArgs.push("--add-platform", platform);
}
const lockRes = await (0, import_execa2.default)(bundlerPath, lockArgs, {
cwd: (0, import_path3.dirname)(gemfilePath),
stdio: "pipe",
env: bundlerEnv,
reject: false
});
if (lockRes.exitCode !== 0) {
console.log(lockRes.stdout);
console.error(lockRes.stderr);
throw lockRes;
}
}
async function bundleInstall(bundlePath, bundleDir, gemfilePath, rubyPath) {
const bundleAppConfig = await (0, import_build_utils3.getWriteableDirectory)();
const bundlerEnv = (0, import_build_utils3.cloneEnv)(process.env, {
PATH: `${(0, import_path3.dirname)(rubyPath)}:${(0, import_path3.dirname)(bundlePath)}:${process.env.PATH}`,
BUNDLE_SILENCE_ROOT_WARNING: "1",
BUNDLE_APP_CONFIG: bundleAppConfig,
BUNDLE_JOBS: "4",
BUNDLE_DEPLOYMENT: "true",
BUNDLE_PATH: bundleDir,
BUNDLE_FROZEN: "true"
});
(0, import_build_utils3.debug)('running "bundle install"');
const installRes = await (0, import_execa2.default)(
bundlePath,
["install", "--gemfile", gemfilePath],
{
stdio: "pipe",
env: bundlerEnv,
reject: false
}
);
if (installRes.exitCode !== 0) {
console.log(installRes.stdout);
console.error(installRes.stderr);
throw installRes;
}
}
var version = 3;
var build = async ({
workPath,
files,
entrypoint,
config,
meta = {}
}) => {
await (0, import_build_utils3.download)(files, workPath, meta);
const entrypointFsDirname = (0, import_path3.join)(workPath, (0, import_path3.dirname)(entrypoint));
const gemfileName = "Gemfile";
let gemfilePath = await (0, import_build_utils3.walkParentDirs)({
base: workPath,
start: entrypointFsDirname,
filename: gemfileName
});
if (!gemfilePath) {
gemfilePath = (0, import_path3.join)(entrypointFsDirname, gemfileName);
await (0, import_fs_extra.writeFile)(gemfilePath, `source "https://rubygems.org"${import_os2.EOL}`);
}
const gemfileContents = gemfilePath ? await (0, import_fs_extra.readFile)(gemfilePath, "utf8") : "";
const { gemHome, bundlerPath, vendorPath, runtime, rubyPath, major } = await installBundler(meta, gemfileContents);
process.env.GEM_HOME = gemHome;
try {
(0, import_build_utils3.debug)("preparing Gemfile");
await prepareGemfile(gemfilePath, major);
(0, import_build_utils3.debug)('running "bundle lock"');
await bundleLock(bundlerPath, gemfilePath, rubyPath);
} catch (err) {
(0, import_build_utils3.debug)(
"failed to normalize Gemfile/lockfile before vendor check",
err
);
}
(0, import_build_utils3.debug)(`Checking existing vendor directory at "${vendorPath}"`);
const vendorDir = (0, import_path3.join)(workPath, vendorPath);
const bundleDir = (0, import_path3.join)(workPath, "vendor", "bundle");
const relativeVendorDir = (0, import_path3.join)(entrypointFsDirname, vendorPath);
const hasRootVendorDir = await (0, import_fs_extra.pathExists)(vendorDir);
const hasRelativeVendorDir = await (0, import_fs_extra.pathExists)(relativeVendorDir);
if (hasRelativeVendorDir) {
if (hasRootVendorDir) {
(0, import_build_utils3.debug)(
"found two vendor directories, choosing the vendor directory relative to entrypoint"
);
} else {
(0, import_build_utils3.debug)("found vendor directory relative to entrypoint");
}
await (0, import_fs_extra.move)(relativeVendorDir, vendorDir);
} else if (hasRootVendorDir) {
(0, import_build_utils3.debug)("found vendor directory in project root");
}
await (0, import_fs_extra.ensureDir)(vendorDir);
await bundleInstall(bundlerPath, bundleDir, gemfilePath, rubyPath);
try {
await (0, import_fs_extra.remove)((0, import_path3.join)(vendorDir, "cache"));
} catch (e) {
}
const originalRbPath = (0, import_path3.join)(__dirname, "..", "vc_init.rb");
const originalHandlerRbContents = await (0, import_fs_extra.readFile)(originalRbPath, "utf8");
(0, import_build_utils3.debug)("entrypoint is", entrypoint);
const userHandlerFilePath = entrypoint.replace(/\.rb$/, "");
const nowHandlerRbContents = originalHandlerRbContents.replace(
/__VC_HANDLER_FILENAME/g,
userHandlerFilePath
);
const handlerRbFilename = "vc__handler__ruby";
const predefinedExcludes = [
".git/**",
".gitignore",
".vercel/**",
".pnpm-store/**",
"**/node_modules/**",
"**/.next/**",
"**/.nuxt/**"
];
const globOptions = {
cwd: workPath,
ignore: predefinedExcludes
};
const outputFiles = await (0, import_build_utils3.glob)("**", globOptions);
outputFiles[`${handlerRbFilename}.rb`] = new import_build_utils3.FileBlob({
data: nowHandlerRbContents
});
if (config && (config.includeFiles || config.excludeFiles)) {
const includedPaths = await matchPaths(config.includeFiles, workPath);
const excludedPaths = await matchPaths(
config.excludeFiles,
workPath
);
for (let i = 0; i < excludedPaths.length; i++) {
if (includedPaths.includes(excludedPaths[i])) {
continue;
}
if (excludedPaths[i] === `${handlerRbFilename}.rb`) {
continue;
}
if (excludedPaths[i].startsWith(vendorPath)) {
continue;
}
delete outputFiles[excludedPaths[i]];
}
}
const output = new import_build_utils3.Lambda({
files: outputFiles,
handler: `${handlerRbFilename}.vc__handler`,
runtime,
environment: {}
});
return { output };
};
var shouldServe = () => true;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
build,
shouldServe,
startDevServer,
version
});