pnpm
Version:
1,413 lines (1,380 loc) • 547 kB
JavaScript
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
// ../error/lib/index.js
var require_lib = __commonJS({
"../error/lib/index.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.FetchError = void 0;
var PnpmError = class extends Error {
constructor(code, message, opts) {
super(message);
this.code = `ERR_PNPM_${code}`;
this.hint = opts === null || opts === void 0 ? void 0 : opts.hint;
this.attempts = opts === null || opts === void 0 ? void 0 : opts.attempts;
}
};
exports2.default = PnpmError;
var FetchError = class extends PnpmError {
constructor(request, response, hint) {
const message = `GET ${request.url}: ${response.statusText} - ${response.status}`;
const authHeaderValue = request.authHeaderValue ? hideAuthInformation(request.authHeaderValue) : void 0;
if (response.status === 401 || response.status === 403 || response.status === 404) {
hint = hint ? `${hint}
` : "";
if (authHeaderValue) {
hint += `An authorization header was used: ${authHeaderValue}`;
} else {
hint += "No authorization header was set for the request.";
}
}
super(`FETCH_${response.status}`, message, { hint });
this.request = request;
this.response = response;
}
};
exports2.FetchError = FetchError;
function hideAuthInformation(authHeaderValue) {
const [authType, token] = authHeaderValue.split(" ");
return `${authType} ${token.substring(0, 4)}[hidden]`;
}
}
});
// ../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js
var require_yocto_queue = __commonJS({
"../../node_modules/.pnpm/yocto-queue@0.1.0/node_modules/yocto-queue/index.js"(exports2, module2) {
var Node = class {
constructor(value) {
this.value = value;
this.next = void 0;
}
};
var Queue = class {
constructor() {
this.clear();
}
enqueue(value) {
const node = new Node(value);
if (this._head) {
this._tail.next = node;
this._tail = node;
} else {
this._head = node;
this._tail = node;
}
this._size++;
}
dequeue() {
const current = this._head;
if (!current) {
return;
}
this._head = this._head.next;
this._size--;
return current.value;
}
clear() {
this._head = void 0;
this._tail = void 0;
this._size = 0;
}
get size() {
return this._size;
}
*[Symbol.iterator]() {
let current = this._head;
while (current) {
yield current.value;
current = current.next;
}
}
};
module2.exports = Queue;
}
});
// ../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js
var require_p_limit = __commonJS({
"../../node_modules/.pnpm/p-limit@3.1.0/node_modules/p-limit/index.js"(exports2, module2) {
"use strict";
var Queue = require_yocto_queue();
var pLimit = (concurrency) => {
if (!((Number.isInteger(concurrency) || concurrency === Infinity) && concurrency > 0)) {
throw new TypeError("Expected `concurrency` to be a number from 1 and up");
}
const queue = new Queue();
let activeCount = 0;
const next = () => {
activeCount--;
if (queue.size > 0) {
queue.dequeue()();
}
};
const run = async (fn, resolve, ...args) => {
activeCount++;
const result = (async () => fn(...args))();
resolve(result);
try {
await result;
} catch {
}
next();
};
const enqueue = (fn, resolve, ...args) => {
queue.enqueue(run.bind(null, fn, resolve, ...args));
(async () => {
await Promise.resolve();
if (activeCount < concurrency && queue.size > 0) {
queue.dequeue()();
}
})();
};
const generator = (fn, ...args) => new Promise((resolve) => {
enqueue(fn, resolve, ...args);
});
Object.defineProperties(generator, {
activeCount: {
get: () => activeCount
},
pendingCount: {
get: () => queue.size
},
clearQueue: {
value: () => {
queue.clear();
}
}
});
return generator;
};
module2.exports = pLimit;
}
});
// ../../node_modules/.pnpm/p-locate@5.0.0/node_modules/p-locate/index.js
var require_p_locate = __commonJS({
"../../node_modules/.pnpm/p-locate@5.0.0/node_modules/p-locate/index.js"(exports2, module2) {
"use strict";
var pLimit = require_p_limit();
var EndError = class extends Error {
constructor(value) {
super();
this.value = value;
}
};
var testElement = async (element, tester) => tester(await element);
var finder = async (element) => {
const values = await Promise.all(element);
if (values[1] === true) {
throw new EndError(values[0]);
}
return false;
};
var pLocate = async (iterable, tester, options) => {
options = {
concurrency: Infinity,
preserveOrder: true,
...options
};
const limit = pLimit(options.concurrency);
const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
try {
await Promise.all(items.map((element) => checkLimit(finder, element)));
} catch (error) {
if (error instanceof EndError) {
return error.value;
}
throw error;
}
};
module2.exports = pLocate;
}
});
// ../../node_modules/.pnpm/locate-path@6.0.0/node_modules/locate-path/index.js
var require_locate_path = __commonJS({
"../../node_modules/.pnpm/locate-path@6.0.0/node_modules/locate-path/index.js"(exports2, module2) {
"use strict";
var path = require("path");
var fs = require("fs");
var { promisify } = require("util");
var pLocate = require_p_locate();
var fsStat = promisify(fs.stat);
var fsLStat = promisify(fs.lstat);
var typeMappings = {
directory: "isDirectory",
file: "isFile"
};
function checkType({ type }) {
if (type in typeMappings) {
return;
}
throw new Error(`Invalid type specified: ${type}`);
}
var matchType = (type, stat) => type === void 0 || stat[typeMappings[type]]();
module2.exports = async (paths, options) => {
options = {
cwd: process.cwd(),
type: "file",
allowSymlinks: true,
...options
};
checkType(options);
const statFn = options.allowSymlinks ? fsStat : fsLStat;
return pLocate(paths, async (path_) => {
try {
const stat = await statFn(path.resolve(options.cwd, path_));
return matchType(options.type, stat);
} catch {
return false;
}
}, options);
};
module2.exports.sync = (paths, options) => {
options = {
cwd: process.cwd(),
allowSymlinks: true,
type: "file",
...options
};
checkType(options);
const statFn = options.allowSymlinks ? fs.statSync : fs.lstatSync;
for (const path_ of paths) {
try {
const stat = statFn(path.resolve(options.cwd, path_));
if (matchType(options.type, stat)) {
return path_;
}
} catch {
}
}
};
}
});
// ../../node_modules/.pnpm/path-exists@4.0.0/node_modules/path-exists/index.js
var require_path_exists = __commonJS({
"../../node_modules/.pnpm/path-exists@4.0.0/node_modules/path-exists/index.js"(exports2, module2) {
"use strict";
var fs = require("fs");
var { promisify } = require("util");
var pAccess = promisify(fs.access);
module2.exports = async (path) => {
try {
await pAccess(path);
return true;
} catch (_) {
return false;
}
};
module2.exports.sync = (path) => {
try {
fs.accessSync(path);
return true;
} catch (_) {
return false;
}
};
}
});
// ../../node_modules/.pnpm/find-up@5.0.0/node_modules/find-up/index.js
var require_find_up = __commonJS({
"../../node_modules/.pnpm/find-up@5.0.0/node_modules/find-up/index.js"(exports2, module2) {
"use strict";
var path = require("path");
var locatePath = require_locate_path();
var pathExists = require_path_exists();
var stop = Symbol("findUp.stop");
module2.exports = async (name, options = {}) => {
let directory = path.resolve(options.cwd || "");
const { root } = path.parse(directory);
const paths = [].concat(name);
const runMatcher = async (locateOptions) => {
if (typeof name !== "function") {
return locatePath(paths, locateOptions);
}
const foundPath = await name(locateOptions.cwd);
if (typeof foundPath === "string") {
return locatePath([foundPath], locateOptions);
}
return foundPath;
};
while (true) {
const foundPath = await runMatcher({ ...options, cwd: directory });
if (foundPath === stop) {
return;
}
if (foundPath) {
return path.resolve(directory, foundPath);
}
if (directory === root) {
return;
}
directory = path.dirname(directory);
}
};
module2.exports.sync = (name, options = {}) => {
let directory = path.resolve(options.cwd || "");
const { root } = path.parse(directory);
const paths = [].concat(name);
const runMatcher = (locateOptions) => {
if (typeof name !== "function") {
return locatePath.sync(paths, locateOptions);
}
const foundPath = name(locateOptions.cwd);
if (typeof foundPath === "string") {
return locatePath.sync([foundPath], locateOptions);
}
return foundPath;
};
while (true) {
const foundPath = runMatcher({ ...options, cwd: directory });
if (foundPath === stop) {
return;
}
if (foundPath) {
return path.resolve(directory, foundPath);
}
if (directory === root) {
return;
}
directory = path.dirname(directory);
}
};
module2.exports.exists = pathExists;
module2.exports.sync.exists = pathExists.sync;
module2.exports.stop = stop;
}
});
// ../find-workspace-dir/lib/index.js
var require_lib2 = __commonJS({
"../find-workspace-dir/lib/index.js"(exports2) {
"use strict";
var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
Object.defineProperty(exports2, "__esModule", { value: true });
var path_12 = __importDefault2(require("path"));
var error_1 = __importDefault2(require_lib());
var find_up_1 = __importDefault2(require_find_up());
var WORKSPACE_DIR_ENV_VAR = "NPM_CONFIG_WORKSPACE_DIR";
var WORKSPACE_MANIFEST_FILENAME = "pnpm-workspace.yaml";
async function findWorkspaceDir(cwd) {
var _a;
const workspaceManifestDirEnvVar = (_a = process.env[WORKSPACE_DIR_ENV_VAR]) !== null && _a !== void 0 ? _a : process.env[WORKSPACE_DIR_ENV_VAR.toLowerCase()];
const workspaceManifestLocation = workspaceManifestDirEnvVar ? path_12.default.join(workspaceManifestDirEnvVar, "pnpm-workspace.yaml") : await (0, find_up_1.default)([WORKSPACE_MANIFEST_FILENAME, "pnpm-workspace.yml"], { cwd });
if (workspaceManifestLocation === null || workspaceManifestLocation === void 0 ? void 0 : workspaceManifestLocation.endsWith(".yml")) {
throw new error_1.default("BAD_WORKSPACE_MANIFEST_NAME", `The workspace manifest file should be named "pnpm-workspace.yaml". File found: ${workspaceManifestLocation}`);
}
return workspaceManifestLocation && path_12.default.dirname(workspaceManifestLocation);
}
exports2.default = findWorkspaceDir;
}
});
// ../../node_modules/.pnpm/@zkochan+rimraf@2.1.1/node_modules/@zkochan/rimraf/index.js
var require_rimraf = __commonJS({
"../../node_modules/.pnpm/@zkochan+rimraf@2.1.1/node_modules/@zkochan/rimraf/index.js"(exports2, module2) {
var fs = require("fs");
var rm = fs.promises.rm ? fs.promises.rm : fs.promises.rmdir;
var rmdirSync = fs.rmSync ? fs.rmSync : fs.rmdirSync;
module2.exports = async (p) => {
try {
await rm(p, { recursive: true, maxRetries: 3 });
} catch (err) {
if (err.code === "ENOTDIR" || err.code === "ENOENT")
return;
throw err;
}
};
module2.exports.sync = (p) => {
try {
rmdirSync(p, { recursive: true, maxRetries: 3 });
} catch (err) {
if (err.code === "ENOTDIR" || err.code === "ENOENT")
return;
throw err;
}
};
}
});
// ../../node_modules/.pnpm/can-link@2.0.0/node_modules/can-link/index.js
var require_can_link = __commonJS({
"../../node_modules/.pnpm/can-link@2.0.0/node_modules/can-link/index.js"(exports2, module2) {
"use strict";
var defaultFS = require("fs");
module2.exports = async (existingPath, newPath, customFS) => {
const fs = customFS || defaultFS;
try {
await fs.promises.link(existingPath, newPath);
fs.promises.unlink(newPath).catch(() => {
});
return true;
} catch (err) {
if (err.code === "EXDEV" || err.code === "EACCES" || err.code === "EPERM") {
return false;
}
throw err;
}
};
module2.exports.sync = (existingPath, newPath, customFS) => {
const fs = customFS || defaultFS;
try {
fs.linkSync(existingPath, newPath);
fs.unlinkSync(newPath);
return true;
} catch (err) {
if (err.code === "EXDEV" || err.code === "EACCES" || err.code === "EPERM") {
return false;
}
throw err;
}
};
}
});
// ../../node_modules/.pnpm/path-absolute@1.0.1/node_modules/path-absolute/index.js
var require_path_absolute = __commonJS({
"../../node_modules/.pnpm/path-absolute@1.0.1/node_modules/path-absolute/index.js"(exports2, module2) {
"use strict";
var os = require("os");
var path = require("path");
module2.exports = function(filepath, cwd) {
const home = getHomedir();
if (isHomepath(filepath)) {
return path.join(home, filepath.substr(2));
}
if (path.isAbsolute(filepath)) {
return filepath;
}
if (cwd) {
return path.join(cwd, filepath);
}
return path.resolve(filepath);
};
function getHomedir() {
const home = os.homedir();
if (!home)
throw new Error("Could not find the homedir");
return home;
}
function isHomepath(filepath) {
return filepath.indexOf("~/") === 0 || filepath.indexOf("~\\") === 0;
}
}
});
// ../../node_modules/.pnpm/crypto-random-string@2.0.0/node_modules/crypto-random-string/index.js
var require_crypto_random_string = __commonJS({
"../../node_modules/.pnpm/crypto-random-string@2.0.0/node_modules/crypto-random-string/index.js"(exports2, module2) {
"use strict";
var crypto = require("crypto");
module2.exports = (length) => {
if (!Number.isFinite(length)) {
throw new TypeError("Expected a finite number");
}
return crypto.randomBytes(Math.ceil(length / 2)).toString("hex").slice(0, length);
};
}
});
// ../../node_modules/.pnpm/unique-string@2.0.0/node_modules/unique-string/index.js
var require_unique_string = __commonJS({
"../../node_modules/.pnpm/unique-string@2.0.0/node_modules/unique-string/index.js"(exports2, module2) {
"use strict";
var cryptoRandomString = require_crypto_random_string();
module2.exports = () => cryptoRandomString(32);
}
});
// ../../node_modules/.pnpm/path-temp@2.0.0/node_modules/path-temp/index.js
var require_path_temp = __commonJS({
"../../node_modules/.pnpm/path-temp@2.0.0/node_modules/path-temp/index.js"(exports2, module2) {
"use strict";
var path = require("path");
var uniqueString = require_unique_string();
module2.exports = function pathTemp(folder) {
return path.join(folder, `_tmp_${process.pid}_${uniqueString()}`);
};
}
});
// ../../node_modules/.pnpm/next-path@1.0.0/node_modules/next-path/index.js
var require_next_path = __commonJS({
"../../node_modules/.pnpm/next-path@1.0.0/node_modules/next-path/index.js"(exports2, module2) {
"use strict";
var path = require("path");
var nextPath = (from, to) => {
const diff = path.relative(from, to);
const sepIndex = diff.indexOf(path.sep);
const next = sepIndex >= 0 ? diff.substring(0, sepIndex) : diff;
return path.join(from, next);
};
module2.exports = nextPath;
}
});
// ../../node_modules/.pnpm/root-link-target@3.1.0/node_modules/root-link-target/index.js
var require_root_link_target = __commonJS({
"../../node_modules/.pnpm/root-link-target@3.1.0/node_modules/root-link-target/index.js"(exports2, module2) {
"use strict";
var canLink = require_can_link();
var path = require("path");
var pathTemp = require_path_temp();
var nextPath = require_next_path();
module2.exports = async (filePath) => {
filePath = path.resolve(filePath);
const end = path.dirname(filePath);
let dir = path.parse(end).root;
while (true) {
const result = await canLink(filePath, pathTemp(dir));
if (result) {
return dir;
} else if (dir === end) {
throw new Error(`${filePath} cannot be linked to anywhere`);
} else {
dir = nextPath(dir, end);
}
}
};
module2.exports.sync = (filePath) => {
filePath = path.resolve(filePath);
const end = path.dirname(filePath);
let dir = path.parse(end).root;
while (true) {
const result = canLink.sync(filePath, pathTemp(dir));
if (result) {
return dir;
} else if (dir === end) {
throw new Error(`${filePath} cannot be linked to anywhere`);
} else {
dir = nextPath(dir, end);
}
}
};
}
});
// ../../node_modules/.pnpm/touch@3.1.0/node_modules/touch/index.js
var require_touch = __commonJS({
"../../node_modules/.pnpm/touch@3.1.0/node_modules/touch/index.js"(exports2, module2) {
"use strict";
var EE = require("events").EventEmitter;
var cons = require("constants");
var fs = require("fs");
module2.exports = (f, options, cb) => {
if (typeof options === "function")
cb = options, options = {};
const p = new Promise((res, rej) => {
new Touch(validOpts(options, f, null)).on("done", res).on("error", rej);
});
return cb ? p.then((res) => cb(null, res), cb) : p;
};
module2.exports.sync = module2.exports.touchSync = (f, options) => (new TouchSync(validOpts(options, f, null)), void 0);
module2.exports.ftouch = (fd, options, cb) => {
if (typeof options === "function")
cb = options, options = {};
const p = new Promise((res, rej) => {
new Touch(validOpts(options, null, fd)).on("done", res).on("error", rej);
});
return cb ? p.then((res) => cb(null, res), cb) : p;
};
module2.exports.ftouchSync = (fd, opt) => (new TouchSync(validOpts(opt, null, fd)), void 0);
var validOpts = (options, path, fd) => {
options = Object.create(options || {});
options.fd = fd;
options.path = path;
const now = parseInt(new Date(options.time || Date.now()).getTime() / 1e3);
if (!options.atime && !options.mtime)
options.atime = options.mtime = now;
else {
if (options.atime === true)
options.atime = now;
if (options.mtime === true)
options.mtime = now;
}
let oflags = 0;
if (!options.force)
oflags = oflags | cons.O_RDWR;
if (!options.nocreate)
oflags = oflags | cons.O_CREAT;
options.oflags = oflags;
return options;
};
var Touch = class extends EE {
constructor(options) {
super(options);
this.fd = options.fd;
this.path = options.path;
this.atime = options.atime;
this.mtime = options.mtime;
this.ref = options.ref;
this.nocreate = !!options.nocreate;
this.force = !!options.force;
this.closeAfter = options.closeAfter;
this.oflags = options.oflags;
this.options = options;
if (typeof this.fd !== "number") {
this.closeAfter = true;
this.open();
} else
this.onopen(null, this.fd);
}
emit(ev, data) {
this.close();
return super.emit(ev, data);
}
close() {
if (typeof this.fd === "number" && this.closeAfter)
fs.close(this.fd, () => {
});
}
open() {
fs.open(this.path, this.oflags, (er, fd) => this.onopen(er, fd));
}
onopen(er, fd) {
if (er) {
if (er.code === "EISDIR")
this.onopen(null, null);
else if (er.code === "ENOENT" && this.nocreate)
this.emit("done");
else
this.emit("error", er);
} else {
this.fd = fd;
if (this.ref)
this.statref();
else if (!this.atime || !this.mtime)
this.fstat();
else
this.futimes();
}
}
statref() {
fs.stat(this.ref, (er, st) => {
if (er)
this.emit("error", er);
else
this.onstatref(st);
});
}
onstatref(st) {
this.atime = this.atime && parseInt(st.atime.getTime() / 1e3, 10);
this.mtime = this.mtime && parseInt(st.mtime.getTime() / 1e3, 10);
if (!this.atime || !this.mtime)
this.fstat();
else
this.futimes();
}
fstat() {
const stat = this.fd ? "fstat" : "stat";
const target = this.fd || this.path;
fs[stat](target, (er, st) => {
if (er)
this.emit("error", er);
else
this.onfstat(st);
});
}
onfstat(st) {
if (typeof this.atime !== "number")
this.atime = parseInt(st.atime.getTime() / 1e3, 10);
if (typeof this.mtime !== "number")
this.mtime = parseInt(st.mtime.getTime() / 1e3, 10);
this.futimes();
}
futimes() {
const utimes = this.fd ? "futimes" : "utimes";
const target = this.fd || this.path;
fs[utimes](target, "" + this.atime, "" + this.mtime, (er) => {
if (er)
this.emit("error", er);
else
this.emit("done");
});
}
};
var TouchSync = class extends Touch {
open() {
try {
this.onopen(null, fs.openSync(this.path, this.oflags));
} catch (er) {
this.onopen(er);
}
}
statref() {
let threw = true;
try {
this.onstatref(fs.statSync(this.ref));
threw = false;
} finally {
if (threw)
this.close();
}
}
fstat() {
let threw = true;
const stat = this.fd ? "fstatSync" : "statSync";
const target = this.fd || this.path;
try {
this.onfstat(fs[stat](target));
threw = false;
} finally {
if (threw)
this.close();
}
}
futimes() {
let threw = true;
const utimes = this.fd ? "futimesSync" : "utimesSync";
const target = this.fd || this.path;
try {
fs[utimes](target, this.atime, this.mtime);
threw = false;
} finally {
if (threw)
this.close();
}
this.emit("done");
}
close() {
if (typeof this.fd === "number" && this.closeAfter)
try {
fs.closeSync(this.fd);
} catch (er) {
}
}
};
}
});
// ../../node_modules/.pnpm/@pnpm+store-path@5.0.0/node_modules/@pnpm/store-path/lib/index.js
var require_lib3 = __commonJS({
"../../node_modules/.pnpm/@pnpm+store-path@5.0.0/node_modules/@pnpm/store-path/lib/index.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
var fs_1 = require("fs");
var rimraf = require_rimraf();
var canLink = require_can_link();
var os = require("os");
var path = require("path");
var pathAbsolute = require_path_absolute();
var pathTemp = require_path_temp();
var rootLinkTarget = require_root_link_target();
var touch = require_touch();
var STORE_VERSION = "v3";
async function default_1(pkgRoot, storePath) {
if (!storePath || isHomepath(storePath)) {
const relStorePath = storePath ? storePath.substr(2) : ".pnpm-store";
return await storePathRelativeToHome(pkgRoot, relStorePath);
}
const storeBasePath = pathAbsolute(storePath, pkgRoot);
if (storeBasePath.endsWith(`${path.sep}${STORE_VERSION}`)) {
return storeBasePath;
}
return path.join(storeBasePath, STORE_VERSION);
}
exports2.default = default_1;
async function storePathRelativeToHome(pkgRoot, relStore) {
const tempFile = pathTemp(pkgRoot);
await fs_1.promises.mkdir(path.dirname(tempFile), { recursive: true });
await touch(tempFile);
const homedir = getHomedir();
if (await canLinkToSubdir(tempFile, homedir)) {
await fs_1.promises.unlink(tempFile);
return path.join(homedir, relStore, STORE_VERSION);
}
try {
let mountpoint = await rootLinkTarget(tempFile);
const mountpointParent = path.join(mountpoint, "..");
if (!dirsAreEqual(mountpointParent, mountpoint) && await canLinkToSubdir(tempFile, mountpointParent)) {
mountpoint = mountpointParent;
}
if (dirsAreEqual(pkgRoot, mountpoint)) {
return path.join(homedir, relStore, STORE_VERSION);
}
return path.join(mountpoint, relStore, STORE_VERSION);
} catch (err) {
return path.join(homedir, relStore, STORE_VERSION);
} finally {
await fs_1.promises.unlink(tempFile);
}
}
async function canLinkToSubdir(fileToLink, dir) {
let result = false;
const tmpDir = pathTemp(dir);
try {
await fs_1.promises.mkdir(tmpDir, { recursive: true });
result = await canLink(fileToLink, pathTemp(tmpDir));
} catch (err) {
result = false;
} finally {
await safeRmdir(tmpDir);
}
return result;
}
async function safeRmdir(dir) {
try {
await rimraf(dir);
} catch (err) {
}
}
function dirsAreEqual(dir1, dir2) {
return path.relative(dir1, dir2) === ".";
}
function getHomedir() {
const home = os.homedir();
if (!home)
throw new Error("Could not find the homedir");
return home;
}
function isHomepath(filepath) {
return filepath.indexOf("~/") === 0 || filepath.indexOf("~\\") === 0;
}
}
});
// ../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js
var require_safe_buffer = __commonJS({
"../../node_modules/.pnpm/safe-buffer@5.2.1/node_modules/safe-buffer/index.js"(exports2, module2) {
var buffer = require("buffer");
var Buffer2 = buffer.Buffer;
function copyProps(src, dst) {
for (var key in src) {
dst[key] = src[key];
}
}
if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
module2.exports = buffer;
} else {
copyProps(buffer, exports2);
exports2.Buffer = SafeBuffer;
}
function SafeBuffer(arg, encodingOrOffset, length) {
return Buffer2(arg, encodingOrOffset, length);
}
SafeBuffer.prototype = Object.create(Buffer2.prototype);
copyProps(Buffer2, SafeBuffer);
SafeBuffer.from = function(arg, encodingOrOffset, length) {
if (typeof arg === "number") {
throw new TypeError("Argument must not be a number");
}
return Buffer2(arg, encodingOrOffset, length);
};
SafeBuffer.alloc = function(size, fill, encoding) {
if (typeof size !== "number") {
throw new TypeError("Argument must be a number");
}
var buf = Buffer2(size);
if (fill !== void 0) {
if (typeof encoding === "string") {
buf.fill(fill, encoding);
} else {
buf.fill(fill);
}
} else {
buf.fill(0);
}
return buf;
};
SafeBuffer.allocUnsafe = function(size) {
if (typeof size !== "number") {
throw new TypeError("Argument must be a number");
}
return Buffer2(size);
};
SafeBuffer.allocUnsafeSlow = function(size) {
if (typeof size !== "number") {
throw new TypeError("Argument must be a number");
}
return buffer.SlowBuffer(size);
};
}
});
// ../../node_modules/.pnpm/@zkochan+libnpx@13.1.5/node_modules/@zkochan/libnpx/util.js
var require_util = __commonJS({
"../../node_modules/.pnpm/@zkochan+libnpx@13.1.5/node_modules/@zkochan/libnpx/util.js"(exports2, module2) {
"use strict";
module2.exports.promisify = promisify;
function promisify(f) {
const util = require("util");
if (util.promisify) {
return util.promisify(f);
} else {
return function() {
return new Promise((resolve, reject) => {
f.apply(this, [].slice.call(arguments).concat((err, val) => {
err ? reject(err) : resolve(val);
}));
});
};
}
}
}
});
// ../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/common-types.js
var require_common_types = __commonJS({
"../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/common-types.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.objectKeys = exports2.assertSingleKey = exports2.assertNotStrictEqual = void 0;
var assert_1 = require("assert");
function assertNotStrictEqual(actual, expected, message) {
assert_1.notStrictEqual(actual, expected, message);
}
exports2.assertNotStrictEqual = assertNotStrictEqual;
function assertSingleKey(actual) {
assert_1.strictEqual(typeof actual, "string");
}
exports2.assertSingleKey = assertSingleKey;
function objectKeys(object) {
return Object.keys(object);
}
exports2.objectKeys = objectKeys;
}
});
// ../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/is-promise.js
var require_is_promise = __commonJS({
"../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/is-promise.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.isPromise = void 0;
function isPromise(maybePromise) {
return !!maybePromise && !!maybePromise.then && typeof maybePromise.then === "function";
}
exports2.isPromise = isPromise;
}
});
// ../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/yerror.js
var require_yerror = __commonJS({
"../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/yerror.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.YError = void 0;
var YError = class extends Error {
constructor(msg) {
super(msg || "yargs error");
this.name = "YError";
Error.captureStackTrace(this, YError);
}
};
exports2.YError = YError;
}
});
// ../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/parse-command.js
var require_parse_command = __commonJS({
"../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/parse-command.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.parseCommand = void 0;
function parseCommand(cmd) {
const extraSpacesStrippedCommand = cmd.replace(/\s{2,}/g, " ");
const splitCommand = extraSpacesStrippedCommand.split(/\s+(?![^[]*]|[^<]*>)/);
const bregex = /\.*[\][<>]/g;
const firstCommand = splitCommand.shift();
if (!firstCommand)
throw new Error(`No command found in: ${cmd}`);
const parsedCommand = {
cmd: firstCommand.replace(bregex, ""),
demanded: [],
optional: []
};
splitCommand.forEach((cmd2, i) => {
let variadic = false;
cmd2 = cmd2.replace(/\s/g, "");
if (/\.+[\]>]/.test(cmd2) && i === splitCommand.length - 1)
variadic = true;
if (/^\[/.test(cmd2)) {
parsedCommand.optional.push({
cmd: cmd2.replace(bregex, "").split("|"),
variadic
});
} else {
parsedCommand.demanded.push({
cmd: cmd2.replace(bregex, "").split("|"),
variadic
});
}
});
return parsedCommand;
}
exports2.parseCommand = parseCommand;
}
});
// ../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/argsert.js
var require_argsert = __commonJS({
"../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/argsert.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.argsert = void 0;
var yerror_1 = require_yerror();
var parse_command_1 = require_parse_command();
var positionName = ["first", "second", "third", "fourth", "fifth", "sixth"];
function argsert(arg1, arg2, arg3) {
function parseArgs() {
return typeof arg1 === "object" ? [{ demanded: [], optional: [] }, arg1, arg2] : [parse_command_1.parseCommand(`cmd ${arg1}`), arg2, arg3];
}
try {
let position = 0;
let [parsed, callerArguments, length] = parseArgs();
const args = [].slice.call(callerArguments);
while (args.length && args[args.length - 1] === void 0)
args.pop();
length = length || args.length;
if (length < parsed.demanded.length) {
throw new yerror_1.YError(`Not enough arguments provided. Expected ${parsed.demanded.length} but received ${args.length}.`);
}
const totalCommands = parsed.demanded.length + parsed.optional.length;
if (length > totalCommands) {
throw new yerror_1.YError(`Too many arguments provided. Expected max ${totalCommands} but received ${length}.`);
}
parsed.demanded.forEach((demanded) => {
const arg = args.shift();
const observedType = guessType(arg);
const matchingTypes = demanded.cmd.filter((type) => type === observedType || type === "*");
if (matchingTypes.length === 0)
argumentTypeError(observedType, demanded.cmd, position);
position += 1;
});
parsed.optional.forEach((optional) => {
if (args.length === 0)
return;
const arg = args.shift();
const observedType = guessType(arg);
const matchingTypes = optional.cmd.filter((type) => type === observedType || type === "*");
if (matchingTypes.length === 0)
argumentTypeError(observedType, optional.cmd, position);
position += 1;
});
} catch (err) {
console.warn(err.stack);
}
}
exports2.argsert = argsert;
function guessType(arg) {
if (Array.isArray(arg)) {
return "array";
} else if (arg === null) {
return "null";
}
return typeof arg;
}
function argumentTypeError(observedType, allowedTypes, position) {
throw new yerror_1.YError(`Invalid ${positionName[position] || "manyith"} argument. Expected ${allowedTypes.join(" or ")} but received ${observedType}.`);
}
}
});
// ../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/middleware.js
var require_middleware = __commonJS({
"../../node_modules/.pnpm/yargs@15.4.1/node_modules/yargs/build/lib/middleware.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
exports2.applyMiddleware = exports2.commandMiddlewareFactory = exports2.globalMiddlewareFactory = void 0;
var argsert_1 = require_argsert();
var is_promise_1 = require_is_promise();
function globalMiddlewareFactory(globalMiddleware, context) {
return function(callback, applyBeforeValidation = false) {
argsert_1.argsert("<array|function> [boolean]", [callback, applyBeforeValidation], arguments.length);
if (Array.isArray(callback)) {
for (let i = 0; i < callback.length; i++) {
if (typeof callback[i] !== "function") {
throw Error("middleware must be a function");
}
callback[i].applyBeforeValidation = applyBeforeValidation;
}
Array.prototype.push.apply(globalMiddleware, callback);
} else if (typeof callback === "function") {
callback.applyBeforeValidation = applyBeforeValidation;
globalMiddleware.push(callback);
}
return context;
};
}
exports2.globalMiddlewareFactory = globalMiddlewareFactory;
function commandMiddlewareFactory(commandMiddleware) {
if (!commandMiddleware)
return [];
return commandMiddleware.map((middleware) => {
middleware.applyBeforeValidation = false;
return middleware;
});
}
exports2.commandMiddlewareFactory = commandMiddlewareFactory;
function applyMiddleware(argv, yargs, middlewares, beforeValidation) {
const beforeValidationError = new Error("middleware cannot return a promise when applyBeforeValidation is true");
return middlewares.reduce((acc, middleware) => {
if (middleware.applyBeforeValidation !== beforeValidation) {
return acc;
}
if (is_promise_1.isPromise(acc)) {
return acc.then((initialObj) => Promise.all([initialObj, middleware(initialObj, yargs)])).then(([initialObj, middlewareObj]) => Object.assign(initialObj, middlewareObj));
} else {
const result = middleware(acc, yargs);
if (beforeValidation && is_promise_1.isPromise(result))
throw beforeValidationError;
return is_promise_1.isPromise(result) ? result.then((middlewareObj) => Object.assign(acc, middlewareObj)) : Object.assign(acc, result);
}
}, argv);
}
exports2.applyMiddleware = applyMiddleware;
}
});
// ../../node_modules/.pnpm/require-directory@2.1.1/node_modules/require-directory/index.js
var require_require_directory = __commonJS({
"../../node_modules/.pnpm/require-directory@2.1.1/node_modules/require-directory/index.js"(exports2, module2) {
"use strict";
var fs = require("fs");
var join = require("path").join;
var resolve = require("path").resolve;
var dirname = require("path").dirname;
var defaultOptions = {
extensions: ["js", "json", "coffee"],
recurse: true,
rename: function(name) {
return name;
},
visit: function(obj) {
return obj;
}
};
function checkFileInclusion(path, filename, options) {
return new RegExp("\\.(" + options.extensions.join("|") + ")$", "i").test(filename) && !(options.include && options.include instanceof RegExp && !options.include.test(path)) && !(options.include && typeof options.include === "function" && !options.include(path, filename)) && !(options.exclude && options.exclude instanceof RegExp && options.exclude.test(path)) && !(options.exclude && typeof options.exclude === "function" && options.exclude(path, filename));
}
function requireDirectory(m, path, options) {
var retval = {};
if (path && !options && typeof path !== "string") {
options = path;
path = null;
}
options = options || {};
for (var prop in defaultOptions) {
if (typeof options[prop] === "undefined") {
options[prop] = defaultOptions[prop];
}
}
path = !path ? dirname(m.filename) : resolve(dirname(m.filename), path);
fs.readdirSync(path).forEach(function(filename) {
var joined = join(path, filename), files, key, obj;
if (fs.statSync(joined).isDirectory() && options.recurse) {
files = requireDirectory(m, joined, options);
if (Object.keys(files).length) {
retval[options.rename(filename, joined, filename)] = files;
}
} else {
if (joined !== m.filename && checkFileInclusion(joined, filename, options)) {
key = filename.substring(0, filename.lastIndexOf("."));
obj = m.require(joined);
retval[options.rename(key, joined, filename)] = options.visit(obj, joined, filename) || obj;
}
}
});
return retval;
}
module2.exports = requireDirectory;
module2.exports.defaults = defaultOptions;
}
});
// ../../node_modules/.pnpm/which-module@2.0.0/node_modules/which-module/index.js
var require_which_module = __commonJS({
"../../node_modules/.pnpm/which-module@2.0.0/node_modules/which-module/index.js"(exports2, module2) {
"use strict";
module2.exports = function whichModule(exported) {
for (var i = 0, files = Object.keys(require.cache), mod; i < files.length; i++) {
mod = require.cache[files[i]];
if (mod.exports === exported)
return mod;
}
return null;
};
}
});
// ../../node_modules/.pnpm/camelcase@5.3.1/node_modules/camelcase/index.js
var require_camelcase = __commonJS({
"../../node_modules/.pnpm/camelcase@5.3.1/node_modules/camelcase/index.js"(exports2, module2) {
"use strict";
var preserveCamelCase = (string) => {
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
for (let i = 0; i < string.length; i++) {
const character = string[i];
if (isLastCharLower && /[a-zA-Z]/.test(character) && character.toUpperCase() === character) {
string = string.slice(0, i) + "-" + string.slice(i);
isLastCharLower = false;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = true;
i++;
} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(character) && character.toLowerCase() === character) {
string = string.slice(0, i - 1) + "-" + string.slice(i - 1);
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = false;
isLastCharLower = true;
} else {
isLastCharLower = character.toLowerCase() === character && character.toUpperCase() !== character;
isLastLastCharUpper = isLastCharUpper;
isLastCharUpper = character.toUpperCase() === character && character.toLowerCase() !== character;
}
}
return string;
};
var camelCase = (input, options) => {
if (!(typeof input === "string" || Array.isArray(input))) {
throw new TypeError("Expected the input to be `string | string[]`");
}
options = Object.assign({
pascalCase: false
}, options);
const postProcess = (x) => options.pascalCase ? x.charAt(0).toUpperCase() + x.slice(1) : x;
if (Array.isArray(input)) {
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
} else {
input = input.trim();
}
if (input.length === 0) {
return "";
}
if (input.length === 1) {
return options.pascalCase ? input.toUpperCase() : input.toLowerCase();
}
const hasUpperCase = input !== input.toLowerCase();
if (hasUpperCase) {
input = preserveCamelCase(input);
}
input = input.replace(/^[_.\- ]+/, "").toLowerCase().replace(/[_.\- ]+(\w|$)/g, (_, p1) => p1.toUpperCase()).replace(/\d+(\w|$)/g, (m) => m.toUpperCase());
return postProcess(input);
};
module2.exports = camelCase;
module2.exports.default = camelCase;
}
});
// ../../node_modules/.pnpm/decamelize@1.2.0/node_modules/decamelize/index.js
var require_decamelize = __commonJS({
"../../node_modules/.pnpm/decamelize@1.2.0/node_modules/decamelize/index.js"(exports2, module2) {
"use strict";
module2.exports = function(str, sep) {
if (typeof str !== "string") {
throw new TypeError("Expected a string");
}
sep = typeof sep === "undefined" ? "_" : sep;
return str.replace(/([a-z\d])([A-Z])/g, "$1" + sep + "$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1" + sep + "$2").toLowerCase();
};
}
});
// ../../node_modules/.pnpm/yargs-parser@18.1.3/node_modules/yargs-parser/lib/tokenize-arg-string.js
var require_tokenize_arg_string = __commonJS({
"../../node_modules/.pnpm/yargs-parser@18.1.3/node_modules/yargs-parser/lib/tokenize-arg-string.js"(exports2, module2) {
module2.exports = function(argString) {
if (Array.isArray(argString)) {
return argString.map((e) => typeof e !== "string" ? e + "" : e);
}
argString = argString.trim();
let i = 0;
let prevC = null;
let c = null;
let opening = null;
const args = [];
for (let ii = 0; ii < argString.length; ii++) {
prevC = c;
c = argString.charAt(ii);
if (c === " " && !opening) {
if (!(prevC === " ")) {
i++;
}
continue;
}
if (c === opening) {
opening = null;
} else if ((c === "'" || c === '"') && !opening) {
opening = c;
}
if (!args[i])
args[i] = "";
args[i] += c;
}
return args;
};
}
});
// ../../node_modules/.pnpm/yargs-parser@18.1.3/node_modules/yargs-parser/index.js
var require_yargs_parser = __commonJS({
"../../node_modules/.pnpm/yargs-parser@18.1.3/node_modules/yargs-parser/index.js"(exports2, module2) {
var camelCase = require_camelcase();
var decamelize = require_decamelize();
var path = require("path");
var tokenizeArgString = require_tokenize_arg_string();
var util = require("util");
function parse(args, opts) {
opts = Object.assign(Object.create(null), opts);
args = tokenizeArgString(args);
const aliases = combineAliases(Object.assign(Object.create(null), opts.alias));
const configuration = Object.assign({
"boolean-negation": true,
"camel-case-expansion": true,
"combine-arrays": false,
"dot-notation": true,
"duplicate-arguments-array": true,
"flatten-duplicate-arrays": true,
"greedy-arrays": true,
"halt-at-non-option": false,
"nargs-eats-options": false,
"negation-prefix": "no-",
"parse-numbers": true,
"populate--": false,
"set-placeholder-key": false,
"short-option-groups": true,
"strip-aliased": false,
"strip-dashed": false,
"unknown-options-as-args": false
}, opts.configuration);
const defaults = Object.assign(Object.create(null), opts.default);
const configObjects = opts.configObjects || [];
const envPrefix = opts.envPrefix;
const notFlagsOption = configuration["populate--"];
const notFlagsArgv = notFlagsOption ? "--" : "_";
const newAliases = Object.create(null);
const defaulted = Object.create(null);
const __ = opts.__ || util.format;
const flags = {
aliases: Object.create(null),
arrays: Object.create(null),
bools: Object.create(null),
strings: Object.create(null),
numbers: Object.create(null),
counts: Object.create(null),
normalize: Object.create(null),
configs: Object.create(null),
nargs: Object.create(null),
coercions: Object.create(null),
keys: []
};
const negative = /^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/;
const negatedBoolean = new RegExp("^--" + configuration["negation-prefix"] + "(.+)");
[].concat(opts.array).filter(Boolean).forEach(function(opt) {
const key = opt.key || opt;
const assignment = Object.keys(opt).map(function(key2) {
return {
boolean: "bools",
string: "strings",
number: "numbers"
}[key2];
}).filter(Boolean).pop();
if (assignment) {
flags[assignment][key] = true;
}
flags.arrays[key] = true;
flags.keys.push(key);
});
[].concat(opts.boolean).filter(Boolean).forEach(function(key) {
flags.bools[key] = true;
flags.keys.push(key);
});
[].concat(opts.string).filter(Boolean).forEach(function(key) {
flags.strings[key] = true;
flags.keys.push(key);
});
[].concat(opts.number).filter(Boolean).forEach(function(key) {
flags.numbers[key] = true;
flags.keys.push(key);
});
[].concat(opts.count).filter(Boolean).forEach(function(key) {
flags.counts[key] = true;
flags.keys.push(key);
});
[].concat(opts.normalize).filter(Boolean).forEach(function(key) {
flags.normalize[key] = true;
flags.keys.push(key);
});
Object.keys(opts.narg || {}).forEach(function(k) {
flags.nargs[k] = opts.narg[k];
flags.keys.push(k);
});
Object.keys(opts.coerce || {}).forEach(function(k) {
f