Commit 9060882b2a9 for nodejs
commit 9060882b2a96b69bf8eddc36385be3e58b108c61
Author: Node.js GitHub Bot <github-bot@iojs.org>
Date: Sun Dec 6 09:25:02 2026 -0500
deps: update corepack to 0.37.0
PR-URL: https://github.com/nodejs/node/pull/68030
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mike McCready <66998419+MikeMcC399@users.noreply.github.com>
diff --git a/deps/corepack/CHANGELOG.md b/deps/corepack/CHANGELOG.md
index c90032328ab..89225887172 100644
--- a/deps/corepack/CHANGELOG.md
+++ b/deps/corepack/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changelog
+## [0.37.0](https://github.com/nodejs/corepack/compare/v0.36.0...v0.37.0) (2026-12-05)
+
+
+### Features
+
+* do not accept registry from env file when token or password is set ([#938](https://github.com/nodejs/corepack/issues/938)) ([b551b5f](https://github.com/nodejs/corepack/commit/b551b5fa1eb5edf82280ce8a233519e257823882))
+* update package manager versions ([#895](https://github.com/nodejs/corepack/issues/895)) ([569b78e](https://github.com/nodejs/corepack/commit/569b78e2e68b502a3d79ff894d02977c4bf8ab82))
+
## [0.36.0](https://github.com/nodejs/corepack/compare/v0.35.0...v0.36.0) (2026-08-28)
diff --git a/deps/corepack/README.md b/deps/corepack/README.md
index e2adeb94958..bc224cbfefb 100644
--- a/deps/corepack/README.md
+++ b/deps/corepack/README.md
@@ -274,9 +274,16 @@ suitable for use with `corepack install -g`.
### `corepack use <name[@<version>]>`
When run, this command will retrieve the latest release matching the provided
-descriptor, assign it to the project's package.json file, and automatically
+descriptor, assign it to the project's `package.json` file, and automatically
perform an install.
+Corepack locates the project manifest by searching the current directory and
+traversing parent directories until a `package.json` is found. In a monorepo or
+workspace structure, it searches upwards for an existing `package.json` that
+defines a `packageManager` field. If no `package.json` exists anywhere in the
+directory hierarchy, a new `package.json` with the assigned `packageManager`
+specification will be created in the current directory.
+
### `corepack up`
Retrieve the latest available version for the current major release line of
@@ -359,6 +366,12 @@ same major line. Should you need to upgrade to a new major, use an explicit
environment variables are required and as plain text. If you want to send an
empty password, explicitly set `COREPACK_NPM_PASSWORD` to an empty string.
+ `COREPACK_NPM_TOKEN`, `COREPACK_NPM_USERNAME`, and `COREPACK_NPM_PASSWORD`
+ are only sent to the origin of `COREPACK_NPM_REGISTRY` (or the default
+ registry). If a `.corepack.env` file sets `COREPACK_NPM_REGISTRY` while any
+ of those credentials is set in your environment, Corepack refuses to run
+ unless `COREPACK_NPM_REGISTRY` is also set in your environment.
+
- `COREPACK_ON_UNVERIFIED_DOWNLOAD` can be set to:
- `warn` (case insensitive): attempting to download an unsigned version without
providing a hash will emit a warning to stderr.
diff --git a/deps/corepack/dist/lib/corepack.cjs b/deps/corepack/dist/lib/corepack.cjs
index ff66960d4ae..56b0f538759 100644
--- a/deps/corepack/dist/lib/corepack.cjs
+++ b/deps/corepack/dist/lib/corepack.cjs
@@ -21,14 +21,14 @@ var __commonJS = (cb, mod) => function __require() {
}
};
var __export = (target, all) => {
- for (var name2 in all)
- __defProp(target, name2, { get: all[name2], enumerable: true });
+ for (var name in all)
+ __defProp(target, name, { get: all[name], enumerable: true });
};
-var __copyProps = (to, from, except, desc2) => {
+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: !(desc2 = __getOwnPropDesc(from, key)) || desc2.enumerable });
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
@@ -77,7 +77,7 @@ var require_errors = __commonJS({
"node_modules/clipanion/lib/errors.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
- var constants2 = require_constants();
+ var constants = require_constants();
var UsageError16 = class extends Error {
constructor(message) {
super(message);
@@ -136,7 +136,7 @@ ${whileRunning(input)}`;
}
};
var whileRunning = (input) => `While running ${input.filter((token) => {
- return token !== constants2.END_OF_INPUT;
+ return token !== constants.END_OF_INPUT;
}).map((token) => {
const json = JSON.stringify(token);
if (token.match(/\s/) || token.length === 0 || json !== `"${token}"`) {
@@ -229,23 +229,23 @@ var require_utils = __commonJS({
function makeCommandOption(spec) {
return { ...spec, [isOptionSymbol]: true };
}
- function rerouteArguments(a, b) {
+ function rerouteArguments(a, b2) {
if (typeof a === `undefined`)
- return [a, b];
+ return [a, b2];
if (typeof a === `object` && a !== null && !Array.isArray(a)) {
return [void 0, a];
} else {
- return [a, b];
+ return [a, b2];
}
}
function cleanValidationError(message, { mergeName = false } = {}) {
const match = message.match(/^([^:]+): (.*)$/m);
if (!match)
return `validation failed`;
- let [, path16, line] = match;
+ let [, path10, line] = match;
if (mergeName)
line = line[0].toLowerCase() + line.slice(1);
- line = path16 !== `.` || !mergeName ? `${path16.replace(/^\.(\[|$)/, `$1`)}: ${line}` : `: ${line}`;
+ line = path10 !== `.` || !mergeName ? `${path10.replace(/^\.(\[|$)/, `$1`)}: ${line}` : `: ${line}`;
return line;
}
function formatError(message, errors$1) {
@@ -257,7 +257,7 @@ ${errors$1.map((error) => `
- ${cleanValidationError(error)}`).join(``)}`);
}
}
- function applyValidator(name2, value, validator) {
+ function applyValidator(name, value, validator) {
if (typeof validator === `undefined`)
return value;
const errors2 = [];
@@ -269,7 +269,7 @@ ${errors$1.map((error) => `
};
const check = validator(value, { errors: errors2, coercions, coercion });
if (!check)
- throw formatError(`Invalid value for ${name2}`, errors2);
+ throw formatError(`Invalid value for ${name}`, errors2);
for (const [, op] of coercions)
op();
return value;
@@ -586,7 +586,7 @@ function isArray(spec, { delimiter } = {}) {
if (!Array.isArray(value))
return pushError(state, `Expected an array (got ${getPrintable(value)})`);
let valid = true;
- for (let t = 0, T = value.length; t < T; ++t) {
+ for (let t = 0, T2 = value.length; t < T2; ++t) {
valid = spec(value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid;
if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {
break;
@@ -706,7 +706,7 @@ function isTuple(spec, { delimiter } = {}) {
if (!Array.isArray(value))
return pushError(state, `Expected a tuple (got ${getPrintable(value)})`);
let valid = lengthValidator(value, Object.assign({}, state));
- for (let t = 0, T = value.length; t < T && t < spec.length; ++t) {
+ for (let t = 0, T2 = value.length; t < T2 && t < spec.length; ++t) {
valid = spec[t](value[t], Object.assign(Object.assign({}, state), { p: computeKey(state, t), coercion: makeCoercionFn(value, t) })) && valid;
if (!valid && (state === null || state === void 0 ? void 0 : state.errors) == null) {
break;
@@ -736,7 +736,7 @@ function isRecord(spec, { keys: keySpec = null } = {}) {
return pushError(state, `Expected an object (got ${getPrintable(value)})`);
const keys = Object.keys(value);
let valid = true;
- for (let t = 0, T = keys.length; t < T && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null); ++t) {
+ for (let t = 0, T2 = keys.length; t < T2 && (valid || (state === null || state === void 0 ? void 0 : state.errors) != null); ++t) {
const key = keys[t];
const sub = value[key];
if (key === `__proto__` || key === `constructor`) {
@@ -893,7 +893,7 @@ function hasUniqueItems({ map } = {}) {
test: (value, state) => {
const set = /* @__PURE__ */ new Set();
const dup = /* @__PURE__ */ new Set();
- for (let t = 0, T = value.length; t < T; ++t) {
+ for (let t = 0, T2 = value.length; t < T2; ++t) {
const sub = value[t];
const key = typeof map !== `undefined` ? map(sub) : sub;
if (set.has(key)) {
@@ -945,20 +945,20 @@ function isAtMost(n) {
}
});
}
-function isInInclusiveRange(a, b) {
+function isInInclusiveRange(a, b2) {
return makeValidator({
test: (value, state) => {
- if (!(value >= a && value <= b))
- return pushError(state, `Expected to be in the [${a}; ${b}] range (got ${value})`);
+ if (!(value >= a && value <= b2))
+ return pushError(state, `Expected to be in the [${a}; ${b2}] range (got ${value})`);
return true;
}
});
}
-function isInExclusiveRange(a, b) {
+function isInExclusiveRange(a, b2) {
return makeValidator({
test: (value, state) => {
- if (!(value >= a && value < b))
- return pushError(state, `Expected to be in the [${a}; ${b}[ range (got ${value})`);
+ if (!(value >= a && value < b2))
+ return pushError(state, `Expected to be in the [${a}; ${b2}[ range (got ${value})`);
return true;
}
});
@@ -1225,7 +1225,7 @@ var init_lib = __esm({
var _a, _b, _c;
const matches = [];
const errorBuffer = typeof (state === null || state === void 0 ? void 0 : state.errors) !== `undefined` ? [] : void 0;
- for (let t = 0, T = specs.length; t < T; ++t) {
+ for (let t = 0, T2 = specs.length; t < T2; ++t) {
const subErrors = typeof (state === null || state === void 0 ? void 0 : state.errors) !== `undefined` ? [] : void 0;
const subCoercions = typeof (state === null || state === void 0 ? void 0 : state.coercions) !== `undefined` ? [] : void 0;
if (specs[t](value, Object.assign(Object.assign({}, state), { errors: subErrors, coercions: subCoercions, p: `${(_a = state === null || state === void 0 ? void 0 : state.p) !== null && _a !== void 0 ? _a : `.`}#${t + 1}` }))) {
@@ -1297,13 +1297,13 @@ var require_Command = __commonJS({
if (e && e.__esModule) return e;
var n = /* @__PURE__ */ Object.create(null);
if (e) {
- Object.keys(e).forEach(function(k) {
- if (k !== "default") {
- var d = Object.getOwnPropertyDescriptor(e, k);
- Object.defineProperty(n, k, d.get ? d : {
+ Object.keys(e).forEach(function(k2) {
+ if (k2 !== "default") {
+ var d = Object.getOwnPropertyDescriptor(e, k2);
+ Object.defineProperty(n, k2, d.get ? d : {
enumerable: true,
get: function() {
- return e[k];
+ return e[k2];
}
});
}
@@ -1368,10 +1368,10 @@ var require_core = __commonJS({
"node_modules/clipanion/lib/core.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
- var constants2 = require_constants();
+ var constants = require_constants();
var errors = require_errors();
function debug(str) {
- if (constants2.DEBUG) {
+ if (constants.DEBUG) {
console.log(str);
}
}
@@ -1384,7 +1384,7 @@ var require_core = __commonJS({
positionals: [],
options: [],
remainder: null,
- selectedIndex: constants2.HELP_COMMAND_INDEX
+ selectedIndex: constants.HELP_COMMAND_INDEX
};
function makeStateMachine() {
return {
@@ -1403,7 +1403,7 @@ var require_core = __commonJS({
offset += input.nodes.length - 2;
}
for (const head of heads)
- registerShortcut(output, constants2.NODE_INITIAL, head);
+ registerShortcut(output, constants.NODE_INITIAL, head);
return output;
}
function injectNode(machine, node) {
@@ -1447,10 +1447,10 @@ var require_core = __commonJS({
}
}
};
- process5(constants2.NODE_INITIAL);
+ process5(constants.NODE_INITIAL);
}
function debugMachine(machine, { prefix = `` } = {}) {
- if (constants2.DEBUG) {
+ if (constants.DEBUG) {
debug(`${prefix}Nodes are:`);
for (let t = 0; t < machine.nodes.length; ++t) {
debug(`${prefix} ${t}: ${JSON.stringify(machine.nodes[t])}`);
@@ -1459,7 +1459,7 @@ var require_core = __commonJS({
}
function runMachineInternal(machine, input, partial = false) {
debug(`Running a vm on ${JSON.stringify(input)}`);
- let branches = [{ node: constants2.NODE_INITIAL, state: {
+ let branches = [{ node: constants.NODE_INITIAL, state: {
candidateUsage: null,
requiredOptions: [],
errorMessage: null,
@@ -1471,7 +1471,7 @@ var require_core = __commonJS({
selectedIndex: null
} }];
debugMachine(machine, { prefix: ` ` });
- const tokens = [constants2.START_OF_INPUT, ...input];
+ const tokens = [constants.START_OF_INPUT, ...input];
for (let t = 0; t < tokens.length; ++t) {
const segment = tokens[t];
debug(` Processing ${JSON.stringify(segment)}`);
@@ -1479,7 +1479,7 @@ var require_core = __commonJS({
for (const { node, state } of branches) {
debug(` Current node is ${node}`);
const nodeDef = machine.nodes[node];
- if (node === constants2.NODE_ERRORED) {
+ if (node === constants.NODE_ERRORED) {
nextBranches.push({ node, state });
continue;
}
@@ -1517,7 +1517,7 @@ var require_core = __commonJS({
debug(` No partial static transition found`);
}
}
- if (segment !== constants2.END_OF_INPUT) {
+ if (segment !== constants.END_OF_INPUT) {
for (const [test, { to, reducer }] of nodeDef.dynamics) {
if (execute(tests, test, state, segment)) {
nextBranches.push({ node: to, state: typeof reducer !== `undefined` ? execute(reducers, reducer, state, segment) : state });
@@ -1526,20 +1526,20 @@ var require_core = __commonJS({
}
}
}
- if (nextBranches.length === 0 && segment === constants2.END_OF_INPUT && input.length === 1) {
+ if (nextBranches.length === 0 && segment === constants.END_OF_INPUT && input.length === 1) {
return [{
- node: constants2.NODE_INITIAL,
+ node: constants.NODE_INITIAL,
state: basicHelpState
}];
}
if (nextBranches.length === 0) {
throw new errors.UnknownSyntaxError(input, branches.filter(({ node }) => {
- return node !== constants2.NODE_ERRORED;
+ return node !== constants.NODE_ERRORED;
}).map(({ state }) => {
return { usage: state.candidateUsage, reason: null };
}));
}
- if (nextBranches.every(({ node }) => node === constants2.NODE_ERRORED)) {
+ if (nextBranches.every(({ node }) => node === constants.NODE_ERRORED)) {
throw new errors.UnknownSyntaxError(input, nextBranches.map(({ state }) => {
return { usage: state.candidateUsage, reason: state.errorMessage };
}));
@@ -1559,9 +1559,9 @@ var require_core = __commonJS({
function checkIfNodeIsFinished(node, state) {
if (state.selectedIndex !== null)
return true;
- if (Object.prototype.hasOwnProperty.call(node.statics, constants2.END_OF_INPUT)) {
- for (const { to } of node.statics[constants2.END_OF_INPUT])
- if (to === constants2.NODE_SUCCESS)
+ if (Object.prototype.hasOwnProperty.call(node.statics, constants.END_OF_INPUT)) {
+ for (const { to } of node.statics[constants.END_OF_INPUT])
+ if (to === constants.NODE_SUCCESS)
return true;
}
return false;
@@ -1606,12 +1606,12 @@ var require_core = __commonJS({
const nodeDef = machine.nodes[node];
const isFinished = checkIfNodeIsFinished(nodeDef, state);
for (const [candidate, transitions] of Object.entries(nodeDef.statics))
- if (isFinished && candidate !== constants2.END_OF_INPUT || !candidate.startsWith(`-`) && transitions.some(({ reducer }) => reducer === `pushPath`))
+ if (isFinished && candidate !== constants.END_OF_INPUT || !candidate.startsWith(`-`) && transitions.some(({ reducer }) => reducer === `pushPath`))
traverseSuggestion([...prefix, candidate], node);
if (!isFinished)
continue;
for (const [test, { to }] of nodeDef.dynamics) {
- if (to === constants2.NODE_ERRORED)
+ if (to === constants.NODE_ERRORED)
continue;
const tokens = suggest(test, state);
if (tokens === null)
@@ -1624,7 +1624,7 @@ var require_core = __commonJS({
return [...suggestions].sort();
}
function runMachine(machine, input) {
- const branches = runMachineInternal(machine, [...input, constants2.END_OF_INPUT]);
+ const branches = runMachineInternal(machine, [...input, constants.END_OF_INPUT]);
return selectBestState(input, branches.map(({ state }) => {
return state;
}));
@@ -1644,7 +1644,7 @@ var require_core = __commonJS({
});
if (terminalStates.length === 0)
throw new Error();
- const requiredOptionsSetStates = terminalStates.filter((state) => state.selectedIndex === constants2.HELP_COMMAND_INDEX || state.requiredOptions.every((names) => names.some((name2) => state.options.find((opt) => opt.name === name2))));
+ const requiredOptionsSetStates = terminalStates.filter((state) => state.selectedIndex === constants.HELP_COMMAND_INDEX || state.requiredOptions.every((names) => names.some((name) => state.options.find((opt) => opt.name === name))));
if (requiredOptionsSetStates.length === 0) {
throw new errors.UnknownSyntaxError(input, terminalStates.map((state) => ({
usage: state.candidateUsage,
@@ -1682,7 +1682,7 @@ var require_core = __commonJS({
const notHelps = [];
const helps = [];
for (const state of states) {
- if (state.selectedIndex === constants2.HELP_COMMAND_INDEX) {
+ if (state.selectedIndex === constants.HELP_COMMAND_INDEX) {
helps.push(state);
} else {
notHelps.push(state);
@@ -1700,7 +1700,7 @@ var require_core = __commonJS({
function findCommonPrefix(firstPath, secondPath, ...rest) {
if (secondPath === void 0)
return Array.from(firstPath);
- return findCommonPrefix(firstPath.filter((segment, i) => segment === secondPath[i]), ...rest);
+ return findCommonPrefix(firstPath.filter((segment, i2) => segment === secondPath[i2]), ...rest);
}
function makeNode() {
return {
@@ -1710,7 +1710,7 @@ var require_core = __commonJS({
};
}
function isTerminalNode(node) {
- return node === constants2.NODE_SUCCESS || node === constants2.NODE_ERRORED;
+ return node === constants.NODE_SUCCESS || node === constants.NODE_ERRORED;
}
function cloneTransition(input, offset = 0) {
return {
@@ -1743,8 +1743,8 @@ var require_core = __commonJS({
}
function execute(store, callback, state, segment) {
if (Array.isArray(callback)) {
- const [name2, ...args] = callback;
- return store[name2](state, segment, ...args);
+ const [name, ...args] = callback;
+ return store[name](state, segment, ...args);
} else {
return store[callback](state, segment);
}
@@ -1766,31 +1766,31 @@ var require_core = __commonJS({
isNotOptionLike: (state, segment) => {
return state.ignoreOptions || segment === `-` || !segment.startsWith(`-`);
},
- isOption: (state, segment, name2, hidden) => {
- return !state.ignoreOptions && segment === name2;
+ isOption: (state, segment, name, hidden) => {
+ return !state.ignoreOptions && segment === name;
},
isBatchOption: (state, segment, names) => {
- return !state.ignoreOptions && constants2.BATCH_REGEX.test(segment) && [...segment.slice(1)].every((name2) => names.includes(`-${name2}`));
+ return !state.ignoreOptions && constants.BATCH_REGEX.test(segment) && [...segment.slice(1)].every((name) => names.includes(`-${name}`));
},
isBoundOption: (state, segment, names, options) => {
- const optionParsing = segment.match(constants2.BINDING_REGEX);
- return !state.ignoreOptions && !!optionParsing && constants2.OPTION_REGEX.test(optionParsing[1]) && names.includes(optionParsing[1]) && options.filter((opt) => opt.names.includes(optionParsing[1])).every((opt) => opt.allowBinding);
+ const optionParsing = segment.match(constants.BINDING_REGEX);
+ return !state.ignoreOptions && !!optionParsing && constants.OPTION_REGEX.test(optionParsing[1]) && names.includes(optionParsing[1]) && options.filter((opt) => opt.names.includes(optionParsing[1])).every((opt) => opt.allowBinding);
},
- isNegatedOption: (state, segment, name2) => {
- return !state.ignoreOptions && segment === `--no-${name2.slice(2)}`;
+ isNegatedOption: (state, segment, name) => {
+ return !state.ignoreOptions && segment === `--no-${name.slice(2)}`;
},
isHelp: (state, segment) => {
- return !state.ignoreOptions && constants2.HELP_REGEX.test(segment);
+ return !state.ignoreOptions && constants.HELP_REGEX.test(segment);
},
isUnsupportedOption: (state, segment, names) => {
- return !state.ignoreOptions && segment.startsWith(`-`) && constants2.OPTION_REGEX.test(segment) && !names.includes(segment);
+ return !state.ignoreOptions && segment.startsWith(`-`) && constants.OPTION_REGEX.test(segment) && !names.includes(segment);
},
isInvalidOption: (state, segment) => {
- return !state.ignoreOptions && segment.startsWith(`-`) && !constants2.OPTION_REGEX.test(segment);
+ return !state.ignoreOptions && segment.startsWith(`-`) && !constants.OPTION_REGEX.test(segment);
}
};
- tests.isOption.suggest = (state, name2, hidden = true) => {
- return !hidden ? [name2] : null;
+ tests.isOption.suggest = (state, name, hidden = true) => {
+ return !hidden ? [name] : null;
};
var reducers = {
setCandidateState: (state, segment, candidateState) => {
@@ -1800,11 +1800,11 @@ var require_core = __commonJS({
return { ...state, selectedIndex: index };
},
pushBatch: (state, segment) => {
- return { ...state, options: state.options.concat([...segment.slice(1)].map((name2) => ({ name: `-${name2}`, value: true }))) };
+ return { ...state, options: state.options.concat([...segment.slice(1)].map((name) => ({ name: `-${name}`, value: true }))) };
},
pushBound: (state, segment) => {
- const [, name2, value] = segment.match(constants2.BINDING_REGEX);
- return { ...state, options: state.options.concat({ name: name2, value }) };
+ const [, name, value] = segment.match(constants.BINDING_REGEX);
+ return { ...state, options: state.options.concat({ name, value }) };
},
pushPath: (state, segment) => {
return { ...state, path: state.path.concat(segment) };
@@ -1818,11 +1818,11 @@ var require_core = __commonJS({
pushExtraNoLimits: (state, segment) => {
return { ...state, positionals: state.positionals.concat({ value: segment, extra: NoLimits }) };
},
- pushTrue: (state, segment, name2 = segment) => {
+ pushTrue: (state, segment, name = segment) => {
return { ...state, options: state.options.concat({ name: segment, value: true }) };
},
- pushFalse: (state, segment, name2 = segment) => {
- return { ...state, options: state.options.concat({ name: name2, value: false }) };
+ pushFalse: (state, segment, name = segment) => {
+ return { ...state, options: state.options.concat({ name, value: false }) };
},
pushUndefined: (state, segment) => {
return { ...state, options: state.options.concat({ name: segment, value: void 0 }) };
@@ -1849,7 +1849,7 @@ var require_core = __commonJS({
/* name */
,
index
- ] = segment.match(constants2.HELP_REGEX);
+ ] = segment.match(constants.HELP_REGEX);
if (typeof index !== `undefined`) {
return { ...state, options: [{ name: `-c`, value: String(command) }, { name: `-i`, value: index }] };
} else {
@@ -1857,7 +1857,7 @@ var require_core = __commonJS({
}
},
setError: (state, segment, errorMessage) => {
- if (segment === constants2.END_OF_INPUT) {
+ if (segment === constants.END_OF_INPUT) {
return { ...state, errorMessage: `${errorMessage}.` };
} else {
return { ...state, errorMessage: `${errorMessage} ("${segment}").` };
@@ -1878,32 +1878,32 @@ var require_core = __commonJS({
this.cliIndex = cliIndex;
this.cliOpts = cliOpts;
}
- addPath(path16) {
- this.paths.push(path16);
+ addPath(path10) {
+ this.paths.push(path10);
}
setArity({ leading = this.arity.leading, trailing = this.arity.trailing, extra = this.arity.extra, proxy = this.arity.proxy }) {
Object.assign(this.arity, { leading, trailing, extra, proxy });
}
- addPositional({ name: name2 = `arg`, required = true } = {}) {
+ addPositional({ name = `arg`, required = true } = {}) {
if (!required && this.arity.extra === NoLimits)
throw new Error(`Optional parameters cannot be declared when using .rest() or .proxy()`);
if (!required && this.arity.trailing.length > 0)
throw new Error(`Optional parameters cannot be declared after the required trailing positional arguments`);
if (!required && this.arity.extra !== NoLimits) {
- this.arity.extra.push(name2);
+ this.arity.extra.push(name);
} else if (this.arity.extra !== NoLimits && this.arity.extra.length === 0) {
- this.arity.leading.push(name2);
+ this.arity.leading.push(name);
} else {
- this.arity.trailing.push(name2);
+ this.arity.trailing.push(name);
}
}
- addRest({ name: name2 = `arg`, required = 0 } = {}) {
+ addRest({ name = `arg`, required = 0 } = {}) {
if (this.arity.extra === NoLimits)
throw new Error(`Infinite lists cannot be declared multiple times in the same command`);
if (this.arity.trailing.length > 0)
throw new Error(`Infinite lists cannot be declared after the required trailing positional arguments`);
for (let t = 0; t < required; ++t)
- this.addPositional({ name: name2 });
+ this.addPositional({ name });
this.arity.extra = NoLimits;
}
addProxy({ required = 0 } = {}) {
@@ -1942,12 +1942,12 @@ var require_core = __commonJS({
segments.push(required ? `<${definition}>` : `[${definition}]`);
}
}
- segments.push(...this.arity.leading.map((name2) => `<${name2}>`));
+ segments.push(...this.arity.leading.map((name) => `<${name}>`));
if (this.arity.extra === NoLimits)
segments.push(`...`);
else
- segments.push(...this.arity.extra.map((name2) => `[${name2}]`));
- segments.push(...this.arity.trailing.map((name2) => `<${name2}>`));
+ segments.push(...this.arity.extra.map((name) => `[${name}]`));
+ segments.push(...this.arity.trailing.map((name) => `<${name}>`));
}
const usage = segments.join(` `);
return { usage, options: detailedOptionList };
@@ -1956,42 +1956,42 @@ var require_core = __commonJS({
if (typeof this.context === `undefined`)
throw new Error(`Assertion failed: No context attached`);
const machine = makeStateMachine();
- let firstNode = constants2.NODE_INITIAL;
+ let firstNode = constants.NODE_INITIAL;
const candidateUsage = this.usage().usage;
const requiredOptions = this.options.filter((opt) => opt.required).map((opt) => opt.names);
firstNode = injectNode(machine, makeNode());
- registerStatic(machine, constants2.NODE_INITIAL, constants2.START_OF_INPUT, firstNode, [`setCandidateState`, { candidateUsage, requiredOptions }]);
+ registerStatic(machine, constants.NODE_INITIAL, constants.START_OF_INPUT, firstNode, [`setCandidateState`, { candidateUsage, requiredOptions }]);
const positionalArgument = this.arity.proxy ? `always` : `isNotOptionLike`;
const paths = this.paths.length > 0 ? this.paths : [[]];
- for (const path16 of paths) {
+ for (const path10 of paths) {
let lastPathNode = firstNode;
- if (path16.length > 0) {
+ if (path10.length > 0) {
const optionPathNode = injectNode(machine, makeNode());
registerShortcut(machine, lastPathNode, optionPathNode);
this.registerOptions(machine, optionPathNode);
lastPathNode = optionPathNode;
}
- for (let t = 0; t < path16.length; ++t) {
+ for (let t = 0; t < path10.length; ++t) {
const nextPathNode = injectNode(machine, makeNode());
- registerStatic(machine, lastPathNode, path16[t], nextPathNode, `pushPath`);
+ registerStatic(machine, lastPathNode, path10[t], nextPathNode, `pushPath`);
lastPathNode = nextPathNode;
}
if (this.arity.leading.length > 0 || !this.arity.proxy) {
const helpNode = injectNode(machine, makeNode());
registerDynamic(machine, lastPathNode, `isHelp`, helpNode, [`useHelp`, this.cliIndex]);
registerDynamic(machine, helpNode, `always`, helpNode, `pushExtra`);
- registerStatic(machine, helpNode, constants2.END_OF_INPUT, constants2.NODE_SUCCESS, [`setSelectedIndex`, constants2.HELP_COMMAND_INDEX]);
+ registerStatic(machine, helpNode, constants.END_OF_INPUT, constants.NODE_SUCCESS, [`setSelectedIndex`, constants.HELP_COMMAND_INDEX]);
this.registerOptions(machine, lastPathNode);
}
if (this.arity.leading.length > 0)
- registerStatic(machine, lastPathNode, constants2.END_OF_INPUT, constants2.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
+ registerStatic(machine, lastPathNode, constants.END_OF_INPUT, constants.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
let lastLeadingNode = lastPathNode;
for (let t = 0; t < this.arity.leading.length; ++t) {
const nextLeadingNode = injectNode(machine, makeNode());
if (!this.arity.proxy || t + 1 !== this.arity.leading.length)
this.registerOptions(machine, nextLeadingNode);
if (this.arity.trailing.length > 0 || t + 1 !== this.arity.leading.length)
- registerStatic(machine, nextLeadingNode, constants2.END_OF_INPUT, constants2.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
+ registerStatic(machine, nextLeadingNode, constants.END_OF_INPUT, constants.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
registerDynamic(machine, lastLeadingNode, `isNotOptionLike`, nextLeadingNode, `pushPositional`);
lastLeadingNode = nextLeadingNode;
}
@@ -2019,19 +2019,19 @@ var require_core = __commonJS({
lastExtraNode = extraShortcutNode;
}
if (this.arity.trailing.length > 0)
- registerStatic(machine, lastExtraNode, constants2.END_OF_INPUT, constants2.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
+ registerStatic(machine, lastExtraNode, constants.END_OF_INPUT, constants.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
let lastTrailingNode = lastExtraNode;
for (let t = 0; t < this.arity.trailing.length; ++t) {
const nextTrailingNode = injectNode(machine, makeNode());
if (!this.arity.proxy)
this.registerOptions(machine, nextTrailingNode);
if (t + 1 < this.arity.trailing.length)
- registerStatic(machine, nextTrailingNode, constants2.END_OF_INPUT, constants2.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
+ registerStatic(machine, nextTrailingNode, constants.END_OF_INPUT, constants.NODE_ERRORED, [`setError`, `Not enough positional arguments`]);
registerDynamic(machine, lastTrailingNode, `isNotOptionLike`, nextTrailingNode, `pushPositional`);
lastTrailingNode = nextTrailingNode;
}
- registerDynamic(machine, lastTrailingNode, positionalArgument, constants2.NODE_ERRORED, [`setError`, `Extraneous positional argument`]);
- registerStatic(machine, lastTrailingNode, constants2.END_OF_INPUT, constants2.NODE_SUCCESS, [`setSelectedIndex`, this.cliIndex]);
+ registerDynamic(machine, lastTrailingNode, positionalArgument, constants.NODE_ERRORED, [`setError`, `Extraneous positional argument`]);
+ registerStatic(machine, lastTrailingNode, constants.END_OF_INPUT, constants.NODE_SUCCESS, [`setSelectedIndex`, this.cliIndex]);
}
return {
machine,
@@ -2042,27 +2042,27 @@ var require_core = __commonJS({
registerDynamic(machine, node, [`isOption`, `--`], node, `inhibateOptions`);
registerDynamic(machine, node, [`isBatchOption`, this.allOptionNames], node, `pushBatch`);
registerDynamic(machine, node, [`isBoundOption`, this.allOptionNames, this.options], node, `pushBound`);
- registerDynamic(machine, node, [`isUnsupportedOption`, this.allOptionNames], constants2.NODE_ERRORED, [`setError`, `Unsupported option name`]);
- registerDynamic(machine, node, [`isInvalidOption`], constants2.NODE_ERRORED, [`setError`, `Invalid option name`]);
+ registerDynamic(machine, node, [`isUnsupportedOption`, this.allOptionNames], constants.NODE_ERRORED, [`setError`, `Unsupported option name`]);
+ registerDynamic(machine, node, [`isInvalidOption`], constants.NODE_ERRORED, [`setError`, `Invalid option name`]);
for (const option of this.options) {
- const longestName = option.names.reduce((longestName2, name2) => {
- return name2.length > longestName2.length ? name2 : longestName2;
+ const longestName = option.names.reduce((longestName2, name) => {
+ return name.length > longestName2.length ? name : longestName2;
}, ``);
if (option.arity === 0) {
- for (const name2 of option.names) {
- registerDynamic(machine, node, [`isOption`, name2, option.hidden || name2 !== longestName], node, `pushTrue`);
- if (name2.startsWith(`--`) && !name2.startsWith(`--no-`)) {
- registerDynamic(machine, node, [`isNegatedOption`, name2], node, [`pushFalse`, name2]);
+ for (const name of option.names) {
+ registerDynamic(machine, node, [`isOption`, name, option.hidden || name !== longestName], node, `pushTrue`);
+ if (name.startsWith(`--`) && !name.startsWith(`--no-`)) {
+ registerDynamic(machine, node, [`isNegatedOption`, name], node, [`pushFalse`, name]);
}
}
} else {
let lastNode = injectNode(machine, makeNode());
- for (const name2 of option.names)
- registerDynamic(machine, node, [`isOption`, name2, option.hidden || name2 !== longestName], lastNode, `pushUndefined`);
+ for (const name of option.names)
+ registerDynamic(machine, node, [`isOption`, name, option.hidden || name !== longestName], lastNode, `pushUndefined`);
for (let t = 0; t < option.arity; ++t) {
const nextNode = injectNode(machine, makeNode());
- registerStatic(machine, lastNode, constants2.END_OF_INPUT, constants2.NODE_ERRORED, `setOptionArityError`);
- registerDynamic(machine, lastNode, `isOptionLike`, constants2.NODE_ERRORED, `setOptionArityError`);
+ registerStatic(machine, lastNode, constants.END_OF_INPUT, constants.NODE_ERRORED, `setOptionArityError`);
+ registerDynamic(machine, lastNode, `isOptionLike`, constants.NODE_ERRORED, `setOptionArityError`);
const action = option.arity === 1 ? `setStringValue` : `pushStringValue`;
registerDynamic(machine, lastNode, `isNotOptionLike`, nextNode, action);
lastNode = nextNode;
@@ -2257,10 +2257,10 @@ var require_Cli = __commonJS({
"node_modules/clipanion/lib/advanced/Cli.js"(exports2) {
"use strict";
Object.defineProperty(exports2, "__esModule", { value: true });
- var constants2 = require_constants();
+ var constants = require_constants();
var core = require_core();
var format = require_format();
- var platform5 = (init_node(), __toCommonJS(node_exports));
+ var platform = (init_node(), __toCommonJS(node_exports));
var advanced_Command = require_Command();
var advanced_HelpCommand = require_HelpCommand();
var errorCommandSymbol = /* @__PURE__ */ Symbol(`clipanion/errorCommand`);
@@ -2377,8 +2377,8 @@ var require_Cli = __commonJS({
const index = builder.cliIndex;
const paths = (_a = commandClass.paths) !== null && _a !== void 0 ? _a : command.paths;
if (typeof paths !== `undefined`)
- for (const path16 of paths)
- builder.addPath(path16);
+ for (const path10 of paths)
+ builder.addPath(path10);
this.registrations.set(commandClass, { specs, builder, index });
for (const [key, { definition }] of specs.entries())
definition(builder, key);
@@ -2394,7 +2394,7 @@ var require_Cli = __commonJS({
...userContext
};
switch (state.selectedIndex) {
- case constants2.HELP_COMMAND_INDEX: {
+ case constants.HELP_COMMAND_INDEX: {
const command = advanced_HelpCommand.HelpCommand.from(state, contexts);
command.context = context;
return command;
@@ -2456,7 +2456,7 @@ var require_Cli = __commonJS({
run: (input2, subContext) => this.run(input2, { ...context, ...subContext }),
usage: (command2, opts) => this.usage(command2, opts)
};
- const activate = this.enableCapture ? (_b = platform5.getCaptureActivator(context)) !== null && _b !== void 0 ? _b : noopCaptureActivator : noopCaptureActivator;
+ const activate = this.enableCapture ? (_b = platform.getCaptureActivator(context)) !== null && _b !== void 0 ? _b : noopCaptureActivator : noopCaptureActivator;
let exitCode;
try {
exitCode = await activate(() => command.validateAndExecute().catch((error) => command.catch(error).then(() => 0)));
@@ -2478,13 +2478,13 @@ var require_Cli = __commonJS({
for (const [commandClass, { index }] of this.registrations) {
if (typeof commandClass.usage === `undefined`)
continue;
- const { usage: path16 } = this.getUsageByIndex(index, { detailed: false });
+ const { usage: path10 } = this.getUsageByIndex(index, { detailed: false });
const { usage, options } = this.getUsageByIndex(index, { detailed: true, inlineOptions: false });
const category = typeof commandClass.usage.category !== `undefined` ? format.formatMarkdownish(commandClass.usage.category, { format: this.format(colored), paragraphs: false }) : void 0;
const description = typeof commandClass.usage.description !== `undefined` ? format.formatMarkdownish(commandClass.usage.description, { format: this.format(colored), paragraphs: false }) : void 0;
const details = typeof commandClass.usage.details !== `undefined` ? format.formatMarkdownish(commandClass.usage.details, { format: this.format(colored), paragraphs: true }) : void 0;
const examples = typeof commandClass.usage.examples !== `undefined` ? commandClass.usage.examples.map(([label, cli]) => [format.formatMarkdownish(label, { format: this.format(colored), paragraphs: false }), cli.replace(/\$0/g, this.binaryName)]) : void 0;
- data.push({ path: path16, usage, category, description, details, examples, options });
+ data.push({ path: path10, usage, category, description, details, examples, options });
}
return data;
}
@@ -2495,7 +2495,7 @@ var require_Cli = __commonJS({
const paths = commandClass2.paths;
const isDocumented = typeof commandClass2.usage !== `undefined`;
const isExclusivelyDefault = !paths || paths.length === 0 || paths.length === 1 && paths[0].length === 0;
- const isDefault = isExclusivelyDefault || ((_a = paths === null || paths === void 0 ? void 0 : paths.some((path16) => path16.length === 0)) !== null && _a !== void 0 ? _a : false);
+ const isDefault = isExclusivelyDefault || ((_a = paths === null || paths === void 0 ? void 0 : paths.some((path10) => path10.length === 0)) !== null && _a !== void 0 ? _a : false);
if (isDefault) {
if (command) {
command = null;
@@ -2528,12 +2528,12 @@ var require_Cli = __commonJS({
const { usage } = this.getUsageByIndex(index);
categoryCommands.push({ commandClass: commandClass2, usage });
}
- const categoryNames = Array.from(commandsByCategories.keys()).sort((a, b) => {
+ const categoryNames = Array.from(commandsByCategories.keys()).sort((a, b2) => {
if (a === null)
return -1;
- if (b === null)
+ if (b2 === null)
return 1;
- return a.localeCompare(b, `en`, { usage: `sort`, caseFirst: `upper` });
+ return a.localeCompare(b2, `en`, { usage: `sort`, caseFirst: `upper` });
});
const hasLabel = typeof this.binaryLabel !== `undefined`;
const hasVersion = typeof this.binaryVersion !== `undefined`;
@@ -2555,8 +2555,8 @@ var require_Cli = __commonJS({
`;
}
for (const categoryName of categoryNames) {
- const commands = commandsByCategories.get(categoryName).slice().sort((a, b) => {
- return a.usage.localeCompare(b.usage, `en`, { usage: `sort`, caseFirst: `upper` });
+ const commands = commandsByCategories.get(categoryName).slice().sort((a, b2) => {
+ return a.usage.localeCompare(b2.usage, `en`, { usage: `sort`, caseFirst: `upper` });
});
const header = categoryName !== null ? categoryName.trim() : `General commands`;
result += `
@@ -2642,10 +2642,10 @@ var require_Cli = __commonJS({
if (!error || typeof error !== `object` || !(`stack` in error))
error = new Error(`Execution failed with a non-error rejection (rejected value: ${JSON.stringify(error)})`);
let result = ``;
- let name2 = error.name.replace(/([a-z])([A-Z])/g, `$1 $2`);
- if (name2 === `Error`)
- name2 = `Internal Error`;
- result += `${this.format(colored).error(name2)}: ${error.message}
+ let name = error.name.replace(/([a-z])([A-Z])/g, `$1 $2`);
+ if (name === `Error`)
+ name = `Internal Error`;
+ result += `${this.format(colored).error(name)}: ${error.message}
`;
const meta = error.clipanion;
if (typeof meta !== `undefined`) {
@@ -2681,7 +2681,7 @@ var require_Cli = __commonJS({
stdin: process.stdin,
stdout: process.stdout,
stderr: process.stderr,
- colorDepth: platform5.getDefaultColorDepth()
+ colorDepth: platform.getDefaultColorDepth()
};
function noopCaptureActivator(fn2) {
return fn2();
@@ -2781,10 +2781,10 @@ var require_Array = __commonJS({
transformer(builder, key, state) {
let usedName;
let currentValue = typeof initialValue !== `undefined` ? [...initialValue] : void 0;
- for (const { name: name2, value } of state.options) {
- if (!nameSet.has(name2))
+ for (const { name, value } of state.options) {
+ if (!nameSet.has(name))
continue;
- usedName = name2;
+ usedName = name;
currentValue = currentValue !== null && currentValue !== void 0 ? currentValue : [];
currentValue.push(value);
}
@@ -2823,8 +2823,8 @@ var require_Boolean = __commonJS({
},
transformer(builer, key, state) {
let currentValue = initialValue;
- for (const { name: name2, value } of state.options) {
- if (!nameSet.has(name2))
+ for (const { name, value } of state.options) {
+ if (!nameSet.has(name))
continue;
currentValue = value;
}
@@ -2859,8 +2859,8 @@ var require_Counter = __commonJS({
},
transformer(builder, key, state) {
let currentValue = initialValue;
- for (const { name: name2, value } of state.options) {
- if (!nameSet.has(name2))
+ for (const { name, value } of state.options) {
+ if (!nameSet.has(name))
continue;
currentValue !== null && currentValue !== void 0 ? currentValue : currentValue = 0;
if (!value) {
@@ -2966,10 +2966,10 @@ var require_String = __commonJS({
usedName = opts.env;
currentValue = context.env[opts.env];
}
- for (const { name: name2, value } of state.options) {
- if (!nameSet.has(name2))
+ for (const { name, value } of state.options) {
+ if (!nameSet.has(name))
continue;
- usedName = name2;
+ usedName = name;
currentValue = value;
}
if (typeof currentValue === `string`) {
@@ -2992,14 +2992,14 @@ var require_String = __commonJS({
},
transformer(builder, key, state) {
var _a;
- for (let i = 0; i < state.positionals.length; ++i) {
- if (state.positionals[i].extra === core.NoLimits)
+ for (let i2 = 0; i2 < state.positionals.length; ++i2) {
+ if (state.positionals[i2].extra === core.NoLimits)
continue;
- if (required && state.positionals[i].extra === true)
+ if (required && state.positionals[i2].extra === true)
continue;
- if (!required && state.positionals[i].extra === false)
+ if (!required && state.positionals[i2].extra === false)
continue;
- const [positional] = state.positionals.splice(i, 1);
+ const [positional] = state.positionals.splice(i2, 1);
return advanced_options_utils.applyValidator((_a = opts.name) !== null && _a !== void 0 ? _a : key, positional.value, opts.validator);
}
return void 0;
@@ -3086,6 +3086,33 @@ var require_constants2 = __commonJS({
9007199254740991;
var MAX_SAFE_COMPONENT_LENGTH = 16;
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
+ var WHITESPACE_CHARACTERS = [
+ " ",
+ "\n",
+ "\v",
+ "\f",
+ "\r",
+ " ",
+ "\xA0",
+ "\u1680",
+ "\u2000",
+ "\u2001",
+ "\u2002",
+ "\u2003",
+ "\u2004",
+ "\u2005",
+ "\u2006",
+ "\u2007",
+ "\u2008",
+ "\u2009",
+ "\u200A",
+ "\u2028",
+ "\u2029",
+ "\u202F",
+ "\u205F",
+ "\u3000",
+ "\uFEFF"
+ ];
var RELEASE_TYPES = [
"major",
"premajor",
@@ -3100,6 +3127,7 @@ var require_constants2 = __commonJS({
MAX_SAFE_COMPONENT_LENGTH,
MAX_SAFE_BUILD_LENGTH,
MAX_SAFE_INTEGER,
+ WHITESPACE_CHARACTERS,
RELEASE_TYPES,
SEMVER_SPEC_VERSION,
FLAG_INCLUDE_PRERELEASE: 1,
@@ -3119,12 +3147,12 @@ var require_re = __commonJS({
} = require_constants2();
var debug = require_debug();
exports2 = module2.exports = {};
- var re = exports2.re = [];
+ var re2 = exports2.re = [];
var safeRe = exports2.safeRe = [];
var src = exports2.src = [];
var safeSrc = exports2.safeSrc = [];
var t = exports2.t = {};
- var R = 0;
+ var R2 = 0;
var LETTERDASHNUMBER = "[a-zA-Z0-9-]";
var safeRegexReplacements = [
["\\s", 1],
@@ -3137,14 +3165,14 @@ var require_re = __commonJS({
}
return value;
};
- var createToken = (name2, value, isGlobal) => {
+ var createToken = (name, value, isGlobal) => {
const safe = makeSafeRegex(value);
- const index = R++;
- debug(name2, index, value);
- t[name2] = index;
+ const index = R2++;
+ debug(name, index, value);
+ t[name] = index;
src[index] = value;
safeSrc[index] = safe;
- re[index] = new RegExp(value, isGlobal ? "g" : void 0);
+ re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
};
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
@@ -3220,19 +3248,19 @@ var require_identifiers = __commonJS({
"node_modules/semver/internal/identifiers.js"(exports2, module2) {
"use strict";
var numeric = /^[0-9]+$/;
- var compareIdentifiers = (a, b) => {
- if (typeof a === "number" && typeof b === "number") {
- return a === b ? 0 : a < b ? -1 : 1;
+ var compareIdentifiers = (a, b2) => {
+ if (typeof a === "number" && typeof b2 === "number") {
+ return a === b2 ? 0 : a < b2 ? -1 : 1;
}
const anum = numeric.test(a);
- const bnum = numeric.test(b);
+ const bnum = numeric.test(b2);
if (anum && bnum) {
a = +a;
- b = +b;
+ b2 = +b2;
}
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
+ return a === b2 ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b2 ? -1 : 1;
};
- var rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
+ var rcompareIdentifiers = (a, b2) => compareIdentifiers(b2, a);
module2.exports = {
compareIdentifiers,
rcompareIdentifiers
@@ -3246,7 +3274,7 @@ var require_semver = __commonJS({
"use strict";
var debug = require_debug();
var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants2();
- var { safeRe: re, t } = require_re();
+ var { safeRe: re2, t } = require_re();
var parseOptions = require_parse_options();
var { compareIdentifiers } = require_identifiers();
var isPrereleaseIdentifier = (prerelease, identifier) => {
@@ -3254,8 +3282,8 @@ var require_semver = __commonJS({
if (identifiers.length > prerelease.length) {
return false;
}
- for (let i = 0; i < identifiers.length; i++) {
- if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) {
+ for (let i2 = 0; i2 < identifiers.length; i2++) {
+ if (compareIdentifiers(prerelease[i2], identifiers[i2]) !== 0) {
return false;
}
}
@@ -3282,7 +3310,7 @@ var require_semver = __commonJS({
this.options = options;
this.loose = !!options.loose;
this.includePrerelease = !!options.includePrerelease;
- const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
+ const m = version.trim().match(options.loose ? re2[t.LOOSE] : re2[t.FULL]);
if (!m) {
throw new TypeError(`Invalid Version: ${version}`);
}
@@ -3373,45 +3401,45 @@ var require_semver = __commonJS({
} else if (!this.prerelease.length && !other.prerelease.length) {
return 0;
}
- let i = 0;
+ let i2 = 0;
do {
- const a = this.prerelease[i];
- const b = other.prerelease[i];
- debug("prerelease compare", i, a, b);
- if (a === void 0 && b === void 0) {
+ const a = this.prerelease[i2];
+ const b2 = other.prerelease[i2];
+ debug("prerelease compare", i2, a, b2);
+ if (a === void 0 && b2 === void 0) {
return 0;
- } else if (b === void 0) {
+ } else if (b2 === void 0) {
return 1;
} else if (a === void 0) {
return -1;
- } else if (a === b) {
+ } else if (a === b2) {
continue;
} else {
- return compareIdentifiers(a, b);
+ return compareIdentifiers(a, b2);
}
- } while (++i);
+ } while (++i2);
}
compareBuild(other) {
if (!(other instanceof _SemVer)) {
other = new _SemVer(other, this.options);
}
- let i = 0;
+ let i2 = 0;
do {
- const a = this.build[i];
- const b = other.build[i];
- debug("build compare", i, a, b);
- if (a === void 0 && b === void 0) {
+ const a = this.build[i2];
+ const b2 = other.build[i2];
+ debug("build compare", i2, a, b2);
+ if (a === void 0 && b2 === void 0) {
return 0;
- } else if (b === void 0) {
+ } else if (b2 === void 0) {
return 1;
} else if (a === void 0) {
return -1;
- } else if (a === b) {
+ } else if (a === b2) {
continue;
} else {
- return compareIdentifiers(a, b);
+ return compareIdentifiers(a, b2);
}
- } while (++i);
+ } while (++i2);
}
// preminor will bump the version up to the next minor release, and immediately
// down to pre-release. premajor and prepatch work the same way.
@@ -3421,7 +3449,7 @@ var require_semver = __commonJS({
throw new Error("invalid increment argument: identifier is empty");
}
if (identifier) {
- const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
+ const match = `-${identifier}`.match(this.options.loose ? re2[t.PRERELEASELOOSE] : re2[t.PRERELEASE]);
if (!match || match[1] !== identifier) {
throw new Error(`invalid identifier: ${identifier}`);
}
@@ -3488,14 +3516,14 @@ var require_semver = __commonJS({
if (this.prerelease.length === 0) {
this.prerelease = [base];
} else {
- let i = this.prerelease.length;
- while (--i >= 0) {
- if (typeof this.prerelease[i] === "number") {
- this.prerelease[i]++;
- i = -2;
+ let i2 = this.prerelease.length;
+ while (--i2 >= 0) {
+ if (typeof this.prerelease[i2] === "number") {
+ this.prerelease[i2]++;
+ i2 = -2;
}
}
- if (i === -1) {
+ if (i2 === -1) {
if (identifier === this.prerelease.join(".") && identifierBase === false) {
throw new Error("invalid increment argument: identifier already exists");
}
@@ -3537,7 +3565,7 @@ var require_compare = __commonJS({
"node_modules/semver/functions/compare.js"(exports2, module2) {
"use strict";
var SemVer3 = require_semver();
- var compare = (a, b, loose) => new SemVer3(a, loose).compare(new SemVer3(b, loose));
+ var compare = (a, b2, loose) => new SemVer3(a, loose).compare(new SemVer3(b2, loose));
module2.exports = compare;
}
});
@@ -3547,7 +3575,7 @@ var require_rcompare = __commonJS({
"node_modules/semver/functions/rcompare.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var rcompare = (a, b, loose) => compare(b, a, loose);
+ var rcompare = (a, b2, loose) => compare(b2, a, loose);
module2.exports = rcompare;
}
});
@@ -3557,7 +3585,7 @@ var require_parse = __commonJS({
"node_modules/semver/functions/parse.js"(exports2, module2) {
"use strict";
var SemVer3 = require_semver();
- var parse4 = (version, options, throwErrors = false) => {
+ var parse = (version, options, throwErrors = false) => {
if (version instanceof SemVer3) {
return version;
}
@@ -3570,7 +3598,7 @@ var require_parse = __commonJS({
throw er;
}
};
- module2.exports = parse4;
+ module2.exports = parse;
}
});
@@ -3578,9 +3606,9 @@ var require_parse = __commonJS({
var require_valid = __commonJS({
"node_modules/semver/functions/valid.js"(exports2, module2) {
"use strict";
- var parse4 = require_parse();
+ var parse = require_parse();
var valid = (version, options) => {
- const v = parse4(version, options);
+ const v = parse(version, options);
return v ? v.version : null;
};
module2.exports = valid;
@@ -3630,7 +3658,7 @@ var require_eq = __commonJS({
"node_modules/semver/functions/eq.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var eq = (a, b, loose) => compare(a, b, loose) === 0;
+ var eq = (a, b2, loose) => compare(a, b2, loose) === 0;
module2.exports = eq;
}
});
@@ -3640,7 +3668,7 @@ var require_neq = __commonJS({
"node_modules/semver/functions/neq.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var neq = (a, b, loose) => compare(a, b, loose) !== 0;
+ var neq = (a, b2, loose) => compare(a, b2, loose) !== 0;
module2.exports = neq;
}
});
@@ -3650,8 +3678,8 @@ var require_gt = __commonJS({
"node_modules/semver/functions/gt.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var gt = (a, b, loose) => compare(a, b, loose) > 0;
- module2.exports = gt;
+ var gt2 = (a, b2, loose) => compare(a, b2, loose) > 0;
+ module2.exports = gt2;
}
});
@@ -3660,7 +3688,7 @@ var require_gte = __commonJS({
"node_modules/semver/functions/gte.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var gte = (a, b, loose) => compare(a, b, loose) >= 0;
+ var gte = (a, b2, loose) => compare(a, b2, loose) >= 0;
module2.exports = gte;
}
});
@@ -3670,8 +3698,8 @@ var require_lt = __commonJS({
"node_modules/semver/functions/lt.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var lt = (a, b, loose) => compare(a, b, loose) < 0;
- module2.exports = lt;
+ var lt2 = (a, b2, loose) => compare(a, b2, loose) < 0;
+ module2.exports = lt2;
}
});
@@ -3680,7 +3708,7 @@ var require_lte = __commonJS({
"node_modules/semver/functions/lte.js"(exports2, module2) {
"use strict";
var compare = require_compare();
- var lte = (a, b, loose) => compare(a, b, loose) <= 0;
+ var lte = (a, b2, loose) => compare(a, b2, loose) <= 0;
module2.exports = lte;
}
});
@@ -3691,42 +3719,42 @@ var require_cmp = __commonJS({
"use strict";
var eq = require_eq();
var neq = require_neq();
- var gt = require_gt();
+ var gt2 = require_gt();
var gte = require_gte();
- var lt = require_lt();
+ var lt2 = require_lt();
var lte = require_lte();
- var cmp = (a, op, b, loose) => {
+ var cmp = (a, op, b2, loose) => {
switch (op) {
case "===":
if (typeof a === "object") {
a = a.version;
}
- if (typeof b === "object") {
- b = b.version;
+ if (typeof b2 === "object") {
+ b2 = b2.version;
}
- return a === b;
+ return a === b2;
case "!==":
if (typeof a === "object") {
a = a.version;
}
- if (typeof b === "object") {
- b = b.version;
+ if (typeof b2 === "object") {
+ b2 = b2.version;
}
- return a !== b;
+ return a !== b2;
case "":
case "=":
case "==":
- return eq(a, b, loose);
+ return eq(a, b2, loose);
case "!=":
- return neq(a, b, loose);
+ return neq(a, b2, loose);
case ">":
- return gt(a, b, loose);
+ return gt2(a, b2, loose);
case ">=":
- return gte(a, b, loose);
+ return gte(a, b2, loose);
case "<":
- return lt(a, b, loose);
+ return lt2(a, b2, loose);
case "<=":
- return lte(a, b, loose);
+ return lte(a, b2, loose);
default:
throw new TypeError(`Invalid operator: ${op}`);
}
@@ -3766,7 +3794,7 @@ var require_comparator = __commonJS({
debug("comp", this);
}
parse(comp) {
- const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
+ const r = this.options.loose ? re2[t.COMPARATORLOOSE] : re2[t.COMPARATOR];
const m = comp.match(r);
if (!m) {
throw new TypeError(`Invalid comparator: ${comp}`);
@@ -3840,7 +3868,7 @@ var require_comparator = __commonJS({
};
module2.exports = Comparator;
var parseOptions = require_parse_options();
- var { safeRe: re, t } = require_re();
+ var { safeRe: re2, t } = require_re();
var cmp = require_cmp();
var debug = require_debug();
var SemVer3 = require_semver();
@@ -3848,6 +3876,197 @@ var require_comparator = __commonJS({
}
});
+// node_modules/semver/internal/trim-comparator-whitespace.js
+var require_trim_comparator_whitespace = __commonJS({
+ "node_modules/semver/internal/trim-comparator-whitespace.js"(exports2, module2) {
+ "use strict";
+ var {
+ MAX_LENGTH,
+ MAX_SAFE_BUILD_LENGTH,
+ WHITESPACE_CHARACTERS
+ } = require_constants2();
+ var whitespace = new Uint8Array(65536);
+ for (const char of WHITESPACE_CHARACTERS) {
+ whitespace[char.charCodeAt(0)] = 1;
+ }
+ var isWhitespace = (char) => char !== void 0 && whitespace[char.charCodeAt(0)] === 1;
+ var isVersionPrefix = (char) => char === "v" || char === "=" || isWhitespace(char);
+ var isDigit = (char) => char !== void 0 && char >= "0" && char <= "9";
+ var isLetter = (char) => char !== void 0 && (char >= "a" && char <= "z" || char >= "A" && char <= "Z");
+ var isIdentifierCharacter = (char) => isDigit(char) || isLetter(char) || char === "-";
+ var isVersionStart = (char) => isDigit(char) || char === "x" || char === "X" || char === "*";
+ var findDigitsEndIndex = (range, start, limit, digitRuns) => {
+ if (!isDigit(range[start])) {
+ return start;
+ }
+ if (start >= digitRuns.start && start < digitRuns.end) {
+ return Math.min(start + limit, digitRuns.end);
+ }
+ if (start >= digitRuns.previousStart && start < digitRuns.previousEnd) {
+ return Math.min(start + limit, digitRuns.previousEnd);
+ }
+ let end = start + 1;
+ while (isDigit(range[end])) {
+ end++;
+ }
+ digitRuns.previousStart = digitRuns.start;
+ digitRuns.previousEnd = digitRuns.end;
+ digitRuns.start = start;
+ digitRuns.end = end;
+ return Math.min(start + limit, end);
+ };
+ var findVersionNumberEndIndex = (range, start, loose, digitRuns) => {
+ if (!loose && range[start] === "0") {
+ return start + 1;
+ }
+ return findDigitsEndIndex(range, start, loose ? MAX_LENGTH : MAX_LENGTH + 1, digitRuns);
+ };
+ var findPrereleaseIdentifierEndIndex = (range, start, loose, digitRuns) => {
+ const digitsEnd = findDigitsEndIndex(range, start, MAX_LENGTH, digitRuns);
+ if (isLetter(range[digitsEnd]) || range[digitsEnd] === "-") {
+ let end = digitsEnd + 1;
+ const limit = end + MAX_SAFE_BUILD_LENGTH;
+ while (end < limit && isIdentifierCharacter(range[end])) {
+ end++;
+ }
+ return end;
+ }
+ return findVersionNumberEndIndex(range, start, loose, digitRuns);
+ };
+ var findPrereleaseEndIndex = (range, start, loose, digitRuns) => {
+ const hyphen = range[start] === "-";
+ if (!loose && !hyphen) {
+ return start;
+ }
+ const identifierStart = start + (hyphen ? 1 : 0);
+ let end = findPrereleaseIdentifierEndIndex(range, identifierStart, loose, digitRuns);
+ if (end === identifierStart) {
+ if (!loose || !hyphen) {
+ return start;
+ }
+ end = findPrereleaseIdentifierEndIndex(range, start, loose, digitRuns);
+ }
+ while (range[end] === ".") {
+ const next = findPrereleaseIdentifierEndIndex(range, end + 1, loose, digitRuns);
+ if (next === end + 1) {
+ break;
+ }
+ end = next;
+ }
+ return end;
+ };
+ var findBuildIdentifierEndIndex = (range, start) => {
+ let end = start;
+ while (end - start < MAX_SAFE_BUILD_LENGTH && isIdentifierCharacter(range[end])) {
+ end++;
+ }
+ return end;
+ };
+ var findBuildEndIndex = (range, start) => {
+ if (range[start] !== "+") {
+ return start;
+ }
+ let end = findBuildIdentifierEndIndex(range, start + 1);
+ if (end === start + 1) {
+ return start;
+ }
+ while (range[end] === ".") {
+ const next = findBuildIdentifierEndIndex(range, end + 1);
+ if (next === end + 1) {
+ break;
+ }
+ end = next;
+ }
+ return end;
+ };
+ var findLooseFullVersionEndIndex = (range, start, digitRuns) => {
+ let end = start;
+ for (let component = 0; component < 3; component++) {
+ const next = findVersionNumberEndIndex(range, end, true, digitRuns);
+ if (next === end) {
+ return start;
+ }
+ end = next;
+ if (component < 2) {
+ if (range[end] !== ".") {
+ return start;
+ }
+ end++;
+ }
+ }
+ const prereleaseEnd = findPrereleaseEndIndex(range, end, true, digitRuns);
+ return findBuildEndIndex(range, prereleaseEnd);
+ };
+ var findPartialVersionComponentEndIndex = (range, start, digitRuns) => {
+ if (isDigit(range[start])) {
+ return findVersionNumberEndIndex(range, start, false, digitRuns);
+ }
+ return isVersionStart(range[start]) ? start + 1 : start;
+ };
+ var findPartialVersionEndIndex = (range, start, digitRuns) => {
+ let end = findPartialVersionComponentEndIndex(range, start, digitRuns);
+ for (let component = 0; component < 2; component++) {
+ if (range[end] !== ".") {
+ return end;
+ }
+ const next = findPartialVersionComponentEndIndex(range, end + 1, digitRuns);
+ if (next === end + 1) {
+ return end;
+ }
+ end = next;
+ }
+ const prereleaseEnd = findPrereleaseEndIndex(range, end, false, digitRuns);
+ return findBuildEndIndex(range, prereleaseEnd);
+ };
+ var findVersionEndIndex = (range, start, digitRuns) => {
+ const fullVersionEnd = findLooseFullVersionEndIndex(range, start, digitRuns);
+ return fullVersionEnd !== start ? fullVersionEnd : findPartialVersionEndIndex(range, start, digitRuns);
+ };
+ var findRemovableWhitespaceIndex = (range, matchStart) => {
+ let position = matchStart;
+ if (isWhitespace(range[position])) {
+ position++;
+ }
+ if (range[position] === "<" || range[position] === ">") {
+ position++;
+ }
+ if (range[position] === "=") {
+ position++;
+ }
+ return isWhitespace(range[position]) ? position : -1;
+ };
+ var trimComparatorWhitespace = (range) => {
+ let result = "";
+ let copyFrom = 0;
+ let cursor = 0;
+ const digitRuns = { start: -1, end: -1, previousStart: -1, previousEnd: -1 };
+ while (cursor < range.length) {
+ const matchStart = cursor;
+ if (range[cursor] === "<" || range[cursor] === ">") {
+ cursor++;
+ } else if (!isVersionPrefix(range[cursor]) && !isVersionStart(range[cursor])) {
+ cursor++;
+ continue;
+ }
+ while (cursor < range.length && isVersionPrefix(range[cursor])) {
+ cursor++;
+ }
+ if (!isVersionStart(range[cursor])) {
+ continue;
+ }
+ const whitespacePosition = findRemovableWhitespaceIndex(range, matchStart);
+ if (whitespacePosition !== -1) {
+ result += range.slice(copyFrom, whitespacePosition);
+ copyFrom = whitespacePosition + 1;
+ }
+ cursor = findVersionEndIndex(range, cursor, digitRuns);
+ }
+ return result + range.slice(copyFrom);
+ };
+ module2.exports = trimComparatorWhitespace;
+ }
+});
+
// node_modules/semver/classes/range.js
var require_range = __commonJS({
"node_modules/semver/classes/range.js"(exports2, module2) {
@@ -3896,16 +4115,16 @@ var require_range = __commonJS({
get range() {
if (this.formatted === void 0) {
this.formatted = "";
- for (let i = 0; i < this.set.length; i++) {
- if (i > 0) {
+ for (let i2 = 0; i2 < this.set.length; i2++) {
+ if (i2 > 0) {
this.formatted += "||";
}
- const comps = this.set[i];
- for (let k = 0; k < comps.length; k++) {
- if (k > 0) {
+ const comps = this.set[i2];
+ for (let k2 = 0; k2 < comps.length; k2++) {
+ if (k2 > 0) {
this.formatted += " ";
}
- this.formatted += comps[k].toString().trim();
+ this.formatted += comps[k2].toString().trim();
}
}
}
@@ -3921,25 +4140,25 @@ var require_range = __commonJS({
range = range.replace(BUILDSTRIPRE, "");
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
const memoKey = memoOpts + ":" + range;
- const cached = cache2.get(memoKey);
+ const cached = cache.get(memoKey);
if (cached) {
return cached;
}
const loose = this.options.loose;
- const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
+ const hr = loose ? re2[t.HYPHENRANGELOOSE] : re2[t.HYPHENRANGE];
range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
debug("hyphen replace", range);
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
+ range = trimComparatorWhitespace(range);
debug("comparator trim", range);
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
+ range = range.replace(re2[t.TILDETRIM], tildeTrimReplace);
debug("tilde trim", range);
- range = range.replace(re[t.CARETTRIM], caretTrimReplace);
+ range = range.replace(re2[t.CARETTRIM], caretTrimReplace);
debug("caret trim", range);
let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
if (loose) {
rangeList = rangeList.filter((comp) => {
debug("loose invalid filter", comp, this.options);
- return !!comp.match(re[t.COMPARATORLOOSE]);
+ return !!comp.match(re2[t.COMPARATORLOOSE]);
});
}
debug("range list", rangeList);
@@ -3955,7 +4174,7 @@ var require_range = __commonJS({
rangeMap.delete("");
}
const result = [...rangeMap.values()];
- cache2.set(memoKey, result);
+ cache.set(memoKey, result);
return result;
}
intersects(range, options) {
@@ -3984,8 +4203,8 @@ var require_range = __commonJS({
return false;
}
}
- for (let i = 0; i < this.set.length; i++) {
- if (testSet(this.set[i], version, this.options)) {
+ for (let i2 = 0; i2 < this.set.length; i2++) {
+ if (testSet(this.set[i2], version, this.options)) {
return true;
}
}
@@ -3994,16 +4213,16 @@ var require_range = __commonJS({
};
module2.exports = Range3;
var LRU = require_lrucache();
- var cache2 = new LRU();
+ var cache = new LRU();
var parseOptions = require_parse_options();
var Comparator = require_comparator();
var debug = require_debug();
var SemVer3 = require_semver();
+ var trimComparatorWhitespace = require_trim_comparator_whitespace();
var {
- safeRe: re,
+ safeRe: re2,
src,
t,
- comparatorTrimReplace,
tildeTrimReplace,
caretTrimReplace
} = require_re();
@@ -4024,7 +4243,7 @@ var require_range = __commonJS({
return result;
};
var parseComparator = (comp, options) => {
- comp = comp.replace(re[t.BUILD], "");
+ comp = comp.replace(re2[t.BUILD], "");
debug("comp", comp, options);
comp = replaceCarets(comp, options);
debug("caret", comp);
@@ -4037,27 +4256,27 @@ var require_range = __commonJS({
return comp;
};
var isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
- var invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
+ var invalidXRangeOrder = (M2, m, p) => isX(M2) && !isX(m) || isX(m) && p && !isX(p);
var replaceTildes = (comp, options) => {
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
};
var replaceTilde = (comp, options) => {
- const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
- const z = options.includePrerelease ? "-0" : "";
- return comp.replace(r, (_, M, m, p, pr) => {
- debug("tilde", comp, _, M, m, p, pr);
+ const r = options.loose ? re2[t.TILDELOOSE] : re2[t.TILDE];
+ const z2 = options.includePrerelease ? "-0" : "";
+ return comp.replace(r, (_2, M2, m, p, pr) => {
+ debug("tilde", comp, _2, M2, m, p, pr);
let ret;
- if (isX(M)) {
+ if (isX(M2)) {
ret = "";
} else if (isX(m)) {
- ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
+ ret = `>=${M2}.0.0${z2} <${+M2 + 1}.0.0-0`;
} else if (isX(p)) {
- ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
+ ret = `>=${M2}.${m}.0${z2} <${M2}.${+m + 1}.0-0`;
} else if (pr) {
debug("replaceTilde pr", pr);
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
+ ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${+m + 1}.0-0`;
} else {
- ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
+ ret = `>=${M2}.${m}.${p} <${M2}.${+m + 1}.0-0`;
}
debug("tilde return", ret);
return ret;
@@ -4068,42 +4287,42 @@ var require_range = __commonJS({
};
var replaceCaret = (comp, options) => {
debug("caret", comp, options);
- const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
- const z = options.includePrerelease ? "-0" : "";
- return comp.replace(r, (_, M, m, p, pr) => {
- debug("caret", comp, _, M, m, p, pr);
+ const r = options.loose ? re2[t.CARETLOOSE] : re2[t.CARET];
+ const z2 = options.includePrerelease ? "-0" : "";
+ return comp.replace(r, (_2, M2, m, p, pr) => {
+ debug("caret", comp, _2, M2, m, p, pr);
let ret;
- if (isX(M)) {
+ if (isX(M2)) {
ret = "";
} else if (isX(m)) {
- ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
+ ret = `>=${M2}.0.0${z2} <${+M2 + 1}.0.0-0`;
} else if (isX(p)) {
- if (M === "0") {
- ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
+ if (M2 === "0") {
+ ret = `>=${M2}.${m}.0${z2} <${M2}.${+m + 1}.0-0`;
} else {
- ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
+ ret = `>=${M2}.${m}.0${z2} <${+M2 + 1}.0.0-0`;
}
} else if (pr) {
debug("replaceCaret pr", pr);
- if (M === "0") {
+ if (M2 === "0") {
if (m === "0") {
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
+ ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${m}.${+p + 1}-0`;
} else {
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
+ ret = `>=${M2}.${m}.${p}-${pr} <${M2}.${+m + 1}.0-0`;
}
} else {
- ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
+ ret = `>=${M2}.${m}.${p}-${pr} <${+M2 + 1}.0.0-0`;
}
} else {
debug("no pr");
- if (M === "0") {
+ if (M2 === "0") {
if (m === "0") {
- ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
+ ret = `>=${M2}.${m}.${p} <${M2}.${m}.${+p + 1}-0`;
} else {
- ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
+ ret = `>=${M2}.${m}.${p} <${M2}.${+m + 1}.0-0`;
}
} else {
- ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
+ ret = `>=${M2}.${m}.${p} <${+M2 + 1}.0.0-0`;
}
}
debug("caret return", ret);
@@ -4116,13 +4335,13 @@ var require_range = __commonJS({
};
var replaceXRange = (comp, options) => {
comp = comp.trim();
- const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
- return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
- debug("xRange", comp, ret, gtlt, M, m, p, pr);
- if (invalidXRangeOrder(M, m, p)) {
+ const r = options.loose ? re2[t.XRANGELOOSE] : re2[t.XRANGE];
+ return comp.replace(r, (ret, gtlt, M2, m, p, pr) => {
+ debug("xRange", comp, ret, gtlt, M2, m, p, pr);
+ if (invalidXRangeOrder(M2, m, p)) {
return comp;
}
- const xM = isX(M);
+ const xM = isX(M2);
const xm = xM || isX(m);
const xp = xm || isX(p);
const anyX = xp;
@@ -4144,7 +4363,7 @@ var require_range = __commonJS({
if (gtlt === ">") {
gtlt = ">=";
if (xm) {
- M = +M + 1;
+ M2 = +M2 + 1;
m = 0;
p = 0;
} else {
@@ -4154,7 +4373,7 @@ var require_range = __commonJS({
} else if (gtlt === "<=") {
gtlt = "<";
if (xm) {
- M = +M + 1;
+ M2 = +M2 + 1;
} else {
m = +m + 1;
}
@@ -4162,11 +4381,11 @@ var require_range = __commonJS({
if (gtlt === "<") {
pr = "-0";
}
- ret = `${gtlt + M}.${m}.${p}${pr}`;
+ ret = `${gtlt + M2}.${m}.${p}${pr}`;
} else if (xm) {
- ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
+ ret = `>=${M2}.0.0${pr} <${+M2 + 1}.0.0-0`;
} else if (xp) {
- ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
+ ret = `>=${M2}.${m}.0${pr} <${M2}.${+m + 1}.0-0`;
}
debug("xRange return", ret);
return ret;
@@ -4174,11 +4393,11 @@ var require_range = __commonJS({
};
var replaceStars = (comp, options) => {
debug("replaceStars", comp, options);
- return comp.trim().replace(re[t.STAR], "");
+ return comp.trim().replace(re2[t.STAR], "");
};
var replaceGTE0 = (comp, options) => {
debug("replaceGTE0", comp, options);
- return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
+ return comp.trim().replace(re2[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
};
var hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
if (isX(fM)) {
@@ -4208,19 +4427,19 @@ var require_range = __commonJS({
return `${from} ${to}`.trim();
};
var testSet = (set, version, options) => {
- for (let i = 0; i < set.length; i++) {
- if (!set[i].test(version)) {
+ for (let i2 = 0; i2 < set.length; i2++) {
+ if (!set[i2].test(version)) {
return false;
}
}
if (version.prerelease.length && !options.includePrerelease) {
- for (let i = 0; i < set.length; i++) {
- debug(set[i].semver);
- if (set[i].semver === Comparator.ANY) {
+ for (let i2 = 0; i2 < set.length; i2++) {
+ debug(set[i2].semver);
+ if (set[i2].semver === Comparator.ANY) {
continue;
}
- if (set[i].semver.prerelease.length > 0) {
- const allowed = set[i].semver;
+ if (set[i2].semver.prerelease.length > 0) {
+ const allowed = set[i2].semver;
if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) {
return true;
}
@@ -4257,12 +4476,12 @@ var require_ms = __commonJS({
var h = m * 60;
var d = h * 24;
var w = d * 7;
- var y = d * 365.25;
+ var y2 = d * 365.25;
module2.exports = function(val, options) {
options = options || {};
var type = typeof val;
if (type === "string" && val.length > 0) {
- return parse4(val);
+ return parse(val);
} else if (type === "number" && isFinite(val)) {
return options.long ? fmtLong(val) : fmtShort(val);
}
@@ -4270,7 +4489,7 @@ var require_ms = __commonJS({
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
);
};
- function parse4(str) {
+ function parse(str) {
str = String(str);
if (str.length > 100) {
return;
@@ -4289,7 +4508,7 @@ var require_ms = __commonJS({
case "yrs":
case "yr":
case "y":
- return n * y;
+ return n * y2;
case "weeks":
case "week":
case "w":
@@ -4326,41 +4545,41 @@ var require_ms = __commonJS({
return void 0;
}
}
- function fmtShort(ms) {
- var msAbs = Math.abs(ms);
+ function fmtShort(ms2) {
+ var msAbs = Math.abs(ms2);
if (msAbs >= d) {
- return Math.round(ms / d) + "d";
+ return Math.round(ms2 / d) + "d";
}
if (msAbs >= h) {
- return Math.round(ms / h) + "h";
+ return Math.round(ms2 / h) + "h";
}
if (msAbs >= m) {
- return Math.round(ms / m) + "m";
+ return Math.round(ms2 / m) + "m";
}
if (msAbs >= s) {
- return Math.round(ms / s) + "s";
+ return Math.round(ms2 / s) + "s";
}
- return ms + "ms";
+ return ms2 + "ms";
}
- function fmtLong(ms) {
- var msAbs = Math.abs(ms);
+ function fmtLong(ms2) {
+ var msAbs = Math.abs(ms2);
if (msAbs >= d) {
- return plural2(ms, msAbs, d, "day");
+ return plural2(ms2, msAbs, d, "day");
}
if (msAbs >= h) {
- return plural2(ms, msAbs, h, "hour");
+ return plural2(ms2, msAbs, h, "hour");
}
if (msAbs >= m) {
- return plural2(ms, msAbs, m, "minute");
+ return plural2(ms2, msAbs, m, "minute");
}
if (msAbs >= s) {
- return plural2(ms, msAbs, s, "second");
+ return plural2(ms2, msAbs, s, "second");
}
- return ms + " ms";
+ return ms2 + " ms";
}
- function plural2(ms, msAbs, n, name2) {
+ function plural2(ms2, msAbs, n, name) {
var isPlural = msAbs >= n * 1.5;
- return Math.round(ms / n) + " " + name2 + (isPlural ? "s" : "");
+ return Math.round(ms2 / n) + " " + name + (isPlural ? "s" : "");
}
}
});
@@ -4385,8 +4604,8 @@ var require_common = __commonJS({
createDebug.formatters = {};
function selectColor(namespace) {
let hash = 0;
- for (let i = 0; i < namespace.length; i++) {
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
+ for (let i2 = 0; i2 < namespace.length; i2++) {
+ hash = (hash << 5) - hash + namespace.charCodeAt(i2);
hash |= 0;
}
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
@@ -4403,8 +4622,8 @@ var require_common = __commonJS({
}
const self2 = debug;
const curr = Number(/* @__PURE__ */ new Date());
- const ms = curr - (prevTime || curr);
- self2.diff = ms;
+ const ms2 = curr - (prevTime || curr);
+ self2.diff = ms2;
self2.prev = prevTime;
self2.curr = curr;
prevTime = curr;
@@ -4469,11 +4688,11 @@ var require_common = __commonJS({
createDebug.names = [];
createDebug.skips = [];
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
- for (const ns of split) {
- if (ns[0] === "-") {
- createDebug.skips.push(ns.slice(1));
+ for (const ns2 of split) {
+ if (ns2[0] === "-") {
+ createDebug.skips.push(ns2.slice(1));
} else {
- createDebug.names.push(ns);
+ createDebug.names.push(ns2);
}
}
}
@@ -4513,14 +4732,14 @@ var require_common = __commonJS({
createDebug.enable("");
return namespaces;
}
- function enabled(name2) {
+ function enabled(name) {
for (const skip of createDebug.skips) {
- if (matchesTemplate(name2, skip)) {
+ if (matchesTemplate(name, skip)) {
return false;
}
}
- for (const ns of createDebug.names) {
- if (matchesTemplate(name2, ns)) {
+ for (const ns2 of createDebug.names) {
+ if (matchesTemplate(name, ns2)) {
return true;
}
}
@@ -4971,8 +5190,8 @@ var require_node = __commonJS({
exports2.inspectOpts = Object.keys(process.env).filter((key) => {
return /^debug_/i.test(key);
}).reduce((obj, key) => {
- const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
- return k.toUpperCase();
+ const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_2, k2) => {
+ return k2.toUpperCase();
});
let val = process.env[key];
if (/^(yes|on|true|enabled)$/i.test(val)) {
@@ -4991,15 +5210,15 @@ var require_node = __commonJS({
return "colors" in exports2.inspectOpts ? Boolean(exports2.inspectOpts.colors) : tty3.isatty(process.stderr.fd);
}
function formatArgs(args) {
- const { namespace: name2, useColors: useColors2 } = this;
+ const { namespace: name, useColors: useColors2 } = this;
if (useColors2) {
const c = this.color;
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
- const prefix = ` ${colorCode};1m${name2} \x1B[0m`;
+ const prefix = ` ${colorCode};1m${name} \x1B[0m`;
args[0] = prefix + args[0].split("\n").join("\n" + prefix);
args.push(colorCode + "m+" + module2.exports.humanize(this.diff) + "\x1B[0m");
} else {
- args[0] = getDate() + name2 + " " + args[0];
+ args[0] = getDate() + name + " " + args[0];
}
}
function getDate() {
@@ -5024,8 +5243,8 @@ var require_node = __commonJS({
function init(debug) {
debug.inspectOpts = {};
const keys = Object.keys(exports2.inspectOpts);
- for (let i = 0; i < keys.length; i++) {
- debug.inspectOpts[keys[i]] = exports2.inspectOpts[keys[i]];
+ for (let i2 = 0; i2 < keys.length; i2++) {
+ debug.inspectOpts[keys[i2]] = exports2.inspectOpts[keys[i2]];
}
}
module2.exports = require_common()(exports2);
@@ -5052,7616 +5271,4234 @@ var require_src = __commonJS({
}
});
-// node_modules/minipass/dist/esm/index.js
-var import_node_events, import_node_stream, import_node_string_decoder, proc, isStream, isReadable, isWritable, EOF, MAYBE_EMIT_END, EMITTED_END, EMITTING_END, EMITTED_ERROR, CLOSED, READ, FLUSH, FLUSHCHUNK, ENCODING, DECODER, FLOWING, PAUSED, RESUME, BUFFER, PIPES, BUFFERLENGTH, BUFFERPUSH, BUFFERSHIFT, OBJECTMODE, DESTROYED, ERROR, EMITDATA, EMITEND, EMITEND2, ASYNC, ABORT, ABORTED, SIGNAL, DATALISTENERS, DISCARDED, defer, nodefer, isEndish, isArrayBufferLike, isArrayBufferView, Pipe, PipeProxyErrors, isObjectModeOptions, isEncodingOptions, Minipass;
-var init_esm = __esm({
- "node_modules/minipass/dist/esm/index.js"() {
- import_node_events = require("node:events");
- import_node_stream = __toESM(require("node:stream"), 1);
- import_node_string_decoder = require("node:string_decoder");
- proc = typeof process === "object" && process ? process : {
- stdout: null,
- stderr: null
- };
- isStream = (s) => !!s && typeof s === "object" && (s instanceof Minipass || s instanceof import_node_stream.default || isReadable(s) || isWritable(s));
- isReadable = (s) => !!s && typeof s === "object" && s instanceof import_node_events.EventEmitter && typeof s.pipe === "function" && // node core Writable streams have a pipe() method, but it throws
- s.pipe !== import_node_stream.default.Writable.prototype.pipe;
- isWritable = (s) => !!s && typeof s === "object" && s instanceof import_node_events.EventEmitter && typeof s.write === "function" && typeof s.end === "function";
- EOF = /* @__PURE__ */ Symbol("EOF");
- MAYBE_EMIT_END = /* @__PURE__ */ Symbol("maybeEmitEnd");
- EMITTED_END = /* @__PURE__ */ Symbol("emittedEnd");
- EMITTING_END = /* @__PURE__ */ Symbol("emittingEnd");
- EMITTED_ERROR = /* @__PURE__ */ Symbol("emittedError");
- CLOSED = /* @__PURE__ */ Symbol("closed");
- READ = /* @__PURE__ */ Symbol("read");
- FLUSH = /* @__PURE__ */ Symbol("flush");
- FLUSHCHUNK = /* @__PURE__ */ Symbol("flushChunk");
- ENCODING = /* @__PURE__ */ Symbol("encoding");
- DECODER = /* @__PURE__ */ Symbol("decoder");
- FLOWING = /* @__PURE__ */ Symbol("flowing");
- PAUSED = /* @__PURE__ */ Symbol("paused");
- RESUME = /* @__PURE__ */ Symbol("resume");
- BUFFER = /* @__PURE__ */ Symbol("buffer");
- PIPES = /* @__PURE__ */ Symbol("pipes");
- BUFFERLENGTH = /* @__PURE__ */ Symbol("bufferLength");
- BUFFERPUSH = /* @__PURE__ */ Symbol("bufferPush");
- BUFFERSHIFT = /* @__PURE__ */ Symbol("bufferShift");
- OBJECTMODE = /* @__PURE__ */ Symbol("objectMode");
- DESTROYED = /* @__PURE__ */ Symbol("destroyed");
- ERROR = /* @__PURE__ */ Symbol("error");
- EMITDATA = /* @__PURE__ */ Symbol("emitData");
- EMITEND = /* @__PURE__ */ Symbol("emitEnd");
- EMITEND2 = /* @__PURE__ */ Symbol("emitEnd2");
- ASYNC = /* @__PURE__ */ Symbol("async");
- ABORT = /* @__PURE__ */ Symbol("abort");
- ABORTED = /* @__PURE__ */ Symbol("aborted");
- SIGNAL = /* @__PURE__ */ Symbol("signal");
- DATALISTENERS = /* @__PURE__ */ Symbol("dataListeners");
- DISCARDED = /* @__PURE__ */ Symbol("discarded");
- defer = (fn2) => Promise.resolve().then(fn2);
- nodefer = (fn2) => fn2();
- isEndish = (ev) => ev === "end" || ev === "finish" || ev === "prefinish";
- isArrayBufferLike = (b) => b instanceof ArrayBuffer || !!b && typeof b === "object" && b.constructor && b.constructor.name === "ArrayBuffer" && b.byteLength >= 0;
- isArrayBufferView = (b) => !Buffer.isBuffer(b) && ArrayBuffer.isView(b);
- Pipe = class {
- src;
- dest;
- opts;
- ondrain;
- constructor(src, dest, opts) {
- this.src = src;
- this.dest = dest;
- this.opts = opts;
- this.ondrain = () => src[RESUME]();
- this.dest.on("drain", this.ondrain);
- }
- unpipe() {
- this.dest.removeListener("drain", this.ondrain);
- }
- // only here for the prototype
- /* c8 ignore start */
- proxyErrors(_er) {
- }
- /* c8 ignore stop */
- end() {
- this.unpipe();
- if (this.opts.end)
- this.dest.end();
- }
- };
- PipeProxyErrors = class extends Pipe {
- unpipe() {
- this.src.removeListener("error", this.proxyErrors);
- super.unpipe();
- }
- constructor(src, dest, opts) {
- super(src, dest, opts);
- this.proxyErrors = (er) => this.dest.emit("error", er);
- src.on("error", this.proxyErrors);
- }
- };
- isObjectModeOptions = (o) => !!o.objectMode;
- isEncodingOptions = (o) => !o.objectMode && !!o.encoding && o.encoding !== "buffer";
- Minipass = class extends import_node_events.EventEmitter {
- [FLOWING] = false;
- [PAUSED] = false;
- [PIPES] = [];
- [BUFFER] = [];
- [OBJECTMODE];
- [ENCODING];
- [ASYNC];
- [DECODER];
- [EOF] = false;
- [EMITTED_END] = false;
- [EMITTING_END] = false;
- [CLOSED] = false;
- [EMITTED_ERROR] = null;
- [BUFFERLENGTH] = 0;
- [DESTROYED] = false;
- [SIGNAL];
- [ABORTED] = false;
- [DATALISTENERS] = 0;
- [DISCARDED] = false;
- /**
- * true if the stream can be written
- */
- writable = true;
- /**
- * true if the stream can be read
- */
- readable = true;
- /**
- * If `RType` is Buffer, then options do not need to be provided.
- * Otherwise, an options object must be provided to specify either
- * {@link Minipass.SharedOptions.objectMode} or
- * {@link Minipass.SharedOptions.encoding}, as appropriate.
- */
- constructor(...args) {
- const options = args[0] || {};
- super();
- if (options.objectMode && typeof options.encoding === "string") {
- throw new TypeError("Encoding and objectMode may not be used together");
- }
- if (isObjectModeOptions(options)) {
- this[OBJECTMODE] = true;
- this[ENCODING] = null;
- } else if (isEncodingOptions(options)) {
- this[ENCODING] = options.encoding;
- this[OBJECTMODE] = false;
+// node_modules/tar/dist/esm/server/index.min.js
+var index_min_exports = {};
+__export(index_min_exports, {
+ AppendScan: () => Pe,
+ CwdError: () => oe,
+ EntryCursor: () => xe,
+ EntryData: () => V,
+ Header: () => R,
+ Pack: () => Re,
+ PackBase: () => Ee,
+ PackJob: () => U,
+ PackSync: () => Ae,
+ Parser: () => B,
+ PathReservations: () => Ne,
+ Pax: () => Y,
+ ReadEntry: () => we,
+ ReadEntrySync: () => ye,
+ SymlinkError: () => W,
+ TarReader: () => S,
+ TarReaderSync: () => b,
+ Unpack: () => Oe,
+ UnpackBase: () => ze,
+ UnpackSync: () => Fe,
+ WriteEntry: () => ne,
+ aliases: () => Ft,
+ c: () => Bo,
+ codecStream: () => nt,
+ create: () => Bo,
+ createSync: () => Ho,
+ delete: () => Yo,
+ deleteSync: () => qo,
+ entries: () => Lo,
+ entriesSync: () => Co,
+ extract: () => _o,
+ extractSync: () => Io,
+ gzip: () => T,
+ list: () => Do,
+ listSync: () => Mo,
+ r: () => $o,
+ replace: () => $o,
+ replaceSync: () => Go,
+ t: () => Do,
+ types: () => at,
+ u: () => Wo,
+ update: () => Wo,
+ updateSync: () => jo,
+ x: () => _o,
+ zlibCodecs: () => Rt
+});
+async function* ds(i2, e, t) {
+ let s = await i2.open(e, "r");
+ try {
+ t.size = (await s.stat()).size;
+ for (let n; n = t.next(); ) {
+ let r = new Uint8Array(n), { bytesRead: o } = await s.read(r, 0, n, t.pos);
+ if (!o) break;
+ t.pos += o, yield o < n ? r.subarray(0, o) : r;
+ }
+ } finally {
+ await s.close().catch(() => {
+ });
+ }
+}
+function* ps(i2, e, t) {
+ let s = i2.openSync(e, "r");
+ try {
+ t.size = i2.fstatSync(s).size;
+ for (let n; n = t.next(); ) {
+ let r = new Uint8Array(n), o = i2.readSync(s, r, 0, n, t.pos);
+ if (!o) break;
+ t.pos += o, yield o < n ? r.subarray(0, o) : r;
+ }
+ } finally {
+ try {
+ i2.closeSync(s);
+ } catch {
+ }
+ }
+}
+async function* Es(i2) {
+ if (E(i2)) yield i2;
+ else if (L(i2) || Ue(i2)) {
+ let e = (L(i2) ? i2.stream() : i2).getReader();
+ try {
+ for (; ; ) {
+ let t = await e.read();
+ if (t.done) break;
+ yield t.value;
+ }
+ } finally {
+ await e.cancel().catch(N);
+ }
+ } else i2 && (yield* i2);
+}
+function* Rs(i2) {
+ if (E(i2)) yield i2;
+ else if (i2 && Symbol.iterator in i2) yield* i2;
+ else if (i2) throw new TypeError("PackSync needs a body that is a string, a Uint8Array, or an iterable");
+}
+async function* Qt(i2) {
+ if (!i2.size) return;
+ let e = i2.size;
+ for await (let s of Es(i2.body)) e = oi(i2, e, s), yield s;
+ let t = ai(i2, e);
+ t.length && (yield t);
+}
+function* ei(i2) {
+ if (!i2.size) return;
+ let e = i2.size;
+ for (let s of Rs(i2.body)) e = oi(i2, e, s), yield s;
+ let t = ai(i2, e);
+ t.length && (yield t);
+}
+function re(i2, e) {
+ let t = y(i2);
+ if (!t.file) return gt(t, e), je(Ve(t, e));
+ try {
+ return gt(t, e), Ts(Ve(t, e), t.fs, t.file, t.mode || 438);
+ } catch (s) {
+ return Promise.reject(s);
+ }
+}
+function Xe(i2, e) {
+ let t = y(i2);
+ gt(t, e);
+ let { file: s } = t, n = t.fs, r = St(t, e);
+ if (!s) return r;
+ let o = n.openSync(s, "w", t.mode || 438);
+ try {
+ kt(n, o, r, 0);
+ } catch (a) {
+ try {
+ n.closeSync(o);
+ } catch {
+ }
+ throw a;
+ }
+ n.closeSync(o);
+}
+function Bo(i2, e) {
+ return re(g(i2, Q, true), e);
+}
+function Ho(i2, e) {
+ return Xe(g(i2, ee, true), e);
+}
+var Bs, Hs, import_node_path, import_node_buffer, _s, Ui, Li, E, rt, L, Ue, Ci, Di, A, z, Le, ot, At, Mi, _i, Tt, Ii, Bi, Nt, zt, de, ie, D, pe, fe, C, M, at, ue, $i, Gi, me, Ce, Wi, R, ji, O, ct, Yi, I, qi, Vi, Xi, Ki, Zi, _, Ji, Qi, es, ht, j, Ot, Y, ts, is, ss, T, Ft, y, F, k, q, ns, rs, De, V, Pt, Ut, Lt, we, ye, Ct, ge, x, Dt, X, Me, _e, Mt, lt, os3, as2, cs, _t, It, B, hs, Bt, ls, Be, Ie, H, $, dt, ke, fs, Se, Ht, He, $t, us, xe, Gt, ms, S, b, pt, Wt, jt, $e, ft, ws, ys, ut, Yt, K, gs, G, be, Ge, Vt, We, je, se, xs, Xt, ne, ks, N, ve, Z, mt, P, wt, Kt, Ye, Ss, ti, yt, ii, si, ni, bs, ri, vs, U, Ee, Zt, Jt, oi, ai, Re, Ae, Te, qe, As, gt, ci, xt, kt, Ts, Ve, St, Ke, J, hi, Ze, li, Ns, di, pi, bt, fi, oe, W, ui, mi, wi, yi, gi, vt, xi, ae, zs, ki, Ne, Si, Os, bi, Fs, Je, ce, Ps, vi, ze, Ei, Oe, Fe, Ri, Qe, Ai, Ti, Ni, Us, et, zi, Pe, he, tt, Ls, Cs, Oi, it, Fi, st, nt, Is, Et, Pi, Rt, Q, ee, Gs, Ws, g, Lo, Co, Do, Mo, _o, Io, $o, Go, Wo, jo, Yo, qo;
+var init_index_min = __esm({
+ "node_modules/tar/dist/esm/server/index.min.js"() {
+ Bs = __toESM(require("node:fs"), 1);
+ Hs = __toESM(require("node:fs/promises"), 1);
+ import_node_path = require("node:path");
+ import_node_buffer = require("node:buffer");
+ _s = __toESM(require("node:zlib"), 1);
+ Ui = Object.defineProperty;
+ Li = (i2, e) => {
+ for (var t in e) Ui(i2, t, { get: e[t], enumerable: true });
+ };
+ E = (i2) => ArrayBuffer.isView(i2) && i2[Symbol.toStringTag] === "Uint8Array";
+ rt = (i2) => Object.prototype.toString.call(i2) === "[object ArrayBuffer]";
+ L = (i2) => typeof i2?.size == "number" && typeof i2.stream == "function";
+ Ue = (i2) => typeof i2?.getReader == "function";
+ Ci = new TextDecoder("utf-8", { ignoreBOM: true });
+ Di = new TextEncoder();
+ A = (i2) => {
+ let e = i2.length;
+ for (let t = 0; t < i2.length; t++) {
+ let s = i2.charCodeAt(t);
+ s < 128 || (s < 2048 ? e += 1 : s >= 55296 && s <= 56319 && (i2.charCodeAt(t + 1) & 64512) === 56320 ? (e += 2, t++) : e += 2);
+ }
+ return e;
+ };
+ z = (i2, e = 0, t = i2.length) => {
+ let s = "";
+ for (let n = e; n < t; n++) {
+ let r = i2[n];
+ if (r >= 128) return Ci.decode(i2.subarray(e, t));
+ s += String.fromCharCode(r);
+ }
+ return s;
+ };
+ Le = (i2, e, t, s) => {
+ let { written: n } = Di.encodeInto(i2, e.subarray(t, t + s));
+ e.fill(0, t + n, t + s);
+ };
+ ot = (i2, e, t) => {
+ for (let s = 0; s < i2.length; s++) e[t + s] = i2.charCodeAt(s);
+ };
+ At = (i2, e) => {
+ if (Number.isSafeInteger(i2)) i2 < 0 ? _i(i2, e) : Mi(i2, e);
+ else throw Error("cannot encode number outside of javascript safe integer range");
+ return e;
+ };
+ Mi = (i2, e) => {
+ e[0] = 128;
+ for (var t = e.length; t > 1; t--) e[t - 1] = i2 & 255, i2 = Math.floor(i2 / 256);
+ };
+ _i = (i2, e) => {
+ e[0] = 255;
+ var t = false;
+ i2 = i2 * -1;
+ for (var s = e.length; s > 1; s--) {
+ var n = i2 & 255;
+ i2 = Math.floor(i2 / 256), t ? e[s - 1] = Nt(n) : n === 0 ? e[s - 1] = 0 : (t = true, e[s - 1] = zt(n));
+ }
+ };
+ Tt = (i2) => {
+ let e = i2[0], t = e === 128 ? Bi(i2.subarray(1, i2.length)) : e === 255 ? Ii(i2) : null;
+ if (t === null) throw Error("invalid base256 encoding");
+ if (!Number.isSafeInteger(t)) throw Error("parsed number outside of javascript safe integer range");
+ return t;
+ };
+ Ii = (i2) => {
+ for (var e = i2.length, t = 0, s = false, n = e - 1; n > -1; n--) {
+ var r = Number(i2[n]), o;
+ s ? o = Nt(r) : r === 0 ? o = r : (s = true, o = zt(r)), o !== 0 && (t -= o * Math.pow(256, e - n - 1));
+ }
+ return t;
+ };
+ Bi = (i2) => {
+ for (var e = i2.length, t = 0, s = e - 1; s > -1; s--) {
+ var n = Number(i2[s]);
+ n !== 0 && (t += n * Math.pow(256, e - s - 1));
+ }
+ return t;
+ };
+ Nt = (i2) => (255 ^ i2) & 255;
+ zt = (i2) => (255 ^ i2) + 1 & 255;
+ de = (i2) => {
+ let e = i2.charCodeAt(0) === 47, t = [];
+ for (let r of i2.split("/")) r === "" || r === "." || (r !== ".." ? t.push(r) : t.length && t[t.length - 1] !== ".." ? t.pop() : e || t.push(r));
+ let s = t.length && i2.charCodeAt(i2.length - 1) === 47, n = t.join("/") + (s ? "/" : "");
+ return e ? "/" + n : n || (i2.endsWith("/") ? "./" : ".");
+ };
+ ie = (...i2) => de(i2.filter((e) => e).join("/"));
+ D = (i2) => {
+ let e = i2.length;
+ for (; e > 1 && i2.charCodeAt(e - 1) === 47; ) e--;
+ let t = i2.lastIndexOf("/", e - 1);
+ return t === -1 ? "." : t === 0 ? "/" : t === 1 && i2.charCodeAt(0) === 47 ? "//" : i2.slice(0, t);
+ };
+ pe = (i2) => {
+ let e = i2.length;
+ for (; e > 0 && i2.charCodeAt(e - 1) === 47; ) e--;
+ return i2.slice(i2.lastIndexOf("/", e - 1) + 1, e);
+ };
+ fe = (i2) => i2.charCodeAt(0) === 47;
+ C = (...i2) => {
+ let e = "";
+ for (let s = i2.length - 1; s >= 0 && !fe(e); s--) {
+ let n = i2[s];
+ n && (e = e ? n + "/" + e : n);
+ }
+ let t = de(e);
+ return t.length > 1 && t.endsWith("/") ? t.slice(0, -1) : t;
+ };
+ M = (i2, e) => {
+ let t = C(i2).split("/"), s = C(e).split("/");
+ t[t.length - 1] || t.pop(), s[s.length - 1] || s.pop();
+ let n = 0;
+ for (; n < t.length && n < s.length && t[n] === s[n]; ) n++;
+ return [...Array.from({ length: t.length - n }, () => ".."), ...s.slice(n)].join("/");
+ };
+ at = {};
+ Li(at, { code: () => Ce, isCode: () => ue, isName: () => $i, name: () => me, normalFsTypes: () => Gi });
+ ue = (i2) => me.has(i2);
+ $i = (i2) => Ce.has(i2);
+ Gi = /* @__PURE__ */ new Set(["0", "", "1", "2", "3", "4", "5", "6", "7", "D"]);
+ me = /* @__PURE__ */ new Map([["0", "File"], ["", "OldFile"], ["1", "Link"], ["2", "SymbolicLink"], ["3", "CharacterDevice"], ["4", "BlockDevice"], ["5", "Directory"], ["6", "FIFO"], ["7", "ContiguousFile"], ["g", "GlobalExtendedHeader"], ["x", "ExtendedHeader"], ["A", "SolarisACL"], ["D", "GNUDumpDir"], ["I", "Inode"], ["K", "NextFileHasLongLinkpath"], ["L", "NextFileHasLongPath"], ["M", "ContinuationFile"], ["N", "OldGnuLongPath"], ["S", "SparseFile"], ["V", "TapeVolumeHeader"], ["X", "OldExtendedHeader"]]);
+ Ce = new Map(Array.from(me).map((i2) => [i2[1], i2[0]]));
+ Wi = (i2) => i2 === void 0 || i2 < 0 ? void 0 : i2;
+ R = class {
+ cksumValid = false;
+ needPax = false;
+ nullBlock = false;
+ block;
+ path;
+ mode;
+ uid;
+ gid;
+ size;
+ cksum;
+ #e = "Unsupported";
+ linkpath;
+ uname;
+ gname;
+ devmaj = 0;
+ devmin = 0;
+ atime;
+ ctime;
+ mtime;
+ charset;
+ comment;
+ sparse;
+ constructor(e, t = 0, s, n) {
+ E(e) ? this.decode(e, t || 0, s, n) : e && this.#t(e);
+ }
+ decode(e, t, s, n) {
+ if (t || (t = 0), !e || !(e.length >= t + 512)) throw new Error("need 512 bytes for header");
+ let r = O(e, t + 156, 1), o = /^[xgXLK]$/.test(r), a = o ? void 0 : s, c = o ? void 0 : n;
+ if (this.path = a?.path ?? O(e, t, 100), this.mode = a?.mode ?? c?.mode ?? I(e, t + 100, 8), this.uid = a?.uid ?? c?.uid ?? I(e, t + 108, 8), this.gid = a?.gid ?? c?.gid ?? I(e, t + 116, 8), this.size = Wi(a?.size ?? Vi(e, t + 124)), this.mtime = a?.mtime ?? c?.mtime ?? ct(e, t + 136, 12), this.cksum = I(e, t + 148, 12), c && this.#t(c, true), a && this.#t(a), ue(r) && (this.#e = r || "0"), this.#e === "5" && (this.size = 0), this.#e === "0" && this.path.slice(-1) === "/" && (this.#e = "5"), this.linkpath = O(e, t + 157, 100), z(e, t + 257, t + 263) === "ustar\0") if (this.uname = a?.uname ?? c?.uname ?? O(e, t + 265, 32), this.gname = a?.gname ?? c?.gname ?? O(e, t + 297, 32), this.devmaj = a?.devmaj ?? c?.devmaj ?? I(e, t + 329, 8) ?? 0, this.devmin = a?.devmin ?? c?.devmin ?? I(e, t + 337, 8) ?? 0, e[t + 475] !== 0) {
+ let l = O(e, t + 345, 155);
+ l && (this.path = l + "/" + this.path);
} else {
- this[OBJECTMODE] = false;
- this[ENCODING] = null;
- }
- this[ASYNC] = !!options.async;
- this[DECODER] = this[ENCODING] ? new import_node_string_decoder.StringDecoder(this[ENCODING]) : null;
- if (options && options.debugExposeBuffer === true) {
- Object.defineProperty(this, "buffer", { get: () => this[BUFFER] });
- }
- if (options && options.debugExposePipes === true) {
- Object.defineProperty(this, "pipes", { get: () => this[PIPES] });
- }
- const { signal } = options;
- if (signal) {
- this[SIGNAL] = signal;
- if (signal.aborted) {
- this[ABORT]();
- } else {
- signal.addEventListener("abort", () => this[ABORT]());
- }
- }
+ let l = O(e, t + 345, 130);
+ l && (this.path = l + "/" + this.path), this.atime = s?.atime ?? n?.atime ?? ct(e, t + 476, 12), this.ctime = s?.ctime ?? n?.ctime ?? ct(e, t + 488, 12);
+ }
+ let h = 256;
+ for (let l = t; l < t + 148; l++) h += e[l];
+ for (let l = t + 156; l < t + 512; l++) h += e[l];
+ this.cksumValid = h === this.cksum, this.cksum === void 0 && h === 256 && (this.nullBlock = true);
+ }
+ #t(e, t = false) {
+ Object.assign(this, Object.fromEntries(Object.entries(e).filter(([s, n]) => !(n == null || s === "size" && (t || Number(n) < 0) || s === "path" && t || s === "linkpath" && t || s === "global"))));
+ }
+ encode(e, t = 0) {
+ if (e || (e = this.block = new Uint8Array(512)), this.#e === "Unsupported" && (this.#e = "0"), !(e.length >= t + 512)) throw new Error("need 512 bytes for header");
+ let s = this.ctime || this.atime ? 130 : 155, n = ji(this.path || "", s), r = n[0], o = n[1];
+ this.needPax = !!n[2], this.needPax = j(e, t, 100, r) || this.needPax, this.needPax = _(e, t + 100, 8, this.mode) || this.needPax, this.needPax = _(e, t + 108, 8, this.uid) || this.needPax, this.needPax = _(e, t + 116, 8, this.gid) || this.needPax, this.needPax = _(e, t + 124, 12, this.size) || this.needPax, this.needPax = ht(e, t + 136, 12, this.mtime) || this.needPax, e[t + 156] = Number(this.#e.codePointAt(0)), this.needPax = j(e, t + 157, 100, this.linkpath) || this.needPax, ot("ustar\x0000", e, t + 257), this.needPax = j(e, t + 265, 32, this.uname) || this.needPax, this.needPax = j(e, t + 297, 32, this.gname) || this.needPax, this.needPax = _(e, t + 329, 8, this.devmaj) || this.needPax, this.needPax = _(e, t + 337, 8, this.devmin) || this.needPax, this.needPax = j(e, t + 345, s, o) || this.needPax, e[t + 475] !== 0 ? this.needPax = j(e, t + 345, 155, o) || this.needPax : (this.needPax = j(e, t + 345, 130, o) || this.needPax, this.needPax = ht(e, t + 476, 12, this.atime) || this.needPax, this.needPax = ht(e, t + 488, 12, this.ctime) || this.needPax);
+ let a = 256;
+ for (let c = t; c < t + 148; c++) a += e[c];
+ for (let c = t + 156; c < t + 512; c++) a += e[c];
+ return this.cksum = a, _(e, t + 148, 8, this.cksum), this.cksumValid = true, this.needPax;
}
- /**
- * The amount of data stored in the buffer waiting to be read.
- *
- * For Buffer strings, this will be the total byte length.
- * For string encoding streams, this will be the string character length,
- * according to JavaScript's `string.length` logic.
- * For objectMode streams, this is a count of the items waiting to be
- * emitted.
- */
- get bufferLength() {
- return this[BUFFERLENGTH];
+ get type() {
+ return this.#e === "Unsupported" ? this.#e : me.get(this.#e);
}
- /**
- * The `BufferEncoding` currently in use, or `null`
- */
- get encoding() {
- return this[ENCODING];
+ get typeKey() {
+ return this.#e;
}
- /**
- * @deprecated - This is a read only property
- */
- set encoding(_enc) {
- throw new Error("Encoding must be set at instantiation time");
+ set type(e) {
+ let t = String(Ce.get(e));
+ if (ue(t) || t === "Unsupported") this.#e = t;
+ else if (ue(e)) this.#e = e;
+ else throw new TypeError("invalid entry type: " + e);
}
- /**
- * @deprecated - Encoding may only be set at instantiation time
- */
- setEncoding(_enc) {
- throw new Error("Encoding must be set at instantiation time");
+ };
+ ji = (i2, e) => {
+ let s = i2, n = "", r, o = i2.charAt(0) === "/" ? "/" : ".";
+ if (A(s) < 100) r = [s, n, false];
+ else {
+ n = D(s), s = pe(s);
+ do
+ A(s) <= 100 && A(n) <= e ? r = [s, n, false] : A(s) > 100 && A(n) <= e ? r = [s.slice(0, 99), n, true] : (s = ie(pe(n), s), n = D(n));
+ while (n !== o && r === void 0);
+ r || (r = [i2.slice(0, 99), "", true]);
}
- /**
- * True if this is an objectMode stream
- */
- get objectMode() {
- return this[OBJECTMODE];
+ return r;
+ };
+ O = (i2, e, t) => {
+ let s = e, n = Math.min(e + t, i2.length);
+ for (; s < n && i2[s] !== 0; ) s++;
+ return z(i2, e, s);
+ };
+ ct = (i2, e, t) => Yi(I(i2, e, t));
+ Yi = (i2) => i2 === void 0 ? void 0 : new Date(i2 * 1e3);
+ I = (i2, e, t) => Number(i2[e]) & 128 ? qi(i2.subarray(e, e + t)) : Ki(i2, e, t);
+ qi = (i2) => {
+ try {
+ return Tt(i2);
+ } catch {
+ return;
}
- /**
- * @deprecated - This is a read-only property
- */
- set objectMode(_om) {
- throw new Error("objectMode must be set at instantiation time");
+ };
+ Vi = (i2, e) => {
+ if (Number(i2[e]) & 128) return I(i2, e, 12);
+ let t = O(i2, e, 12);
+ return /^ *[0-7]* *$/.test(t) && i2.subarray(e + t.length, e + 12).every((s) => s === 0) ? parseInt(t, 8) || 0 : void 0;
+ };
+ Xi = (i2) => isNaN(i2) ? void 0 : i2;
+ Ki = (i2, e, t) => Xi(parseInt(O(i2, e, t).trim(), 8));
+ Zi = { 12: 8589934591, 8: 2097151 };
+ _ = (i2, e, t, s) => s === void 0 ? false : s > Zi[t] || s < 0 ? (At(s, i2.subarray(e, e + t)), true) : (Ji(i2, e, t, s), false);
+ Ji = (i2, e, t, s) => ot(Qi(s, t), i2, e);
+ Qi = (i2, e) => es(Math.floor(i2).toString(8), e);
+ es = (i2, e) => (i2.length === e - 1 ? i2 : "0".repeat(e - i2.length - 2) + i2 + " ") + "\0";
+ ht = (i2, e, t, s) => s === void 0 ? false : _(i2, e, t, Math.floor(s.getTime() / 1e3));
+ j = (i2, e, t, s) => s === void 0 ? false : (Le(s, i2, e, t), s.length !== A(s) || s.length > t);
+ Ot = /^\d+$/;
+ Y = class i {
+ atime;
+ mtime;
+ ctime;
+ charset;
+ comment;
+ gid;
+ uid;
+ gname;
+ uname;
+ linkpath;
+ dev;
+ ino;
+ nlink;
+ path;
+ size;
+ mode;
+ sparse;
+ global;
+ constructor(e, t = false) {
+ this.atime = e.atime, this.charset = e.charset, this.comment = e.comment, this.ctime = e.ctime, this.dev = e.dev, this.gid = e.gid, this.global = t, this.gname = e.gname, this.ino = e.ino, this.linkpath = e.linkpath, this.mtime = e.mtime, this.nlink = e.nlink, this.path = e.path, this.size = e.size, this.sparse = e.sparse, this.uid = e.uid, this.uname = e.uname;
}
- /**
- * true if this is an async stream
- */
- get ["async"]() {
- return this[ASYNC];
+ encode() {
+ let e = this.encodeBody();
+ if (e === "") return new Uint8Array(0);
+ let t = A(e), s = 512 * Math.ceil(1 + t / 512), n = new Uint8Array(s);
+ return new R({ path: ("PaxHeader/" + pe(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: t, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(n), Le(e, n, 512, t), n;
}
- /**
- * Set to true to make this stream async.
- *
- * Once set, it cannot be unset, as this would potentially cause incorrect
- * behavior. Ie, a sync stream can be made async, but an async stream
- * cannot be safely made sync.
- */
- set ["async"](a) {
- this[ASYNC] = this[ASYNC] || !!a;
+ encodeBody() {
+ return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
}
- // drop everything and get out of the flow completely
- [ABORT]() {
- this[ABORTED] = true;
- this.emit("abort", this[SIGNAL]?.reason);
- this.destroy(this[SIGNAL]?.reason);
+ encodeField(e) {
+ if (this[e] === void 0) return "";
+ let t = this[e], s = typeof t == "object" ? t.getTime() / 1e3 : t, n = " " + (e === "dev" || e === "ino" || e === "nlink" ? "SCHILY." : "") + e + "=" + s + `
+`, r = A(n), o = Math.floor(Math.log(r) / Math.log(10)) + 1;
+ return r + o >= Math.pow(10, o) && (o += 1), o + r + n;
+ }
+ static parse(e, t, s = false) {
+ return i.parseBytes(new TextEncoder().encode(e), t, s);
+ }
+ static parseBytes(e, t, s = false) {
+ return new i(ts(is(e), t), s);
+ }
+ };
+ ts = (i2, e) => e ? Object.assign({}, e, i2) : i2;
+ is = (i2) => {
+ let e = /* @__PURE__ */ Object.create(null), t = 0;
+ for (; t < i2.length && i2[t] !== 0; ) {
+ let s = t;
+ for (; s < i2.length && i2[s] >= 48 && i2[s] <= 57; ) s++;
+ let n = t + Number(z(i2, t, s));
+ if (s === t || i2[s] !== 32 || i2[s + 1] === 32 || i2[s + 1] === 9 || n <= s + 1 || n > i2.length || i2[n - 1] !== 10) throw new Error("invalid PAX record");
+ ss(e, z(i2, s + 1, n - 1)), t = n;
+ }
+ return e;
+ };
+ ss = (i2, e) => {
+ let t = e.split("=");
+ if (t.length === 1) throw new Error("invalid PAX record");
+ let s = t.shift();
+ if (!s) return i2;
+ let n = s.replace(/^SCHILY\.(dev|ino|nlink)/, "$1");
+ n.startsWith("GNU.sparse.") && (i2.sparse = true);
+ let r = t.join("="), o = r.indexOf("\0"), a = o === -1 ? r : r.slice(0, o);
+ switch (n) {
+ case "path":
+ case "linkpath":
+ case "type":
+ case "charset":
+ case "comment":
+ case "gname":
+ case "uname":
+ i2[n] = a;
+ break;
+ case "ctime":
+ case "atime":
+ case "mtime":
+ let c = new Date(Number(a) * 1e3);
+ isNaN(c.getTime()) || (i2[n] = c);
+ break;
+ case "size":
+ if (!Ot.test(r) || !Number.isSafeInteger(+r)) throw new Error("invalid PAX size");
+ i2[n] = +r;
+ break;
+ case "gid":
+ case "uid":
+ case "dev":
+ case "ino":
+ case "nlink":
+ case "mode":
+ if (!Ot.test(a.trim())) break;
+ let h = +a;
+ if (!Number.isSafeInteger(h)) break;
+ i2[n] = h;
+ break;
}
- /**
- * True if the stream has been aborted.
- */
- get aborted() {
- return this[ABORTED];
+ return i2;
+ };
+ T = { name: "gzip", headLength: 2, detect: (i2) => i2[0] === 31 && i2[1] === 139, decompress: () => new DecompressionStream("gzip"), compress: (i2) => {
+ let e = new CompressionStream("gzip");
+ if (!i2?.portable) return e;
+ let t = 0;
+ return { writable: e.writable, readable: e.readable.pipeThrough(new TransformStream({ transform: (s, n) => {
+ t <= 9 && t + s.length > 9 && (s[9 - t] = 255), t += s.length, n.enqueue(s);
+ } })) };
+ } };
+ Ft = { C: "cwd", f: "file", z: "gzip", P: "preservePaths", U: "unlink", "strip-components": "strip", stripComponents: "strip", "keep-newer": "newer", keepNewer: "newer", "keep-newer-files": "newer", keepNewerFiles: "newer", k: "keep", "keep-existing": "keep", keepExisting: "keep", m: "noMtime", "no-mtime": "noMtime", p: "preserveOwner", L: "follow", h: "follow", onentry: "onEntry", onReadEntry: "onEntry" };
+ y = (i2) => {
+ let e = Object.assign(/* @__PURE__ */ Object.create(null), i2);
+ for (let [t, s] of Object.entries(Ft)) e[t] !== void 0 && (e[s] ??= e[t]), delete e[t];
+ return e.noChmod === false && (e.chmod ??= true), delete e.noChmod, e;
+ };
+ F = (i2) => {
+ if (i2.length === 1) return i2[0].slice();
+ let e = 0;
+ for (let n of i2) e += n.length;
+ let t = new Uint8Array(e), s = 0;
+ for (let n of i2) t.set(n, s), s += n.length;
+ return t;
+ };
+ k = (i2, e) => Object.assign(/* @__PURE__ */ Object.create(null), i2, e);
+ q = (i2, e, t) => {
+ if (e == null || e === 0) return t;
+ if (e === 1 / 0 || Number.isInteger(e) && Number(e) > 0) return e;
+ throw new TypeError(`${i2} must be a positive integer`);
+ };
+ ns = /* @__PURE__ */ new Set(["File", "OldFile", "ContiguousFile"]);
+ rs = /* @__PURE__ */ new Set(["File", "OldFile", "Link", "SymbolicLink", "CharacterDevice", "BlockDevice", "Directory", "FIFO", "ContiguousFile", "GNUDumpDir", "SparseFile"]);
+ De = (i2) => i2.replaceAll("\\", "/");
+ V = class {
+ header;
+ extended;
+ globalExtended;
+ type;
+ path;
+ mode;
+ uid;
+ gid;
+ uname;
+ gname;
+ size;
+ mtime;
+ atime;
+ ctime;
+ linkpath;
+ devmaj;
+ devmin;
+ dev;
+ ino;
+ nlink;
+ absolute;
+ ignore;
+ invalid = false;
+ unsupported = false;
+ constructor(e, t, s, n = false) {
+ if (!e.path) throw new Error("no path provided for tar.ReadEntry");
+ this.header = e, this.extended = t, this.globalExtended = s, this.type = e.sparse && ns.has(e.type) ? "SparseFile" : e.type, this.ignore = !rs.has(this.type), this.path = n ? De(e.path) : e.path, this.mode = e.mode && e.mode & 4095, this.uid = e.uid, this.gid = e.gid, this.uname = e.uname, this.gname = e.gname, this.size = e.size ?? 0, this.mtime = e.mtime, this.atime = e.atime, this.ctime = e.ctime;
+ let r = this.type === "Link" || this.type === "SymbolicLink";
+ this.linkpath = r && e.linkpath ? n ? De(e.linkpath) : e.linkpath : void 0, this.devmaj = e.devmaj, this.devmin = e.devmin, s && this.#e(s), t && (this.#e(t), t.path != null && (this.path = n ? De(t.path) : t.path), r && t.linkpath != null && (this.linkpath = n ? De(t.linkpath) : t.linkpath));
+ }
+ #e(e) {
+ e.uid != null && (this.uid = e.uid), e.gid != null && (this.gid = e.gid), e.uname != null && (this.uname = e.uname), e.gname != null && (this.gname = e.gname), e.mtime != null && (this.mtime = e.mtime), e.atime != null && (this.atime = e.atime), e.ctime != null && (this.ctime = e.ctime), e.dev != null && (this.dev = e.dev), e.ino != null && (this.ino = e.ino), e.nlink != null && (this.nlink = e.nlink);
+ }
+ };
+ Pt = new TextDecoder();
+ Ut = (i2) => {
+ let e = "";
+ for (let t of i2) e += Pt.decode(t, { stream: true });
+ return e + Pt.decode();
+ };
+ Lt = () => new TypeError("Body has already been consumed");
+ we = class extends V {
+ #e;
+ #t = false;
+ #i;
+ constructor(e, t, s, n, r) {
+ super(e, t, s, n), this.#e = r;
+ }
+ get bodyUsed() {
+ return this.#t;
+ }
+ get body() {
+ if (this.#i) return this.#i;
+ let e = false;
+ return this.#i = new ReadableStream({ pull: async (t) => {
+ e || (this.#s(), e = true);
+ let [s] = await this.#n(1);
+ s ? t.enqueue(s) : t.close();
+ } }, { highWaterMark: 0 });
+ }
+ #s() {
+ if (this.#t) throw Lt();
+ this.#t = true;
+ }
+ #r(e, t = 1 / 0) {
+ let s = this.#e;
+ for (; s && e.length < t; ) {
+ let n = s.readBody(this);
+ if (n === null) break;
+ if (n === void 0) return false;
+ e.push(n);
+ }
+ return true;
}
- /**
- * No-op setter. Stream aborted status is set via the AbortSignal provided
- * in the constructor options.
- */
- set aborted(_) {
+ async #n(e) {
+ let t = [];
+ for (; !this.#r(t, e); ) await this.#e?.fill();
+ return t;
+ }
+ async bytes() {
+ this.#s();
+ let e = [];
+ for (; !this.#r(e); ) await this.#e?.fill();
+ return F(e);
+ }
+ async arrayBuffer() {
+ return (await this.bytes()).buffer;
+ }
+ async text() {
+ return this.#s(), Ut(await this.#n());
+ }
+ async blob() {
+ return this.#s(), new Blob(await this.#n());
+ }
+ };
+ ye = class extends V {
+ #e;
+ #t = false;
+ #i;
+ constructor(e, t, s, n, r) {
+ super(e, t, s, n), this.#e = r;
+ }
+ get bodyUsed() {
+ return this.#t;
+ }
+ get body() {
+ return this.#i ??= this.#s();
+ }
+ *#s() {
+ this.#r();
+ for (let e; e = this.#e?.readBody(this); ) yield e;
+ }
+ #r() {
+ if (this.#t) throw Lt();
+ this.#t = true;
+ }
+ #n() {
+ this.#r();
+ let e = [];
+ for (let t; t = this.#e?.readBody(this); ) e.push(t);
+ return e;
+ }
+ bytes() {
+ return F(this.#n());
+ }
+ arrayBuffer() {
+ return this.bytes().buffer;
+ }
+ text() {
+ return Ut(this.#n());
+ }
+ };
+ Ct = (i2, e, t, s) => (i2.file && (s.file = i2.file), s.code = typeof t == "object" && t.code || e, s.tarCode = e, s);
+ ge = (i2, e, t, s = {}) => Object.assign(typeof t == "object" ? t : new Error(`${e}: ${t}`), Ct(i2, e, t, s));
+ x = (i2, e, t, s = {}) => {
+ let n = Object.hasOwn(s, "recoverable") && s.recoverable === false;
+ if (i2.strict || n) throw ge(i2, e, t, s);
+ Ct(i2, e, t, s), typeof t == "object" && (s = Object.assign(t, s), t = t.message), i2.onwarn?.(e, t, s);
+ };
+ Dt = 0;
+ X = 1;
+ Me = 2;
+ _e = 3;
+ Mt = 4;
+ lt = { type: "entryEnd" };
+ os3 = { type: "end" };
+ as2 = /* @__PURE__ */ new Set(["ExtendedHeader", "OldExtendedHeader", "GlobalExtendedHeader", "NextFileHasLongPath", "NextFileHasLongLinkpath"]);
+ cs = /* @__PURE__ */ new Set(["Link", "SymbolicLink", "CharacterDevice", "BlockDevice", "FIFO", "TapeVolumeHeader"]);
+ _t = (i2, e, t) => {
+ for (let s = 0; s < t; s++) if (!i2[e + s * 24] || !i2[e + s * 24 + 12]) return false;
+ return true;
+ };
+ It = (i2) => {
+ let e = i2.indexOf(0);
+ return z(i2, 0, e === -1 ? i2.length : e);
+ };
+ B = class {
+ maxMetaEntrySize;
+ position = 0;
+ offset = 0;
+ #e;
+ #t;
+ #i;
+ #s = [];
+ #r;
+ #n = 0;
+ #a;
+ #o = 0;
+ #c = Dt;
+ #l;
+ #d;
+ #y;
+ #x = 0;
+ #f = 0;
+ #p = 0;
+ #u;
+ #w;
+ #k;
+ #R;
+ #S;
+ #b = false;
+ #g;
+ #v = false;
+ #m = false;
+ #E = 0;
+ constructor(e = {}, t) {
+ e = this.#e = k(e), this.maxMetaEntrySize = e.maxMetaEntrySize || 1024 * 1024, this.#t = e.filter;
+ let s = e.platform === "win32";
+ this.#i = t ?? ((n, r, o) => new V(n, r, o, s));
+ }
+ warn(e, t, s) {
+ x(this.#e, e, t, s);
+ }
+ push(e) {
+ this.#b || this.#s.push(e);
}
- write(chunk, encoding, cb) {
- if (this[ABORTED])
- return false;
- if (this[EOF])
- throw new Error("write after end");
- if (this[DESTROYED]) {
- this.emit("error", Object.assign(new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" }));
- return true;
+ end() {
+ this.#b = true;
+ }
+ get bodyRemain() {
+ let e = this.#r, t = this.#c;
+ return t !== Me && t !== _e || this.#s.length || e && this.#n < e.length ? 0 : this.#p;
+ }
+ skipBody() {
+ this.#m = this.#c === Me, this.offset += this.#p, this.#f = this.#p = 0, this.#A();
+ }
+ next() {
+ if (this.#m) return this.#m = false, lt;
+ for (; ; ) {
+ let e = this.#r, t = this.#n;
+ if (!e || t === e.length) {
+ if (e = this.#r = this.#s.shift(), t = this.#n = 0, !e) {
+ if (!this.#b || this.#E === 2) return;
+ let l = this.#O();
+ if (l) return l;
+ }
+ continue;
+ }
+ let s = e.length - t, n = this.#c;
+ if (n <= X) {
+ let l;
+ if (this.#o === 0 && s >= 512) this.#n = t + 512, l = this.#N(e, t);
+ else {
+ let d = this.#a ??= new Uint8Array(512), p = Math.min(512 - this.#o, s);
+ if (d.set(e.subarray(t, t + p), this.#o), this.#n = t + p, this.#o += p, this.#o < 512) continue;
+ this.#o = 0, l = this.#N(d, 0);
+ }
+ if (l) return l;
+ continue;
+ }
+ let r = this.#p, o = s < r ? s : r, a = this.#f, c = o < a ? o : a;
+ this.#n = t + o, this.offset += o, this.#p = r - o, this.#f = a - c;
+ let h = o === r;
+ if (n === Mt) {
+ let l = this.#y;
+ l.set(e.subarray(t, t + c), this.#x), this.#x += c, h && (this.#A(), this.#F(l));
+ continue;
+ }
+ if (h && this.#A(), n !== _e) {
+ if (c === 0) {
+ if (h) return lt;
+ continue;
+ }
+ return this.#m = h, { type: "body", data: c === e.length ? e : e.subarray(t, t + c) };
+ }
}
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = "utf8";
- }
- if (!encoding)
- encoding = "utf8";
- const fn2 = this[ASYNC] ? defer : nodefer;
- if (!this[OBJECTMODE] && !Buffer.isBuffer(chunk)) {
- if (isArrayBufferView(chunk)) {
- chunk = Buffer.from(chunk.buffer, chunk.byteOffset, chunk.byteLength);
- } else if (isArrayBufferLike(chunk)) {
- chunk = Buffer.from(chunk);
- } else if (typeof chunk !== "string") {
- throw new Error("Non-contiguous data written to non-objectMode stream");
- }
- }
- if (this[OBJECTMODE]) {
- if (this[FLOWING] && this[BUFFERLENGTH] !== 0)
- this[FLUSH](true);
- if (this[FLOWING])
- this.emit("data", chunk);
- else
- this[BUFFERPUSH](chunk);
- if (this[BUFFERLENGTH] !== 0)
- this.emit("readable");
- if (cb)
- fn2(cb);
- return this[FLOWING];
- }
- if (!chunk.length) {
- if (this[BUFFERLENGTH] !== 0)
- this.emit("readable");
- if (cb)
- fn2(cb);
- return this[FLOWING];
- }
- if (typeof chunk === "string" && // unless it is a string already ready for us to use
- !(encoding === this[ENCODING] && !this[DECODER]?.lastNeed)) {
- chunk = Buffer.from(chunk, encoding);
- }
- if (Buffer.isBuffer(chunk) && this[ENCODING]) {
- chunk = this[DECODER].write(chunk);
- }
- if (this[FLOWING] && this[BUFFERLENGTH] !== 0)
- this[FLUSH](true);
- if (this[FLOWING])
- this.emit("data", chunk);
- else
- this[BUFFERPUSH](chunk);
- if (this[BUFFERLENGTH] !== 0)
- this.emit("readable");
- if (cb)
- fn2(cb);
- return this[FLOWING];
}
- /**
- * Low-level explicit read method.
- *
- * In objectMode, the argument is ignored, and one item is returned if
- * available.
- *
- * `n` is the number of bytes (or in the case of encoding streams,
- * characters) to consume. If `n` is not provided, then the entire buffer
- * is returned, or `null` is returned if no data is available.
- *
- * If `n` is greater that the amount of data in the internal buffer,
- * then `null` is returned.
- */
- read(n) {
- if (this[DESTROYED])
- return null;
- this[DISCARDED] = false;
- if (this[BUFFERLENGTH] === 0 || n === 0 || n && n > this[BUFFERLENGTH]) {
- this[MAYBE_EMIT_END]();
- return null;
+ #A() {
+ let e = this.#l;
+ e && (this.position = this.offset, this.#l = void 0), !e?.invalid && !this.#v && (this.#g = true), this.#v = false, this.#c = X;
+ }
+ #O() {
+ let e = this.#c;
+ if (e > X) {
+ let t = this.#l, s = (512 - this.#p % 512) % 512, n = this.#p + s;
+ this.#l = void 0, this.#y = void 0, this.#c = X, !t?.invalid && !this.#v && (this.#g = true), this.#v = false, this.#m = e === Me, this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${n} more bytes, only ${s} available)`, { entry: t, header: this.#d });
+ return;
}
- if (this[OBJECTMODE])
- n = null;
- if (this[BUFFER].length > 1 && !this[OBJECTMODE]) {
- this[BUFFER] = [
- this[ENCODING] ? this[BUFFER].join("") : Buffer.concat(this[BUFFER], this[BUFFERLENGTH])
- ];
+ if (this.#m) return this.#m = false, lt;
+ if (this.#S) {
+ this.#S = void 0, this.warn("TAR_BAD_ARCHIVE", "Truncated input (in the extension blocks of a GNU sparse header)", { header: this.#d });
+ return;
}
- const ret = this[READ](n || null, this[BUFFER][0]);
- this[MAYBE_EMIT_END]();
- return ret;
- }
- [READ](n, chunk) {
- if (this[OBJECTMODE])
- this[BUFFERSHIFT]();
- else {
- const c = chunk;
- if (n === c.length || n === null)
- this[BUFFERSHIFT]();
- else if (typeof c === "string") {
- this[BUFFER][0] = c.slice(n);
- chunk = c.slice(0, n);
- this[BUFFERLENGTH] -= n;
- } else {
- this[BUFFER][0] = c.subarray(n);
- chunk = c.subarray(0, n);
- this[BUFFERLENGTH] -= n;
- }
- }
- this.emit("data", chunk);
- if (!this[BUFFER].length && !this[EOF])
- this.emit("drain");
- return chunk;
- }
- end(chunk, encoding, cb) {
- if (typeof chunk === "function") {
- cb = chunk;
- chunk = void 0;
- }
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = "utf8";
- }
- if (chunk !== void 0)
- this.write(chunk, encoding);
- if (cb)
- this.once("end", cb);
- this[EOF] = true;
- this.writable = false;
- if (this[FLOWING] || !this[PAUSED])
- this[MAYBE_EMIT_END]();
- return this;
+ return this.#E === 0 && (this.#E = 1, (e === Dt || this.#g === false) && this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format")), this.#E = 2, os3;
}
- // don't let the internal resume be overwritten
- [RESUME]() {
- if (this[DESTROYED])
+ #N(e, t) {
+ this.offset += 512, this.#g === void 0 && (this.#g = false);
+ let s = this.#S;
+ if (s) {
+ let f = this.#d;
+ if (!e[t + 504]) return this.#S = void 0, this.#z(f, s.ex);
+ _t(e, t, 21) || this.#h("GNU sparse extension block with an unused extent", f);
return;
- if (!this[DATALISTENERS] && !this[PIPES].length) {
- this[DISCARDED] = true;
- }
- this[PAUSED] = false;
- this[FLOWING] = true;
- this.emit("resume");
- if (this[BUFFER].length)
- this[FLUSH]();
- else if (this[EOF])
- this[MAYBE_EMIT_END]();
- else
- this.emit("drain");
+ }
+ let n = this.#u, r = this.#w, o = this.#k;
+ (r !== void 0 || o !== void 0) && (n = Object.assign(/* @__PURE__ */ Object.create(null), n), n.path ??= r, n.linkpath ??= o);
+ let a = new R(e, t, n, this.#R);
+ if (a.nullBlock) {
+ this.#b = true, this.#r = void 0, this.#s.length = 0, this.#o = 0, this.#c = X;
+ return;
+ }
+ let c = a.type, h = as2.has(c);
+ if (!a.cksumValid) {
+ this.#T(a, "checksum failure", false);
+ return;
+ }
+ let l = z(e, t + 257, t + 265);
+ e[t + 345] && l.startsWith("ustar") && l[5] !== "\0" && l !== "ustar \0" && this.#h("prefix with an unknown ustar magic", a);
+ let d = a.size;
+ d === void 0 && this.#h("invalid size", a), (d && cs.has(c) || c === "Directory" && n?.size) && this.#h(`${c} entry with a body`, a), d && !h && c !== "GNUDumpDir" && a.path?.endsWith("/") && this.#h("entry with a body and a directory name", a);
+ let p = false;
+ if (e[t + 482]) {
+ let f = l === "ustar \0";
+ c === "SparseFile" ? ((!f || !_t(e, t + 386, 4)) && this.#h("GNU sparse extension without the GNU magic and 4 extents", a), p = true) : f && e[t + 386] && this.#h(`GNU sparse extension in a ${c} header`, a);
+ }
+ if (!a.path && !h) {
+ p && this.#h("path is required", a), this.#T(a, "path is required", true);
+ return;
+ }
+ if ((c === "Link" || c === "SymbolicLink") && !(n?.linkpath ?? a.linkpath)) {
+ this.#T(a, "linkpath required", true);
+ return;
+ }
+ if (this.#d = a, this.#f = d, this.#p = 512 * Math.ceil(d / 512), d || (this.#g = true), h) {
+ d > this.maxMetaEntrySize && this.#h(`${c} entry larger than maxMetaEntrySize`, a), (c === "NextFileHasLongPath" ? r !== void 0 : c === "NextFileHasLongLinkpath" ? o !== void 0 : c !== "GlobalExtendedHeader" && this.#u) && this.#h(`two ${c} entries for one entry`, a), this.#u && c.startsWith("NextFile") && this.#h(`${c} entry after a PAX header`, a), d > 0 && (this.#y = new Uint8Array(d), this.#x = 0, this.#c = Mt);
+ return;
+ }
+ if (p) {
+ this.#S = { ex: n };
+ return;
+ }
+ return this.#z(a, n);
}
- /**
- * Resume the stream if it is currently in a paused state
- *
- * If called when there are no pipe destinations or `data` event listeners,
- * this will place the stream in a "discarded" state, where all data will
- * be thrown away. The discarded state is removed if a pipe destination or
- * data handler is added, if pause() is called, or if any synchronous or
- * asynchronous iteration is started.
- */
- resume() {
- return this[RESUME]();
- }
- /**
- * Pause the stream
- */
- pause() {
- this[FLOWING] = false;
- this[PAUSED] = true;
- this[DISCARDED] = false;
+ #z(e, t) {
+ let s = e.size;
+ this.#u = this.#w = this.#k = void 0;
+ let n = this.#i(e, t, this.#R);
+ return !n.ignore && this.#t && !this.#t(n.path, n) && (n.ignore = true), s ? (this.#l = n, this.#c = n.ignore ? _e : Me) : (this.#c = X, this.position = this.offset, this.#m = !n.ignore), { type: "entry", entry: n };
}
- /**
- * true if the stream has been forcibly destroyed
- */
- get destroyed() {
- return this[DESTROYED];
+ #T(e, t, s) {
+ this.#u = this.#w = this.#k = void 0;
+ let n = s ? e.size : 0;
+ n && (this.#d = e, this.#f = n, this.#p = 512 * Math.ceil(n / 512), this.#c = _e, this.#v = true), this.warn("TAR_ENTRY_INVALID", t, { header: e });
}
- /**
- * true if the stream is currently in a flowing state, meaning that
- * any writes will be immediately emitted.
- */
- get flowing() {
- return this[FLOWING];
+ #h(e, t) {
+ throw this.#b = true, this.#r = this.#y = void 0, this.#s.length = 0, this.#o = 0, this.#c = X, this.#E = 2, ge(this.#e, "TAR_BAD_ARCHIVE", e, { header: t, recoverable: false });
}
- /**
- * true if the stream is currently in a paused state
- */
- get paused() {
- return this[PAUSED];
+ #F(e) {
+ let t = this.#d, s = t.type;
+ if (s === "NextFileHasLongPath") {
+ this.#w = It(e);
+ return;
+ }
+ if (s === "NextFileHasLongLinkpath") {
+ this.#k = It(e);
+ return;
+ }
+ let n = s === "GlobalExtendedHeader", r;
+ try {
+ r = Y.parseBytes(e, n ? this.#R : void 0, n);
+ } catch (o) {
+ this.#h(o.message, t);
+ }
+ if (!n) {
+ (r.path !== void 0 && this.#w !== void 0 || r.linkpath !== void 0 && this.#k !== void 0) && this.#h("PAX name after a GNU long name", t), this.#u = r;
+ return;
+ }
+ (r.size !== void 0 || r.path !== void 0 || r.linkpath !== void 0) && this.#h("size or path in a global PAX header", t), this.#R = r;
}
- [BUFFERPUSH](chunk) {
- if (this[OBJECTMODE])
- this[BUFFERLENGTH] += 1;
- else
- this[BUFFERLENGTH] += chunk.length;
- this[BUFFER].push(chunk);
+ };
+ hs = 16 * 1024 * 1024;
+ Bt = 64 * 1024;
+ ls = 1024 * 1024;
+ Be = /* @__PURE__ */ Symbol.for("tar.readFile.skip");
+ Ie = class {
+ pos = 0;
+ size = 0;
+ #e;
+ #t = Bt;
+ constructor(e) {
+ this.#e = q("maxReadSize", e, hs);
}
- [BUFFERSHIFT]() {
- if (this[OBJECTMODE])
- this[BUFFERLENGTH] -= 1;
- else
- this[BUFFERLENGTH] -= this[BUFFER][0].length;
- return this[BUFFER].shift();
+ next() {
+ let e = Math.min(this.#t, this.#e, this.size - this.pos);
+ return this.#t *= 2, e;
}
- [FLUSH](noDrain = false) {
- do {
- } while (this[FLUSHCHUNK](this[BUFFERSHIFT]()) && this[BUFFER].length);
- if (!noDrain && !this[BUFFER].length && !this[EOF])
- this.emit("drain");
+ skip(e) {
+ return e < ls || this.pos + e > this.size ? false : (this.pos += e, this.#t = Bt, true);
}
- [FLUSHCHUNK](chunk) {
- this.emit("data", chunk);
- return this[FLOWING];
+ };
+ H = (i2, e, t) => {
+ let s = new Ie(t);
+ return Object.assign(ds(i2, e, s), { [Be]: (n) => s.skip(n) });
+ };
+ $ = (i2, e, t) => {
+ let s = new Ie(t);
+ return Object.assign(ps(i2, e, s), { [Be]: (n) => s.skip(n) });
+ };
+ dt = () => {
+ };
+ ke = (i2) => Math.max(512, ...i2.map((e) => e.headLength));
+ fs = (i2) => {
+ try {
+ let e = new R(i2);
+ return e.cksumValid || e.nullBlock;
+ } catch {
+ return false;
}
- /**
- * Pipe all data emitted by this stream into the destination provided.
- *
- * Triggers the flow of data.
- */
- pipe(dest, opts) {
- if (this[DESTROYED])
- return dest;
- this[DISCARDED] = false;
- const ended = this[EMITTED_END];
- opts = opts || {};
- if (dest === proc.stdout || dest === proc.stderr)
- opts.end = false;
- else
- opts.end = opts.end !== false;
- opts.proxyErrors = !!opts.proxyErrors;
- if (ended) {
- if (opts.end)
- dest.end();
- } else {
- this[PIPES].push(!opts.proxyErrors ? new Pipe(this, dest, opts) : new PipeProxyErrors(this, dest, opts));
- if (this[ASYNC])
- defer(() => this[RESUME]());
- else
- this[RESUME]();
+ };
+ Se = (i2, e, t = "") => i2.find((s) => s.detect(e)) ?? (fs(e) ? void 0 : i2.find((s) => s.extensions?.some((n) => t.endsWith(n))));
+ Ht = (i2) => typeof i2.maxDecompressionRatio == "number" ? i2.maxDecompressionRatio : 1e3;
+ He = (i2, e) => ge(i2, "TAR_ABORT", e, { recoverable: false });
+ $t = (i2, e, t) => He(i2, new Error(`max decompression ratio exceeded: ${e.toFixed(2)} > ${t}`));
+ us = () => new TypeError("The body of an entry cannot be read after a later entry");
+ xe = class {
+ parser;
+ current;
+ ended = false;
+ constructor(e) {
+ this.parser = e;
+ }
+ entry() {
+ if (this.current = void 0, this.ended) return null;
+ for (let e; e = this.parser.next(); ) {
+ if (e.type === "end") return this.ended = true, null;
+ if (e.type === "entry" && !e.entry.ignore) return this.current = e.entry;
+ }
+ }
+ body(e) {
+ if (e !== this.current) throw us();
+ let t = this.parser.next();
+ if (t) return t.type === "body" ? t.data : (this.current = void 0, null);
+ }
+ };
+ Gt = (i2, e) => {
+ if (i2.current) return;
+ let t = i2.parser.bodyRemain;
+ t && e[Be]?.(t) && i2.parser.skipBody();
+ };
+ ms = (i2) => {
+ if (E(i2)) return [i2].values();
+ if (rt(i2)) return [new Uint8Array(i2)].values();
+ if (L(i2) && (i2 = i2.stream()), Ue(i2)) {
+ let e = i2.getReader();
+ return { next: () => e.read(), return: () => e.cancel() };
+ }
+ return Symbol.asyncIterator in i2 ? i2[Symbol.asyncIterator]() : i2[Symbol.iterator]();
+ };
+ S = class {
+ parser;
+ #e;
+ #t;
+ #i;
+ #s;
+ #r;
+ #n;
+ #a = false;
+ constructor(e, t = {}) {
+ t = k(t);
+ let s = t.platform === "win32";
+ this.parser = new B(t, (n, r, o) => new we(n, r, o, s, this)), this.#e = new xe(this.parser), this.#t = t, this.#i = ms(e);
+ }
+ poll() {
+ return this.#a ? null : this.#e.entry();
+ }
+ readBody(e) {
+ return this.#e.body(e);
+ }
+ fill() {
+ return this.#n ??= this.#o();
+ }
+ async #o() {
+ try {
+ let e = this.#s ??= await this.#c(this.#i), t = this.#r;
+ this.#r = void 0, e === this.#i && Gt(this.#e, e);
+ let s = t ? { value: t, done: false } : await e.next();
+ s.done ? this.parser.end() : this.parser.push(s.value);
+ } finally {
+ this.#n = void 0;
}
- return dest;
}
- /**
- * Fully unhook a piped destination stream.
- *
- * If the destination stream was the only consumer of this stream (ie,
- * there are no other piped destinations or `'data'` event listeners)
- * then the flow of data will stop until there is another consumer or
- * {@link Minipass#resume} is explicitly called.
- */
- unpipe(dest) {
- const p = this[PIPES].find((p2) => p2.dest === dest);
- if (p) {
- if (this[PIPES].length === 1) {
- if (this[FLOWING] && this[DATALISTENERS] === 0) {
- this[FLOWING] = false;
+ async #c(e) {
+ let t = this.#t, s = [...t.codecs ?? [], T], n = ke(s), r;
+ for (; !r || r.length < n; ) {
+ let u = await e.next();
+ if (u.done) break;
+ r = r ? F([r, u.value]) : u.value;
+ }
+ let o = r && Se(s, r, t.file);
+ if (!o) return this.#r = r, e;
+ let a = 0, c = 0, { readable: h, writable: l } = o.decompress(), d = l.getWriter(), p = h.getReader(), f = false;
+ (async () => {
+ try {
+ for (; ; ) {
+ if (await d.ready, f) return;
+ let u = r ? { value: r, done: false } : await e.next();
+ if (r = void 0, f) return;
+ if (u.done) return await d.close();
+ a += u.value.length, await d.write(u.value);
}
- this[PIPES] = [];
- } else
- this[PIPES].splice(this[PIPES].indexOf(p), 1);
- p.unpipe();
+ } catch (u) {
+ f || await d.abort(u).catch(dt);
+ }
+ })();
+ let m = Ht(t);
+ return { next: async () => {
+ let u = await p.read().catch((v) => {
+ throw He(t, v);
+ });
+ if (!u.done) {
+ c += u.value.length;
+ let v = c / a;
+ if (v > m) throw $t(t, v, m);
+ }
+ return u;
+ }, return: async () => (f = true, await p.cancel().catch(dt), await d.abort().catch(dt), await e.return?.(), { value: void 0, done: true }) };
+ }
+ async next() {
+ try {
+ for (; ; ) {
+ let e = this.poll();
+ if (e) return { value: e, done: false };
+ if (e === null) break;
+ await this.fill();
+ }
+ } catch (e) {
+ throw await this.return(), e;
}
+ return this.return();
}
- /**
- * Alias for {@link Minipass#on}
- */
- addListener(ev, handler) {
- return this.on(ev, handler);
+ async return() {
+ return this.#a || (this.#a = true, this.#e.current = void 0, await (this.#s ?? this.#i).return?.()), { value: void 0, done: true };
}
- /**
- * Mostly identical to `EventEmitter.on`, with the following
- * behavior differences to prevent data loss and unnecessary hangs:
- *
- * - Adding a 'data' event handler will trigger the flow of data
- *
- * - Adding a 'readable' event handler when there is data waiting to be read
- * will cause 'readable' to be emitted immediately.
- *
- * - Adding an 'endish' event handler ('end', 'finish', etc.) which has
- * already passed will cause the event to be emitted immediately and all
- * handlers removed.
- *
- * - Adding an 'error' event handler after an error has been emitted will
- * cause the event to be re-emitted immediately with the error previously
- * raised.
- */
- on(ev, handler) {
- const ret = super.on(ev, handler);
- if (ev === "data") {
- this[DISCARDED] = false;
- this[DATALISTENERS]++;
- if (!this[PIPES].length && !this[FLOWING]) {
- this[RESUME]();
- }
- } else if (ev === "readable" && this[BUFFERLENGTH] !== 0) {
- super.emit("readable");
- } else if (isEndish(ev) && this[EMITTED_END]) {
- super.emit(ev);
- this.removeAllListeners(ev);
- } else if (ev === "error" && this[EMITTED_ERROR]) {
- const h = handler;
- if (this[ASYNC])
- defer(() => h.call(this, this[EMITTED_ERROR]));
- else
- h.call(this, this[EMITTED_ERROR]);
- }
- return ret;
+ [Symbol.asyncIterator]() {
+ return this;
}
- /**
- * Alias for {@link Minipass#off}
- */
- removeListener(ev, handler) {
- return this.off(ev, handler);
+ };
+ b = class {
+ parser;
+ #e;
+ #t;
+ #i;
+ #s;
+ #r;
+ #n = false;
+ constructor(e, t = {}) {
+ t = k(t);
+ let s = t.platform === "win32";
+ this.parser = new B(t, (n, r, o) => new ye(n, r, o, s, this)), this.#e = new xe(this.parser), this.#t = t, this.#i = E(e) ? [e].values() : rt(e) ? [new Uint8Array(e)].values() : e[Symbol.iterator]();
+ }
+ readBody(e) {
+ for (; ; ) {
+ let t = this.#e.body(e);
+ if (t !== void 0) return t;
+ this.#a();
+ }
+ }
+ #a() {
+ let e = this.#s ??= this.#o(this.#i), t = this.#r;
+ this.#r = void 0, e === this.#i && Gt(this.#e, e);
+ let s = t ? { value: t, done: false } : e.next();
+ s.done ? this.parser.end() : this.parser.push(s.value);
+ }
+ #o(e) {
+ let t = this.#t, s = [...t.codecs ?? [], T], n = ke(s), r, o;
+ for (; (!r || r.length < n) && !(o = e.next()).done; ) r = r ? F([r, o.value]) : o.value;
+ let a = r && Se(s, r, t.file);
+ if (!r || !a) return this.#r = r, e;
+ let { decompressSync: c } = a;
+ if (!c) throw He(t, new Error(`the ${a.name} codec has no decompressSync function`));
+ let h = [r];
+ for (; !(o = e.next()).done; ) h.push(o.value);
+ let l = F(h), d = Ht(t), p;
+ try {
+ p = c(l, { maxOutputLength: l.length * d });
+ } catch (w) {
+ throw He(t, w);
+ }
+ let f = p.length / l.length;
+ if (f > d) throw $t(t, f, d);
+ return [p].values();
}
- /**
- * Mostly identical to `EventEmitter.off`
- *
- * If a 'data' event handler is removed, and it was the last consumer
- * (ie, there are no pipe destinations or other 'data' event listeners),
- * then the flow of data will stop until there is another consumer or
- * {@link Minipass#resume} is explicitly called.
- */
- off(ev, handler) {
- const ret = super.off(ev, handler);
- if (ev === "data") {
- this[DATALISTENERS] = this.listeners("data").length;
- if (this[DATALISTENERS] === 0 && !this[DISCARDED] && !this[PIPES].length) {
- this[FLOWING] = false;
+ next() {
+ try {
+ for (; ; ) {
+ let e = this.#n ? null : this.#e.entry();
+ if (e) return { value: e, done: false };
+ if (e === null) break;
+ this.#a();
}
+ } catch (e) {
+ throw this.return(), e;
}
- return ret;
+ return this.return();
}
- /**
- * Mostly identical to `EventEmitter.removeAllListeners`
- *
- * If all 'data' event handlers are removed, and they were the last consumer
- * (ie, there are no pipe destinations), then the flow of data will stop
- * until there is another consumer or {@link Minipass#resume} is explicitly
- * called.
- */
- removeAllListeners(ev) {
- const ret = super.removeAllListeners(ev);
- if (ev === "data" || ev === void 0) {
- this[DATALISTENERS] = 0;
- if (!this[DISCARDED] && !this[PIPES].length) {
- this[FLOWING] = false;
+ return() {
+ return this.#n || (this.#n = true, this.#e.current = void 0, (this.#s ?? this.#i).return?.()), { value: void 0, done: true };
+ }
+ [Symbol.iterator]() {
+ return this;
+ }
+ };
+ pt = (i2, e) => new S(i2, e);
+ Wt = (i2, e) => new b(i2, e);
+ jt = (i2, e, t) => (i2 &= 4095, t && (i2 = (i2 | 384) & -19), e && (i2 & 256 && (i2 |= 64), i2 & 32 && (i2 |= 8), i2 & 4 && (i2 |= 1)), i2);
+ $e = ["|", "<", ">", "?", ":"];
+ ft = $e.map((i2) => String.fromCodePoint(61440 + Number(i2.codePointAt(0))));
+ ws = new Map($e.map((i2, e) => [i2, ft[e]]));
+ ys = new Map(ft.map((i2, e) => [i2, $e[e]]));
+ ut = (i2) => $e.reduce((e, t) => e.split(t).join(ws.get(t)), i2);
+ Yt = (i2) => ft.reduce((e, t) => e.split(t).join(ys.get(t)), i2);
+ K = (i2) => i2 === 47 || i2 === 92;
+ gs = (i2) => i2 >= 65 && i2 <= 90 || i2 >= 97 && i2 <= 122;
+ G = (i2) => {
+ let e = i2.length, t = 0;
+ if (K(i2.charCodeAt(0))) {
+ if (t = 1, K(i2.charCodeAt(1))) {
+ let s = 2, n = s;
+ for (; s < e && !K(i2.charCodeAt(s)); ) s++;
+ if (s < e && s !== n) {
+ for (n = s; s < e && K(i2.charCodeAt(s)); ) s++;
+ if (s < e && s !== n) {
+ for (n = s; s < e && !K(i2.charCodeAt(s)); ) s++;
+ s === e ? t = s : s !== n && (t = s + 1);
+ }
}
}
- return ret;
- }
- /**
- * true if the 'end' event has been emitted
- */
- get emittedEnd() {
- return this[EMITTED_END];
+ } else gs(i2.charCodeAt(0)) && i2.charCodeAt(1) === 58 && (t = K(i2.charCodeAt(2)) ? 3 : 2);
+ return i2.slice(0, t);
+ };
+ be = (i2) => K(i2.charCodeAt(0)) || G(i2).length === 3;
+ Ge = (i2, e) => {
+ let t = be(e) ? e : i2 + "/" + e, s = G(t);
+ return s + C("/", t.slice(s.length)).slice(1);
+ };
+ Vt = (i2) => {
+ let e = G(i2), t = D(i2.slice(e.length));
+ return t === "." ? e : e + t;
+ };
+ We = (i2) => {
+ let e = "";
+ for (let t; t = G(i2); ) i2.charAt(0) === "/" && i2.slice(0, 4) !== "//?/" && (t = "/"), i2 = i2.slice(t.length), e += t;
+ return [e, i2];
+ };
+ je = (i2) => new ReadableStream({ pull: async (e) => {
+ let t = await i2.next();
+ t.done ? e.close() : e.enqueue(t.value);
+ }, cancel: async () => {
+ await i2.return?.();
+ } }, { highWaterMark: 0 });
+ se = (i2) => {
+ let e = i2.length - 1, t = -1;
+ for (; e > -1 && i2.charAt(e) === "/"; ) t = e, e--;
+ return t === -1 ? i2 : i2.slice(0, t);
+ };
+ xs = new TextEncoder();
+ Xt = (i2, e) => e ? se(e) + "/" + i2.replace(/^\.(\/|$)/, "") : i2;
+ ne = class {
+ path;
+ type;
+ mode;
+ uid;
+ gid;
+ uname;
+ gname;
+ size;
+ mtime;
+ atime;
+ ctime;
+ linkpath;
+ dev;
+ ino;
+ nlink;
+ body;
+ absolute;
+ header;
+ constructor(e, t) {
+ if (e.type === "Unsupported") throw new Error("writing entry that should be ignored");
+ if (typeof t == "string" && (t = xs.encode(t)), this.path = e.path, this.type = e.type ?? "File", this.mode = e.mode, this.uid = e.uid, this.gid = e.gid, this.uname = e.uname, this.gname = e.gname, e.size === void 0 && t !== void 0 && !E(t) && !L(t)) throw new TypeError("a stream body needs the size option");
+ this.size = e.size ?? (E(t) ? t.length : L(t) ? t.size : 0), this.mtime = e.mtime, this.atime = e.atime, this.ctime = e.ctime, this.linkpath = e.linkpath, this.dev = e.dev, this.ino = e.ino, this.nlink = e.nlink, this.body = t;
+ }
+ encode(e = {}, t = new Uint8Array(512)) {
+ e = k(e);
+ let s = Xt(this.path, e.prefix), n = this.type === "Link" && this.linkpath !== void 0 ? Xt(this.linkpath, e.prefix) : this.linkpath, { uid: r, gid: o, uname: a, gname: c, size: h, mtime: l, atime: d, ctime: p } = this;
+ if (this.header = new R({ path: s, linkpath: n, mode: this.mode, uid: r, gid: o, size: h, mtime: l, type: this.type, uname: a, gname: c, atime: d, ctime: p }), !this.header.encode(t) || e.noPax) return [t];
+ let { dev: f, ino: w, nlink: m } = this;
+ return [new Y({ atime: d, ctime: p, gid: o, gname: c, mtime: l, path: s, linkpath: n, size: h, uid: r, uname: a, dev: f, ino: w, nlink: m }).encode(), t];
+ }
+ };
+ ks = 16 * 1024 * 1024;
+ N = () => {
+ };
+ ve = (i2) => 512 * Math.ceil(i2 / 512);
+ Z = (i2) => i2.replaceAll("\\", "/");
+ mt = (i2) => `${i2.dev}:${i2.ino}`;
+ P = { bigint: true };
+ wt = ({ dev: i2, ino: e }) => typeof e == "number" && !(Number.isSafeInteger(i2) && Number.isSafeInteger(e));
+ Kt = (i2, e) => typeof i2 == typeof e ? i2 === e : Number(i2) === Number(e);
+ Ye = (i2, e) => Kt(i2.dev, e.dev) && Kt(i2.ino, e.ino);
+ Ss = (i2) => typeof i2.size == "number" ? i2 : { isFile: () => i2.isFile(), isDirectory: () => i2.isDirectory(), isSymbolicLink: () => i2.isSymbolicLink(), dev: Number(i2.dev), ino: Number(i2.ino), nlink: Number(i2.nlink), mode: Number(i2.mode), uid: Number(i2.uid), gid: Number(i2.gid), size: Number(i2.size), mtime: i2.mtime, atime: i2.atime, ctime: i2.ctime };
+ ti = (i2, e) => typeof i2.ino == "bigint" && typeof e.ino == "bigint" && !(i2.dev === e.dev && i2.ino === e.ino);
+ yt = (i2, e) => Object.assign(new Error(i2), { path: e, syscall: "read", code: "EOF" });
+ ii = (i2, e) => yt(`encountered unexpected EOF: ${i2} has fewer than the ${e} bytes of its stat`, i2);
+ si = (i2, e) => yt(`did not encounter expected EOF: ${i2} has more than the ${e} bytes of its stat`, i2);
+ ni = (i2) => i2.absolute ?? i2.path;
+ bs = (i2) => Object.assign(new Error("writing more data than expected"), { path: ni(i2) });
+ ri = (i2) => Symbol.asyncIterator in i2 || Symbol.iterator in i2;
+ vs = (i2) => typeof i2.encode == "function";
+ U = class {
+ path;
+ absolute;
+ up;
+ linkpath;
+ ready;
+ constructor(e, t) {
+ this.path = e, this.absolute = t;
}
- [MAYBE_EMIT_END]() {
- if (!this[EMITTING_END] && !this[EMITTED_END] && !this[DESTROYED] && this[BUFFER].length === 0 && this[EOF]) {
- this[EMITTING_END] = true;
- this.emit("end");
- this.emit("prefinish");
- this.emit("finish");
- if (this[CLOSED])
- this.emit("close");
- this[EMITTING_END] = false;
+ };
+ Ee = class {
+ opt;
+ fs;
+ cwd;
+ win32;
+ big;
+ maxReadSize;
+ header;
+ codec;
+ codecOptions;
+ ended = false;
+ head;
+ tail;
+ wake;
+ #e = /* @__PURE__ */ new Map();
+ constructor(e, t) {
+ e = this.opt = k(e), this.fs = e.fs, this.win32 = e.platform === "win32", (e.bigint ?? this.win32) && (this.big = P), this.maxReadSize = q("maxReadSize", e.maxReadSize, ks);
+ let { prefix: s, noPax: n } = e;
+ this.header = { prefix: s && this.win32 ? Z(s) : s, noPax: n };
+ let r = e.cwd && (this.win32 ? Z(e.cwd) : e.cwd);
+ if (r && !(this.win32 ? be : fe)(r)) throw new TypeError("cwd must be an absolute path");
+ this.cwd = r && this.#t(r, "");
+ let o = e, a = ["gzip", "brotli", "zstd", "compress"].filter((h) => o[h]);
+ if (a.length > 1) throw new TypeError(`${a.join(", ")} are mutually exclusive`);
+ let [c] = a;
+ if (c) {
+ let h = e.compress, [l, d] = h ? Array.isArray(h) ? h : [h] : [[...e.codecs ?? [], T].find((p) => p.name === c), o[c]];
+ if (!l?.[t]) throw new TypeError(`no codec named ${l?.name ?? c} has a ${t} function`);
+ this.codec = l, this.codecOptions = { ...typeof d == "object" ? d : void 0, ...l.name === "gzip" && e.portable ? { portable: true } : void 0 };
+ }
+ }
+ #t(e, t) {
+ return this.win32 ? Ge(e, t) : C(e, t);
+ }
+ resolve(e) {
+ if (!this.cwd || !this.fs) throw new TypeError("a path needs the cwd and fs options");
+ return this.#t(this.cwd, this.win32 ? Z(e) : e);
+ }
+ add(e) {
+ if (this.ended) throw new Error("write after end");
+ if (typeof e != "string") this.push(e);
+ else {
+ let t = this.win32 ? Z(e) : e;
+ this.push(new U(t || "./", this.resolve(t)));
}
+ return this;
}
- /**
- * Mostly identical to `EventEmitter.emit`, with the following
- * behavior differences to prevent data loss and unnecessary hangs:
- *
- * If the stream has been destroyed, and the event is something other
- * than 'close' or 'error', then `false` is returned and no handlers
- * are called.
- *
- * If the event is 'end', and has already been emitted, then the event
- * is ignored. If the stream is in a paused or non-flowing state, then
- * the event will be deferred until data flow resumes. If the stream is
- * async, then handlers will be called on the next tick rather than
- * immediately.
- *
- * If the event is 'close', and 'end' has not yet been emitted, then
- * the event will be deferred until after 'end' is emitted.
- *
- * If the event is 'error', and an AbortSignal was provided for the stream,
- * and there are no listeners, then the event is ignored, matching the
- * behavior of node core streams in the presense of an AbortSignal.
- *
- * If the event is 'finish' or 'prefinish', then all listeners will be
- * removed after emitting the event, to prevent double-firing.
- */
- emit(ev, ...args) {
- const data = args[0];
- if (ev !== "error" && ev !== "close" && ev !== DESTROYED && this[DESTROYED]) {
- return false;
- } else if (ev === "data") {
- return !this[OBJECTMODE] && !data ? false : this[ASYNC] ? (defer(() => this[EMITDATA](data)), true) : this[EMITDATA](data);
- } else if (ev === "end") {
- return this[EMITEND]();
- } else if (ev === "close") {
- this[CLOSED] = true;
- if (!this[EMITTED_END] && !this[DESTROYED])
- return false;
- const ret2 = super.emit("close");
- this.removeAllListeners("close");
- return ret2;
- } else if (ev === "error") {
- this[EMITTED_ERROR] = data;
- super.emit(ERROR, data);
- const ret2 = !this[SIGNAL] || this.listeners("error").length ? super.emit("error", data) : false;
- this[MAYBE_EMIT_END]();
- return ret2;
- } else if (ev === "resume") {
- const ret2 = super.emit("resume");
- this[MAYBE_EMIT_END]();
- return ret2;
- } else if (ev === "finish" || ev === "prefinish") {
- const ret2 = super.emit(ev);
- this.removeAllListeners(ev);
- return ret2;
- }
- const ret = super.emit(ev, ...args);
- this[MAYBE_EMIT_END]();
- return ret;
+ end() {
+ return this.ended = true, this.wake?.(), this;
}
- [EMITDATA](data) {
- for (const p of this[PIPES]) {
- if (p.dest.write(data) === false)
- this.pause();
- }
- const ret = this[DISCARDED] ? false : super.emit("data", data);
- this[MAYBE_EMIT_END]();
- return ret;
+ push(e) {
+ let t = { item: e };
+ this.tail ? this.tail.next = t : this.head = t, this.tail = t, this.wake?.();
}
- [EMITEND]() {
- if (this[EMITTED_END])
- return false;
- this[EMITTED_END] = true;
- this.readable = false;
- return this[ASYNC] ? (defer(() => this[EMITEND2]()), true) : this[EMITEND2]();
- }
- [EMITEND2]() {
- if (this[DECODER]) {
- const data = this[DECODER].end();
- if (data) {
- for (const p of this[PIPES]) {
- p.dest.write(data);
+ shift() {
+ this.head = this.head?.next, this.head || (this.tail = void 0);
+ }
+ needsExact(e) {
+ return wt(e) && (e.isDirectory() ? !!this.opt.follow : e.isFile() && e.nlink > 1);
+ }
+ plan(e, t, s) {
+ let { filter: n } = this.opt;
+ if (!(n && !n(e.path, Ss(t)))) {
+ if (t.isDirectory()) {
+ for (let r = e.up; r; r = r.up) if (r.key === mt(s)) {
+ x(this.opt, "TAR_ENTRY_ERROR", "directory is its own ancestor", { path: e.path, absolute: e.absolute });
+ return;
}
- if (!this[DISCARDED])
- super.emit("data", data);
+ return "Directory";
}
+ if (t.isSymbolicLink()) return "SymbolicLink";
+ if (!t.isFile()) {
+ x(this.opt, "TAR_ENTRY_UNSUPPORTED", "unsupported file type", { path: e.path, absolute: e.absolute });
+ return;
+ }
+ if (t.nlink > 1) {
+ let r = mt(s), o = this.#e.get(r), a = this.cwd;
+ if (o !== e.absolute && o?.startsWith(a.endsWith("/") ? a : a + "/")) return e.linkpath = M(a, o), "Link";
+ this.#e.set(r, e.absolute);
+ }
+ return "File";
}
- for (const p of this[PIPES]) {
- p.end();
- }
- const ret = super.emit("end");
- this.removeAllListeners("end");
- return ret;
}
- /**
- * Return a Promise that resolves to an array of all emitted data once
- * the stream ends.
- */
- async collect() {
- const buf = Object.assign([], {
- dataLength: 0
- });
- if (!this[OBJECTMODE])
- buf.dataLength = 0;
- const p = this.promise();
- this.on("data", (c) => {
- buf.push(c);
- if (!this[OBJECTMODE])
- buf.dataLength += c.length;
+ children(e, t, s) {
+ let n = e.path === "./" ? "" : e.path.replace(/\/*$/, "/"), r = e.absolute.endsWith("/") ? e.absolute : e.absolute + "/", o = this.opt.follow ? { key: mt(s), up: e.up } : void 0;
+ return [...t].sort().map((a) => {
+ let c = new U(n + a, r + a);
+ return c.up = o, c;
});
- await p;
- return buf;
}
- /**
- * Return a Promise that resolves to the concatenation of all emitted data
- * once the stream ends.
- *
- * Not allowed on objectMode streams.
- */
- async concat() {
- if (this[OBJECTMODE]) {
- throw new Error("cannot concat in objectMode");
- }
- const buf = await this.collect();
- return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
+ missing(e, t) {
+ if (t?.code !== "ENOENT") throw t;
+ x(this.opt, "TAR_ENTRY_ERROR", t, { path: e.path, absolute: e.absolute });
}
- /**
- * Return a void Promise that resolves once the stream ends.
- */
- async promise() {
- return new Promise((resolve, reject) => {
- this.on(DESTROYED, () => reject(new Error("stream destroyed")));
- this.on("error", (er) => reject(er));
- this.on("end", () => resolve());
- });
+ changed(e, t) {
+ x(this.opt, "TAR_ENTRY_ERROR", t === "Directory" ? "directory changed between lstat and readdir" : "file changed between lstat and open", { path: e.path, absolute: e.absolute });
}
- /**
- * Asynchronous `for await of` iteration.
- *
- * This will continue emitting all chunks until the stream terminates.
- */
- [Symbol.asyncIterator]() {
- this[DISCARDED] = false;
- let stopped = false;
- const stop = async () => {
- this.pause();
- stopped = true;
- return { value: void 0, done: true };
- };
- const next = () => {
- if (stopped)
- return stop();
- const res = this.read();
- if (res !== null)
- return Promise.resolve({ done: false, value: res });
- if (this[EOF])
- return stop();
- let resolve;
- let reject;
- const onerr = (er) => {
- this.off("data", ondata);
- this.off("end", onend);
- this.off(DESTROYED, ondestroy);
- stop();
- reject(er);
- };
- const ondata = (value) => {
- this.off("error", onerr);
- this.off("end", onend);
- this.off(DESTROYED, ondestroy);
- this.pause();
- resolve({ value, done: !!this[EOF] });
- };
- const onend = () => {
- this.off("error", onerr);
- this.off("data", ondata);
- this.off(DESTROYED, ondestroy);
- stop();
- resolve({ done: true, value: void 0 });
- };
- const ondestroy = () => onerr(new Error("stream destroyed"));
- return new Promise((res2, rej) => {
- reject = rej;
- resolve = res2;
- this.once(DESTROYED, ondestroy);
- this.once("error", onerr);
- this.once("end", onend);
- this.once("data", ondata);
- });
- };
- return {
- next,
- throw: stop,
- return: stop,
- [Symbol.asyncIterator]() {
- return this;
- },
- [Symbol.asyncDispose]: async () => {
- }
- };
+ pathEntry(e, t, s, n, r) {
+ let { processUid: o, processUname: a = "" } = this.opt, c = Number(t.uid), h = new ne({ path: e.path, type: s, mode: Number(t.mode), uid: c, gid: Number(t.gid), uname: c === o ? a : "", size: s === "File" ? Number(t.size) : 0, mtime: t.mtime, atime: t.atime, ctime: t.ctime, linkpath: n && this.win32 ? Z(n) : n, dev: Number(t.dev), ino: Number(t.ino), nlink: Number(t.nlink) }, r);
+ return h.absolute = e.absolute, this.#i(h, true);
}
- /**
- * Synchronous `for of` iteration.
- *
- * The iteration will terminate when the internal buffer runs out, even
- * if the stream has not yet terminated.
- */
- [Symbol.iterator]() {
- this[DISCARDED] = false;
- let stopped = false;
- const stop = () => {
- this.pause();
- this.off(ERROR, stop);
- this.off(DESTROYED, stop);
- this.off("end", stop);
- stopped = true;
- return { done: true, value: void 0 };
- };
- const next = () => {
- if (stopped)
- return stop();
- const value = this.read();
- return value === null ? stop() : { done: false, value };
- };
- this.once("end", stop);
- this.once(ERROR, stop);
- this.once(DESTROYED, stop);
- return {
- next,
- throw: stop,
- return: stop,
- [Symbol.iterator]() {
- return this;
- },
- [Symbol.dispose]: () => {
+ addedEntry(e) {
+ if (vs(e)) return this.#i(e, false);
+ let { filter: t } = this.opt;
+ if (!(t && !t(e.path, e))) {
+ if (e.type === "SparseFile") {
+ x(this.opt, "TAR_ENTRY_UNSUPPORTED", "unsupported entry type", { entry: e });
+ return;
}
- };
- }
- /**
- * Destroy a stream, preventing it from being used for any further purpose.
- *
- * If the stream has a `close()` method, then it will be called on
- * destruction.
- *
- * After destruction, any attempt to write data, read data, or emit most
- * events will be ignored.
- *
- * If an error argument is provided, then it will be emitted in an
- * 'error' event.
- */
- destroy(er) {
- if (this[DESTROYED]) {
- if (er)
- this.emit("error", er);
- else
- this.emit(DESTROYED);
- return this;
+ return this.#i(new ne(e, e.body), false);
}
- this[DESTROYED] = true;
- this[DISCARDED] = true;
- this[BUFFER].length = 0;
- this[BUFFERLENGTH] = 0;
- const wc = this;
- if (typeof wc.close === "function" && !this[CLOSED])
- wc.close();
- if (er)
- this.emit("error", er);
- else
- this.emit(DESTROYED);
- return this;
}
- /**
- * Alias for {@link isStream}
- *
- * Former export location, maintained for backwards compatibility.
- *
- * @deprecated
- */
- static get isStream() {
- return isStream;
+ #i(e, t) {
+ let { opt: s, win32: n } = this, r = e.type === "Directory";
+ n && !t && (e.path = Z(e.path), e.linkpath && (e.linkpath = Z(e.linkpath)));
+ let [o, a] = s.preservePaths ? ["", e.path] : We(e.path);
+ return e.path = a, t && (n && (e.path = Yt(e.path)), e.path === "" && (e.path = "./")), o && x(s, "TAR_ENTRY_INFO", `stripping ${o} from absolute path`, { entry: e, path: o + e.path }), t && r && !e.path.endsWith("/") && (e.path += "/"), s.portable && (e.uid = e.gid = e.dev = e.ino = e.nlink = void 0, e.uname = e.gname = void 0, e.atime = e.ctime = void 0), e.mode !== void 0 && (e.mode = jt(e.mode, r, !!s.portable)), e.mtime = s.noMtime || s.portable && r ? void 0 : s.mtime || e.mtime, e;
}
};
- }
-});
-
-// node_modules/@isaacs/fs-minipass/dist/esm/index.js
-var import_events2, import_fs2, writev, _autoClose, _close, _ended, _fd, _finished, _flags, _flush, _handleChunk, _makeBuf, _mode, _needDrain, _onerror, _onopen, _onread, _onwrite, _open, _path, _pos, _queue, _read, _readSize, _reading, _remain, _size, _write, _writing, _defaultFlag, _errored, ReadStream, ReadStreamSync, WriteStream, WriteStreamSync;
-var init_esm2 = __esm({
- "node_modules/@isaacs/fs-minipass/dist/esm/index.js"() {
- import_events2 = __toESM(require("events"), 1);
- import_fs2 = __toESM(require("fs"), 1);
- init_esm();
- writev = import_fs2.default.writev;
- _autoClose = /* @__PURE__ */ Symbol("_autoClose");
- _close = /* @__PURE__ */ Symbol("_close");
- _ended = /* @__PURE__ */ Symbol("_ended");
- _fd = /* @__PURE__ */ Symbol("_fd");
- _finished = /* @__PURE__ */ Symbol("_finished");
- _flags = /* @__PURE__ */ Symbol("_flags");
- _flush = /* @__PURE__ */ Symbol("_flush");
- _handleChunk = /* @__PURE__ */ Symbol("_handleChunk");
- _makeBuf = /* @__PURE__ */ Symbol("_makeBuf");
- _mode = /* @__PURE__ */ Symbol("_mode");
- _needDrain = /* @__PURE__ */ Symbol("_needDrain");
- _onerror = /* @__PURE__ */ Symbol("_onerror");
- _onopen = /* @__PURE__ */ Symbol("_onopen");
- _onread = /* @__PURE__ */ Symbol("_onread");
- _onwrite = /* @__PURE__ */ Symbol("_onwrite");
- _open = /* @__PURE__ */ Symbol("_open");
- _path = /* @__PURE__ */ Symbol("_path");
- _pos = /* @__PURE__ */ Symbol("_pos");
- _queue = /* @__PURE__ */ Symbol("_queue");
- _read = /* @__PURE__ */ Symbol("_read");
- _readSize = /* @__PURE__ */ Symbol("_readSize");
- _reading = /* @__PURE__ */ Symbol("_reading");
- _remain = /* @__PURE__ */ Symbol("_remain");
- _size = /* @__PURE__ */ Symbol("_size");
- _write = /* @__PURE__ */ Symbol("_write");
- _writing = /* @__PURE__ */ Symbol("_writing");
- _defaultFlag = /* @__PURE__ */ Symbol("_defaultFlag");
- _errored = /* @__PURE__ */ Symbol("_errored");
- ReadStream = class extends Minipass {
- [_errored] = false;
- [_fd];
- [_path];
- [_readSize];
- [_reading] = false;
- [_size];
- [_remain];
- [_autoClose];
- constructor(path16, opt) {
- opt = opt || {};
- super(opt);
- this.readable = true;
- this.writable = false;
- if (typeof path16 !== "string") {
- throw new TypeError("path must be a string");
- }
- this[_errored] = false;
- this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0;
- this[_path] = path16;
- this[_readSize] = opt.readSize || 16 * 1024 * 1024;
- this[_reading] = false;
- this[_size] = typeof opt.size === "number" ? opt.size : Infinity;
- this[_remain] = this[_size];
- this[_autoClose] = typeof opt.autoClose === "boolean" ? opt.autoClose : true;
- if (typeof this[_fd] === "number") {
- this[_read]();
- } else {
- this[_open]();
- }
- }
- get fd() {
- return this[_fd];
+ Zt = async (i2, e, t, s, n, r) => {
+ for (; t < e.length && s < n; ) {
+ let { bytesRead: o } = await i2.read(e, t, e.length - t, s);
+ if (o <= 0) throw ii(r, n);
+ if (o > n - s) throw si(r, n);
+ t += o, s += o;
}
- get path() {
- return this[_path];
+ return s;
+ };
+ Jt = (i2, e, t, s, n, r, o) => {
+ for (; s < t.length && n < r; ) {
+ let a = i2.readSync(e, t, s, t.length - s, n);
+ if (a <= 0) throw ii(o, r);
+ if (a > r - n) throw si(o, r);
+ s += a, n += a;
}
- //@ts-ignore
- write() {
- throw new TypeError("this is a readable stream");
+ return n;
+ };
+ oi = (i2, e, t) => {
+ if (t.length > e) throw bs(i2);
+ return e - t.length;
+ };
+ ai = (i2, e) => {
+ if (e) throw yt("encountered unexpected EOF", ni(i2));
+ return new Uint8Array(ve(i2.size) - i2.size);
+ };
+ Re = class extends Ee {
+ jobs;
+ #e;
+ #t = Promise.resolve();
+ constructor(e = {}) {
+ super(e, "compress"), this.jobs = q("jobs", this.opt.jobs, 4);
}
- //@ts-ignore
- end() {
- throw new TypeError("this is a readable stream");
+ async next() {
+ let e = await (this.#e ??= this.#i()).next();
+ return e.done ? { value: void 0, done: true } : e;
}
- [_open]() {
- import_fs2.default.open(this[_path], "r", (er, fd) => this[_onopen](er, fd));
+ async return() {
+ return this.end(), await this.#e?.return(), { value: void 0, done: true };
}
- [_onopen](er, fd) {
- if (er) {
- this[_onerror](er);
- } else {
- this[_fd] = fd;
- this.emit("open", fd);
- this[_read]();
- }
+ [Symbol.asyncIterator]() {
+ return this;
}
- [_makeBuf]() {
- return Buffer.allocUnsafe(Math.min(this[_readSize], this[_remain]));
+ #i() {
+ let { codec: e } = this;
+ return e?.compress ? this.#s(e.compress(this.codecOptions)) : this.#r();
}
- [_read]() {
- if (!this[_reading]) {
- this[_reading] = true;
- const buf = this[_makeBuf]();
- if (buf.length === 0) {
- return process.nextTick(() => this[_onread](null, 0, buf));
+ async *#s(e) {
+ let t = this.#r(), s, n = je({ next: () => t.next().catch((r) => {
+ throw s = { er: r }, n.cancel().catch(N), r;
+ }) }).pipeThrough(e).getReader();
+ try {
+ for (; ; ) {
+ let r = await n.read();
+ if (s) throw s.er;
+ if (r.done) break;
+ yield r.value;
}
- import_fs2.default.read(this[_fd], buf, 0, buf.length, null, (er, br, b) => this[_onread](er, br, b));
- }
- }
- [_onread](er, br, buf) {
- this[_reading] = false;
- if (er) {
- this[_onerror](er);
- } else if (this[_handleChunk](br, buf)) {
- this[_read]();
- }
- }
- [_close]() {
- if (this[_autoClose] && typeof this[_fd] === "number") {
- const fd = this[_fd];
- this[_fd] = void 0;
- import_fs2.default.close(fd, (er) => er ? this.emit("error", er) : this.emit("close"));
- }
- }
- [_onerror](er) {
- this[_reading] = true;
- this[_close]();
- this.emit("error", er);
- }
- [_handleChunk](br, buf) {
- let ret = false;
- this[_remain] -= br;
- if (br > 0) {
- ret = super.write(br < buf.length ? buf.subarray(0, br) : buf);
- }
- if (br === 0 || this[_remain] <= 0) {
- ret = false;
- this[_close]();
- super.end();
- }
- return ret;
- }
- emit(ev, ...args) {
- switch (ev) {
- case "prefinish":
- case "finish":
- return false;
- case "drain":
- if (typeof this[_fd] === "number") {
- this[_read]();
- }
- return false;
- case "error":
- if (this[_errored]) {
- return false;
- }
- this[_errored] = true;
- return super.emit(ev, ...args);
- default:
- return super.emit(ev, ...args);
+ } finally {
+ await n.cancel().catch(N), await t.return();
}
}
- };
- ReadStreamSync = class extends ReadStream {
- [_open]() {
- let threw = true;
+ async *#r() {
try {
- this[_onopen](null, import_fs2.default.openSync(this[_path], "r"));
- threw = false;
+ for (; ; ) {
+ let e = this.head;
+ if (!e) {
+ if (this.ended) break;
+ await new Promise((s) => this.wake = s);
+ continue;
+ }
+ this.#n();
+ let { item: t } = e;
+ if (t instanceof U) yield* this.#c(t);
+ else if (!ri(t)) yield* this.#d(t);
+ else for await (let s of t) yield* this.#d(s);
+ this.shift();
+ }
+ yield new Uint8Array(1024);
} finally {
- if (threw) {
- this[_close]();
+ for (let e = this.head; e; e = e.next) {
+ let { item: t } = e;
+ if (!(t instanceof U) || !t.ready) break;
+ await (await t.ready.catch(N))?.handle?.close().catch(N);
+ }
+ }
+ }
+ #n() {
+ let e = this.fs, t = this.head;
+ for (let s = 0; t && s < this.jobs; s++, t = t.next) {
+ let n = t.item;
+ if (!(n instanceof U)) break;
+ if (n.ready) continue;
+ let r = this.#a(e, n.absolute);
+ r.catch(N);
+ let o = this.#t.then(() => r).then(([a, c]) => {
+ let h = this.plan(n, a, c);
+ return h && { load: this.#o(e, n, a, c, h) };
+ }, (a) => this.missing(n, a));
+ this.#t = o.catch(N), n.ready = o.then((a) => a?.load), n.ready.catch(N);
+ }
+ }
+ async #a(e, t) {
+ let { follow: s } = this.opt, { big: n } = this, r = await (s ? e.stat(t, n) : e.lstat(t, n)), o = this.needsExact(r) ? await (s ? e.stat(t, P) : e.lstat(t, P)) : r;
+ return [r, o];
+ }
+ async #o(e, t, s, n, r) {
+ let { absolute: o } = t, { follow: a, noDirRecurse: c } = this.opt, h = { stat: s, id: n, type: r };
+ if (r === "SymbolicLink") h.linkpath = await e.readlink(o);
+ else if (r === "Directory" && !c) {
+ if (h.names = await e.readdir(o), !a) {
+ let l = await e.lstat(o, this.big);
+ h.changed = !l.isDirectory() || !Ye(s, l);
+ }
+ } else if (r === "File" && s.size) {
+ let l = await e.open(o, "r");
+ try {
+ let d = Number(s.size), p = ve(d);
+ !a && (!Ye(s, await l.stat(this.big)) || wt(s) && ti(await l.stat(P), n === s ? await e.lstat(o, P) : n)) ? h.changed = true : p > this.maxReadSize ? h.handle = l : (h.buf = new Uint8Array(512 + p), await Zt(l, h.buf, 512, 0, d, o));
+ } catch (d) {
+ throw await l.close().catch(N), d;
}
+ h.handle || await l.close();
}
+ return h;
}
- [_read]() {
- let threw = true;
+ async *#c(e) {
+ let t = await e.ready;
+ if (!t) return;
+ let { stat: s, id: n, type: r, names: o, buf: a, handle: c } = t;
+ if (t.changed) return this.changed(e, r);
+ let h = Number(s.size), l = false;
try {
- if (!this[_reading]) {
- this[_reading] = true;
- do {
- const buf = this[_makeBuf]();
- const br = buf.length === 0 ? 0 : import_fs2.default.readSync(this[_fd], buf, 0, buf.length, null);
- if (!this[_handleChunk](br, buf)) {
- break;
- }
- } while (true);
- this[_reading] = false;
- }
- threw = false;
+ let d = a ? a.subarray(512, 512 + h) : c && this.#l(c, h, e.absolute), p = this.pathEntry(e, s, r, t.linkpath ?? e.linkpath, d);
+ if (o) for (let w of this.children(e, o, n)) this.push(w);
+ await this.opt.onWriteEntry?.(p);
+ let f = a && p.body === d && p.size === h;
+ yield* p.encode(this.header, f ? a : void 0), f || (yield* Qt(p)), l = true;
} finally {
- if (threw) {
- this[_close]();
- }
- }
- }
- [_close]() {
- if (this[_autoClose] && typeof this[_fd] === "number") {
- const fd = this[_fd];
- this[_fd] = void 0;
- import_fs2.default.closeSync(fd);
- this.emit("close");
- }
- }
- };
- WriteStream = class extends import_events2.default {
- readable = false;
- writable = true;
- [_errored] = false;
- [_writing] = false;
- [_ended] = false;
- [_queue] = [];
- [_needDrain] = false;
- [_path];
- [_mode];
- [_autoClose];
- [_fd];
- [_defaultFlag];
- [_flags];
- [_finished] = false;
- [_pos];
- constructor(path16, opt) {
- opt = opt || {};
- super(opt);
- this[_path] = path16;
- this[_fd] = typeof opt.fd === "number" ? opt.fd : void 0;
- this[_mode] = opt.mode === void 0 ? 438 : opt.mode;
- this[_pos] = typeof opt.start === "number" ? opt.start : void 0;
- this[_autoClose] = typeof opt.autoClose === "boolean" ? opt.autoClose : true;
- const defaultFlag = this[_pos] !== void 0 ? "r+" : "w";
- this[_defaultFlag] = opt.flags === void 0;
- this[_flags] = opt.flags === void 0 ? defaultFlag : opt.flags;
- if (this[_fd] === void 0) {
- this[_open]();
- }
- }
- emit(ev, ...args) {
- if (ev === "error") {
- if (this[_errored]) {
- return false;
+ if (c) {
+ t.handle = void 0;
+ let d = c.close();
+ await (l ? d : d.catch(N));
}
- this[_errored] = true;
}
- return super.emit(ev, ...args);
}
- get fd() {
- return this[_fd];
+ async *#l(e, t, s) {
+ let n = ve(t);
+ for (let r = 0; r < t; ) {
+ let o = new Uint8Array(Math.min(n - r, this.maxReadSize)), a = await Zt(e, o, 0, r, t, s);
+ yield o.subarray(0, a - r), r = a;
+ }
}
- get path() {
- return this[_path];
+ async *#d(e) {
+ let t = this.addedEntry(e);
+ t && (await this.opt.onWriteEntry?.(t), yield* t.encode(this.header), yield* Qt(t));
}
- [_onerror](er) {
- this[_close]();
- this[_writing] = true;
- this.emit("error", er);
+ };
+ Ae = class extends Ee {
+ #e;
+ constructor(e = {}) {
+ super(e, "compressSync");
}
- [_open]() {
- import_fs2.default.open(this[_path], this[_flags], this[_mode], (er, fd) => this[_onopen](er, fd));
+ next() {
+ let e = (this.#e ??= this.#t()).next();
+ return e.done ? { value: void 0, done: true } : e;
}
- [_onopen](er, fd) {
- if (this[_defaultFlag] && this[_flags] === "r+" && er && er.code === "ENOENT") {
- this[_flags] = "w";
- this[_open]();
- } else if (er) {
- this[_onerror](er);
- } else {
- this[_fd] = fd;
- this.emit("open", fd);
- if (!this[_writing]) {
- this[_flush]();
- }
- }
+ return() {
+ return this.ended = true, this.#e?.return(), { value: void 0, done: true };
}
- end(buf, enc) {
- if (buf) {
- this.write(buf, enc);
- }
- this[_ended] = true;
- if (!this[_writing] && !this[_queue].length && typeof this[_fd] === "number") {
- this[_onwrite](null, 0);
- }
+ [Symbol.iterator]() {
return this;
}
- write(buf, enc) {
- if (typeof buf === "string") {
- buf = Buffer.from(buf, enc);
- }
- if (this[_ended]) {
- this.emit("error", new Error("write() after end()"));
- return false;
- }
- if (this[_fd] === void 0 || this[_writing] || this[_queue].length) {
- this[_queue].push(buf);
- this[_needDrain] = true;
- return false;
- }
- this[_writing] = true;
- this[_write](buf);
- return true;
+ *#t() {
+ let { codec: e } = this;
+ if (!e?.compressSync) return yield* this.#i();
+ yield e.compressSync(F([...this.#i()]), this.codecOptions);
}
- [_write](buf) {
- import_fs2.default.write(this[_fd], buf, 0, buf.length, this[_pos], (er, bw) => this[_onwrite](er, bw));
+ *#i() {
+ for (let e; e = this.head; this.shift()) {
+ let { item: t } = e;
+ if (t instanceof U) {
+ let s = [t];
+ for (let n of s) yield* this.#s(n, s);
+ } else if (!ri(t)) yield* this.#n(t);
+ else for (let s of t) yield* this.#n(s);
+ }
+ this.ended = true, yield new Uint8Array(1024);
}
- [_onwrite](er, bw) {
- if (er) {
- this[_onerror](er);
- } else {
- if (this[_pos] !== void 0 && typeof bw === "number") {
- this[_pos] += bw;
- }
- if (this[_queue].length) {
- this[_flush]();
- } else {
- this[_writing] = false;
- if (this[_ended] && !this[_finished]) {
- this[_finished] = true;
- this[_close]();
- this.emit("finish");
- } else if (this[_needDrain]) {
- this[_needDrain] = false;
- this.emit("drain");
+ *#s(e, t) {
+ let s = this.fs, { absolute: n } = e, { follow: r, noDirRecurse: o } = this.opt, { big: a } = this, c;
+ try {
+ c = r ? s.statSync(n, a) : s.lstatSync(n, a);
+ } catch (u) {
+ return this.missing(e, u);
+ }
+ let h = this.needsExact(c) ? r ? s.statSync(n, P) : s.lstatSync(n, P) : c, l = this.plan(e, c, h);
+ if (!l) return;
+ let { linkpath: d } = e, p, f, w, m = false;
+ try {
+ if (l === "SymbolicLink") d = s.readlinkSync(n);
+ else if (l === "Directory" && !o) {
+ let te = s.readdirSync(n);
+ if (!r) {
+ let le = s.lstatSync(n, a);
+ if (!le.isDirectory() || !Ye(c, le)) return this.changed(e, l);
}
+ t.push(...this.children(e, te, h));
+ } else if (l === "File" && c.size) {
+ let te = Number(c.size), le = ve(te);
+ if (w = s.openSync(n, "r"), !r && (!Ye(c, s.fstatSync(w, a)) || wt(c) && ti(s.fstatSync(w, P), h === c ? s.lstatSync(n, P) : h))) return this.changed(e, l);
+ le > this.maxReadSize ? f = this.#r(s, w, te, n) : (p = new Uint8Array(512 + le), Jt(s, w, p, 512, 0, te, n), f = p.subarray(512, 512 + te));
+ }
+ let u = this.pathEntry(e, c, l, d, f);
+ this.opt.onWriteEntry?.(u);
+ let v = p && u.body === f && u.size === Number(c.size);
+ yield* u.encode(this.header, v ? p : void 0), v || (yield* ei(u)), m = true;
+ } finally {
+ if (w !== void 0 && !m) try {
+ s.closeSync(w);
+ } catch {
}
}
+ w !== void 0 && s.closeSync(w);
}
- [_flush]() {
- if (this[_queue].length === 0) {
- if (this[_ended]) {
- this[_onwrite](null, 0);
- }
- } else if (this[_queue].length === 1) {
- this[_write](this[_queue].pop());
- } else {
- const iovec = this[_queue];
- this[_queue] = [];
- writev(this[_fd], iovec, this[_pos], (er, bw) => this[_onwrite](er, bw));
+ *#r(e, t, s, n) {
+ let r = ve(s);
+ for (let o = 0; o < s; ) {
+ let a = new Uint8Array(Math.min(r - o, this.maxReadSize)), c = Jt(e, t, a, 0, o, s, n);
+ yield a.subarray(0, c - o), o = c;
}
}
- [_close]() {
- if (this[_autoClose] && typeof this[_fd] === "number") {
- const fd = this[_fd];
- this[_fd] = void 0;
- import_fs2.default.close(fd, (er) => er ? this.emit("error", er) : this.emit("close"));
- }
+ *#n(e) {
+ let t = this.addedEntry(e);
+ t && (this.opt.onWriteEntry?.(t), yield* t.encode(this.header), yield* ei(t));
}
};
- WriteStreamSync = class extends WriteStream {
- [_open]() {
- let fd;
- if (this[_defaultFlag] && this[_flags] === "r+") {
- try {
- fd = import_fs2.default.openSync(this[_path], this[_flags], this[_mode]);
- } catch (er) {
- if (er?.code === "ENOENT") {
- this[_flags] = "w";
- return this[_open]();
- } else {
- throw er;
- }
- }
- } else {
- fd = import_fs2.default.openSync(this[_path], this[_flags], this[_mode]);
+ Te = 64 * 1024;
+ qe = 4 * Te;
+ As = () => {
+ };
+ gt = (i2, e) => {
+ if (!e?.length) throw new TypeError("no paths specified to add to archive");
+ if (i2.file && !i2.fs) throw new TypeError("the file option needs the fs option");
+ };
+ ci = async (i2, e, t, s) => {
+ for (let n = 0; n < t; ) n += (await i2.write(e, n, t - n, s + n)).bytesWritten;
+ };
+ xt = async (i2, e, t) => {
+ let s = new Uint8Array(qe), n = 0, r = async () => {
+ await ci(i2, s, n, t), t += n, n = 0;
+ };
+ for await (let o of e) (n + o.length > qe || o.length >= Te) && await r(), o.length >= Te ? (await ci(i2, o, o.length, t), t += o.length) : (s.set(o, n), n += o.length);
+ await r();
+ };
+ kt = (i2, e, t, s) => {
+ let n = new Uint8Array(qe), r = 0, o = (a, c) => {
+ for (let h = 0; h < c; ) h += i2.writeSync(e, a, h, c - h, s + h);
+ s += c;
+ };
+ for (let a of t) (r + a.length > qe || a.length >= Te) && (o(n, r), r = 0), a.length >= Te ? o(a, a.length) : (n.set(a, r), r += a.length);
+ o(n, r);
+ };
+ Ts = async (i2, e, t, s) => {
+ let n = await e.open(t, "w", s), r = false;
+ try {
+ await xt(n, i2, 0), r = true;
+ } finally {
+ let o = n.close();
+ await (r ? o : o.catch(As));
+ }
+ };
+ Ve = (i2, e) => {
+ let { fs: t, strict: s, onwarn: n, codecs: r, platform: o } = i2, a = new Re(i2);
+ for (let c of e) if (typeof c != "string" || c.charAt(0) !== "@") a.add(c);
+ else {
+ let h = a.resolve(c.slice(1));
+ a.add(new S(H(t, h, i2.maxReadSize), { strict: s, onwarn: n, codecs: r, platform: o, file: h }));
+ }
+ return a.end();
+ };
+ St = (i2, e) => {
+ let { strict: t, onwarn: s, codecs: n, platform: r } = i2, o = new Ae(i2);
+ for (let a of e) if (typeof a != "string" || a.charAt(0) !== "@") o.add(a);
+ else {
+ let c = o.resolve(a.slice(1));
+ o.add(new b($(i2.fs, c, i2.maxReadSize), { strict: t, onwarn: s, codecs: n, platform: r, file: c }));
+ }
+ return o;
+ };
+ Ke = (i2) => i2.length > 2 && i2.startsWith("./") && i2.charAt(2) !== "/" ? i2.slice(2) : i2;
+ J = (i2, e) => {
+ let t = (a) => Ke(se(a)), s = new Set(i2.map(t)), n = new Set(s), r = 0;
+ for (let a of s) r = Math.max(r, a.length);
+ let o = (a) => {
+ let c = t(a), h = c.charAt(0) === "/" ? "/" : ".", l = false;
+ for (let d = c.length; d > 0; d = c.lastIndexOf("/", d - 1)) {
+ if (d > r) continue;
+ let p = c.slice(0, d);
+ if (!(p === h || !s.has(p)) && (l = true, n.delete(p), !n.size)) break;
+ }
+ return l;
+ };
+ return [(a, c) => {
+ let h = !e || e(a, c);
+ return o(a) && h;
+ }, (a) => {
+ for (let c of n) x(a, "TAR_ENTRY_ERROR", `${c}: not found in archive`, { path: c });
+ }];
+ };
+ hi = () => new TypeError("list needs input, or file and fs");
+ Ze = async (i2, e) => {
+ let t = y(i2), { input: s, file: n, fs: r, onEntry: o } = t, a = s ?? (n && r ? H(r, n, t.maxReadSize) : void 0);
+ if (!a) throw hi();
+ let [c, h] = e?.length ? J(e, t.filter) : [];
+ c && (t.filter = c);
+ let l = new S(a, t);
+ try {
+ for (; ; ) {
+ let d = l.poll();
+ if (d === null) break;
+ d === void 0 ? await l.fill() : o && await o(d);
}
- this[_onopen](null, fd);
+ } finally {
+ await l.return();
+ }
+ h?.(t);
+ };
+ li = (i2, e) => {
+ let t = y(i2), { input: s, file: n, fs: r, onEntry: o } = t, a = s ?? (n && r ? $(r, n, t.maxReadSize) : void 0);
+ if (!a) throw hi();
+ let [c, h] = e?.length ? J(e, t.filter) : [];
+ c && (t.filter = c);
+ let l = new b(a, t);
+ for (let d of l) o?.(d);
+ h?.(t);
+ };
+ Ns = () => {
+ };
+ di = (i2, e) => {
+ if (!i2.file) throw new TypeError("file is required");
+ if (!i2.fs) throw new TypeError("the file option needs the fs option");
+ let t = [...i2.codecs ?? [], T];
+ if (e?.length) return [t, ...J(e, i2.filter)];
+ if (i2.filter) return [t, i2.filter];
+ throw new TypeError("no paths specified to delete");
+ };
+ pi = (i2) => `${i2}.${Math.random().toString(36).slice(2)}.tmp`;
+ bt = async (i2, e) => {
+ let t = y(i2), [s, n, r] = di(t, e), { fs: o, file: a, filter: c, maxReadSize: h, ...l } = t, d = new Uint8Array(ke(s)), p = 0, f = await o.open(a, "r");
+ try {
+ for (let u = 1; u > 0 && p < d.length; p += u) u = (await f.read(d, p, d.length - p, p)).bytesRead;
+ } finally {
+ await f.close();
}
- [_close]() {
- if (this[_autoClose] && typeof this[_fd] === "number") {
- const fd = this[_fd];
- this[_fd] = void 0;
- import_fs2.default.closeSync(fd);
- this.emit("close");
- }
+ let w = (await o.stat(a)).mode & 511, m = pi(a);
+ try {
+ await re({ ...l, fs: o, file: m, mode: w, compress: Se(s, d.subarray(0, p), a), preservePaths: true, filter: (u, v) => !n(u, v) }, [new S(H(o, a, h), { ...l, file: a })]), await o.chmod?.(m, w), r?.(t), await o.rename(m, a);
+ } catch (u) {
+ throw await o.unlink(m).catch(Ns), u;
+ }
+ };
+ fi = (i2, e) => {
+ let t = y(i2), [s, n, r] = di(t, e), { fs: o, file: a, filter: c, maxReadSize: h, ...l } = t, d = new Uint8Array(ke(s)), p = 0, f = o.openSync(a, "r");
+ try {
+ for (let u = 1; u > 0 && p < d.length; p += u) u = o.readSync(f, d, p, d.length - p, p);
+ } finally {
+ o.closeSync(f);
}
- [_write](buf) {
- let threw = true;
+ let w = o.statSync(a).mode & 511, m = pi(a);
+ try {
+ Xe({ ...l, fs: o, file: m, mode: w, compress: Se(s, d.subarray(0, p), a), preservePaths: true, filter: (u, v) => !n(u, v) }, [new b($(o, a, h), { ...l, file: a })]), o.chmodSync?.(m, w), r?.(t), o.renameSync(m, a);
+ } catch (u) {
try {
- this[_onwrite](null, import_fs2.default.writeSync(this[_fd], buf, 0, buf.length, this[_pos]));
- threw = false;
- } finally {
- if (threw) {
- try {
- this[_close]();
- } catch {
- }
- }
+ o.unlinkSync(m);
+ } catch {
}
+ throw u;
}
};
- }
-});
-
-// node_modules/tar/dist/esm/options.js
-var argmap, isSyncFile, isAsyncFile, isSyncNoFile, isAsyncNoFile, dealiasKey, dealias;
-var init_options = __esm({
- "node_modules/tar/dist/esm/options.js"() {
- argmap = /* @__PURE__ */ new Map([
- ["C", "cwd"],
- ["f", "file"],
- ["z", "gzip"],
- ["P", "preservePaths"],
- ["U", "unlink"],
- ["strip-components", "strip"],
- ["stripComponents", "strip"],
- ["keep-newer", "newer"],
- ["keepNewer", "newer"],
- ["keep-newer-files", "newer"],
- ["keepNewerFiles", "newer"],
- ["k", "keep"],
- ["keep-existing", "keep"],
- ["keepExisting", "keep"],
- ["m", "noMtime"],
- ["no-mtime", "noMtime"],
- ["p", "preserveOwner"],
- ["L", "follow"],
- ["h", "follow"],
- ["onentry", "onReadEntry"]
- ]);
- isSyncFile = (o) => !!o.sync && !!o.file;
- isAsyncFile = (o) => !o.sync && !!o.file;
- isSyncNoFile = (o) => !!o.sync && !o.file;
- isAsyncNoFile = (o) => !o.sync && !o.file;
- dealiasKey = (k) => {
- const d = argmap.get(k);
- if (d)
- return d;
- return k;
- };
- dealias = (opt = {}) => {
- if (!opt)
- return {};
- const result = {};
- for (const [key, v] of Object.entries(opt)) {
- const k = dealiasKey(key);
- result[k] = v;
- }
- if (result.chmod === void 0 && result.noChmod === false) {
- result.chmod = true;
- }
- delete result.noChmod;
- return result;
- };
- }
-});
-
-// node_modules/tar/dist/esm/make-command.js
-var makeCommand;
-var init_make_command = __esm({
- "node_modules/tar/dist/esm/make-command.js"() {
- init_options();
- makeCommand = (syncFile, asyncFile, syncNoFile, asyncNoFile, validate) => {
- return Object.assign((opt_ = [], entries, cb) => {
- if (Array.isArray(opt_)) {
- entries = opt_;
- opt_ = {};
- }
- if (typeof entries === "function") {
- cb = entries;
- entries = void 0;
- }
- entries = !entries ? [] : Array.from(entries);
- const opt = dealias(opt_);
- validate?.(opt, entries);
- if (isSyncFile(opt)) {
- if (typeof cb === "function") {
- throw new TypeError("callback not supported for sync tar functions");
- }
- return syncFile(opt, entries);
- } else if (isAsyncFile(opt)) {
- const p = asyncFile(opt, entries);
- return cb ? p.then(() => cb(), cb) : p;
- } else if (isSyncNoFile(opt)) {
- if (typeof cb === "function") {
- throw new TypeError("callback not supported for sync tar functions");
- }
- return syncNoFile(opt, entries);
- } else if (isAsyncNoFile(opt)) {
- if (typeof cb === "function") {
- throw new TypeError("callback only supported with file option");
- }
- return asyncNoFile(opt, entries);
- }
- throw new Error("impossible options??");
- }, {
- syncFile,
- asyncFile,
- syncNoFile,
- asyncNoFile,
- validate
- });
- };
- }
-});
-
-// node_modules/minizlib/dist/esm/constants.js
-var import_zlib, realZlibConstants, constants;
-var init_constants = __esm({
- "node_modules/minizlib/dist/esm/constants.js"() {
- import_zlib = __toESM(require("zlib"), 1);
- realZlibConstants = import_zlib.default.constants || { ZLIB_VERNUM: 4736 };
- constants = Object.freeze(Object.assign(/* @__PURE__ */ Object.create(null), {
- Z_NO_FLUSH: 0,
- Z_PARTIAL_FLUSH: 1,
- Z_SYNC_FLUSH: 2,
- Z_FULL_FLUSH: 3,
- Z_FINISH: 4,
- Z_BLOCK: 5,
- Z_OK: 0,
- Z_STREAM_END: 1,
- Z_NEED_DICT: 2,
- Z_ERRNO: -1,
- Z_STREAM_ERROR: -2,
- Z_DATA_ERROR: -3,
- Z_MEM_ERROR: -4,
- Z_BUF_ERROR: -5,
- Z_VERSION_ERROR: -6,
- Z_NO_COMPRESSION: 0,
- Z_BEST_SPEED: 1,
- Z_BEST_COMPRESSION: 9,
- Z_DEFAULT_COMPRESSION: -1,
- Z_FILTERED: 1,
- Z_HUFFMAN_ONLY: 2,
- Z_RLE: 3,
- Z_FIXED: 4,
- Z_DEFAULT_STRATEGY: 0,
- DEFLATE: 1,
- INFLATE: 2,
- GZIP: 3,
- GUNZIP: 4,
- DEFLATERAW: 5,
- INFLATERAW: 6,
- UNZIP: 7,
- BROTLI_DECODE: 8,
- BROTLI_ENCODE: 9,
- Z_MIN_WINDOWBITS: 8,
- Z_MAX_WINDOWBITS: 15,
- Z_DEFAULT_WINDOWBITS: 15,
- Z_MIN_CHUNK: 64,
- Z_MAX_CHUNK: Infinity,
- Z_DEFAULT_CHUNK: 16384,
- Z_MIN_MEMLEVEL: 1,
- Z_MAX_MEMLEVEL: 9,
- Z_DEFAULT_MEMLEVEL: 8,
- Z_MIN_LEVEL: -1,
- Z_MAX_LEVEL: 9,
- Z_DEFAULT_LEVEL: -1,
- BROTLI_OPERATION_PROCESS: 0,
- BROTLI_OPERATION_FLUSH: 1,
- BROTLI_OPERATION_FINISH: 2,
- BROTLI_OPERATION_EMIT_METADATA: 3,
- BROTLI_MODE_GENERIC: 0,
- BROTLI_MODE_TEXT: 1,
- BROTLI_MODE_FONT: 2,
- BROTLI_DEFAULT_MODE: 0,
- BROTLI_MIN_QUALITY: 0,
- BROTLI_MAX_QUALITY: 11,
- BROTLI_DEFAULT_QUALITY: 11,
- BROTLI_MIN_WINDOW_BITS: 10,
- BROTLI_MAX_WINDOW_BITS: 24,
- BROTLI_LARGE_MAX_WINDOW_BITS: 30,
- BROTLI_DEFAULT_WINDOW: 22,
- BROTLI_MIN_INPUT_BLOCK_BITS: 16,
- BROTLI_MAX_INPUT_BLOCK_BITS: 24,
- BROTLI_PARAM_MODE: 0,
- BROTLI_PARAM_QUALITY: 1,
- BROTLI_PARAM_LGWIN: 2,
- BROTLI_PARAM_LGBLOCK: 3,
- BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4,
- BROTLI_PARAM_SIZE_HINT: 5,
- BROTLI_PARAM_LARGE_WINDOW: 6,
- BROTLI_PARAM_NPOSTFIX: 7,
- BROTLI_PARAM_NDIRECT: 8,
- BROTLI_DECODER_RESULT_ERROR: 0,
- BROTLI_DECODER_RESULT_SUCCESS: 1,
- BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT: 2,
- BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT: 3,
- BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION: 0,
- BROTLI_DECODER_PARAM_LARGE_WINDOW: 1,
- BROTLI_DECODER_NO_ERROR: 0,
- BROTLI_DECODER_SUCCESS: 1,
- BROTLI_DECODER_NEEDS_MORE_INPUT: 2,
- BROTLI_DECODER_NEEDS_MORE_OUTPUT: 3,
- BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE: -1,
- BROTLI_DECODER_ERROR_FORMAT_RESERVED: -2,
- BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE: -3,
- BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET: -4,
- BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME: -5,
- BROTLI_DECODER_ERROR_FORMAT_CL_SPACE: -6,
- BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE: -7,
- BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT: -8,
- BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1: -9,
- BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2: -10,
- BROTLI_DECODER_ERROR_FORMAT_TRANSFORM: -11,
- BROTLI_DECODER_ERROR_FORMAT_DICTIONARY: -12,
- BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS: -13,
- BROTLI_DECODER_ERROR_FORMAT_PADDING_1: -14,
- BROTLI_DECODER_ERROR_FORMAT_PADDING_2: -15,
- BROTLI_DECODER_ERROR_FORMAT_DISTANCE: -16,
- BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET: -19,
- BROTLI_DECODER_ERROR_INVALID_ARGUMENTS: -20,
- BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES: -21,
- BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS: -22,
- BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP: -25,
- BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1: -26,
- BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2: -27,
- BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES: -30,
- BROTLI_DECODER_ERROR_UNREACHABLE: -31
- }, realZlibConstants));
- }
-});
-
-// node_modules/minizlib/dist/esm/index.js
-var import_assert2, import_buffer, realZlib2, OriginalBufferConcat, desc, noop, passthroughBufferConcat, _superWrite, ZlibError, _flushFlag, ZlibBase, Zlib, Gzip, Unzip, Brotli, BrotliCompress, BrotliDecompress, Zstd, ZstdCompress, ZstdDecompress;
-var init_esm3 = __esm({
- "node_modules/minizlib/dist/esm/index.js"() {
- import_assert2 = __toESM(require("assert"), 1);
- import_buffer = require("buffer");
- init_esm();
- realZlib2 = __toESM(require("zlib"), 1);
- init_constants();
- init_constants();
- OriginalBufferConcat = import_buffer.Buffer.concat;
- desc = Object.getOwnPropertyDescriptor(import_buffer.Buffer, "concat");
- noop = (args) => args;
- passthroughBufferConcat = desc?.writable === true || desc?.set !== void 0 ? (makeNoOp) => {
- import_buffer.Buffer.concat = makeNoOp ? noop : OriginalBufferConcat;
- } : (_) => {
- };
- _superWrite = /* @__PURE__ */ Symbol("_superWrite");
- ZlibError = class extends Error {
+ oe = class extends Error {
+ path;
code;
- errno;
- constructor(err, origin) {
- super("zlib: " + err.message, { cause: err });
- this.code = err.code;
- this.errno = err.errno;
- if (!this.code)
- this.code = "ZLIB_ERROR";
- this.message = "zlib: " + err.message;
- Error.captureStackTrace(this, origin ?? this.constructor);
+ syscall = "chdir";
+ constructor(e, t) {
+ super(`${t}: Cannot cd into '${e}'`), this.path = e, this.code = t;
}
get name() {
- return "ZlibError";
- }
- };
- _flushFlag = /* @__PURE__ */ Symbol("flushFlag");
- ZlibBase = class extends Minipass {
- #sawError = false;
- #ended = false;
- #flushFlag;
- #finishFlushFlag;
- #fullFlushFlag;
- #handle;
- #onError;
- get sawError() {
- return this.#sawError;
- }
- get handle() {
- return this.#handle;
- }
- /* c8 ignore start */
- get flushFlag() {
- return this.#flushFlag;
- }
- /* c8 ignore stop */
- constructor(opts, mode) {
- if (!opts || typeof opts !== "object")
- throw new TypeError("invalid options for ZlibBase constructor");
- super(opts);
- this.#flushFlag = opts.flush ?? 0;
- this.#finishFlushFlag = opts.finishFlush ?? 0;
- this.#fullFlushFlag = opts.fullFlushFlag ?? 0;
- if (typeof realZlib2[mode] !== "function") {
- throw new TypeError("Compression method not supported: " + mode);
- }
- try {
- this.#handle = new realZlib2[mode](opts);
- } catch (er) {
- throw new ZlibError(er, this.constructor);
- }
- this.#onError = (err) => {
- if (this.#sawError)
- return;
- this.#sawError = true;
- this.close();
- this.emit("error", err);
- };
- this.#handle?.on("error", (er) => this.#onError(new ZlibError(er)));
- this.once("end", () => this.close);
- }
- close() {
- if (this.#handle) {
- this.#handle.close();
- this.#handle = void 0;
- this.emit("close");
- }
- }
- reset() {
- if (!this.#sawError) {
- (0, import_assert2.default)(this.#handle, "zlib binding closed");
- return this.#handle.reset?.();
- }
+ return "CwdError";
}
- flush(flushFlag) {
- if (this.ended)
- return;
- if (typeof flushFlag !== "number")
- flushFlag = this.#fullFlushFlag;
- this.write(Object.assign(import_buffer.Buffer.alloc(0), { [_flushFlag]: flushFlag }));
- }
- end(chunk, encoding, cb) {
- if (typeof chunk === "function") {
- cb = chunk;
- encoding = void 0;
- chunk = void 0;
- }
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
- }
- if (chunk) {
- if (encoding)
- this.write(chunk, encoding);
- else
- this.write(chunk);
- }
- this.flush(this.#finishFlushFlag);
- this.#ended = true;
- return super.end(cb);
+ };
+ W = class extends Error {
+ path;
+ symlink;
+ syscall = "symlink";
+ code = "TAR_SYMLINK_ERROR";
+ constructor(e, t) {
+ super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"), this.symlink = e, this.path = t;
}
- get ended() {
- return this.#ended;
+ get name() {
+ return "SymlinkError";
}
- // overridden in the gzip classes to do portable writes
- [_superWrite](data) {
- return super.write(data);
+ };
+ ui = (i2) => {
+ let e = i2.mode | 448, { uid: t, gid: s } = i2;
+ return { mode: e, needChmod: (e & i2.umask) !== 0, owner: typeof t == "number" && typeof s == "number" && (t !== i2.processUid || s !== i2.processGid) ? { uid: t, gid: s } : void 0 };
+ };
+ mi = (i2, e) => i2.endsWith("/") ? i2 + e : i2 + "/" + e;
+ wi = (i2, e) => {
+ let t = i2.replaceAll("\\", "/"), s = [e];
+ for (let n = e.length; !t.endsWith(e.slice(0, n)); ) {
+ if (n = e.lastIndexOf("/", n - 1), n <= 0) return [e];
+ s.push(e.slice(0, n));
}
- write(chunk, encoding, cb) {
- if (typeof encoding === "function")
- cb = encoding, encoding = "utf8";
- if (typeof chunk === "string")
- chunk = import_buffer.Buffer.from(chunk, encoding);
- if (this.#sawError)
- return;
- (0, import_assert2.default)(this.#handle, "zlib binding closed");
- const nativeHandle = this.#handle._handle;
- const originalNativeClose = nativeHandle.close;
- nativeHandle.close = () => {
- };
- const originalClose = this.#handle.close;
- this.#handle.close = () => {
- };
- passthroughBufferConcat(true);
- let result = void 0;
- try {
- const flushFlag = typeof chunk[_flushFlag] === "number" ? chunk[_flushFlag] : this.#flushFlag;
- result = this.#handle._processChunk(chunk, flushFlag);
- passthroughBufferConcat(false);
- } catch (err) {
- passthroughBufferConcat(false);
- this.#onError(new ZlibError(err, this.write));
- } finally {
- if (this.#handle) {
- ;
- this.#handle._handle = nativeHandle;
- nativeHandle.close = originalNativeClose;
- this.#handle.close = originalClose;
- this.#handle.removeAllListeners("error");
- }
- }
- if (this.#handle)
- this.#handle.on("error", (er) => this.#onError(new ZlibError(er, this.write)));
- let writeReturn;
- if (result) {
- if (Array.isArray(result) && result.length > 0) {
- const r = result[0];
- writeReturn = this[_superWrite](import_buffer.Buffer.from(r));
- for (let i = 1; i < result.length; i++) {
- writeReturn = this[_superWrite](result[i]);
+ return s;
+ };
+ yi = async (i2, e, t) => {
+ let { mode: s, needChmod: n, owner: r } = ui(t), { cwd: o } = t, a = [];
+ if (e === o) {
+ let c = "ENOTDIR";
+ if (!await i2.stat(e).then((l) => l.isDirectory(), (l) => (c = l?.code || c, false))) throw new oe(e, c);
+ } else if (t.preserve) {
+ let c = await i2.mkdir(e, { mode: s, recursive: true });
+ c && (a = wi(c, e));
+ } else {
+ let c = M(o, e).split("/"), h = o;
+ for (let l = 0; l < c.length; l++) {
+ h = mi(h, c[l]);
+ try {
+ await i2.mkdir(h, { mode: s });
+ } catch (d) {
+ let p = await i2.lstat(h).catch((f) => {
+ if (!t.unlink) throw f;
+ });
+ if (p?.isDirectory()) continue;
+ if (p && !t.unlink) throw p.isSymbolicLink() ? new W(h, h + "/" + c.slice(l + 1).join("/")) : d;
+ try {
+ p && await i2.unlink(h).catch((f) => {
+ if (f?.code !== "ENOENT") throw f;
+ }), await i2.mkdir(h, { mode: s });
+ } catch (f) {
+ if ((await i2.lstat(h).catch(() => {
+ }))?.isDirectory()) continue;
+ throw f;
}
- } else {
- writeReturn = this[_superWrite](import_buffer.Buffer.from(result));
}
+ a.push(h);
}
- if (cb)
- cb();
- return writeReturn;
}
+ if (r) for (let c of a) await i2.lchown(c, r.uid, r.gid);
+ n && await i2.chmod(e, s);
};
- Zlib = class extends ZlibBase {
- #level;
- #strategy;
- constructor(opts, mode) {
- opts = opts || {};
- opts.flush = opts.flush || constants.Z_NO_FLUSH;
- opts.finishFlush = opts.finishFlush || constants.Z_FINISH;
- opts.fullFlushFlag = constants.Z_FULL_FLUSH;
- super(opts, mode);
- this.#level = opts.level;
- this.#strategy = opts.strategy;
- }
- params(level, strategy) {
- if (this.sawError)
- return;
- if (!this.handle)
- throw new Error("cannot switch params when binding is closed");
- if (!this.handle.params)
- throw new Error("not supported in this implementation");
- if (this.#level !== level || this.#strategy !== strategy) {
- this.flush(constants.Z_SYNC_FLUSH);
- (0, import_assert2.default)(this.handle, "zlib binding closed");
- const origFlush = this.handle.flush;
- this.handle.flush = (flushFlag, cb) => {
- if (typeof flushFlag === "function") {
- cb = flushFlag;
- flushFlag = this.flushFlag;
- }
- this.flush(flushFlag);
- cb?.();
- };
+ gi = (i2, e, t) => {
+ let { mode: s, needChmod: n, owner: r } = ui(t), { cwd: o } = t, a = [];
+ if (e === o) {
+ let c = "ENOTDIR", h = false;
+ try {
+ h = i2.statSync(e).isDirectory();
+ } catch (l) {
+ c = l?.code || c;
+ }
+ if (!h) throw new oe(e, c);
+ } else if (t.preserve) {
+ let c = i2.mkdirSync(e, { mode: s, recursive: true });
+ c && (a = wi(c, e));
+ } else {
+ let c = M(o, e).split("/"), h = o;
+ for (let l = 0; l < c.length; l++) {
+ h = mi(h, c[l]);
try {
- ;
- this.handle.params(level, strategy);
- } finally {
- this.handle.flush = origFlush;
- }
- if (this.handle) {
- this.#level = level;
- this.#strategy = strategy;
- }
+ i2.mkdirSync(h, { mode: s });
+ } catch (d) {
+ let p = i2.lstatSync(h);
+ if (p.isDirectory()) continue;
+ if (!t.unlink) throw p.isSymbolicLink() ? new W(h, h + "/" + c.slice(l + 1).join("/")) : d;
+ i2.unlinkSync(h), i2.mkdirSync(h, { mode: s });
+ }
+ a.push(h);
+ }
+ }
+ if (r) for (let c of a) i2.lchownSync(c, r.uid, r.gid);
+ n && i2.chmodSync(e, s);
+ };
+ vt = /* @__PURE__ */ Object.create(null);
+ xi = 1e4;
+ ae = /* @__PURE__ */ new Set();
+ zs = 256;
+ ki = (i2) => {
+ if (i2.length > zs) return i2.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en");
+ ae.has(i2) ? ae.delete(i2) : vt[i2] = i2.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"), ae.add(i2);
+ let e = vt[i2], t = ae.size - xi;
+ if (t > xi / 10) {
+ for (let s of ae) if (ae.delete(s), delete vt[s], --t <= 0) break;
+ }
+ return e;
+ };
+ Ne = class {
+ #e = { queue: [], name: "" };
+ #t = /* @__PURE__ */ new Map();
+ #i = /* @__PURE__ */ new Set();
+ #s;
+ constructor(e = false) {
+ this.#s = e;
+ }
+ reserve(e, t) {
+ return new Promise((s, n) => {
+ let r = () => {
+ t().then(() => {
+ this.#a(r), s();
+ }, (o) => {
+ this.#a(r), n(o);
+ });
+ };
+ this.#r(e, r);
+ });
+ }
+ #r(e, t) {
+ let s = this.#e, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
+ for (let o of this.#s ? ["win32 parallelization disabled"] : e) {
+ let a = this.#s ? o : se(ie(ki(o))), c = s;
+ for (let h of a === "." ? [] : a.split("/")) {
+ r.add(c);
+ let l = c.kids ??= /* @__PURE__ */ new Map(), d = l.get(h);
+ d || l.set(h, d = { queue: [], name: h, up: c }), c = d;
+ }
+ n.add(c);
+ }
+ for (let o of n) r.delete(o);
+ this.#t.set(t, { dirs: r, paths: n });
+ for (let o of n) o.queue.push(t);
+ for (let { queue: o } of r) {
+ let a = o[o.length - 1];
+ a instanceof Set ? a.add(t) : o.push(/* @__PURE__ */ new Set([t]));
+ }
+ this.#n(t);
+ }
+ #n(e) {
+ let { paths: t, dirs: s } = this.#t.get(e);
+ for (let n of t) if (n.queue[0] !== e) return;
+ for (let { queue: n } of s) {
+ let r = n[0];
+ if (!(r instanceof Set) || !r.has(e)) return;
+ }
+ this.#i.add(e), e();
+ }
+ #a(e) {
+ let { paths: t, dirs: s } = this.#t.get(e), n = /* @__PURE__ */ new Set();
+ for (let { queue: r } of t) {
+ r.shift();
+ let o = r[0];
+ if (typeof o == "function") n.add(o);
+ else if (o) for (let a of o) n.add(a);
+ }
+ for (let { queue: r } of s) {
+ let o = r[0];
+ o.size > 1 ? o.delete(e) : (r.shift(), r.length && n.add(r[0]));
+ }
+ for (let r of t) for (; r.up && !r.queue.length && !r.kids?.size; ) r.up.kids?.delete(r.name), r = r.up;
+ this.#i.delete(e), this.#t.delete(e);
+ for (let r of n) this.#n(r);
+ }
+ };
+ Si = (i2, e) => {
+ if (!i2) return () => "w";
+ let { O_CREAT: t, O_TRUNC: s, O_WRONLY: n, O_NOFOLLOW: r, UV_FS_O_FILEMAP: o } = i2, a = s | t | n;
+ if (!e) {
+ let h = typeof r == "number" ? r | a : "w";
+ return () => h;
+ }
+ if (!o) return () => "w";
+ let c = o | a;
+ return (h) => h < 524288 ? c : "w";
+ };
+ Os = 1024;
+ bi = 32768;
+ Fs = 16;
+ Je = /* @__PURE__ */ new Set(["File", "OldFile", "ContiguousFile"]);
+ ce = /* @__PURE__ */ new Set(["Directory", "GNUDumpDir"]);
+ Ps = /* @__PURE__ */ new Set(["Link", "SymbolicLink"]);
+ vi = (i2, e, t) => i2 !== void 0 ? i2 : e !== void 0 && e === e >>> 0 ? e : t;
+ ze = class {
+ opt;
+ cwd;
+ win32;
+ strip;
+ maxDepth;
+ preservePaths;
+ unlink;
+ keep;
+ newer;
+ noMtime;
+ chmod;
+ uid;
+ gid;
+ preserveOwner;
+ forceChown;
+ processUid;
+ processGid;
+ processUmask;
+ umask;
+ dmode;
+ fmode;
+ writeFlag;
+ resolve;
+ dirname;
+ fatal;
+ constructor(e) {
+ let t = this.opt = k(e), s = this.win32 = t.platform === "win32";
+ if (this.resolve = s ? Ge : C, this.dirname = s ? Vt : D, typeof t.cwd != "string") throw new TypeError("cwd is required");
+ let n = s ? t.cwd.replaceAll("\\", "/") : t.cwd;
+ if (!(s ? be : fe)(n)) throw new TypeError("cwd must be an absolute path");
+ if (this.cwd = this.resolve(n, ""), typeof t.uid == "number" || typeof t.gid == "number") {
+ if (typeof t.uid != "number" || typeof t.gid != "number") throw new TypeError("cannot set owner without number uid and gid");
+ if (t.uid !== t.uid >>> 0 || t.gid !== t.gid >>> 0) throw new TypeError("uid and gid must be unsigned 32-bit integers");
+ if (t.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
+ this.uid = t.uid, this.gid = t.gid;
+ }
+ this.processUid = t.processUid, this.processGid = t.processGid, this.preserveOwner = t.preserveOwner === void 0 && typeof t.uid != "number" ? t.processUid === 0 : !!t.preserveOwner, this.forceChown = t.forceChown === true, this.maxDepth = typeof t.maxDepth == "number" ? t.maxDepth : Os, this.strip = Number(t.strip) || 0, this.preservePaths = !!t.preservePaths, this.unlink = !!t.unlink, this.keep = !!t.keep, this.newer = !!t.newer, this.noMtime = !!t.noMtime, this.chmod = !!t.chmod, this.processUmask = this.chmod ? typeof t.processUmask == "number" ? t.processUmask : 18 : 0, this.umask = typeof t.umask == "number" ? t.umask : this.processUmask, this.dmode = t.dmode || 511 & ~this.umask, this.fmode = t.fmode || 438 & ~this.umask, this.writeFlag = Si(t.fs.constants, s);
+ }
+ warn(e, t, s = {}) {
+ (e === "TAR_BAD_ARCHIVE" || e === "TAR_ABORT") && (s.recoverable = false), s.cwd = this.cwd, x(this.opt, e, t, s);
+ }
+ readerOptions() {
+ return k(this.opt, { strict: false, onwarn: (e, t, s) => this.warn(e, t, s) });
+ }
+ entryError(e, t) {
+ if (this.fatal?.error === e || e?.name === "CwdError") throw e;
+ this.warn("TAR_ENTRY_ERROR", e, { entry: t });
+ }
+ fail(e) {
+ return this.fatal ??= { error: e }, e;
+ }
+ #e(e, t) {
+ let s = e[t];
+ if (!s || this.preservePaths) return true;
+ let [n, r] = We(s), o = r.replaceAll("\\", "/").split("/");
+ if (o.includes("..")) {
+ if (t === "path" || e.type === "Link") return this.warn("TAR_ENTRY_ERROR", `${t} contains '..'`, { entry: e, [t]: s }), false;
+ let a = o.findIndex((l) => l !== ".." && l !== "." && l !== "");
+ if (a !== -1 && o.includes("..", a)) return this.warn("TAR_ENTRY_ERROR", `${t} contains '..' after a path portion`, { entry: e, [t]: s }), false;
+ let c = D(de(e.path)), h = de(ie(c, o.join("/")));
+ if (h.startsWith("../") || h === "..") return this.warn("TAR_ENTRY_ERROR", `${t} escapes extraction directory`, { entry: e, [t]: s }), false;
+ }
+ return n && (e[t] = r, this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${t}`, { entry: e, [t]: s })), true;
+ }
+ check(e) {
+ let t = e.path, s = t.split("/");
+ if (this.strip) {
+ if (s.length < this.strip) return false;
+ if (e.type === "Link") {
+ let c = String(e.linkpath).split("/");
+ if (c.length < this.strip) return false;
+ e.linkpath = c.slice(this.strip).join("/");
+ }
+ if (s.splice(0, this.strip), s.every((c) => c === "")) return false;
+ e.path = s.join("/");
+ }
+ let { maxDepth: n } = this;
+ if (isFinite(n) && s.length > n) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: e, path: t, depth: s.length, maxDepth: n }), false;
+ let { linkpath: r } = e;
+ if (r && isFinite(n) && r.split("/").length > n) return this.warn("TAR_ENTRY_ERROR", "linkpath excessively deep", { entry: e, path: t, linkpath: r, maxDepth: n }), false;
+ for (let c of ["path", "linkpath"]) {
+ let { length: h } = e[c] ?? "";
+ if (h > bi) return this.warn("TAR_ENTRY_ERROR", `${c} excessively long`, { entry: e, path: t, length: h, maxLength: bi }), false;
+ }
+ if (!this.#e(e, "path") || !this.#e(e, "linkpath")) return false;
+ let { cwd: o } = this, a = this.resolve(o, e.path);
+ if (!this.preservePaths && a !== o && !a.startsWith(o.endsWith("/") ? o : o + "/")) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: e, path: e.path, resolvedPath: a, cwd: o }), false;
+ if (a === o && !ce.has(e.type)) return false;
+ if (this.win32) {
+ let c = G(a);
+ a = c + ut(a.slice(c.length));
+ let h = G(e.path);
+ e.path = h + ut(e.path.slice(h.length));
}
+ if (e.absolute = a, typeof e.mode == "number" && (e.mode &= 511), ce.has(e.type)) e.mode && (e.mode |= 448);
+ else if (!Je.has(e.type) && !Ps.has(e.type)) return e.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${e.type}`, { entry: e }), false;
+ return true;
}
- };
- Gzip = class extends Zlib {
- #portable;
- constructor(opts) {
- super(opts, "Gzip");
- this.#portable = opts && !!opts.portable;
+ reservedPaths(e) {
+ let { path: t, linkpath: s } = e, { cwd: n } = this, r = this.resolve(n, t);
+ return s ? [r, this.resolve(e.type === "SymbolicLink" ? this.dirname(r) : n, s)] : [r];
}
- [_superWrite](data) {
- if (!this.#portable)
- return super[_superWrite](data);
- this.#portable = false;
- data[9] = 255;
- return super[_superWrite](data);
+ mkdirOptions(e) {
+ return { uid: this.uid, gid: this.gid, processUid: this.processUid, processGid: this.processGid, umask: this.processUmask, preserve: this.preservePaths, unlink: this.unlink, cwd: this.cwd, mode: e };
}
- };
- Unzip = class extends Zlib {
- constructor(opts) {
- super(opts, "Unzip");
+ owner(e) {
+ let t = this.forceChown || this.preserveOwner && (typeof e.uid == "number" && e.uid !== this.processUid || typeof e.gid == "number" && e.gid !== this.processGid) || typeof this.uid == "number" && this.uid !== this.processUid || typeof this.gid == "number" && this.gid !== this.processGid, s = vi(this.uid, e.uid, this.processUid), n = vi(this.gid, e.gid, this.processGid);
+ return t && typeof s == "number" && typeof n == "number" ? { uid: s, gid: n } : void 0;
}
- };
- Brotli = class extends ZlibBase {
- constructor(opts, mode) {
- opts = opts || {};
- opts.flush = opts.flush || constants.BROTLI_OPERATION_PROCESS;
- opts.finishFlush = opts.finishFlush || constants.BROTLI_OPERATION_FINISH;
- opts.fullFlushFlag = constants.BROTLI_OPERATION_FLUSH;
- super(opts, mode);
+ times(e) {
+ return e.mtime && !this.noMtime ? { atime: e.atime || /* @__PURE__ */ new Date(), mtime: e.mtime } : void 0;
}
- };
- BrotliCompress = class extends Brotli {
- constructor(opts) {
- super(opts, "BrotliCompress");
+ skip(e, t) {
+ return this.keep || this.newer && t.mtime > (e.mtime ?? t.mtime);
}
- };
- BrotliDecompress = class extends Brotli {
- constructor(opts) {
- super(opts, "BrotliDecompress");
+ isReusable(e, t) {
+ return e.type === "File" && !this.unlink && t.isFile() && t.nlink <= 1 && !this.win32;
}
- };
- Zstd = class extends ZlibBase {
- constructor(opts, mode) {
- opts = opts || {};
- opts.flush = opts.flush || constants.ZSTD_e_continue;
- opts.finishFlush = opts.finishFlush || constants.ZSTD_e_end;
- opts.fullFlushFlag = constants.ZSTD_e_flush;
- super(opts, mode);
+ linkParts(e, t) {
+ let s = String(e.linkpath);
+ return e.type === "Link" ? s.split("/") : M(this.cwd, this.resolve(this.dirname(t), s)).split("/");
}
- };
- ZstdCompress = class extends Zstd {
- constructor(opts) {
- super(opts, "ZstdCompress");
+ parentParts(e) {
+ let { cwd: t } = this, s = e === t ? t : this.dirname(e);
+ return s === t ? [] : M(t, s).split("/");
}
- };
- ZstdDecompress = class extends Zstd {
- constructor(opts) {
- super(opts, "ZstdDecompress");
+ symlinkError(e, t) {
+ return new W(e, this.resolve(this.cwd, t.join("/")));
}
};
- }
-});
-
-// node_modules/tar/dist/esm/large-numbers.js
-var encode, encodePositive, encodeNegative, parse, twos, pos, onesComp, twosComp;
-var init_large_numbers = __esm({
- "node_modules/tar/dist/esm/large-numbers.js"() {
- encode = (num, buf) => {
- if (!Number.isSafeInteger(num)) {
- throw Error("cannot encode number outside of javascript safe integer range");
- } else if (num < 0) {
- encodeNegative(num, buf);
- } else {
- encodePositive(num, buf);
- }
- return buf;
- };
- encodePositive = (num, buf) => {
- buf[0] = 128;
- for (var i = buf.length; i > 1; i--) {
- buf[i - 1] = num & 255;
- num = Math.floor(num / 256);
- }
- };
- encodeNegative = (num, buf) => {
- buf[0] = 255;
- var flipped = false;
- num = num * -1;
- for (var i = buf.length; i > 1; i--) {
- var byte = num & 255;
- num = Math.floor(num / 256);
- if (flipped) {
- buf[i - 1] = onesComp(byte);
- } else if (byte === 0) {
- buf[i - 1] = 0;
- } else {
- flipped = true;
- buf[i - 1] = twosComp(byte);
+ Ei = (i2) => i2 + ".DELETE." + Array.from(crypto.getRandomValues(new Uint8Array(16)), (e) => e.toString(16).padStart(2, "0")).join("");
+ Oe = class extends ze {
+ #e;
+ #t;
+ #i;
+ #s = 0;
+ #r;
+ #n = false;
+ #a;
+ constructor(e) {
+ super(e), this.#e = this.opt.fs, this.#t = new Ne(this.win32), this.#i = q("jobs", this.opt.jobs, Fs);
+ }
+ async extract(e) {
+ let t = new S(e, this.readerOptions()), { onEntry: s } = this.opt, n = !!this.opt.transform;
+ try {
+ for (; !this.fatal; ) {
+ let r = t.poll();
+ if (r === null) break;
+ if (r === void 0) {
+ await t.fill();
+ continue;
+ }
+ if (s && await s(r), r.bodyUsed || !this.check(r)) continue;
+ let o = [], a = !n;
+ if (a && Je.has(r.type)) for (; ; ) {
+ let h = t.readBody(r);
+ if (h === null) break;
+ if (h === void 0) {
+ a = false;
+ break;
+ }
+ o.push(h);
+ }
+ let c = this.#c(r, o, a ? void 0 : t);
+ for (a || await c; this.#s >= this.#i; ) await this.#o();
+ }
+ } catch (r) {
+ this.fail(r);
+ }
+ for (await t.return().catch((r) => this.fail(r)); this.#s > 0; ) await this.#o();
+ if (this.fatal) {
+ let { error: r } = this.fatal;
+ throw r && typeof r == "object" && "tarCode" in r && Object.assign(r, { cwd: this.cwd }), r;
}
}
- };
- parse = (buf) => {
- const pre = buf[0];
- const value = pre === 128 ? pos(buf.subarray(1, buf.length)) : pre === 255 ? twos(buf) : null;
- if (value === null) {
- throw Error("invalid base256 encoding");
+ #o() {
+ return new Promise((e) => {
+ this.#r = e;
+ });
+ }
+ #c(e, t, s) {
+ return this.#s++, this.#t.reserve(this.reservedPaths(e), async () => {
+ try {
+ this.fatal || await this.#y(e, t, s);
+ } catch (n) {
+ try {
+ this.entryError(n, e);
+ } catch (r) {
+ this.fail(r);
+ }
+ }
+ this.#s--, this.#r?.();
+ });
}
- if (!Number.isSafeInteger(value)) {
- throw Error("parsed number outside of javascript safe integer range");
+ #l(e, t) {
+ return yi(this.#e, e, this.mkdirOptions(t));
}
- return value;
- };
- twos = (buf) => {
- var len = buf.length;
- var sum = 0;
- var flipped = false;
- for (var i = len - 1; i > -1; i--) {
- var byte = Number(buf[i]);
- var f;
- if (flipped) {
- f = onesComp(byte);
- } else if (byte === 0) {
- f = byte;
- } else {
- flipped = true;
- f = twosComp(byte);
+ #d() {
+ return this.#a ??= this.#l(this.cwd, this.dmode).then(() => {
+ this.#n = true;
+ }, (e) => {
+ throw this.#a = void 0, e;
+ });
+ }
+ async #y(e, t, s) {
+ let n = this.#e, r = e.absolute, { cwd: o } = this;
+ if (this.#n || await this.#d(), r !== o) {
+ let c = this.dirname(r);
+ c !== o && await this.#l(c, this.dmode);
}
- if (f !== 0) {
- sum -= f * Math.pow(256, len - i - 1);
+ let a = await n.lstat(r).catch(() => {
+ });
+ if (!(a && this.skip(e, a))) {
+ if (a && !this.isReusable(e, a) && (a.isDirectory() && ce.has(e.type) ? this.chmod && e.mode && (a.mode & 4095) !== e.mode && await n.chmod(r, e.mode) : r !== o && (a.isDirectory() ? await n.rmdir(r) : await this.#x(r))), Je.has(e.type)) return this.#u(e, r, t, s);
+ if (ce.has(e.type)) await this.#p(e, r);
+ else {
+ await this.#f(this.linkParts(e, r));
+ let c = String(e.linkpath);
+ e.type === "Link" ? await n.link(this.resolve(o, c), r) : await n.symlink(c, r);
+ }
+ await this.#f(this.parentParts(r));
+ }
+ }
+ async #x(e) {
+ let t = this.#e;
+ if (!this.win32) return t.unlink(e);
+ let s = Ei(e);
+ await t.rename(e, s), await t.unlink(s);
+ }
+ async #f(e) {
+ if (this.preservePaths) return;
+ let t = this.cwd;
+ for (let s of e) {
+ t = this.resolve(t, s);
+ let n = await this.#e.lstat(t).catch(() => {
+ });
+ if (!n) return;
+ if (n.isSymbolicLink()) throw this.symlinkError(t, e);
}
}
- return sum;
- };
- pos = (buf) => {
- var len = buf.length;
- var sum = 0;
- for (var i = len - 1; i > -1; i--) {
- var byte = Number(buf[i]);
- if (byte !== 0) {
- sum += byte * Math.pow(256, len - i - 1);
+ async #p(e, t) {
+ let s = this.#e;
+ await this.#l(t, e.mode ?? this.dmode);
+ let n = this.times(e);
+ n && await s.lutimes(t, n.atime, n.mtime).catch(() => {
+ });
+ let r = this.owner(e);
+ r && await s.lchown(t, r.uid, r.gid).catch(() => {
+ });
+ }
+ async #u(e, t, s, n) {
+ let r = this.#e, o = await r.open(t, this.writeFlag(e.size), e.mode ?? this.fmode);
+ try {
+ if (await this.#f(this.parentParts(t)), n) await this.#w(e, s, n, o);
+ else for (let h of s) await o.write(h);
+ let a = this.times(e);
+ if (a) {
+ let { atime: h, mtime: l } = a;
+ await o.utimes(h, l).catch(async (d) => {
+ await r.utimes(t, h, l).catch(() => {
+ throw d;
+ });
+ });
+ }
+ let c = this.owner(e);
+ if (c) {
+ let { uid: h, gid: l } = c;
+ await o.chown(h, l).catch(async (d) => {
+ await r.chown(t, h, l).catch(() => {
+ throw d;
+ });
+ });
+ }
+ } catch (a) {
+ throw await o.close().catch(() => {
+ }), a;
}
+ await o.close();
}
- return sum;
- };
- onesComp = (byte) => (255 ^ byte) & 255;
- twosComp = (byte) => (255 ^ byte) + 1 & 255;
- }
-});
-
-// node_modules/tar/dist/esm/types.js
-var isCode, normalFsTypes, name, code;
-var init_types = __esm({
- "node_modules/tar/dist/esm/types.js"() {
- isCode = (c) => name.has(c);
- normalFsTypes = /* @__PURE__ */ new Set([
- "0",
- "",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "D"
- ]);
- name = /* @__PURE__ */ new Map([
- ["0", "File"],
- // same as File
- ["", "OldFile"],
- ["1", "Link"],
- ["2", "SymbolicLink"],
- // Devices and FIFOs aren't fully supported
- // they are parsed, but skipped when unpacking
- ["3", "CharacterDevice"],
- ["4", "BlockDevice"],
- ["5", "Directory"],
- ["6", "FIFO"],
- // same as File
- ["7", "ContiguousFile"],
- // pax headers
- ["g", "GlobalExtendedHeader"],
- ["x", "ExtendedHeader"],
- // vendor-specific stuff
- // skip
- ["A", "SolarisACL"],
- // like 5, but with data, which should be skipped
- ["D", "GNUDumpDir"],
- // metadata only, skip
- ["I", "Inode"],
- // data = link path of next file
- ["K", "NextFileHasLongLinkpath"],
- // data = path of next file
- ["L", "NextFileHasLongPath"],
- // skip
- ["M", "ContinuationFile"],
- // like L
- ["N", "OldGnuLongPath"],
- // skip
- ["S", "SparseFile"],
- // skip
- ["V", "TapeVolumeHeader"],
- // like x
- ["X", "OldExtendedHeader"]
- ]);
- code = new Map(Array.from(name).map((kv) => [kv[1], kv[0]]));
- }
-});
-
-// node_modules/tar/dist/esm/header.js
-var import_node_path, notNegative, Header, splitPrefix, decString, decDate, numToDate, decNumber, nanUndef, decSmallNumber, MAXNUM, encNumber, encSmallNumber, octalString, padOctal, encDate, NULLS, encString;
-var init_header = __esm({
- "node_modules/tar/dist/esm/header.js"() {
- import_node_path = require("node:path");
- init_large_numbers();
- init_types();
- notNegative = (n) => n === void 0 || n < 0 ? void 0 : n;
- Header = class {
- cksumValid = false;
- needPax = false;
- nullBlock = false;
- block;
- path;
- mode;
- uid;
- gid;
- size;
- cksum;
- #type = "Unsupported";
- linkpath;
- uname;
- gname;
- devmaj = 0;
- devmin = 0;
- atime;
- ctime;
- mtime;
- charset;
- comment;
- constructor(data, off = 0, ex, gex) {
- if (Buffer.isBuffer(data)) {
- this.decode(data, off || 0, ex, gex);
- } else if (data) {
- this.#slurp(data);
- }
- }
- decode(buf, off, ex, gex) {
- if (!off) {
- off = 0;
- }
- if (!buf || !(buf.length >= off + 512)) {
- throw new Error("need 512 bytes for header");
- }
- const t = decString(buf, off + 156, 1);
- const isNormalFS = normalFsTypes.has(t);
- const exForFields = isNormalFS ? ex : void 0;
- const gexForFields = isNormalFS ? gex : void 0;
- this.path = exForFields?.path ?? decString(buf, off, 100);
- this.mode = exForFields?.mode ?? gexForFields?.mode ?? decNumber(buf, off + 100, 8);
- this.uid = exForFields?.uid ?? gexForFields?.uid ?? decNumber(buf, off + 108, 8);
- this.gid = exForFields?.gid ?? gexForFields?.gid ?? decNumber(buf, off + 116, 8);
- this.size = notNegative(exForFields?.size ?? gexForFields?.size ?? decNumber(buf, off + 124, 12));
- this.mtime = exForFields?.mtime ?? gexForFields?.mtime ?? decDate(buf, off + 136, 12);
- this.cksum = decNumber(buf, off + 148, 12);
- if (gexForFields)
- this.#slurp(gexForFields, true);
- if (exForFields)
- this.#slurp(exForFields);
- if (isCode(t)) {
- this.#type = t || "0";
- }
- if (this.#type === "0" && this.path.slice(-1) === "/") {
- this.#type = "5";
- }
- if (this.#type === "5") {
- this.size = 0;
- }
- this.linkpath = decString(buf, off + 157, 100);
- if (buf.subarray(off + 257, off + 265).toString() === "ustar\x0000") {
- this.uname = exForFields?.uname ?? gexForFields?.uname ?? decString(buf, off + 265, 32);
- this.gname = exForFields?.gname ?? gexForFields?.gname ?? decString(buf, off + 297, 32);
- this.devmaj = exForFields?.devmaj ?? gexForFields?.devmaj ?? decNumber(buf, off + 329, 8) ?? 0;
- this.devmin = exForFields?.devmin ?? gexForFields?.devmin ?? decNumber(buf, off + 337, 8) ?? 0;
- if (buf[off + 475] !== 0) {
- const prefix = decString(buf, off + 345, 155);
- this.path = prefix + "/" + this.path;
- } else {
- const prefix = decString(buf, off + 345, 130);
- if (prefix) {
- this.path = prefix + "/" + this.path;
+ async #w(e, t, s, n) {
+ let r = 0, o = async () => {
+ if (r < t.length) return t[r++];
+ try {
+ for (; ; ) {
+ let f = s.readBody(e);
+ if (f !== void 0) return f;
+ await s.fill();
}
- this.atime = ex?.atime ?? gex?.atime ?? decDate(buf, off + 476, 12);
- this.ctime = ex?.ctime ?? gex?.ctime ?? decDate(buf, off + 488, 12);
+ } catch (f) {
+ throw this.fail(f);
}
+ }, a = this.opt.transform?.(e);
+ if (!a) {
+ let f, w;
+ try {
+ for (let m; (m = await o()) && (await f, !w); ) f = n.write(m).then(() => {
+ }, (u) => {
+ w = { error: u };
+ });
+ } finally {
+ await f;
+ }
+ if (w) throw w.error;
+ return;
}
- let sum = 8 * 32;
- for (let i = off; i < off + 148; i++) {
- sum += buf[i];
- }
- for (let i = off + 156; i < off + 512; i++) {
- sum += buf[i];
+ let c = a.writable.getWriter(), h = a.readable.getReader(), l, d = async (f) => {
+ l ??= { error: f }, await h.cancel(f).catch(() => {
+ }), await c.abort(f).catch(() => {
+ });
+ }, p = (async () => {
+ try {
+ for (let f; f = await o(); ) await c.write(f);
+ await c.close();
+ } catch (f) {
+ await d(f);
+ }
+ })();
+ try {
+ for (; ; ) {
+ let { done: f, value: w } = await h.read();
+ if (f) break;
+ await n.write(w);
+ }
+ } catch (f) {
+ await d(f);
}
- this.cksumValid = sum === this.cksum;
- if (this.cksum === void 0 && sum === 8 * 32) {
- this.nullBlock = true;
+ if (await p, l) throw l.error;
+ }
+ };
+ Fe = class extends ze {
+ #e;
+ #t = false;
+ constructor(e) {
+ super(e), this.#e = this.opt.fs;
+ }
+ extract(e) {
+ let t = new b(e, this.readerOptions()), { onEntry: s } = this.opt;
+ try {
+ for (let n of t) if (s?.(n), !n.bodyUsed && this.check(n)) try {
+ this.#s(n, t);
+ } catch (r) {
+ this.entryError(r, n);
+ }
+ } catch (n) {
+ throw n && typeof n == "object" && "tarCode" in n && Object.assign(n, { cwd: this.cwd }), n;
}
}
- #slurp(ex, gex = false) {
- Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
- return !(v === null || v === void 0 || k === "size" && Number(v) < 0 || k === "path" && gex || k === "linkpath" && gex || k === "global");
- })));
+ #i(e, t) {
+ gi(this.#e, e, this.mkdirOptions(t));
}
- encode(buf, off = 0) {
- if (!buf) {
- buf = this.block = Buffer.alloc(512);
- }
- if (this.#type === "Unsupported") {
- this.#type = "0";
- }
- if (!(buf.length >= off + 512)) {
- throw new Error("need 512 bytes for header");
- }
- const prefixSize = this.ctime || this.atime ? 130 : 155;
- const split = splitPrefix(this.path || "", prefixSize);
- const path16 = split[0];
- const prefix = split[1];
- this.needPax = !!split[2];
- this.needPax = encString(buf, off, 100, path16) || this.needPax;
- this.needPax = encNumber(buf, off + 100, 8, this.mode) || this.needPax;
- this.needPax = encNumber(buf, off + 108, 8, this.uid) || this.needPax;
- this.needPax = encNumber(buf, off + 116, 8, this.gid) || this.needPax;
- this.needPax = encNumber(buf, off + 124, 12, this.size) || this.needPax;
- this.needPax = encDate(buf, off + 136, 12, this.mtime) || this.needPax;
- buf[off + 156] = Number(this.#type.codePointAt(0));
- this.needPax = encString(buf, off + 157, 100, this.linkpath) || this.needPax;
- buf.write("ustar\x0000", off + 257, 8);
- this.needPax = encString(buf, off + 265, 32, this.uname) || this.needPax;
- this.needPax = encString(buf, off + 297, 32, this.gname) || this.needPax;
- this.needPax = encNumber(buf, off + 329, 8, this.devmaj) || this.needPax;
- this.needPax = encNumber(buf, off + 337, 8, this.devmin) || this.needPax;
- this.needPax = encString(buf, off + 345, prefixSize, prefix) || this.needPax;
- if (buf[off + 475] !== 0) {
- this.needPax = encString(buf, off + 345, 155, prefix) || this.needPax;
- } else {
- this.needPax = encString(buf, off + 345, 130, prefix) || this.needPax;
- this.needPax = encDate(buf, off + 476, 12, this.atime) || this.needPax;
- this.needPax = encDate(buf, off + 488, 12, this.ctime) || this.needPax;
+ #s(e, t) {
+ let s = this.#e, n = e.absolute, { cwd: r } = this;
+ if (this.#t || (this.#i(r, this.dmode), this.#t = true), n !== r) {
+ let a = this.dirname(n);
+ a !== r && this.#i(a, this.dmode);
}
- let sum = 8 * 32;
- for (let i = off; i < off + 148; i++) {
- sum += buf[i];
+ let o;
+ try {
+ o = s.lstatSync(n);
+ } catch {
}
- for (let i = off + 156; i < off + 512; i++) {
- sum += buf[i];
+ if (!(o && this.skip(e, o))) {
+ if (o && !this.isReusable(e, o) && (o.isDirectory() && ce.has(e.type) ? this.chmod && e.mode && (o.mode & 4095) !== e.mode && s.chmodSync(n, e.mode) : n !== r && (o.isDirectory() ? s.rmdirSync(n) : this.#r(n))), Je.has(e.type)) return this.#o(e, n, t);
+ if (ce.has(e.type)) this.#a(e, n);
+ else {
+ this.#n(this.linkParts(e, n));
+ let a = String(e.linkpath);
+ e.type === "Link" ? s.linkSync(this.resolve(r, a), n) : s.symlinkSync(a, n);
+ }
+ this.#n(this.parentParts(n));
+ }
+ }
+ #r(e) {
+ let t = this.#e;
+ if (!this.win32) return t.unlinkSync(e);
+ let s = Ei(e);
+ t.renameSync(e, s), t.unlinkSync(s);
+ }
+ #n(e) {
+ if (this.preservePaths) return;
+ let t = this.cwd;
+ for (let s of e) {
+ t = this.resolve(t, s);
+ let n;
+ try {
+ n = this.#e.lstatSync(t);
+ } catch {
+ return;
+ }
+ if (n.isSymbolicLink()) throw this.symlinkError(t, e);
}
- this.cksum = sum;
- encNumber(buf, off + 148, 8, this.cksum);
- this.cksumValid = true;
- return this.needPax;
}
- get type() {
- return this.#type === "Unsupported" ? this.#type : name.get(this.#type);
+ #a(e, t) {
+ let s = this.#e;
+ this.#i(t, e.mode ?? this.dmode);
+ let n = this.times(e);
+ if (n) try {
+ s.lutimesSync(t, n.atime, n.mtime);
+ } catch {
+ }
+ let r = this.owner(e);
+ if (r) try {
+ s.lchownSync(t, r.uid, r.gid);
+ } catch {
+ }
}
- get typeKey() {
- return this.#type;
- }
- set type(type) {
- const c = String(code.get(type));
- if (isCode(c) || c === "Unsupported") {
- this.#type = c;
- } else if (isCode(type)) {
- this.#type = type;
- } else {
- throw new TypeError("invalid entry type: " + type);
+ #o(e, t, s) {
+ let n = this.#e, r = n.openSync(t, this.writeFlag(e.size), e.mode ?? this.fmode);
+ try {
+ this.#n(this.parentParts(t));
+ let o = this.opt.transform?.(e);
+ for (; ; ) {
+ let h;
+ try {
+ h = s.readBody(e);
+ } catch (l) {
+ throw this.fail(l);
+ }
+ if (!h) break;
+ n.writeSync(r, o ? o(h) : h);
+ }
+ let a = this.times(e);
+ if (a) {
+ let { atime: h, mtime: l } = a;
+ try {
+ n.futimesSync(r, h, l);
+ } catch (d) {
+ try {
+ n.utimesSync(t, h, l);
+ } catch {
+ throw d;
+ }
+ }
+ }
+ let c = this.owner(e);
+ if (c) {
+ let { uid: h, gid: l } = c;
+ try {
+ n.fchownSync(r, h, l);
+ } catch (d) {
+ try {
+ n.chownSync(t, h, l);
+ } catch {
+ throw d;
+ }
+ }
+ }
+ } catch (o) {
+ try {
+ n.closeSync(r);
+ } catch {
+ }
+ throw o;
}
+ n.closeSync(r);
}
};
- splitPrefix = (p, prefixSize) => {
- const pathSize = 100;
- let pp = p;
- let prefix = "";
- let ret = void 0;
- const root = import_node_path.posix.parse(p).root || ".";
- if (Buffer.byteLength(pp) < pathSize) {
- ret = [pp, prefix, false];
- } else {
- prefix = import_node_path.posix.dirname(pp);
- pp = import_node_path.posix.basename(pp);
- do {
- if (Buffer.byteLength(pp) <= pathSize && Buffer.byteLength(prefix) <= prefixSize) {
- ret = [pp, prefix, false];
- } else if (Buffer.byteLength(pp) > pathSize && Buffer.byteLength(prefix) <= prefixSize) {
- ret = [pp.slice(0, pathSize - 1), prefix, true];
- } else {
- pp = import_node_path.posix.join(import_node_path.posix.basename(prefix), pp);
- prefix = import_node_path.posix.dirname(prefix);
- }
- } while (prefix !== root && ret === void 0);
- if (!ret) {
- ret = [p.slice(0, pathSize - 1), "", true];
- }
- }
- return ret;
- };
- decString = (buf, off, size) => buf.subarray(off, off + size).toString("utf8").replace(/\0.*/, "");
- decDate = (buf, off, size) => numToDate(decNumber(buf, off, size));
- numToDate = (num) => num === void 0 ? void 0 : new Date(num * 1e3);
- decNumber = (buf, off, size) => Number(buf[off]) & 128 ? parse(buf.subarray(off, off + size)) : decSmallNumber(buf, off, size);
- nanUndef = (value) => isNaN(value) ? void 0 : value;
- decSmallNumber = (buf, off, size) => nanUndef(parseInt(buf.subarray(off, off + size).toString("utf8").replace(/\0.*$/, "").trim(), 8));
- MAXNUM = {
- 12: 8589934591,
- 8: 2097151
- };
- encNumber = (buf, off, size, num) => num === void 0 ? false : num > MAXNUM[size] || num < 0 ? (encode(num, buf.subarray(off, off + size)), true) : (encSmallNumber(buf, off, size, num), false);
- encSmallNumber = (buf, off, size, num) => buf.write(octalString(num, size), off, size, "ascii");
- octalString = (num, size) => padOctal(Math.floor(num).toString(8), size);
- padOctal = (str, size) => (str.length === size - 1 ? str : new Array(size - str.length - 1).join("0") + str + " ") + "\0";
- encDate = (buf, off, size, date) => date === void 0 ? false : encNumber(buf, off, size, date.getTime() / 1e3);
- NULLS = new Array(156).join("\0");
- encString = (buf, off, size, str) => str === void 0 ? false : (buf.write(str + NULLS, off, size, "utf8"), str.length !== Buffer.byteLength(str) || str.length > size);
- }
-});
-
-// node_modules/tar/dist/esm/pax.js
-var import_node_path2, Pax, merge, parseKV, parseKVLine;
-var init_pax = __esm({
- "node_modules/tar/dist/esm/pax.js"() {
- import_node_path2 = require("node:path");
- init_header();
- Pax = class _Pax {
- atime;
- mtime;
- ctime;
- charset;
- comment;
- gid;
- uid;
- gname;
- uname;
- linkpath;
- dev;
- ino;
- nlink;
- path;
- size;
- mode;
- global;
- constructor(obj, global2 = false) {
- this.atime = obj.atime;
- this.charset = obj.charset;
- this.comment = obj.comment;
- this.ctime = obj.ctime;
- this.dev = obj.dev;
- this.gid = obj.gid;
- this.global = global2;
- this.gname = obj.gname;
- this.ino = obj.ino;
- this.linkpath = obj.linkpath;
- this.mtime = obj.mtime;
- this.nlink = obj.nlink;
- this.path = obj.path;
- this.size = obj.size;
- this.uid = obj.uid;
- this.uname = obj.uname;
- }
- encode() {
- const body = this.encodeBody();
- if (body === "") {
- return Buffer.allocUnsafe(0);
- }
- const bodyLen = Buffer.byteLength(body);
- const bufLen = 512 * Math.ceil(1 + bodyLen / 512);
- const buf = Buffer.allocUnsafe(bufLen);
- for (let i = 0; i < 512; i++) {
- buf[i] = 0;
- }
- new Header({
- // XXX split the path
- // then the path should be PaxHeader + basename, but less than 99,
- // prepend with the dirname
- /* c8 ignore start */
- path: ("PaxHeader/" + (0, import_node_path2.basename)(this.path ?? "")).slice(0, 99),
- /* c8 ignore stop */
- mode: this.mode || 420,
- uid: this.uid,
- gid: this.gid,
- size: bodyLen,
- mtime: this.mtime,
- type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader",
- linkpath: "",
- uname: this.uname || "",
- gname: this.gname || "",
- devmaj: 0,
- devmin: 0,
- atime: this.atime,
- ctime: this.ctime
- }).encode(buf);
- buf.write(body, 512, bodyLen, "utf8");
- for (let i = bodyLen + 512; i < buf.length; i++) {
- buf[i] = 0;
- }
- return buf;
- }
- encodeBody() {
- return this.encodeField("path") + this.encodeField("ctime") + this.encodeField("atime") + this.encodeField("dev") + this.encodeField("ino") + this.encodeField("nlink") + this.encodeField("charset") + this.encodeField("comment") + this.encodeField("gid") + this.encodeField("gname") + this.encodeField("linkpath") + this.encodeField("mtime") + this.encodeField("size") + this.encodeField("uid") + this.encodeField("uname");
- }
- encodeField(field) {
- if (this[field] === void 0) {
- return "";
- }
- const r = this[field];
- const v = r instanceof Date ? r.getTime() / 1e3 : r;
- const s = " " + (field === "dev" || field === "ino" || field === "nlink" ? "SCHILY." : "") + field + "=" + v + "\n";
- const byteLen = Buffer.byteLength(s);
- let digits = Math.floor(Math.log(byteLen) / Math.log(10)) + 1;
- if (byteLen + digits >= Math.pow(10, digits)) {
- digits += 1;
- }
- const len = digits + byteLen;
- return len + s;
- }
- static parse(str, ex, g = false) {
- return new _Pax(merge(parseKV(str), ex), g);
- }
- };
- merge = (a, b) => b ? Object.assign({}, b, a) : a;
- parseKV = (str) => str.replace(/\n$/, "").split("\n").reduce(parseKVLine, /* @__PURE__ */ Object.create(null));
- parseKVLine = (set, line) => {
- const n = parseInt(line, 10);
- if (n !== Buffer.byteLength(line) + 1) {
- return set;
- }
- line = line.slice((n + " ").length);
- const kv = line.split("=");
- const r = kv.shift();
- if (!r) {
- return set;
- }
- const k = r.replace(/^SCHILY\.(dev|ino|nlink)/, "$1");
- const v = kv.join("=").replace(/\0.*/, "");
- switch (k) {
- case "path":
- case "linkpath":
- case "type":
- case "charset":
- case "comment":
- case "gname":
- case "uname":
- set[k] = v;
- break;
- case "ctime":
- case "atime":
- case "mtime":
- set[k] = new Date(Number(v) * 1e3);
- break;
- case "size":
- const s = +v;
- if (s >= 0)
- set[k] = s;
- break;
- case "gid":
- case "uid":
- case "dev":
- case "ino":
- case "nlink":
- case "mode":
- set[k] = +v;
- break;
- }
- return set;
+ Ri = () => new TypeError("extract needs input or file");
+ Qe = async (i2, e) => {
+ let t = y(i2), s = t.input ?? (t.file ? H(t.fs, t.file, t.maxReadSize) : void 0);
+ if (!s) throw Ri();
+ let [n, r] = e?.length ? J(e, t.filter) : [];
+ n && (t.filter = n), await new Oe(t).extract(s), r?.(t);
};
- }
-});
-
-// node_modules/tar/dist/esm/normalize-windows-path.js
-var platform, normalizeWindowsPath;
-var init_normalize_windows_path = __esm({
- "node_modules/tar/dist/esm/normalize-windows-path.js"() {
- platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
- normalizeWindowsPath = platform !== "win32" ? (p) => String(p) : (p) => String(p).replaceAll(/\\/g, "/");
- }
-});
-
-// node_modules/tar/dist/esm/read-entry.js
-var ReadEntry;
-var init_read_entry = __esm({
- "node_modules/tar/dist/esm/read-entry.js"() {
- init_esm();
- init_normalize_windows_path();
- ReadEntry = class extends Minipass {
- extended;
- globalExtended;
- header;
- startBlockSize;
- blockRemain;
- remain;
- type;
- meta = false;
- ignore = false;
- path;
- mode;
- uid;
- gid;
- uname;
- gname;
- size = 0;
- mtime;
- atime;
- ctime;
- linkpath;
- dev;
- ino;
- nlink;
- invalid = false;
- absolute;
- unsupported = false;
- constructor(header, ex, gex) {
- super({});
- this.pause();
- this.extended = ex;
- this.globalExtended = gex;
- this.header = header;
- this.remain = header.size ?? 0;
- this.startBlockSize = 512 * Math.ceil(this.remain / 512);
- this.blockRemain = this.startBlockSize;
- this.type = header.type;
- switch (this.type) {
- case "File":
- case "OldFile":
- case "Link":
- case "SymbolicLink":
- case "CharacterDevice":
- case "BlockDevice":
- case "Directory":
- case "FIFO":
- case "ContiguousFile":
- case "GNUDumpDir":
- break;
- case "NextFileHasLongLinkpath":
- case "NextFileHasLongPath":
- case "OldGnuLongPath":
- case "GlobalExtendedHeader":
- case "ExtendedHeader":
- case "OldExtendedHeader":
- this.meta = true;
- break;
- // NOTE: gnutar and bsdtar treat unrecognized types as 'File'
- // it may be worth doing the same, but with a warning.
- default:
- this.ignore = true;
- }
- if (!header.path) {
- throw new Error("no path provided for tar.ReadEntry");
- }
- this.path = normalizeWindowsPath(header.path);
- this.mode = header.mode;
- if (this.mode) {
- this.mode = this.mode & 4095;
- }
- this.uid = header.uid;
- this.gid = header.gid;
- this.uname = header.uname;
- this.gname = header.gname;
- this.size = this.remain;
- this.mtime = header.mtime;
- this.atime = header.atime;
- this.ctime = header.ctime;
- this.linkpath = header.linkpath ? normalizeWindowsPath(header.linkpath) : void 0;
- this.uname = header.uname;
- this.gname = header.gname;
- if (ex) {
- this.#slurp(ex);
- }
- if (gex) {
- this.#slurp(gex, true);
- }
- }
- write(data) {
- const writeLen = data.length;
- if (writeLen > this.blockRemain) {
- throw new Error("writing more to entry than is appropriate");
- }
- const r = this.remain;
- const br = this.blockRemain;
- this.remain = Math.max(0, r - writeLen);
- this.blockRemain = Math.max(0, br - writeLen);
- if (this.ignore) {
- return true;
- }
- if (r >= writeLen) {
- return super.write(data);
+ Ai = (i2, e) => {
+ let t = y(i2), s = t.input ?? (t.file ? $(t.fs, t.file, t.maxReadSize) : void 0);
+ if (!s) throw Ri();
+ let [n, r] = e?.length ? J(e, t.filter) : [];
+ n && (t.filter = n), new Fe(t).extract(s), r?.(t);
+ };
+ Ti = 64 * 1024;
+ Ni = {};
+ Us = () => {
+ };
+ et = () => new Error("cannot append to compressed archives");
+ zi = (i2, e) => {
+ let { file: t } = i2;
+ if (!t) throw new TypeError("file is required");
+ if (i2.gzip || i2.brotli || i2.zstd || t.endsWith(".br") || t.endsWith(".tbr")) throw new TypeError(et().message);
+ if (!e?.length) throw new TypeError("no paths specified to add/replace");
+ };
+ Pe = class {
+ buf = new Uint8Array(Ti);
+ pos = 0;
+ #e;
+ #t;
+ #i;
+ #s;
+ constructor(e, t = [], s) {
+ this.#e = e, this.#i = [...t, T], this.#s = s, this.#t = new B({ filter: () => false, onwarn: () => {
+ throw Ni;
+ } });
+ }
+ get position() {
+ return this.#t.position;
+ }
+ get want() {
+ return Math.min(Ti, this.#e - this.pos);
+ }
+ push(e) {
+ let t = this.buf.subarray(0, e);
+ if (this.pos === 0 && this.#i.some((r) => r.detect(t))) throw et();
+ let s = this.#t;
+ this.pos += e;
+ let n = 0;
+ s.push(t);
+ try {
+ for (let r; r = s.next(); ) {
+ if (r.type !== "entry") return false;
+ let { entry: o } = r;
+ if (n = s.offset + 512 * Math.ceil(o.size / 512), n > this.#e) return false;
+ o.mtime && this.#s?.set(o.path, o.mtime);
+ }
+ this.pos < n && (s.skipBody(), this.pos = n);
+ } catch (r) {
+ if (r !== Ni) throw r;
+ return false;
}
- return super.write(data.subarray(0, r));
+ return e > 0 && this.pos < this.#e;
}
- #slurp(ex, gex = false) {
- if (ex.path)
- ex.path = normalizeWindowsPath(ex.path);
- if (ex.linkpath)
- ex.linkpath = normalizeWindowsPath(ex.linkpath);
- Object.assign(this, Object.fromEntries(Object.entries(ex).filter(([k, v]) => {
- return !(v === null || v === void 0 || k === "path" && gex);
- })));
+ };
+ he = async (i2, e) => {
+ let t = y(i2);
+ zi(t, e);
+ let { fs: s, file: n } = t, r = Ve(t, e);
+ if (r.codec) throw new TypeError(et().message);
+ let o = await s.open(n, "r+").catch((c) => {
+ if (c?.code !== "ENOENT") throw c;
+ return s.open(n, "w+", t.mode || 438);
+ }), a = false;
+ try {
+ let { size: c } = await o.stat(), h = new Pe(c, t.codecs, t.mtimeCache);
+ for (; h.push((await o.read(h.buf, 0, h.want, h.pos)).bytesRead); ) ;
+ await xt(o, r, h.position), a = true;
+ } finally {
+ let c = o.close();
+ await (a ? c : c.catch(Us));
}
};
- }
-});
-
-// node_modules/tar/dist/esm/warn-method.js
-var warnMethod;
-var init_warn_method = __esm({
- "node_modules/tar/dist/esm/warn-method.js"() {
- warnMethod = (self2, code2, message, data = {}) => {
- if (self2.file) {
- data.file = self2.file;
- }
- if (self2.cwd) {
- data.cwd = self2.cwd;
- }
- data.code = message instanceof Error && message.code || code2;
- data.tarCode = code2;
- if (!self2.strict && data.recoverable !== false) {
- if (message instanceof Error) {
- data = Object.assign(message, data);
- message = message.message;
- }
- self2.emit("warn", code2, message, data);
- } else if (message instanceof Error) {
- self2.emit("error", Object.assign(message, data));
- } else {
- self2.emit("error", Object.assign(new Error(`${code2}: ${message}`), data));
+ tt = (i2, e) => {
+ let t = y(i2);
+ zi(t, e);
+ let { fs: s, file: n } = t, r = St(t, e);
+ if (r.codec) throw new TypeError(et().message);
+ let o;
+ try {
+ o = s.openSync(n, "r+");
+ } catch (a) {
+ if (a?.code !== "ENOENT") throw a;
+ o = s.openSync(n, "w+", t.mode || 438);
}
+ try {
+ let { size: a } = s.fstatSync(o), c = new Pe(a, t.codecs, t.mtimeCache);
+ for (; c.push(s.readSync(o, c.buf, 0, c.want, c.pos)); ) ;
+ kt(s, o, r, c.position);
+ } catch (a) {
+ try {
+ s.closeSync(o);
+ } catch {
+ }
+ throw a;
+ }
+ s.closeSync(o);
+ };
+ Ls = (i2, e) => {
+ let t = e.getTime(), s = i2.getTime();
+ return (t % 1e3 === 0 ? Math.floor(s / 1e3) * 1e3 : s) > t;
+ };
+ Cs = (i2, e) => {
+ let t = Ke(e);
+ return i2.get(e) ?? i2.get(t) ?? (t.charAt(0) === "/" ? void 0 : i2.get("./" + t));
+ };
+ Oi = (i2) => {
+ let { filter: e } = i2, t = i2.mtimeCache ?? /* @__PURE__ */ new Map();
+ return { ...i2, mtimeCache: t, filter: (s, n) => {
+ if (e && !e(s, n)) return false;
+ if ("isDirectory" in n && n.isDirectory()) return true;
+ let r = Cs(t, s);
+ return !r || !n.mtime || Ls(n.mtime, r);
+ } };
+ };
+ it = (i2, e) => he(Oi(i2), e);
+ Fi = (i2, e) => tt(Oi(i2), e);
+ st = 64 * 1024;
+ nt = (i2, e = false, t) => {
+ let s, n, r = false, o = false, a, c, h = e ? new Uint8Array(st) : void 0, l = 0, d = (m) => new Promise((u) => {
+ a = u, i2.write(m, () => u());
+ }), p = async (m) => {
+ l && await d(m.subarray(0, l)), l = 0;
+ }, f = () => {
+ o = true, a?.(), c?.();
+ }, w = () => {
+ f(), i2.destroy();
+ };
+ return i2.pause(), i2.on("data", (m) => {
+ t?.(m), t = void 0, r = false, i2.pause(), s.enqueue(m);
+ }), i2.on("end", () => {
+ o || s.close();
+ }), i2.on("error", (m) => {
+ s.error(m), n.error(m), f();
+ }), i2.on("close", f), { readable: new ReadableStream({ start: (m) => {
+ s = m;
+ }, pull: () => {
+ r = true, c?.(), i2.resume();
+ }, cancel: (m) => {
+ n.error(m), w();
+ } }, { highWaterMark: 0 }), writable: new WritableStream({ start: (m) => {
+ n = m;
+ let { signal: u } = m;
+ u.addEventListener("abort", () => {
+ s.error(u.reason), w();
+ });
+ }, write: async (m) => {
+ h ? (l + m.length > st && await p(h), m.length > st ? await d(m) : (h.set(m, l), l += m.length)) : await d(m), !r && !o && await new Promise((u) => c = u);
+ }, close: async () => {
+ h && await p(h), await new Promise((m) => {
+ a = m, i2.end();
+ });
+ } }) };
};
+ Is = (i2) => i2 >= import_node_buffer.constants.MAX_LENGTH ? {} : { maxOutputLength: Math.max(1, Math.floor(i2)) };
+ Et = (i2, e, t, s, n) => ({ ...i2, decompress: () => nt(t({ chunkSize: st })), compress: (r) => nt(e(r), true), decompressSync: (r, { maxOutputLength: o }) => {
+ try {
+ return n(r, Is(o));
+ } catch (a) {
+ throw a?.code !== "ERR_BUFFER_TOO_LARGE" ? a : new Error(`max decompression ratio exceeded: the output is larger than ${o} bytes`);
+ }
+ }, compressSync: s });
+ Pi = (i2) => {
+ i2[9] = 255;
+ };
+ Rt = (i2 = _s) => {
+ let { createBrotliCompress: e, createBrotliDecompress: t, brotliCompressSync: s, brotliDecompressSync: n, createZstdCompress: r, createZstdDecompress: o, zstdCompressSync: a, zstdDecompressSync: c } = i2, l = [{ ...Et({ name: "gzip", headLength: 2, detect: (d) => d[0] === 31 && d[1] === 139 }, i2.createGzip, i2.createGunzip, i2.gzipSync, i2.gunzipSync), compress: ({ portable: d, ...p } = {}) => nt(i2.createGzip(p), true, d ? Pi : void 0), compressSync: (d, { portable: p, ...f } = {}) => {
+ let w = i2.gzipSync(d, f);
+ return p && Pi(w), w;
+ } }];
+ return e && t && s && n && l.push(Et({ name: "brotli", headLength: 0, detect: () => false, extensions: [".tar.br", ".tbr"] }, e, t, s, n)), r && o && a && c && l.push(Et({ name: "zstd", headLength: 4, detect: (d) => d[0] === 40 && d[1] === 181 && d[2] === 47 && d[3] === 253 }, r, o, a, c)), l;
+ };
+ Q = Hs;
+ ee = Bs;
+ Gs = process.platform === "win32" ? "win32" : "posix";
+ Ws = Rt();
+ g = (i2, e, t) => {
+ let s = y(i2);
+ return s.fs ??= e, s.platform ??= Gs, s.codecs = [...s.codecs ?? [], ...Ws], t && (s.cwd = (0, import_node_path.resolve)(s.cwd ?? ""), s.processUid ??= process.getuid?.(), s.processGid ??= process.getgid?.(), s.processUname ??= process.env.USER, s.chmod && (s.processUmask ??= process.umask())), s;
+ };
+ Lo = (i2, e = {}) => pt(i2, g(e, Q, false));
+ Co = (i2, e = {}) => Wt(i2, g(e, ee, false));
+ Do = (i2, e) => Ze(g(i2, Q, false), e);
+ Mo = (i2, e) => li(g(i2, ee, false), e);
+ _o = (i2, e) => Qe(g(i2, Q, true), e);
+ Io = (i2, e) => Ai(g(i2, ee, true), e);
+ $o = (i2, e) => he(g(i2, Q, true), e);
+ Go = (i2, e) => tt(g(i2, ee, true), e);
+ Wo = (i2, e) => it(g(i2, Q, true), e);
+ jo = (i2, e) => Fi(g(i2, ee, true), e);
+ Yo = (i2, e) => bt(g(i2, Q, false), e);
+ qo = (i2, e) => fi(g(i2, ee, false), e);
}
});
-// node_modules/tar/dist/esm/parse.js
-var import_events3, maxMetaEntrySize, gzipHeader, zstdHeader, ZIP_HEADER_LEN, STATE, WRITEENTRY, READENTRY, NEXTENTRY, PROCESSENTRY, EX, GEX, META, EMITMETA, BUFFER2, QUEUE, ENDED, EMITTEDEND, EMIT, UNZIP, CONSUMECHUNK, CONSUMECHUNKSUB, CONSUMEBODY, CONSUMEMETA, CONSUMEHEADER, CONSUMING, BUFFERCONCAT, MAYBEEND, WRITING, ABORTED2, DONE, SAW_VALID_ENTRY, SAW_NULL_BLOCK, SAW_EOF, CLOSESTREAM, MAX_DECOMPRESSION_RATIO, COMPRESSEDBYTESREAD, DECOMPRESSEDBYTESREAD, CHECKDECOMPRESSIONRATIO, noop2, Parser;
-var init_parse = __esm({
- "node_modules/tar/dist/esm/parse.js"() {
- import_events3 = require("events");
- init_esm3();
- init_header();
- init_pax();
- init_read_entry();
- init_warn_method();
- maxMetaEntrySize = 1024 * 1024;
- gzipHeader = Buffer.from([31, 139]);
- zstdHeader = Buffer.from([40, 181, 47, 253]);
- ZIP_HEADER_LEN = Math.max(gzipHeader.length, zstdHeader.length);
- STATE = /* @__PURE__ */ Symbol("state");
- WRITEENTRY = /* @__PURE__ */ Symbol("writeEntry");
- READENTRY = /* @__PURE__ */ Symbol("readEntry");
- NEXTENTRY = /* @__PURE__ */ Symbol("nextEntry");
- PROCESSENTRY = /* @__PURE__ */ Symbol("processEntry");
- EX = /* @__PURE__ */ Symbol("extendedHeader");
- GEX = /* @__PURE__ */ Symbol("globalExtendedHeader");
- META = /* @__PURE__ */ Symbol("meta");
- EMITMETA = /* @__PURE__ */ Symbol("emitMeta");
- BUFFER2 = /* @__PURE__ */ Symbol("buffer");
- QUEUE = /* @__PURE__ */ Symbol("queue");
- ENDED = /* @__PURE__ */ Symbol("ended");
- EMITTEDEND = /* @__PURE__ */ Symbol("emittedEnd");
- EMIT = /* @__PURE__ */ Symbol("emit");
- UNZIP = /* @__PURE__ */ Symbol("unzip");
- CONSUMECHUNK = /* @__PURE__ */ Symbol("consumeChunk");
- CONSUMECHUNKSUB = /* @__PURE__ */ Symbol("consumeChunkSub");
- CONSUMEBODY = /* @__PURE__ */ Symbol("consumeBody");
- CONSUMEMETA = /* @__PURE__ */ Symbol("consumeMeta");
- CONSUMEHEADER = /* @__PURE__ */ Symbol("consumeHeader");
- CONSUMING = /* @__PURE__ */ Symbol("consuming");
- BUFFERCONCAT = /* @__PURE__ */ Symbol("bufferConcat");
- MAYBEEND = /* @__PURE__ */ Symbol("maybeEnd");
- WRITING = /* @__PURE__ */ Symbol("writing");
- ABORTED2 = /* @__PURE__ */ Symbol("aborted");
- DONE = /* @__PURE__ */ Symbol("onDone");
- SAW_VALID_ENTRY = /* @__PURE__ */ Symbol("sawValidEntry");
- SAW_NULL_BLOCK = /* @__PURE__ */ Symbol("sawNullBlock");
- SAW_EOF = /* @__PURE__ */ Symbol("sawEOF");
- CLOSESTREAM = /* @__PURE__ */ Symbol("closeStream");
- MAX_DECOMPRESSION_RATIO = 1e3;
- COMPRESSEDBYTESREAD = /* @__PURE__ */ Symbol("compressedBytesRead");
- DECOMPRESSEDBYTESREAD = /* @__PURE__ */ Symbol("decompressedBytesRead");
- CHECKDECOMPRESSIONRATIO = /* @__PURE__ */ Symbol("checkDecompressionRatio");
- noop2 = () => true;
- Parser = class extends import_events3.EventEmitter {
- file;
- strict;
- maxMetaEntrySize;
- filter;
- brotli;
- zstd;
- maxDecompressionRatio;
- writable = true;
- readable = false;
- [QUEUE] = [];
- [BUFFER2];
- [READENTRY];
- [WRITEENTRY];
- [STATE] = "begin";
- [META] = "";
- [EX];
- [GEX];
- [ENDED] = false;
- [UNZIP];
- [ABORTED2] = false;
- [SAW_VALID_ENTRY];
- [SAW_NULL_BLOCK] = false;
- [SAW_EOF] = false;
- [WRITING] = false;
- [CONSUMING] = false;
- [EMITTEDEND] = false;
- [COMPRESSEDBYTESREAD] = 0;
- [DECOMPRESSEDBYTESREAD] = 0;
- constructor(opt = {}) {
- super();
- this.file = opt.file || "";
- this.on(DONE, () => {
- if (this[STATE] === "begin" || this[SAW_VALID_ENTRY] === false) {
- this.warn("TAR_BAD_ARCHIVE", "Unrecognized archive format");
- }
- });
- if (opt.ondone) {
- this.on(DONE, opt.ondone);
- } else {
- this.on(DONE, () => {
- this.emit("prefinish");
- this.emit("finish");
- this.emit("end");
- });
- }
- this.strict = !!opt.strict;
- this.maxDecompressionRatio = typeof opt.maxDecompressionRatio === "number" ? opt.maxDecompressionRatio : MAX_DECOMPRESSION_RATIO;
- this.maxMetaEntrySize = opt.maxMetaEntrySize || maxMetaEntrySize;
- this.filter = typeof opt.filter === "function" ? opt.filter : noop2;
- const isTBR = opt.file && (opt.file.endsWith(".tar.br") || opt.file.endsWith(".tbr"));
- this.brotli = !(opt.gzip || opt.zstd) && opt.brotli !== void 0 ? opt.brotli : isTBR ? void 0 : false;
- const isTZST = opt.file && (opt.file.endsWith(".tar.zst") || opt.file.endsWith(".tzst"));
- this.zstd = !(opt.gzip || opt.brotli) && opt.zstd !== void 0 ? opt.zstd : isTZST ? true : void 0;
- this.on("end", () => this[CLOSESTREAM]());
- if (typeof opt.onwarn === "function") {
- this.on("warn", opt.onwarn);
- }
- if (typeof opt.onReadEntry === "function") {
- this.on("entry", opt.onReadEntry);
- }
- }
- warn(code2, message, data = {}) {
- warnMethod(this, code2, message, data);
+// node_modules/v8-compile-cache/v8-compile-cache.js
+var require_v8_compile_cache = __commonJS({
+ "node_modules/v8-compile-cache/v8-compile-cache.js"(exports2, module2) {
+ "use strict";
+ var Module2 = require("module");
+ var crypto2 = require("crypto");
+ var fs9 = require("fs");
+ var path10 = require("path");
+ var vm = require("vm");
+ var os4 = require("os");
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ var FileSystemBlobStore = class {
+ constructor(directory, prefix) {
+ const name = prefix ? slashEscape(prefix + ".") : "";
+ this._blobFilename = path10.join(directory, name + "BLOB");
+ this._mapFilename = path10.join(directory, name + "MAP");
+ this._lockFilename = path10.join(directory, name + "LOCK");
+ this._directory = directory;
+ this._load();
}
- [CONSUMEHEADER](chunk, position) {
- if (this[SAW_VALID_ENTRY] === void 0) {
- this[SAW_VALID_ENTRY] = false;
+ has(key, invalidationKey) {
+ if (hasOwnProperty.call(this._memoryBlobs, key)) {
+ return this._invalidationKeys[key] === invalidationKey;
+ } else if (hasOwnProperty.call(this._storedMap, key)) {
+ return this._storedMap[key][0] === invalidationKey;
}
- let header;
- try {
- header = new Header(chunk, position, this[EX], this[GEX]);
- } catch (er) {
- return this.warn("TAR_ENTRY_INVALID", er);
- }
- if (header.nullBlock) {
- if (this[SAW_NULL_BLOCK]) {
- this[SAW_EOF] = true;
- if (this[STATE] === "begin") {
- this[STATE] = "header";
- }
- this[EMIT]("eof");
- } else {
- this[SAW_NULL_BLOCK] = true;
- this[EMIT]("nullBlock");
+ return false;
+ }
+ get(key, invalidationKey) {
+ if (hasOwnProperty.call(this._memoryBlobs, key)) {
+ if (this._invalidationKeys[key] === invalidationKey) {
+ return this._memoryBlobs[key];
}
- } else {
- this[SAW_NULL_BLOCK] = false;
- if (!header.cksumValid) {
- this.warn("TAR_ENTRY_INVALID", "checksum failure", { header });
- } else if (!header.path) {
- this.warn("TAR_ENTRY_INVALID", "path is required", { header });
- } else {
- const type = header.type;
- if (/^(Symbolic)?Link$/.test(type) && !header.linkpath) {
- this.warn("TAR_ENTRY_INVALID", "linkpath required", {
- header
- });
- } else if (!/^(Symbolic)?Link$/.test(type) && !/^(Global)?ExtendedHeader$/.test(type) && header.linkpath) {
- this.warn("TAR_ENTRY_INVALID", "linkpath forbidden", {
- header
- });
- } else {
- const entry = this[WRITEENTRY] = new ReadEntry(header, this[EX], this[GEX]);
- if (!this[SAW_VALID_ENTRY]) {
- if (entry.remain) {
- const onend = () => {
- if (!entry.invalid) {
- this[SAW_VALID_ENTRY] = true;
- }
- };
- entry.on("end", onend);
- } else {
- this[SAW_VALID_ENTRY] = true;
- }
- }
- if (entry.meta) {
- if (entry.size > this.maxMetaEntrySize) {
- entry.ignore = true;
- this[EMIT]("ignoredEntry", entry);
- this[STATE] = "ignore";
- entry.resume();
- } else if (entry.size > 0) {
- this[META] = "";
- entry.on("data", (c) => this[META] += c);
- this[STATE] = "meta";
- }
- } else {
- this[EX] = void 0;
- entry.ignore = entry.ignore || !this.filter(entry.path, entry);
- if (entry.ignore) {
- this[EMIT]("ignoredEntry", entry);
- this[STATE] = entry.remain ? "ignore" : "header";
- entry.resume();
- } else {
- if (entry.remain) {
- this[STATE] = "body";
- } else {
- this[STATE] = "header";
- entry.end();
- }
- if (!this[READENTRY]) {
- this[QUEUE].push(entry);
- this[NEXTENTRY]();
- } else {
- this[QUEUE].push(entry);
- }
- }
- }
- }
+ } else if (hasOwnProperty.call(this._storedMap, key)) {
+ const mapping = this._storedMap[key];
+ if (mapping[0] === invalidationKey) {
+ return this._storedBlob.slice(mapping[1], mapping[2]);
}
}
}
- [CLOSESTREAM]() {
- queueMicrotask(() => this.emit("close"));
- }
- [PROCESSENTRY](entry) {
- let go = true;
- if (!entry) {
- this[READENTRY] = void 0;
- go = false;
- } else if (Array.isArray(entry)) {
- const [ev, ...args] = entry;
- this.emit(ev, ...args);
- } else {
- this[READENTRY] = entry;
- this.emit("entry", entry);
- if (!entry.emittedEnd) {
- entry.on("end", () => this[NEXTENTRY]());
- go = false;
- }
- }
- return go;
+ set(key, invalidationKey, buffer) {
+ this._invalidationKeys[key] = invalidationKey;
+ this._memoryBlobs[key] = buffer;
+ this._dirty = true;
}
- [NEXTENTRY]() {
- do {
- } while (this[PROCESSENTRY](this[QUEUE].shift()));
- if (this[QUEUE].length === 0) {
- const re = this[READENTRY];
- const drainNow = !re || re.flowing || re.size === re.remain;
- if (drainNow) {
- if (!this[WRITING]) {
- this.emit("drain");
- }
- } else {
- re.once("drain", () => this.emit("drain"));
- }
+ delete(key) {
+ if (hasOwnProperty.call(this._memoryBlobs, key)) {
+ this._dirty = true;
+ delete this._memoryBlobs[key];
}
- }
- [CONSUMEBODY](chunk, position) {
- const entry = this[WRITEENTRY];
- if (!entry) {
- throw new Error("attempt to consume body without entry??");
+ if (hasOwnProperty.call(this._invalidationKeys, key)) {
+ this._dirty = true;
+ delete this._invalidationKeys[key];
}
- const br = entry.blockRemain ?? 0;
- const c = br >= chunk.length && position === 0 ? chunk : chunk.subarray(position, position + br);
- entry.write(c);
- if (!entry.blockRemain) {
- this[STATE] = "header";
- this[WRITEENTRY] = void 0;
- entry.end();
+ if (hasOwnProperty.call(this._storedMap, key)) {
+ this._dirty = true;
+ delete this._storedMap[key];
}
- return c.length;
}
- [CONSUMEMETA](chunk, position) {
- const entry = this[WRITEENTRY];
- const ret = this[CONSUMEBODY](chunk, position);
- if (!this[WRITEENTRY] && entry) {
- this[EMITMETA](entry);
- }
- return ret;
+ isDirty() {
+ return this._dirty;
}
- [EMIT](ev, data, extra) {
- if (this[QUEUE].length === 0 && !this[READENTRY]) {
- this.emit(ev, data, extra);
- } else {
- this[QUEUE].push([ev, data, extra]);
+ save() {
+ const dump = this._getDump();
+ const blobToStore = Buffer.concat(dump[0]);
+ const mapToStore = JSON.stringify(dump[1]);
+ try {
+ mkdirpSync(this._directory);
+ fs9.writeFileSync(this._lockFilename, "LOCK", { flag: "wx" });
+ } catch (error) {
+ return false;
}
- }
- [EMITMETA](entry) {
- this[EMIT]("meta", this[META]);
- switch (entry.type) {
- case "ExtendedHeader":
- case "OldExtendedHeader":
- this[EX] = Pax.parse(this[META], this[EX], false);
- break;
- case "GlobalExtendedHeader":
- this[GEX] = Pax.parse(this[META], this[GEX], true);
- break;
- case "NextFileHasLongPath":
- case "OldGnuLongPath": {
- const ex = this[EX] ?? /* @__PURE__ */ Object.create(null);
- this[EX] = ex;
- ex.path = this[META].replace(/\0.*/, "");
- break;
- }
- case "NextFileHasLongLinkpath": {
- const ex = this[EX] || /* @__PURE__ */ Object.create(null);
- this[EX] = ex;
- ex.linkpath = this[META].replace(/\0.*/, "");
- break;
- }
- /* c8 ignore start */
- default:
- throw new Error("unknown meta: " + entry.type);
+ try {
+ fs9.writeFileSync(this._blobFilename, blobToStore);
+ fs9.writeFileSync(this._mapFilename, mapToStore);
+ } finally {
+ fs9.unlinkSync(this._lockFilename);
}
+ return true;
}
- abort(error) {
- if (this[ABORTED2]) {
- return;
- }
- if (this[UNZIP]) {
- const u = this[UNZIP];
- u.write = () => true;
- u.end = () => u;
- u.emit = () => false;
- u.destroy?.();
- }
- this[ABORTED2] = true;
- this.emit("abort", error);
- this.warn("TAR_ABORT", error, { recoverable: false });
- }
- [CHECKDECOMPRESSIONRATIO](chunk) {
- this[DECOMPRESSEDBYTESREAD] += chunk.length;
- const ratio = this[DECOMPRESSEDBYTESREAD] / this[COMPRESSEDBYTESREAD];
- if (ratio > this.maxDecompressionRatio) {
- this.abort(new Error(`max decompression ratio exceeded: ${ratio.toFixed(2)} > ${this.maxDecompressionRatio}`));
- return false;
+ _load() {
+ try {
+ this._storedBlob = fs9.readFileSync(this._blobFilename);
+ this._storedMap = JSON.parse(fs9.readFileSync(this._mapFilename));
+ } catch (e) {
+ this._storedBlob = Buffer.alloc(0);
+ this._storedMap = {};
}
- return true;
+ this._dirty = false;
+ this._memoryBlobs = {};
+ this._invalidationKeys = {};
}
- write(chunk, encoding, cb) {
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
+ _getDump() {
+ const buffers = [];
+ const newMap = {};
+ let offset = 0;
+ function push(key, invalidationKey, buffer) {
+ buffers.push(buffer);
+ newMap[key] = [invalidationKey, offset, offset + buffer.length];
+ offset += buffer.length;
}
- if (typeof chunk === "string") {
- chunk = Buffer.from(
- chunk,
- /* c8 ignore next */
- typeof encoding === "string" ? encoding : "utf8"
- );
+ for (const key of Object.keys(this._memoryBlobs)) {
+ const buffer = this._memoryBlobs[key];
+ const invalidationKey = this._invalidationKeys[key];
+ push(key, invalidationKey, buffer);
}
- if (this[ABORTED2]) {
- cb?.();
- return false;
+ for (const key of Object.keys(this._storedMap)) {
+ if (hasOwnProperty.call(newMap, key)) continue;
+ const mapping = this._storedMap[key];
+ const buffer = this._storedBlob.slice(mapping[1], mapping[2]);
+ push(key, mapping[0], buffer);
}
- const needSniff = this[UNZIP] === void 0 || this.brotli === void 0 && this[UNZIP] === false;
- if (needSniff && chunk) {
- if (this[BUFFER2]) {
- chunk = Buffer.concat([this[BUFFER2], chunk]);
- this[BUFFER2] = void 0;
- }
- if (chunk.length < ZIP_HEADER_LEN) {
- this[BUFFER2] = chunk;
- cb?.();
- return true;
+ return [buffers, newMap];
+ }
+ };
+ var NativeCompileCache = class {
+ constructor() {
+ this._cacheStore = null;
+ this._previousModuleCompile = null;
+ }
+ setCacheStore(cacheStore) {
+ this._cacheStore = cacheStore;
+ }
+ install() {
+ const self2 = this;
+ const hasRequireResolvePaths = typeof require.resolve.paths === "function";
+ this._previousModuleCompile = Module2.prototype._compile;
+ Module2.prototype._compile = function(content, filename) {
+ const mod = this;
+ function require2(id) {
+ return mod.require(id);
}
- for (let i = 0; this[UNZIP] === void 0 && i < gzipHeader.length; i++) {
- if (chunk[i] !== gzipHeader[i]) {
- this[UNZIP] = false;
- }
+ function resolve(request, options) {
+ return Module2._resolveFilename(request, mod, false, options);
}
- let isZstd = false;
- if (this[UNZIP] === false && this.zstd !== false) {
- isZstd = true;
- for (let i = 0; i < zstdHeader.length; i++) {
- if (chunk[i] !== zstdHeader[i]) {
- isZstd = false;
- break;
- }
- }
+ require2.resolve = resolve;
+ if (hasRequireResolvePaths) {
+ resolve.paths = function paths(request) {
+ return Module2._resolveLookupPaths(request, mod, true);
+ };
}
- const maybeBrotli = this.brotli === void 0 && !isZstd;
- if (this[UNZIP] === false && maybeBrotli) {
- if (chunk.length < 512) {
- if (this[ENDED]) {
- this.brotli = true;
- } else {
- this[BUFFER2] = chunk;
- cb?.();
- return true;
- }
+ require2.main = process.mainModule;
+ require2.extensions = Module2._extensions;
+ require2.cache = Module2._cache;
+ const dirname = path10.dirname(filename);
+ const compiledWrapper = self2._moduleCompile(filename, content);
+ const args = [mod.exports, require2, mod, filename, dirname, process, global, Buffer];
+ return compiledWrapper.apply(mod.exports, args);
+ };
+ }
+ uninstall() {
+ Module2.prototype._compile = this._previousModuleCompile;
+ }
+ _moduleCompile(filename, content) {
+ var contLen = content.length;
+ if (contLen >= 2) {
+ if (content.charCodeAt(0) === 35 && content.charCodeAt(1) === 33) {
+ if (contLen === 2) {
+ content = "";
} else {
- try {
- new Header(chunk.subarray(0, 512));
- this.brotli = false;
- } catch (_) {
- this.brotli = true;
+ var i2 = 2;
+ for (; i2 < contLen; ++i2) {
+ var code = content.charCodeAt(i2);
+ if (code === 10 || code === 13) break;
+ }
+ if (i2 === contLen) {
+ content = "";
+ } else {
+ content = content.slice(i2);
}
}
}
- if (this[UNZIP] === void 0 || this[UNZIP] === false && (this.brotli || isZstd)) {
- const ended = this[ENDED];
- this[ENDED] = false;
- this[UNZIP] = this[UNZIP] === void 0 ? new Unzip({}) : isZstd ? new ZstdDecompress({}) : new BrotliDecompress({});
- this[UNZIP].on("data", (chunk2) => {
- if (this[CHECKDECOMPRESSIONRATIO](chunk2)) {
- this[CONSUMECHUNK](chunk2);
- }
- });
- this[UNZIP].on("error", (er) => {
- if (!this[ABORTED2]) {
- this.abort(er);
- }
- });
- this[UNZIP].on("end", () => {
- this[ENDED] = true;
- this[CONSUMECHUNK]();
- });
- this[WRITING] = true;
- this[COMPRESSEDBYTESREAD] += chunk.length;
- const ret2 = !!this[UNZIP][ended ? "end" : "write"](chunk);
- this[WRITING] = false;
- cb?.();
- return ret2;
- }
- }
- this[WRITING] = true;
- if (this[UNZIP]) {
- this[COMPRESSEDBYTESREAD] += chunk.length;
- this[UNZIP].write(chunk);
- } else {
- this[CONSUMECHUNK](chunk);
- }
- this[WRITING] = false;
- const ret = this[QUEUE].length > 0 ? false : this[READENTRY] ? this[READENTRY].flowing : true;
- if (!ret && this[QUEUE].length === 0) {
- this[READENTRY]?.once("drain", () => this.emit("drain"));
}
- cb?.();
- return ret;
- }
- [BUFFERCONCAT](c) {
- if (c && !this[ABORTED2]) {
- this[BUFFER2] = this[BUFFER2] ? Buffer.concat([this[BUFFER2], c]) : c;
+ var wrapper = Module2.wrap(content);
+ var invalidationKey = crypto2.createHash("sha1").update(content, "utf8").digest("hex");
+ var buffer = this._cacheStore.get(filename, invalidationKey);
+ var script = new vm.Script(wrapper, {
+ filename,
+ lineOffset: 0,
+ displayErrors: true,
+ cachedData: buffer,
+ produceCachedData: true
+ });
+ if (script.cachedDataProduced) {
+ this._cacheStore.set(filename, invalidationKey, script.cachedData);
+ } else if (script.cachedDataRejected) {
+ this._cacheStore.delete(filename);
}
+ var compiledWrapper = script.runInThisContext({
+ filename,
+ lineOffset: 0,
+ columnOffset: 0,
+ displayErrors: true
+ });
+ return compiledWrapper;
}
- [MAYBEEND]() {
- if (this[ENDED] && !this[EMITTEDEND] && !this[ABORTED2] && !this[CONSUMING]) {
- this[EMITTEDEND] = true;
- const entry = this[WRITEENTRY];
- if (entry?.blockRemain) {
- const have = this[BUFFER2] ? this[BUFFER2].length : 0;
- this.warn("TAR_BAD_ARCHIVE", `Truncated input (needed ${entry.blockRemain} more bytes, only ${have} available)`, { entry });
- if (this[BUFFER2]) {
- entry.write(this[BUFFER2]);
+ };
+ function mkdirpSync(p_) {
+ _mkdirpSync(path10.resolve(p_), 511);
+ }
+ function _mkdirpSync(p, mode) {
+ try {
+ fs9.mkdirSync(p, mode);
+ } catch (err0) {
+ if (err0.code === "ENOENT") {
+ _mkdirpSync(path10.dirname(p));
+ _mkdirpSync(p);
+ } else {
+ try {
+ const stat = fs9.statSync(p);
+ if (!stat.isDirectory()) {
+ throw err0;
}
- entry.end();
- }
- this[EMIT](DONE);
- }
- }
- [CONSUMECHUNK](chunk) {
- if (this[CONSUMING] && chunk) {
- this[BUFFERCONCAT](chunk);
- } else if (!chunk && !this[BUFFER2]) {
- this[MAYBEEND]();
- } else if (chunk) {
- this[CONSUMING] = true;
- if (this[BUFFER2]) {
- this[BUFFERCONCAT](chunk);
- const c = this[BUFFER2];
- this[BUFFER2] = void 0;
- this[CONSUMECHUNKSUB](c);
- } else {
- this[CONSUMECHUNKSUB](chunk);
- }
- while (this[BUFFER2] && this[BUFFER2]?.length >= 512 && !this[ABORTED2] && !this[SAW_EOF]) {
- const c = this[BUFFER2];
- this[BUFFER2] = void 0;
- this[CONSUMECHUNKSUB](c);
+ } catch (err1) {
+ throw err0;
}
- this[CONSUMING] = false;
- }
- if (!this[BUFFER2] || this[ENDED]) {
- this[MAYBEEND]();
}
}
- [CONSUMECHUNKSUB](chunk) {
- let position = 0;
- const length = chunk.length;
- while (position + 512 <= length && !this[ABORTED2] && !this[SAW_EOF]) {
- switch (this[STATE]) {
- case "begin":
- case "header":
- this[CONSUMEHEADER](chunk, position);
- position += 512;
- break;
- case "ignore":
- case "body":
- position += this[CONSUMEBODY](chunk, position);
- break;
- case "meta":
- position += this[CONSUMEMETA](chunk, position);
- break;
- /* c8 ignore start */
- default:
- throw new Error("invalid state: " + this[STATE]);
- }
- }
- if (position < length) {
- this[BUFFER2] = this[BUFFER2] ? Buffer.concat([chunk.subarray(position), this[BUFFER2]]) : chunk.subarray(position);
- }
+ }
+ function slashEscape(str) {
+ const ESCAPE_LOOKUP = {
+ "\\": "zB",
+ ":": "zC",
+ "/": "zS",
+ "\0": "z0",
+ "z": "zZ"
+ };
+ const ESCAPE_REGEX = /[\\:/\x00z]/g;
+ return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
+ }
+ function supportsCachedData() {
+ const script = new vm.Script('""', { produceCachedData: true });
+ return script.cachedDataProduced === true;
+ }
+ function getCacheDir() {
+ const v8_compile_cache_cache_dir = process.env.V8_COMPILE_CACHE_CACHE_DIR;
+ if (v8_compile_cache_cache_dir) {
+ return v8_compile_cache_cache_dir;
}
- end(chunk, encoding, cb) {
- if (typeof chunk === "function") {
- cb = chunk;
- encoding = void 0;
- chunk = void 0;
- }
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
- }
- if (typeof chunk === "string") {
- chunk = Buffer.from(chunk, encoding);
- }
- if (cb)
- this.once("finish", cb);
- if (!this[ABORTED2]) {
- if (this[UNZIP]) {
- if (chunk) {
- this[COMPRESSEDBYTESREAD] += chunk.length;
- this[UNZIP].write(chunk);
- }
- this[UNZIP].end();
- } else {
- this[ENDED] = true;
- if (this.brotli === void 0 || this.zstd === void 0)
- chunk = chunk || Buffer.alloc(0);
- if (chunk)
- this.write(chunk);
- this[MAYBEEND]();
- }
+ const dirname = typeof process.getuid === "function" ? "v8-compile-cache-" + process.getuid() : "v8-compile-cache";
+ const arch = process.arch;
+ const version = typeof process.versions.v8 === "string" ? process.versions.v8 : typeof process.versions.chakracore === "string" ? "chakracore-" + process.versions.chakracore : "node-" + process.version;
+ const cacheDir = path10.join(os4.tmpdir(), dirname, arch, version);
+ return cacheDir;
+ }
+ function getMainName() {
+ const mainName = require.main && typeof require.main.filename === "string" ? require.main.filename : process.cwd();
+ return mainName;
+ }
+ if (!process.env.DISABLE_V8_COMPILE_CACHE && supportsCachedData()) {
+ const cacheDir = getCacheDir();
+ const prefix = getMainName();
+ const blobStore = new FileSystemBlobStore(cacheDir, prefix);
+ const nativeCompileCache = new NativeCompileCache();
+ nativeCompileCache.setCacheStore(blobStore);
+ nativeCompileCache.install();
+ process.once("exit", () => {
+ if (blobStore.isDirty()) {
+ blobStore.save();
}
- return this;
- }
+ nativeCompileCache.uninstall();
+ });
+ }
+ module2.exports.__TEST__ = {
+ FileSystemBlobStore,
+ NativeCompileCache,
+ mkdirpSync,
+ slashEscape,
+ supportsCachedData,
+ getCacheDir,
+ getMainName
};
}
});
-// node_modules/tar/dist/esm/strip-trailing-slashes.js
-var stripTrailingSlashes;
-var init_strip_trailing_slashes = __esm({
- "node_modules/tar/dist/esm/strip-trailing-slashes.js"() {
- stripTrailingSlashes = (str) => {
- let i = str.length - 1;
- let slashesStart = -1;
- while (i > -1 && str.charAt(i) === "/") {
- slashesStart = i;
- i--;
+// node_modules/semver/functions/satisfies.js
+var require_satisfies = __commonJS({
+ "node_modules/semver/functions/satisfies.js"(exports2, module2) {
+ "use strict";
+ var Range3 = require_range();
+ var satisfies = (version, range, options) => {
+ try {
+ range = new Range3(range, options);
+ } catch (er) {
+ return false;
}
- return slashesStart === -1 ? str : str.slice(0, slashesStart);
+ return range.test(version);
};
+ module2.exports = satisfies;
}
});
-// node_modules/tar/dist/esm/list.js
-var list_exports = {};
-__export(list_exports, {
- filesFilter: () => filesFilter,
- list: () => list
-});
-var import_node_fs, import_path2, onReadEntryFunction, filesFilter, listFileSync, listFile, list;
-var init_list = __esm({
- "node_modules/tar/dist/esm/list.js"() {
- init_esm2();
- import_node_fs = __toESM(require("node:fs"), 1);
- import_path2 = require("path");
- init_make_command();
- init_parse();
- init_strip_trailing_slashes();
- onReadEntryFunction = (opt) => {
- const onReadEntry = opt.onReadEntry;
- opt.onReadEntry = onReadEntry ? (e) => {
- onReadEntry(e);
- e.resume();
- } : (e) => e.resume();
- };
- filesFilter = (opt, files) => {
- const map = new Map(files.map((f) => [stripTrailingSlashes(f), true]));
- const filter = opt.filter;
- const MAX2 = 100;
- const mapHas = (file, r = "", depth = 0) => {
- if (depth >= MAX2) {
- map.set(file, false);
- return false;
+// node_modules/which/node_modules/isexe/dist/commonjs/index.min.js
+var require_index_min = __commonJS({
+ "node_modules/which/node_modules/isexe/dist/commonjs/index.min.js"(exports2) {
+ "use strict";
+ var a = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
+ var _2 = a((i2) => {
+ "use strict";
+ Object.defineProperty(i2, "__esModule", { value: true });
+ i2.sync = i2.isexe = void 0;
+ var M2 = require("node:fs"), x2 = require("node:fs/promises"), q2 = async (t, e = {}) => {
+ let { ignoreErrors: r = false } = e;
+ try {
+ return d(await (0, x2.stat)(t), e);
+ } catch (s) {
+ let n = s;
+ if (r || n.code === "EACCES") return false;
+ throw n;
}
- const root = r || (0, import_path2.parse)(file).root || ".";
- let ret;
- if (file === root)
- ret = false;
- else {
- const m = map.get(file);
- ret = m !== void 0 ? m : mapHas((0, import_path2.dirname)(file), root, depth + 1);
+ };
+ i2.isexe = q2;
+ var m = (t, e = {}) => {
+ let { ignoreErrors: r = false } = e;
+ try {
+ return d((0, M2.statSync)(t), e);
+ } catch (s) {
+ let n = s;
+ if (r || n.code === "EACCES") return false;
+ throw n;
}
- map.set(file, ret);
- return ret;
};
- opt.filter = filter ? (file, entry) => filter(file, entry) && mapHas(stripTrailingSlashes(file)) : (file) => mapHas(stripTrailingSlashes(file));
- };
- listFileSync = (opt) => {
- const p = new Parser(opt);
- const file = opt.file;
- let fd;
- try {
- fd = import_node_fs.default.openSync(file, "r");
- const stat = import_node_fs.default.fstatSync(fd);
- const readSize = opt.maxReadSize || 16 * 1024 * 1024;
- if (stat.size < readSize) {
- const buf = Buffer.allocUnsafe(stat.size);
- const read = import_node_fs.default.readSync(fd, buf, 0, stat.size, 0);
- p.end(read === buf.byteLength ? buf : buf.subarray(0, read));
- } else {
- let pos2 = 0;
- const buf = Buffer.allocUnsafe(readSize);
- while (pos2 < stat.size) {
- const bytesRead = import_node_fs.default.readSync(fd, buf, 0, readSize, pos2);
- if (bytesRead === 0)
- break;
- pos2 += bytesRead;
- p.write(buf.subarray(0, bytesRead));
- }
- p.end();
+ i2.sync = m;
+ var d = (t, e) => t.isFile() && A2(t, e), A2 = (t, e) => {
+ let r = e.uid ?? process.getuid?.(), s = e.groups ?? process.getgroups?.() ?? [], n = e.gid ?? process.getgid?.() ?? s[0];
+ if (r === void 0 || n === void 0) throw new Error("cannot get uid or gid");
+ let u = /* @__PURE__ */ new Set([n, ...s]), c = t.mode, S2 = t.uid, P2 = t.gid, f = parseInt("100", 8), l = parseInt("010", 8), j2 = parseInt("001", 8), C2 = f | l;
+ return !!(c & j2 || c & l && u.has(P2) || c & f && S2 === r || c & C2 && r === 0);
+ };
+ });
+ var g2 = a((o) => {
+ "use strict";
+ Object.defineProperty(o, "__esModule", { value: true });
+ o.sync = o.isexe = void 0;
+ var T2 = require("node:fs"), I2 = require("node:fs/promises"), D2 = require("node:path"), F2 = async (t, e = {}) => {
+ let { ignoreErrors: r = false } = e;
+ try {
+ return y2(await (0, I2.stat)(t), t, e);
+ } catch (s) {
+ let n = s;
+ if (r || n.code === "EACCES") return false;
+ throw n;
}
- } finally {
- if (typeof fd === "number") {
- try {
- import_node_fs.default.closeSync(fd);
- } catch {
- }
+ };
+ o.isexe = F2;
+ var L2 = (t, e = {}) => {
+ let { ignoreErrors: r = false } = e;
+ try {
+ return y2((0, T2.statSync)(t), t, e);
+ } catch (s) {
+ let n = s;
+ if (r || n.code === "EACCES") return false;
+ throw n;
}
- }
- };
- listFile = (opt, _files) => {
- const parse4 = new Parser(opt);
- const readSize = opt.maxReadSize || 16 * 1024 * 1024;
- const file = opt.file;
- const p = new Promise((resolve, reject) => {
- parse4.on("error", reject);
- parse4.on("end", resolve);
- import_node_fs.default.stat(file, (er, stat) => {
- if (er) {
- reject(er);
- } else {
- const stream = new ReadStream(file, {
- readSize,
- size: stat.size
- });
- stream.on("error", reject);
- stream.pipe(parse4);
- }
- });
- });
- return p;
- };
- list = makeCommand(listFileSync, listFile, (opt) => new Parser(opt), (opt) => new Parser(opt), (opt, files) => {
- if (files?.length)
- filesFilter(opt, files);
- if (!opt.noResume)
- onReadEntryFunction(opt);
+ };
+ o.sync = L2;
+ var B2 = (t, e) => {
+ let { pathExt: r = process.env.PATHEXT || "" } = e, s = r.split(D2.delimiter);
+ if (s.indexOf("") !== -1) return true;
+ for (let n of s) {
+ let u = n.toLowerCase(), c = t.substring(t.length - u.length).toLowerCase();
+ if (u && c === u) return true;
+ }
+ return false;
+ }, y2 = (t, e, r) => t.isFile() && B2(e, r);
+ });
+ var p = a((h) => {
+ "use strict";
+ Object.defineProperty(h, "__esModule", { value: true });
+ });
+ var v = exports2 && exports2.__createBinding || (Object.create ? (function(t, e, r, s) {
+ s === void 0 && (s = r);
+ var n = Object.getOwnPropertyDescriptor(e, r);
+ (!n || ("get" in n ? !e.__esModule : n.writable || n.configurable)) && (n = { enumerable: true, get: function() {
+ return e[r];
+ } }), Object.defineProperty(t, s, n);
+ }) : (function(t, e, r, s) {
+ s === void 0 && (s = r), t[s] = e[r];
+ }));
+ var G2 = exports2 && exports2.__setModuleDefault || (Object.create ? (function(t, e) {
+ Object.defineProperty(t, "default", { enumerable: true, value: e });
+ }) : function(t, e) {
+ t.default = e;
});
+ var w = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
+ var t = function(e) {
+ return t = Object.getOwnPropertyNames || function(r) {
+ var s = [];
+ for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (s[s.length] = n);
+ return s;
+ }, t(e);
+ };
+ return function(e) {
+ if (e && e.__esModule) return e;
+ var r = {};
+ if (e != null) for (var s = t(e), n = 0; n < s.length; n++) s[n] !== "default" && v(r, e, s[n]);
+ return G2(r, e), r;
+ };
+ })();
+ var X2 = exports2 && exports2.__exportStar || function(t, e) {
+ for (var r in t) r !== "default" && !Object.prototype.hasOwnProperty.call(e, r) && v(e, t, r);
+ };
+ Object.defineProperty(exports2, "__esModule", { value: true });
+ exports2.sync = exports2.isexe = exports2.posix = exports2.win32 = void 0;
+ var E2 = w(_2());
+ exports2.posix = E2;
+ var O2 = w(g2());
+ exports2.win32 = O2;
+ X2(p(), exports2);
+ var H2 = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
+ var b2 = H2 === "win32" ? O2 : E2;
+ exports2.isexe = b2.isexe;
+ exports2.sync = b2.sync;
}
});
-// node_modules/tar/dist/esm/get-write-flag.js
-var import_fs3, platform2, isWindows, O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY, UV_FS_O_FILEMAP, fMapEnabled, fMapLimit, fMapFlag, noFollowFlag, getWriteFlag;
-var init_get_write_flag = __esm({
- "node_modules/tar/dist/esm/get-write-flag.js"() {
- import_fs3 = __toESM(require("fs"), 1);
- platform2 = process.env.__FAKE_PLATFORM__ || process.platform;
- isWindows = platform2 === "win32";
- ({ O_CREAT, O_NOFOLLOW, O_TRUNC, O_WRONLY } = import_fs3.default.constants);
- UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) || import_fs3.default.constants.UV_FS_O_FILEMAP || 0;
- fMapEnabled = isWindows && !!UV_FS_O_FILEMAP;
- fMapLimit = 512 * 1024;
- fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
- noFollowFlag = !isWindows && typeof O_NOFOLLOW === "number" ? O_NOFOLLOW | O_TRUNC | O_CREAT | O_WRONLY : null;
- getWriteFlag = noFollowFlag !== null ? () => noFollowFlag : !fMapEnabled ? () => "w" : (size) => size < fMapLimit ? fMapFlag : "w";
- }
-});
-
-// node_modules/chownr/dist/esm/index.js
-var import_node_fs2, import_node_path3, lchownSync, chown, chownrKid, chownr, chownrKidSync, chownrSync;
-var init_esm4 = __esm({
- "node_modules/chownr/dist/esm/index.js"() {
- import_node_fs2 = __toESM(require("node:fs"), 1);
- import_node_path3 = __toESM(require("node:path"), 1);
- lchownSync = (path16, uid, gid) => {
- try {
- return import_node_fs2.default.lchownSync(path16, uid, gid);
- } catch (er) {
- if (er?.code !== "ENOENT")
- throw er;
+// node_modules/which/lib/index.js
+var require_lib = __commonJS({
+ "node_modules/which/lib/index.js"(exports2, module2) {
+ var { isexe, sync: isexeSync } = require_index_min();
+ var { join: join2, 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).flatMap((item) => [item, item.toLowerCase()]);
+ if (cmd.includes(".") && pathExt[0] !== "") {
+ pathExt.unshift("");
+ }
+ return { pathEnv, pathExt, pathExtExe };
}
+ return { pathEnv, pathExt: [""] };
};
- chown = (cpath, uid, gid, cb) => {
- import_node_fs2.default.lchown(cpath, uid, gid, (er) => {
- cb(er && er?.code !== "ENOENT" ? er : null);
- });
+ 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 + join2(pathPart, cmd);
};
- chownrKid = (p, child, uid, gid, cb) => {
- if (child.isDirectory()) {
- chownr(import_node_path3.default.resolve(p, child.name), uid, gid, (er) => {
- if (er)
- return cb(er);
- const cpath = import_node_path3.default.resolve(p, child.name);
- chown(cpath, uid, gid, cb);
- });
- } else {
- const cpath = import_node_path3.default.resolve(p, child.name);
- chown(cpath, uid, gid, cb);
- }
- };
- chownr = (p, uid, gid, cb) => {
- import_node_fs2.default.readdir(p, { withFileTypes: true }, (er, children) => {
- if (er) {
- if (er.code === "ENOENT")
- return cb();
- else if (er.code !== "ENOTDIR" && er.code !== "ENOTSUP")
- return cb(er);
- }
- if (er || !children.length)
- return chown(p, uid, gid, cb);
- let len = children.length;
- let errState = null;
- const then = (er2) => {
- if (errState)
- return;
- if (er2)
- return cb(errState = er2);
- if (--len === 0)
- return chown(p, uid, gid, cb);
- };
- for (const child of children) {
- chownrKid(p, child, uid, gid, then);
+ 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 is2 = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
+ if (is2) {
+ if (!opt.all) {
+ return withExt;
+ }
+ found.push(withExt);
+ }
}
- });
- };
- chownrKidSync = (p, child, uid, gid) => {
- if (child.isDirectory())
- chownrSync(import_node_path3.default.resolve(p, child.name), uid, gid);
- lchownSync(import_node_path3.default.resolve(p, child.name), uid, gid);
- };
- chownrSync = (p, uid, gid) => {
- let children;
- try {
- children = import_node_fs2.default.readdirSync(p, { withFileTypes: true });
- } catch (er) {
- const e = er;
- if (e?.code === "ENOENT")
- return;
- else if (e?.code === "ENOTDIR" || e?.code === "ENOTSUP")
- return lchownSync(p, uid, gid);
- else
- throw e;
- }
- for (const child of children) {
- chownrKidSync(p, child, uid, gid);
- }
- return lchownSync(p, uid, gid);
- };
- }
-});
-
-// node_modules/tar/dist/esm/cwd-error.js
-var CwdError;
-var init_cwd_error = __esm({
- "node_modules/tar/dist/esm/cwd-error.js"() {
- CwdError = class extends Error {
- path;
- code;
- syscall = "chdir";
- constructor(path16, code2) {
- super(`${code2}: Cannot cd into '${path16}'`);
- this.path = path16;
- this.code = code2;
- }
- get name() {
- return "CwdError";
}
- };
- }
-});
-
-// node_modules/tar/dist/esm/symlink-error.js
-var SymlinkError;
-var init_symlink_error = __esm({
- "node_modules/tar/dist/esm/symlink-error.js"() {
- SymlinkError = class extends Error {
- path;
- symlink;
- syscall = "symlink";
- code = "TAR_SYMLINK_ERROR";
- constructor(symlink, path16) {
- super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link");
- this.symlink = symlink;
- this.path = path16;
+ if (opt.all && found.length) {
+ return found;
}
- get name() {
- return "SymlinkError";
+ if (opt.nothrow) {
+ return null;
}
+ throw getNotFoundError(cmd);
};
- }
-});
-
-// node_modules/tar/dist/esm/mkdir.js
-var import_node_fs3, import_promises, import_node_path4, checkCwd, mkdir, mkdir_, onmkdir, checkCwdSync, mkdirSync2;
-var init_mkdir = __esm({
- "node_modules/tar/dist/esm/mkdir.js"() {
- init_esm4();
- import_node_fs3 = __toESM(require("node:fs"), 1);
- import_promises = __toESM(require("node:fs/promises"), 1);
- import_node_path4 = __toESM(require("node:path"), 1);
- init_cwd_error();
- init_normalize_windows_path();
- init_symlink_error();
- checkCwd = (dir, cb) => {
- import_node_fs3.default.stat(dir, (er, st) => {
- if (er || !st.isDirectory()) {
- er = new CwdError(dir, er?.code || "ENOTDIR");
- }
- cb(er);
- });
- };
- mkdir = (dir, opt, cb) => {
- dir = normalizeWindowsPath(dir);
- const umask2 = opt.umask ?? 18;
- const mode = opt.mode | 448;
- const needChmod = (mode & umask2) !== 0;
- const uid = opt.uid;
- const gid = opt.gid;
- const doChown = typeof uid === "number" && typeof gid === "number" && (uid !== opt.processUid || gid !== opt.processGid);
- const preserve = opt.preserve;
- const unlink = opt.unlink;
- const cwd = normalizeWindowsPath(opt.cwd);
- const done = (er, created) => {
- if (er) {
- cb(er);
- } else {
- if (created && doChown) {
- chownr(created, uid, gid, (er2) => done(er2));
- } else if (needChmod) {
- import_node_fs3.default.chmod(dir, mode, cb);
- } else {
- cb();
+ 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 is2 = isexeSync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
+ if (is2) {
+ if (!opt.all) {
+ return withExt;
+ }
+ found.push(withExt);
}
}
- };
- if (dir === cwd) {
- return checkCwd(dir, done);
- }
- if (preserve) {
- return import_promises.default.mkdir(dir, { mode, recursive: true }).then(
- (made) => done(null, made ?? void 0),
- // oh, ts
- done
- );
- }
- const sub = normalizeWindowsPath(import_node_path4.default.relative(cwd, dir));
- const parts = sub.split("/");
- mkdir_(cwd, parts, mode, unlink, cwd, void 0, done);
- };
- mkdir_ = (base, parts, mode, unlink, cwd, created, cb) => {
- if (parts.length === 0) {
- return cb(null, created);
- }
- const p = parts.shift();
- const part = normalizeWindowsPath(import_node_path4.default.resolve(base + "/" + p));
- import_node_fs3.default.mkdir(part, mode, onmkdir(part, parts, mode, unlink, cwd, created, cb));
- };
- onmkdir = (part, parts, mode, unlink, cwd, created, cb) => (er) => {
- if (er) {
- import_node_fs3.default.lstat(part, (statEr, st) => {
- if (statEr) {
- statEr.path = statEr.path && normalizeWindowsPath(statEr.path);
- cb(statEr);
- } else if (st.isDirectory()) {
- mkdir_(part, parts, mode, unlink, cwd, created, cb);
- } else if (unlink) {
- import_node_fs3.default.unlink(part, (er2) => {
- if (er2) {
- return cb(er2);
- }
- import_node_fs3.default.mkdir(part, mode, onmkdir(part, parts, mode, unlink, cwd, created, cb));
- });
- } else if (st.isSymbolicLink()) {
- return cb(new SymlinkError(part, part + "/" + parts.join("/")));
- } else {
- cb(er);
- }
- });
- } else {
- created = created || part;
- mkdir_(part, parts, mode, unlink, cwd, created, cb);
}
- };
- checkCwdSync = (dir) => {
- let ok = false;
- let code2;
- try {
- ok = import_node_fs3.default.statSync(dir).isDirectory();
- } catch (er) {
- code2 = er?.code;
- } finally {
- if (!ok) {
- throw new CwdError(dir, code2 ?? "ENOTDIR");
- }
+ if (opt.all && found.length) {
+ return found;
}
- };
- mkdirSync2 = (dir, opt) => {
- dir = normalizeWindowsPath(dir);
- const umask2 = opt.umask ?? 18;
- const mode = opt.mode | 448;
- const needChmod = (mode & umask2) !== 0;
- const uid = opt.uid;
- const gid = opt.gid;
- const doChown = typeof uid === "number" && typeof gid === "number" && (uid !== opt.processUid || gid !== opt.processGid);
- const preserve = opt.preserve;
- const unlink = opt.unlink;
- const cwd = normalizeWindowsPath(opt.cwd);
- const done = (created2) => {
- if (created2 && doChown) {
- chownrSync(created2, uid, gid);
- }
- if (needChmod) {
- import_node_fs3.default.chmodSync(dir, mode);
- }
- };
- if (dir === cwd) {
- checkCwdSync(cwd);
- return done();
- }
- if (preserve) {
- return done(import_node_fs3.default.mkdirSync(dir, { mode, recursive: true }) ?? void 0);
- }
- const sub = normalizeWindowsPath(import_node_path4.default.relative(cwd, dir));
- const parts = sub.split("/");
- let created;
- for (let p = parts.shift(), part = cwd; p && (part += "/" + p); p = parts.shift()) {
- part = normalizeWindowsPath(import_node_path4.default.resolve(part));
- try {
- import_node_fs3.default.mkdirSync(part, mode);
- created = created || part;
- } catch {
- const st = import_node_fs3.default.lstatSync(part);
- if (st.isDirectory()) {
- continue;
- } else if (unlink) {
- import_node_fs3.default.unlinkSync(part);
- import_node_fs3.default.mkdirSync(part, mode);
- created = created || part;
- continue;
- } else if (st.isSymbolicLink()) {
- return new SymlinkError(part, part + "/" + parts.join("/"));
- }
- }
+ if (opt.nothrow) {
+ return null;
}
- return done(created);
+ throw getNotFoundError(cmd);
};
+ module2.exports = which3;
+ which3.sync = whichSync;
}
});
-// node_modules/tar/dist/esm/strip-absolute-path.js
-var import_node_path5, isAbsolute, parse3, stripAbsolutePath;
-var init_strip_absolute_path = __esm({
- "node_modules/tar/dist/esm/strip-absolute-path.js"() {
- import_node_path5 = require("node:path");
- ({ isAbsolute, parse: parse3 } = import_node_path5.win32);
- stripAbsolutePath = (path16) => {
- let r = "";
- let parsed = parse3(path16);
- while (isAbsolute(path16) || parsed.root) {
- const root = path16.charAt(0) === "/" && path16.slice(0, 4) !== "//?/" ? "/" : parsed.root;
- path16 = path16.slice(root.length);
- r += root;
- parsed = parse3(path16);
- }
- return [r, path16];
- };
+// node_modules/is-windows/index.js
+var require_is_windows = __commonJS({
+ "node_modules/is-windows/index.js"(exports2, module2) {
+ (function(factory) {
+ if (exports2 && typeof exports2 === "object" && typeof module2 !== "undefined") {
+ module2.exports = factory();
+ } else if (typeof define === "function" && define.amd) {
+ define([], factory);
+ } else if (typeof window !== "undefined") {
+ window.isWindows = factory();
+ } else if (typeof global !== "undefined") {
+ global.isWindows = factory();
+ } else if (typeof self !== "undefined") {
+ self.isWindows = factory();
+ } else {
+ this.isWindows = factory();
+ }
+ })(function() {
+ "use strict";
+ return function isWindows() {
+ return process && (process.platform === "win32" || /^(msys|cygwin)$/.test(process.env.OSTYPE));
+ };
+ });
}
});
-// node_modules/tar/dist/esm/winchars.js
-var raw, win, toWin, toRaw, encode2, decode;
-var init_winchars = __esm({
- "node_modules/tar/dist/esm/winchars.js"() {
- raw = ["|", "<", ">", "?", ":"];
- win = raw.map((char) => String.fromCodePoint(61440 + Number(char.codePointAt(0))));
- toWin = new Map(raw.map((char, i) => [char, win[i]]));
- toRaw = new Map(win.map((char, i) => [char, raw[i]]));
- encode2 = (s) => raw.reduce((s2, c) => s2.split(c).join(toWin.get(c)), s);
- decode = (s) => win.reduce((s2, c) => s2.split(c).join(toRaw.get(c)), s);
+// node_modules/cmd-extension/index.js
+var require_cmd_extension = __commonJS({
+ "node_modules/cmd-extension/index.js"(exports2, module2) {
+ "use strict";
+ var path10 = require("path");
+ var cmdExtension;
+ if (process.env.PATHEXT) {
+ cmdExtension = process.env.PATHEXT.split(path10.delimiter).find((ext) => ext.toUpperCase() === ".CMD");
+ }
+ module2.exports = cmdExtension || ".cmd";
}
});
-// node_modules/tar/dist/esm/normalize-unicode.js
-var normalizeCache, MAX, cache, normalizeUnicode;
-var init_normalize_unicode = __esm({
- "node_modules/tar/dist/esm/normalize-unicode.js"() {
- normalizeCache = /* @__PURE__ */ Object.create(null);
- MAX = 1e4;
- cache = /* @__PURE__ */ new Set();
- normalizeUnicode = (s) => {
- if (!cache.has(s)) {
- normalizeCache[s] = s.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en");
- } else {
- cache.delete(s);
- }
- cache.add(s);
- const ret = normalizeCache[s];
- let i = cache.size - MAX;
- if (i > MAX / 10) {
- for (const s2 of cache) {
- cache.delete(s2);
- delete normalizeCache[s2];
- if (--i <= 0)
- break;
- }
- }
- return ret;
+// node_modules/graceful-fs/polyfills.js
+var require_polyfills = __commonJS({
+ "node_modules/graceful-fs/polyfills.js"(exports2, 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;
};
- }
-});
-
-// node_modules/tar/dist/esm/path-reservations.js
-var import_node_path6, platform3, isWindows2, getDirs, PathReservations;
-var init_path_reservations = __esm({
- "node_modules/tar/dist/esm/path-reservations.js"() {
- import_node_path6 = require("node:path");
- init_normalize_unicode();
- init_strip_trailing_slashes();
- platform3 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
- isWindows2 = platform3 === "win32";
- getDirs = (path16) => {
- const dirs = path16.split("/").slice(0, -1).reduce((set, path17) => {
- const s = set.at(-1);
- if (s !== void 0) {
- path17 = (0, import_node_path6.join)(s, path17);
- }
- set.push(path17 || "/");
- return set;
- }, []);
- return dirs;
- };
- PathReservations = class {
- // path => [function or Set]
- // A Set object means a directory reservation
- // A fn is a direct reservation on that path
- #queues = /* @__PURE__ */ new Map();
- // fn => {paths:[path,...], dirs:[path, ...]}
- #reservations = /* @__PURE__ */ new Map();
- // functions currently running
- #running = /* @__PURE__ */ new Set();
- reserve(paths, fn2) {
- paths = isWindows2 ? ["win32 parallelization disabled"] : paths.map((p) => {
- return stripTrailingSlashes((0, import_node_path6.join)(normalizeUnicode(p)));
- });
- const dirs = new Set(paths.map((path16) => getDirs(path16)).reduce((a, b) => a.concat(b)));
- this.#reservations.set(fn2, { dirs, paths });
- for (const p of paths) {
- const q = this.#queues.get(p);
- if (!q) {
- this.#queues.set(p, [fn2]);
- } else {
- q.push(fn2);
- }
- }
- for (const dir of dirs) {
- const q = this.#queues.get(dir);
- if (!q) {
- this.#queues.set(dir, [/* @__PURE__ */ new Set([fn2])]);
- } else {
- const l = q.at(-1);
- if (l instanceof Set) {
- l.add(fn2);
- } else {
- q.push(/* @__PURE__ */ new Set([fn2]));
- }
- }
- }
- return this.#run(fn2);
- }
- // return the queues for each path the function cares about
- // fn => {paths, dirs}
- #getQueues(fn2) {
- const res = this.#reservations.get(fn2);
- if (!res) {
- throw new Error("function does not have any path reservations");
- }
- return {
- paths: res.paths.map((path16) => this.#queues.get(path16)),
- dirs: [...res.dirs].map((path16) => this.#queues.get(path16))
+ 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(fs9) {
+ if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
+ patchLchmod(fs9);
+ }
+ if (!fs9.lutimes) {
+ patchLutimes(fs9);
+ }
+ fs9.chown = chownFix(fs9.chown);
+ fs9.fchown = chownFix(fs9.fchown);
+ fs9.lchown = chownFix(fs9.lchown);
+ fs9.chmod = chmodFix(fs9.chmod);
+ fs9.fchmod = chmodFix(fs9.fchmod);
+ fs9.lchmod = chmodFix(fs9.lchmod);
+ fs9.chownSync = chownFixSync(fs9.chownSync);
+ fs9.fchownSync = chownFixSync(fs9.fchownSync);
+ fs9.lchownSync = chownFixSync(fs9.lchownSync);
+ fs9.chmodSync = chmodFixSync(fs9.chmodSync);
+ fs9.fchmodSync = chmodFixSync(fs9.fchmodSync);
+ fs9.lchmodSync = chmodFixSync(fs9.lchmodSync);
+ fs9.stat = statFix(fs9.stat);
+ fs9.fstat = statFix(fs9.fstat);
+ fs9.lstat = statFix(fs9.lstat);
+ fs9.statSync = statFixSync(fs9.statSync);
+ fs9.fstatSync = statFixSync(fs9.fstatSync);
+ fs9.lstatSync = statFixSync(fs9.lstatSync);
+ if (fs9.chmod && !fs9.lchmod) {
+ fs9.lchmod = function(path10, mode, cb) {
+ if (cb) process.nextTick(cb);
+ };
+ fs9.lchmodSync = function() {
};
}
- // check if fn is first in line for all its paths, and is
- // included in the first set for all its dir queues
- check(fn2) {
- const { paths, dirs } = this.#getQueues(fn2);
- return paths.every((q) => q && q[0] === fn2) && dirs.every((q) => q && q[0] instanceof Set && q[0].has(fn2));
- }
- // run the function if it's first in line and not already running
- #run(fn2) {
- if (this.#running.has(fn2) || !this.check(fn2)) {
- return false;
- }
- this.#running.add(fn2);
- fn2(() => this.#clear(fn2));
- return true;
+ if (fs9.chown && !fs9.lchown) {
+ fs9.lchown = function(path10, uid, gid, cb) {
+ if (cb) process.nextTick(cb);
+ };
+ fs9.lchownSync = function() {
+ };
}
- #clear(fn2) {
- if (!this.#running.has(fn2)) {
- return false;
- }
- const res = this.#reservations.get(fn2);
- if (!res) {
- throw new Error("invalid reservation");
- }
- const { paths, dirs } = res;
- const next = /* @__PURE__ */ new Set();
- for (const path16 of paths) {
- const q = this.#queues.get(path16);
- if (!q || q?.[0] !== fn2) {
- continue;
- }
- const q0 = q[1];
- if (!q0) {
- this.#queues.delete(path16);
- continue;
- }
- q.shift();
- if (typeof q0 === "function") {
- next.add(q0);
- } else {
- for (const f of q0) {
- next.add(f);
- }
+ if (platform === "win32") {
+ fs9.rename = typeof fs9.rename !== "function" ? fs9.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() {
+ fs9.stat(to, function(stater, st2) {
+ if (stater && stater.code === "ENOENT")
+ fs$rename(from, to, CB);
+ else
+ cb(er);
+ });
+ }, backoff);
+ if (backoff < 100)
+ backoff += 10;
+ return;
+ }
+ if (cb) cb(er);
+ });
}
- }
- for (const dir of dirs) {
- const q = this.#queues.get(dir);
- const q0 = q?.[0];
- if (!q || !(q0 instanceof Set))
- continue;
- if (q0.size === 1 && q.length === 1) {
- this.#queues.delete(dir);
- continue;
- } else if (q0.size === 1) {
- q.shift();
- const n = q[0];
- if (typeof n === "function") {
- next.add(n);
- }
- } else {
- q0.delete(fn2);
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
+ return rename;
+ })(fs9.rename);
+ }
+ fs9.read = typeof fs9.read !== "function" ? fs9.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, _2, __) {
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
+ eagCounter++;
+ return fs$read.call(fs9, fd, buffer, offset, length, position, callback);
+ }
+ callback_.apply(this, arguments);
+ };
}
+ return fs$read.call(fs9, fd, buffer, offset, length, position, callback);
}
- this.#running.delete(fn2);
- next.forEach((fn3) => this.#run(fn3));
- return true;
- }
- };
- }
-});
-
-// node_modules/tar/dist/esm/process-umask.js
-var umask;
-var init_process_umask = __esm({
- "node_modules/tar/dist/esm/process-umask.js"() {
- umask = () => process.umask();
- }
-});
-
-// node_modules/tar/dist/esm/unpack.js
-var import_node_assert, import_node_crypto, import_node_fs4, import_node_path7, ONENTRY, CHECKFS, CHECKFS2, ISREUSABLE, MAKEFS, FILE, DIRECTORY, LINK, SYMLINK, HARDLINK, ENSURE_NO_SYMLINK, UNSUPPORTED, CHECKPATH, STRIPABSOLUTEPATH, MKDIR, ONERROR, PENDING, PEND, UNPEND, ENDED2, MAYBECLOSE, SKIP, DOCHOWN, UID, GID, CHECKED_CWD, platform4, isWindows3, DEFAULT_MAX_DEPTH, unlinkFile, unlinkFileSync, uint32, Unpack, callSync, UnpackSync;
-var init_unpack = __esm({
- "node_modules/tar/dist/esm/unpack.js"() {
- init_esm2();
- import_node_assert = __toESM(require("node:assert"), 1);
- import_node_crypto = require("node:crypto");
- import_node_fs4 = __toESM(require("node:fs"), 1);
- import_node_path7 = __toESM(require("node:path"), 1);
- init_get_write_flag();
- init_mkdir();
- init_normalize_windows_path();
- init_parse();
- init_strip_absolute_path();
- init_winchars();
- init_path_reservations();
- init_symlink_error();
- init_process_umask();
- ONENTRY = /* @__PURE__ */ Symbol("onEntry");
- CHECKFS = /* @__PURE__ */ Symbol("checkFs");
- CHECKFS2 = /* @__PURE__ */ Symbol("checkFs2");
- ISREUSABLE = /* @__PURE__ */ Symbol("isReusable");
- MAKEFS = /* @__PURE__ */ Symbol("makeFs");
- FILE = /* @__PURE__ */ Symbol("file");
- DIRECTORY = /* @__PURE__ */ Symbol("directory");
- LINK = /* @__PURE__ */ Symbol("link");
- SYMLINK = /* @__PURE__ */ Symbol("symlink");
- HARDLINK = /* @__PURE__ */ Symbol("hardlink");
- ENSURE_NO_SYMLINK = /* @__PURE__ */ Symbol("ensureNoSymlink");
- UNSUPPORTED = /* @__PURE__ */ Symbol("unsupported");
- CHECKPATH = /* @__PURE__ */ Symbol("checkPath");
- STRIPABSOLUTEPATH = /* @__PURE__ */ Symbol("stripAbsolutePath");
- MKDIR = /* @__PURE__ */ Symbol("mkdir");
- ONERROR = /* @__PURE__ */ Symbol("onError");
- PENDING = /* @__PURE__ */ Symbol("pending");
- PEND = /* @__PURE__ */ Symbol("pend");
- UNPEND = /* @__PURE__ */ Symbol("unpend");
- ENDED2 = /* @__PURE__ */ Symbol("ended");
- MAYBECLOSE = /* @__PURE__ */ Symbol("maybeClose");
- SKIP = /* @__PURE__ */ Symbol("skip");
- DOCHOWN = /* @__PURE__ */ Symbol("doChown");
- UID = /* @__PURE__ */ Symbol("uid");
- GID = /* @__PURE__ */ Symbol("gid");
- CHECKED_CWD = /* @__PURE__ */ Symbol("checkedCwd");
- platform4 = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
- isWindows3 = platform4 === "win32";
- DEFAULT_MAX_DEPTH = 1024;
- unlinkFile = (path16, cb) => {
- if (!isWindows3) {
- return import_node_fs4.default.unlink(path16, cb);
- }
- const name2 = path16 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex");
- import_node_fs4.default.rename(path16, name2, (er) => {
- if (er) {
- return cb(er);
- }
- import_node_fs4.default.unlink(name2, cb);
- });
- };
- unlinkFileSync = (path16) => {
- if (!isWindows3) {
- return import_node_fs4.default.unlinkSync(path16);
- }
- const name2 = path16 + ".DELETE." + (0, import_node_crypto.randomBytes)(16).toString("hex");
- import_node_fs4.default.renameSync(path16, name2);
- import_node_fs4.default.unlinkSync(name2);
- };
- uint32 = (a, b, c) => a !== void 0 && a === a >>> 0 ? a : b !== void 0 && b === b >>> 0 ? b : c;
- Unpack = class extends Parser {
- [ENDED2] = false;
- [CHECKED_CWD] = false;
- [PENDING] = 0;
- reservations = new PathReservations();
- transform;
- writable = true;
- readable = false;
- uid;
- gid;
- setOwner;
- preserveOwner;
- processGid;
- processUid;
- maxDepth;
- forceChown;
- win32;
- newer;
- keep;
- noMtime;
- preservePaths;
- unlink;
- cwd;
- strip;
- processUmask;
- umask;
- dmode;
- fmode;
- chmod;
- constructor(opt = {}) {
- opt.ondone = () => {
- this[ENDED2] = true;
- this[MAYBECLOSE]();
- };
- super(opt);
- this.transform = opt.transform;
- this.chmod = !!opt.chmod;
- if (typeof opt.uid === "number" || typeof opt.gid === "number") {
- if (typeof opt.uid !== "number" || typeof opt.gid !== "number") {
- throw new TypeError("cannot set owner without number uid and gid");
- }
- if (opt.preserveOwner) {
- throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
- }
- this.uid = opt.uid;
- this.gid = opt.gid;
- this.setOwner = true;
- } else {
- this.uid = void 0;
- this.gid = void 0;
- this.setOwner = false;
- }
- this.preserveOwner = opt.preserveOwner === void 0 && typeof opt.uid !== "number" ? !!(process.getuid?.() === 0) : !!opt.preserveOwner;
- this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0;
- this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0;
- this.maxDepth = typeof opt.maxDepth === "number" ? opt.maxDepth : DEFAULT_MAX_DEPTH;
- this.forceChown = opt.forceChown === true;
- this.win32 = !!opt.win32 || isWindows3;
- this.newer = !!opt.newer;
- this.keep = !!opt.keep;
- this.noMtime = !!opt.noMtime;
- this.preservePaths = !!opt.preservePaths;
- this.unlink = !!opt.unlink;
- this.cwd = normalizeWindowsPath(import_node_path7.default.resolve(opt.cwd || process.cwd()));
- this.strip = Number(opt.strip) || 0;
- this.processUmask = !this.chmod ? 0 : typeof opt.processUmask === "number" ? opt.processUmask : umask();
- this.umask = typeof opt.umask === "number" ? opt.umask : this.processUmask;
- this.dmode = opt.dmode || 511 & ~this.umask;
- this.fmode = opt.fmode || 438 & ~this.umask;
- this.on("entry", (entry) => this[ONENTRY](entry));
- }
- // a bad or damaged archive is a warning for Parser, but an error
- // when extracting. Mark those errors as unrecoverable, because
- // the Unpack contract cannot be met.
- warn(code2, msg, data = {}) {
- if (code2 === "TAR_BAD_ARCHIVE" || code2 === "TAR_ABORT") {
- data.recoverable = false;
- }
- return super.warn(code2, msg, data);
- }
- [MAYBECLOSE]() {
- if (this[ENDED2] && this[PENDING] === 0) {
- this.emit("prefinish");
- this.emit("finish");
- this.emit("end");
- }
- }
- // return false if we need to skip this file
- // return true if the field was successfully sanitized
- [STRIPABSOLUTEPATH](entry, field) {
- const p = entry[field];
- const { type } = entry;
- if (!p || this.preservePaths)
- return true;
- const [root, stripped] = stripAbsolutePath(p);
- const parts = stripped.replaceAll(/\\/g, "/").split("/");
- if (parts.includes("..") || /* c8 ignore next */
- isWindows3 && /^[a-z]:\.\.$/i.test(parts[0] ?? "")) {
- if (field === "path" || type === "Link") {
- this.warn("TAR_ENTRY_ERROR", `${field} contains '..'`, {
- entry,
- [field]: p
- });
- return false;
- }
- const entryDir = import_node_path7.default.posix.dirname(entry.path);
- const resolved = import_node_path7.default.posix.normalize(import_node_path7.default.posix.join(entryDir, parts.join("/")));
- if (resolved.startsWith("../") || resolved === "..") {
- this.warn("TAR_ENTRY_ERROR", `${field} escapes extraction directory`, {
- entry,
- [field]: p
- });
- return false;
- }
- }
- if (root) {
- entry[field] = String(stripped);
- this.warn("TAR_ENTRY_INFO", `stripping ${root} from absolute ${field}`, {
- entry,
- [field]: p
- });
- }
- return true;
- }
- // no IO, just string checking for absolute indicators
- [CHECKPATH](entry) {
- const p = normalizeWindowsPath(entry.path);
- const parts = p.split("/");
- if (this.strip) {
- if (parts.length < this.strip) {
- return false;
- }
- if (entry.type === "Link") {
- const linkparts = normalizeWindowsPath(String(entry.linkpath)).split("/");
- if (linkparts.length >= this.strip) {
- entry.linkpath = linkparts.slice(this.strip).join("/");
- } else {
- return false;
- }
- }
- parts.splice(0, this.strip);
- entry.path = parts.join("/");
- }
- if (isFinite(this.maxDepth) && parts.length > this.maxDepth) {
- this.warn("TAR_ENTRY_ERROR", "path excessively deep", {
- entry,
- path: p,
- depth: parts.length,
- maxDepth: this.maxDepth
- });
- return false;
- }
- if (!this[STRIPABSOLUTEPATH](entry, "path") || !this[STRIPABSOLUTEPATH](entry, "linkpath")) {
- return false;
- }
- entry.absolute = import_node_path7.default.isAbsolute(entry.path) ? normalizeWindowsPath(import_node_path7.default.resolve(entry.path)) : normalizeWindowsPath(import_node_path7.default.resolve(this.cwd, entry.path));
- if (!this.preservePaths && typeof entry.absolute === "string" && entry.absolute.indexOf(this.cwd + "/") !== 0 && entry.absolute !== this.cwd) {
- this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", {
- entry,
- path: normalizeWindowsPath(entry.path),
- resolvedPath: entry.absolute,
- cwd: this.cwd
- });
- return false;
- }
- if (entry.absolute === this.cwd && entry.type !== "Directory" && entry.type !== "GNUDumpDir") {
- return false;
- }
- if (this.win32) {
- const { root: aRoot } = import_node_path7.default.win32.parse(String(entry.absolute));
- entry.absolute = aRoot + encode2(String(entry.absolute).slice(aRoot.length));
- const { root: pRoot } = import_node_path7.default.win32.parse(entry.path);
- entry.path = pRoot + encode2(entry.path.slice(pRoot.length));
- }
- return true;
- }
- [ONENTRY](entry) {
- if (!this[CHECKPATH](entry)) {
- return entry.resume();
- }
- import_node_assert.default.equal(typeof entry.absolute, "string");
- switch (entry.type) {
- case "Directory":
- case "GNUDumpDir":
- if (entry.mode) {
- entry.mode = entry.mode | 448;
- }
- // eslint-disable-next-line no-fallthrough
- case "File":
- case "OldFile":
- case "ContiguousFile":
- case "Link":
- case "SymbolicLink":
- return this[CHECKFS](entry);
- case "CharacterDevice":
- case "BlockDevice":
- case "FIFO":
- default:
- return this[UNSUPPORTED](entry);
- }
- }
- [ONERROR](er, entry) {
- if (er.name === "CwdError") {
- this.emit("error", er);
- } else {
- this.warn("TAR_ENTRY_ERROR", er, { entry });
- this[UNPEND]();
- entry.resume();
- }
- }
- [MKDIR](dir, mode, cb) {
- void mkdir(normalizeWindowsPath(dir), {
- uid: this.uid,
- gid: this.gid,
- processUid: this.processUid,
- processGid: this.processGid,
- umask: this.processUmask,
- preserve: this.preservePaths,
- unlink: this.unlink,
- cwd: this.cwd,
- mode
- }, cb);
- }
- [DOCHOWN](entry) {
- return this.forceChown || this.preserveOwner && (typeof entry.uid === "number" && entry.uid !== this.processUid || typeof entry.gid === "number" && entry.gid !== this.processGid) || typeof this.uid === "number" && this.uid !== this.processUid || typeof this.gid === "number" && this.gid !== this.processGid;
- }
- [UID](entry) {
- return uint32(this.uid, entry.uid, this.processUid);
- }
- [GID](entry) {
- return uint32(this.gid, entry.gid, this.processGid);
- }
- [FILE](entry, fullyDone) {
- const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.fmode;
- const stream = new WriteStream(String(entry.absolute), {
- // slight lie, but it can be numeric flags
- flags: getWriteFlag(entry.size),
- mode,
- autoClose: false
- });
- stream.on("error", (er) => {
- if (stream.fd) {
- import_node_fs4.default.close(stream.fd, () => {
- });
- }
- stream.write = () => true;
- this[ONERROR](er, entry);
- fullyDone();
- });
- let actions = 1;
- const done = (er) => {
- if (er) {
- if (stream.fd) {
- import_node_fs4.default.close(stream.fd, () => {
- });
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
+ return read;
+ })(fs9.read);
+ fs9.readSync = typeof fs9.readSync !== "function" ? fs9.readSync : /* @__PURE__ */ (function(fs$readSync) {
+ return function(fd, buffer, offset, length, position) {
+ var eagCounter = 0;
+ while (true) {
+ try {
+ return fs$readSync.call(fs9, fd, buffer, offset, length, position);
+ } catch (er) {
+ if (er.code === "EAGAIN" && eagCounter < 10) {
+ eagCounter++;
+ continue;
+ }
+ throw er;
}
- this[ONERROR](er, entry);
- fullyDone();
- return;
}
- if (--actions === 0) {
- if (stream.fd !== void 0) {
- import_node_fs4.default.close(stream.fd, (er2) => {
- if (er2) {
- this[ONERROR](er2, entry);
- } else {
- this[UNPEND]();
- }
- fullyDone();
+ };
+ })(fs9.readSync);
+ function patchLchmod(fs10) {
+ fs10.lchmod = function(path10, mode, callback) {
+ fs10.open(
+ path10,
+ constants.O_WRONLY | constants.O_SYMLINK,
+ mode,
+ function(err, fd) {
+ if (err) {
+ if (callback) callback(err);
+ return;
+ }
+ fs10.fchmod(fd, mode, function(err2) {
+ fs10.close(fd, function(err22) {
+ if (callback) callback(err2 || err22);
+ });
});
}
- }
+ );
};
- stream.on("finish", () => {
- const abs = String(entry.absolute);
- const fd = stream.fd;
- if (typeof fd === "number" && entry.mtime && !this.noMtime) {
- actions++;
- const atime = entry.atime || /* @__PURE__ */ new Date();
- const mtime = entry.mtime;
- import_node_fs4.default.futimes(fd, atime, mtime, (er) => er ? import_node_fs4.default.utimes(abs, atime, mtime, (er2) => done(er2 && er)) : done());
- }
- if (typeof fd === "number" && this[DOCHOWN](entry)) {
- actions++;
- const uid = this[UID](entry);
- const gid = this[GID](entry);
- if (typeof uid === "number" && typeof gid === "number") {
- import_node_fs4.default.fchown(fd, uid, gid, (er) => er ? import_node_fs4.default.chown(abs, uid, gid, (er2) => done(er2 && er)) : done());
+ fs10.lchmodSync = function(path10, mode) {
+ var fd = fs10.openSync(path10, constants.O_WRONLY | constants.O_SYMLINK, mode);
+ var threw = true;
+ var ret;
+ try {
+ ret = fs10.fchmodSync(fd, mode);
+ threw = false;
+ } finally {
+ if (threw) {
+ try {
+ fs10.closeSync(fd);
+ } catch (er) {
+ }
+ } else {
+ fs10.closeSync(fd);
}
}
- done();
- });
- const tx = this.transform ? this.transform(entry) || entry : entry;
- if (tx !== entry) {
- tx.on("error", (er) => {
- this[ONERROR](er, entry);
- fullyDone();
- });
- entry.pipe(tx);
- }
- tx.pipe(stream);
+ return ret;
+ };
}
- [DIRECTORY](entry, fullyDone) {
- const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.dmode;
- this[MKDIR](String(entry.absolute), mode, (er) => {
- if (er) {
- this[ONERROR](er, entry);
- fullyDone();
- return;
- }
- let actions = 1;
- const done = () => {
- if (--actions === 0) {
- fullyDone();
- this[UNPEND]();
- entry.resume();
+ function patchLutimes(fs10) {
+ if (constants.hasOwnProperty("O_SYMLINK") && fs10.futimes) {
+ fs10.lutimes = function(path10, at2, mt2, cb) {
+ fs10.open(path10, constants.O_SYMLINK, function(er, fd) {
+ if (er) {
+ if (cb) cb(er);
+ return;
+ }
+ fs10.futimes(fd, at2, mt2, function(er2) {
+ fs10.close(fd, function(er22) {
+ if (cb) cb(er2 || er22);
+ });
+ });
+ });
+ };
+ fs10.lutimesSync = function(path10, at2, mt2) {
+ var fd = fs10.openSync(path10, constants.O_SYMLINK);
+ var ret;
+ var threw = true;
+ try {
+ ret = fs10.futimesSync(fd, at2, mt2);
+ threw = false;
+ } finally {
+ if (threw) {
+ try {
+ fs10.closeSync(fd);
+ } catch (er) {
+ }
+ } else {
+ fs10.closeSync(fd);
+ }
}
+ return ret;
+ };
+ } else if (fs10.futimes) {
+ fs10.lutimes = function(_a, _b, _c, cb) {
+ if (cb) process.nextTick(cb);
+ };
+ fs10.lutimesSync = function() {
};
- if (entry.mtime && !this.noMtime) {
- actions++;
- import_node_fs4.default.utimes(String(entry.absolute), entry.atime || /* @__PURE__ */ new Date(), entry.mtime, done);
- }
- if (this[DOCHOWN](entry)) {
- actions++;
- import_node_fs4.default.chown(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)), done);
- }
- done();
- });
- }
- [UNSUPPORTED](entry) {
- entry.unsupported = true;
- this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${entry.type}`, { entry });
- entry.resume();
- }
- [SYMLINK](entry, done) {
- const parts = normalizeWindowsPath(import_node_path7.default.relative(this.cwd, import_node_path7.default.resolve(import_node_path7.default.dirname(String(entry.absolute)), String(entry.linkpath)))).split("/");
- this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, String(entry.linkpath), "symlink", done), (er) => {
- this[ONERROR](er, entry);
- done();
- });
- }
- [HARDLINK](entry, done) {
- const linkpath = normalizeWindowsPath(import_node_path7.default.resolve(this.cwd, String(entry.linkpath)));
- const parts = normalizeWindowsPath(String(entry.linkpath)).split("/");
- this[ENSURE_NO_SYMLINK](entry, this.cwd, parts, () => this[LINK](entry, linkpath, "link", done), (er) => {
- this[ONERROR](er, entry);
- done();
- });
- }
- [ENSURE_NO_SYMLINK](entry, cwd, parts, done, onError) {
- const p = parts.shift();
- if (this.preservePaths || p === void 0)
- return done();
- const t = import_node_path7.default.resolve(cwd, p);
- import_node_fs4.default.lstat(t, (er, st) => {
- if (er)
- return done();
- if (st?.isSymbolicLink()) {
- return onError(new SymlinkError(t, import_node_path7.default.resolve(t, parts.join("/"))));
- }
- this[ENSURE_NO_SYMLINK](entry, t, parts, done, onError);
- });
- }
- [PEND]() {
- this[PENDING]++;
- }
- [UNPEND]() {
- this[PENDING]--;
- this[MAYBECLOSE]();
- }
- [SKIP](entry) {
- this[UNPEND]();
- entry.resume();
- }
- // Check if we can reuse an existing filesystem entry safely and
- // overwrite it, rather than unlinking and recreating
- // Windows doesn't report a useful nlink, so we just never reuse entries
- [ISREUSABLE](entry, st) {
- return entry.type === "File" && !this.unlink && st.isFile() && st.nlink <= 1 && !isWindows3;
- }
- // check if a thing is there, and if so, try to clobber it
- [CHECKFS](entry) {
- this[PEND]();
- const paths = [entry.path];
- if (entry.linkpath) {
- paths.push(entry.linkpath);
}
- this.reservations.reserve(paths, (done) => this[CHECKFS2](entry, done));
}
- [CHECKFS2](entry, fullyDone) {
- const done = (er) => {
- fullyDone(er);
- };
- const checkCwd2 = () => {
- this[MKDIR](this.cwd, this.dmode, (er) => {
- if (er) {
- this[ONERROR](er, entry);
- done();
- return;
- }
- this[CHECKED_CWD] = true;
- start();
+ function chmodFix(orig) {
+ if (!orig) return orig;
+ return function(target, mode, cb) {
+ return orig.call(fs9, target, mode, function(er) {
+ if (chownErOk(er)) er = null;
+ if (cb) cb.apply(this, arguments);
});
};
- const start = () => {
- if (entry.absolute !== this.cwd) {
- const parent = normalizeWindowsPath(import_node_path7.default.dirname(String(entry.absolute)));
- if (parent !== this.cwd) {
- return this[MKDIR](parent, this.dmode, (er) => {
- if (er) {
- this[ONERROR](er, entry);
- done();
- return;
- }
- afterMakeParent();
- });
- }
+ }
+ function chmodFixSync(orig) {
+ if (!orig) return orig;
+ return function(target, mode) {
+ try {
+ return orig.call(fs9, target, mode);
+ } catch (er) {
+ if (!chownErOk(er)) throw er;
}
- afterMakeParent();
};
- const afterMakeParent = () => {
- import_node_fs4.default.lstat(String(entry.absolute), (lstatEr, st) => {
- if (st && (this.keep || /* c8 ignore next */
- this.newer && st.mtime > (entry.mtime ?? st.mtime))) {
- this[SKIP](entry);
- done();
- return;
- }
- if (lstatEr || this[ISREUSABLE](entry, st)) {
- return this[MAKEFS](null, entry, done);
- }
- if (st.isDirectory()) {
- if (entry.type === "Directory") {
- const needChmod = this.chmod && entry.mode && (st.mode & 4095) !== entry.mode;
- const afterChmod = (er) => this[MAKEFS](er ?? null, entry, done);
- if (!needChmod) {
- return afterChmod();
- }
- return import_node_fs4.default.chmod(String(entry.absolute), Number(entry.mode), afterChmod);
- }
- if (entry.absolute !== this.cwd) {
- return import_node_fs4.default.rmdir(String(entry.absolute), (er) => this[MAKEFS](er ?? null, entry, done));
- }
- }
- if (entry.absolute === this.cwd) {
- return this[MAKEFS](null, entry, done);
- }
- unlinkFile(String(entry.absolute), (er) => this[MAKEFS](er ?? null, entry, done));
+ }
+ function chownFix(orig) {
+ if (!orig) return orig;
+ return function(target, uid, gid, cb) {
+ return orig.call(fs9, target, uid, gid, function(er) {
+ if (chownErOk(er)) er = null;
+ if (cb) cb.apply(this, arguments);
});
};
- if (this[CHECKED_CWD]) {
- start();
- } else {
- checkCwd2();
- }
}
- [MAKEFS](er, entry, done) {
- if (er) {
- this[ONERROR](er, entry);
- done();
- return;
- }
- switch (entry.type) {
- case "File":
- case "OldFile":
- case "ContiguousFile":
- return this[FILE](entry, done);
- case "Link":
- return this[HARDLINK](entry, done);
- case "SymbolicLink":
- return this[SYMLINK](entry, done);
- case "Directory":
- case "GNUDumpDir":
- return this[DIRECTORY](entry, done);
- }
- }
- [LINK](entry, linkpath, link, done) {
- import_node_fs4.default[link](linkpath, String(entry.absolute), (er) => {
- if (er) {
- this[ONERROR](er, entry);
- } else {
- this[UNPEND]();
- entry.resume();
+ function chownFixSync(orig) {
+ if (!orig) return orig;
+ return function(target, uid, gid) {
+ try {
+ return orig.call(fs9, target, uid, gid);
+ } catch (er) {
+ if (!chownErOk(er)) throw er;
}
- done();
- });
- }
- };
- callSync = (fn2) => {
- try {
- return [null, fn2()];
- } catch (er) {
- return [er, null];
- }
- };
- UnpackSync = class extends Unpack {
- sync = true;
- [MAKEFS](er, entry) {
- return super[MAKEFS](er, entry, () => {
- });
+ };
}
- [CHECKFS](entry) {
- if (!this[CHECKED_CWD]) {
- const er2 = this[MKDIR](this.cwd, this.dmode);
- if (er2) {
- return this[ONERROR](er2, entry);
+ function statFix(orig) {
+ if (!orig) return orig;
+ return function(target, options, cb) {
+ if (typeof options === "function") {
+ cb = options;
+ options = null;
}
- this[CHECKED_CWD] = true;
- }
- if (entry.absolute !== this.cwd) {
- const parent = normalizeWindowsPath(import_node_path7.default.dirname(String(entry.absolute)));
- if (parent !== this.cwd) {
- const mkParent = this[MKDIR](parent, this.dmode);
- if (mkParent) {
- return this[ONERROR](mkParent, entry);
+ 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);
}
- }
- const [lstatEr, st] = callSync(() => import_node_fs4.default.lstatSync(String(entry.absolute)));
- if (st && (this.keep || /* c8 ignore next */
- this.newer && st.mtime > (entry.mtime ?? st.mtime))) {
- return this[SKIP](entry);
- }
- if (lstatEr || this[ISREUSABLE](entry, st)) {
- return this[MAKEFS](null, entry);
- }
- if (st.isDirectory()) {
- if (entry.type === "Directory") {
- const needChmod = this.chmod && entry.mode && (st.mode & 4095) !== entry.mode;
- const [er3] = needChmod ? callSync(() => {
- import_node_fs4.default.chmodSync(String(entry.absolute), Number(entry.mode));
- }) : [];
- return this[MAKEFS](er3, entry);
- }
- const [er2] = callSync(() => import_node_fs4.default.rmdirSync(String(entry.absolute)));
- this[MAKEFS](er2, entry);
- }
- const [er] = entry.absolute === this.cwd ? [] : callSync(() => unlinkFileSync(String(entry.absolute)));
- this[MAKEFS](er, entry);
+ return options ? orig.call(fs9, target, options, callback) : orig.call(fs9, target, callback);
+ };
}
- [FILE](entry, done) {
- const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.fmode;
- const oner = (er) => {
- let closeError;
- try {
- import_node_fs4.default.closeSync(fd);
- } catch (e) {
- closeError = e;
- }
- if (er || closeError) {
- this[ONERROR](er || closeError, entry);
+ function statFixSync(orig) {
+ if (!orig) return orig;
+ return function(target, options) {
+ var stats = options ? orig.call(fs9, target, options) : orig.call(fs9, target);
+ if (stats) {
+ if (stats.uid < 0) stats.uid += 4294967296;
+ if (stats.gid < 0) stats.gid += 4294967296;
}
- done();
+ return stats;
};
- let fd;
- try {
- fd = import_node_fs4.default.openSync(String(entry.absolute), getWriteFlag(entry.size), mode);
- } catch (er) {
- return oner(er);
- }
- const tx = this.transform ? this.transform(entry) || entry : entry;
- if (tx !== entry) {
- tx.on("error", (er) => this[ONERROR](er, entry));
- entry.pipe(tx);
- }
- tx.on("data", (chunk) => {
- try {
- import_node_fs4.default.writeSync(fd, chunk, 0, chunk.length);
- } catch (er) {
- oner(er);
- }
- });
- tx.on("end", () => {
- let er = null;
- if (entry.mtime && !this.noMtime) {
- const atime = entry.atime || /* @__PURE__ */ new Date();
- const mtime = entry.mtime;
- try {
- import_node_fs4.default.futimesSync(fd, atime, mtime);
- } catch (futimeser) {
- try {
- import_node_fs4.default.utimesSync(String(entry.absolute), atime, mtime);
- } catch {
- er = futimeser;
- }
- }
- }
- if (this[DOCHOWN](entry)) {
- const uid = this[UID](entry);
- const gid = this[GID](entry);
- try {
- import_node_fs4.default.fchownSync(fd, Number(uid), Number(gid));
- } catch (fchowner) {
- try {
- import_node_fs4.default.chownSync(String(entry.absolute), Number(uid), Number(gid));
- } catch {
- er = er || fchowner;
- }
- }
- }
- oner(er);
- });
}
- [DIRECTORY](entry, done) {
- const mode = typeof entry.mode === "number" ? entry.mode & 4095 : this.dmode;
- const er = this[MKDIR](String(entry.absolute), mode);
- if (er) {
- this[ONERROR](er, entry);
- done();
- return;
- }
- if (entry.mtime && !this.noMtime) {
- try {
- import_node_fs4.default.utimesSync(String(entry.absolute), entry.atime || /* @__PURE__ */ new Date(), entry.mtime);
- } catch {
- }
+ 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;
}
- if (this[DOCHOWN](entry)) {
- try {
- import_node_fs4.default.chownSync(String(entry.absolute), Number(this[UID](entry)), Number(this[GID](entry)));
- } catch {
+ return false;
+ }
+ }
+ }
+});
+
+// node_modules/graceful-fs/legacy-streams.js
+var require_legacy_streams = __commonJS({
+ "node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
+ var Stream = require("stream").Stream;
+ module2.exports = legacy;
+ function legacy(fs9) {
+ return {
+ ReadStream,
+ WriteStream
+ };
+ function ReadStream(path10, options) {
+ if (!(this instanceof ReadStream)) return new ReadStream(path10, options);
+ Stream.call(this);
+ var self2 = this;
+ this.path = path10;
+ 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;
}
- done();
- entry.resume();
- }
- [MKDIR](dir, mode) {
- try {
- return mkdirSync2(normalizeWindowsPath(dir), {
- uid: this.uid,
- gid: this.gid,
- processUid: this.processUid,
- processGid: this.processGid,
- umask: this.processUmask,
- preserve: this.preservePaths,
- unlink: this.unlink,
- cwd: this.cwd,
- mode
+ if (this.fd !== null) {
+ process.nextTick(function() {
+ self2._read();
});
- } catch (er) {
- return er;
+ return;
}
+ fs9.open(this.path, this.flags, this.mode, function(err, fd) {
+ if (err) {
+ self2.emit("error", err);
+ self2.readable = false;
+ return;
+ }
+ self2.fd = fd;
+ self2.emit("open", fd);
+ self2._read();
+ });
}
- [ENSURE_NO_SYMLINK](_entry, cwd, parts, done, onError) {
- if (this.preservePaths || parts.length === 0)
- return done();
- let t = cwd;
- for (const p of parts) {
- t = import_node_path7.default.resolve(t, p);
- const [er, st] = callSync(() => import_node_fs4.default.lstatSync(t));
- if (er)
- return done();
- if (st.isSymbolicLink()) {
- return onError(new SymlinkError(t, import_node_path7.default.resolve(cwd, parts.join("/"))));
+ function WriteStream(path10, options) {
+ if (!(this instanceof WriteStream)) return new WriteStream(path10, options);
+ Stream.call(this);
+ this.path = path10;
+ 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;
}
- done();
- }
- [LINK](entry, linkpath, link, done) {
- const linkSync = `${link}Sync`;
- try {
- import_node_fs4.default[linkSync](linkpath, String(entry.absolute));
- done();
- entry.resume();
- } catch (er) {
- return this[ONERROR](er, entry);
+ this.busy = false;
+ this._queue = [];
+ if (this.fd === null) {
+ this._open = fs9.open;
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
+ this.flush();
}
}
- };
+ }
}
});
-// node_modules/tar/dist/esm/extract.js
-var extract_exports = {};
-__export(extract_exports, {
- extract: () => extract
-});
-var import_node_fs5, extractFileSync, extractFile, extract;
-var init_extract = __esm({
- "node_modules/tar/dist/esm/extract.js"() {
- init_esm2();
- import_node_fs5 = __toESM(require("node:fs"), 1);
- init_list();
- init_make_command();
- init_unpack();
- extractFileSync = (opt) => {
- const u = new UnpackSync(opt);
- const file = opt.file;
- const stat = import_node_fs5.default.statSync(file);
- const readSize = opt.maxReadSize || 16 * 1024 * 1024;
- const stream = new ReadStreamSync(file, {
- readSize,
- size: stat.size
- });
- stream.pipe(u);
- };
- extractFile = (opt, _) => {
- const u = new Unpack(opt);
- const readSize = opt.maxReadSize || 16 * 1024 * 1024;
- const file = opt.file;
- const p = new Promise((resolve, reject) => {
- u.on("error", reject);
- u.on("close", resolve);
- import_node_fs5.default.stat(file, (er, stat) => {
- if (er) {
- reject(er);
- } else {
- const stream = new ReadStream(file, {
- readSize,
- size: stat.size
- });
- stream.on("error", reject);
- stream.pipe(u);
- }
- });
- });
- return p;
+// node_modules/graceful-fs/clone.js
+var require_clone = __commonJS({
+ "node_modules/graceful-fs/clone.js"(exports2, module2) {
+ "use strict";
+ module2.exports = clone;
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
+ return obj.__proto__;
};
- extract = makeCommand(extractFileSync, extractFile, (opt) => new UnpackSync(opt), (opt) => new Unpack(opt), (opt, files) => {
- if (files?.length)
- filesFilter(opt, files);
- });
+ 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/v8-compile-cache/v8-compile-cache.js
-var require_v8_compile_cache = __commonJS({
- "node_modules/v8-compile-cache/v8-compile-cache.js"(exports2, module2) {
- "use strict";
- var Module2 = require("module");
- var crypto = require("crypto");
- var fs17 = require("fs");
- var path16 = require("path");
- var vm = require("vm");
- var os3 = require("os");
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var FileSystemBlobStore = class {
- constructor(directory, prefix) {
- const name2 = prefix ? slashEscape(prefix + ".") : "";
- this._blobFilename = path16.join(directory, name2 + "BLOB");
- this._mapFilename = path16.join(directory, name2 + "MAP");
- this._lockFilename = path16.join(directory, name2 + "LOCK");
- this._directory = directory;
- this._load();
- }
- has(key, invalidationKey) {
- if (hasOwnProperty.call(this._memoryBlobs, key)) {
- return this._invalidationKeys[key] === invalidationKey;
- } else if (hasOwnProperty.call(this._storedMap, key)) {
- return this._storedMap[key][0] === invalidationKey;
- }
- return false;
- }
- get(key, invalidationKey) {
- if (hasOwnProperty.call(this._memoryBlobs, key)) {
- if (this._invalidationKeys[key] === invalidationKey) {
- return this._memoryBlobs[key];
- }
- } else if (hasOwnProperty.call(this._storedMap, key)) {
- const mapping = this._storedMap[key];
- if (mapping[0] === invalidationKey) {
- return this._storedBlob.slice(mapping[1], mapping[2]);
- }
- }
- }
- set(key, invalidationKey, buffer) {
- this._invalidationKeys[key] = invalidationKey;
- this._memoryBlobs[key] = buffer;
- this._dirty = true;
- }
- delete(key) {
- if (hasOwnProperty.call(this._memoryBlobs, key)) {
- this._dirty = true;
- delete this._memoryBlobs[key];
+// node_modules/graceful-fs/graceful-fs.js
+var require_graceful_fs = __commonJS({
+ "node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
+ var fs9 = 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 = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
+ previousSymbol = /* @__PURE__ */ 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;
}
- if (hasOwnProperty.call(this._invalidationKeys, key)) {
- this._dirty = true;
- delete this._invalidationKeys[key];
+ });
+ }
+ var debug = noop;
+ if (util.debuglog)
+ debug = util.debuglog("gfs4");
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
+ debug = function() {
+ var m = util.format.apply(util, arguments);
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
+ console.error(m);
+ };
+ if (!fs9[gracefulQueue]) {
+ queue = global[gracefulQueue] || [];
+ publishQueue(fs9, queue);
+ fs9.close = (function(fs$close) {
+ function close(fd, cb) {
+ return fs$close.call(fs9, fd, function(err) {
+ if (!err) {
+ resetQueue();
+ }
+ if (typeof cb === "function")
+ cb.apply(this, arguments);
+ });
}
- if (hasOwnProperty.call(this._storedMap, key)) {
- this._dirty = true;
- delete this._storedMap[key];
+ Object.defineProperty(close, previousSymbol, {
+ value: fs$close
+ });
+ return close;
+ })(fs9.close);
+ fs9.closeSync = (function(fs$closeSync) {
+ function closeSync(fd) {
+ fs$closeSync.apply(fs9, arguments);
+ resetQueue();
}
+ Object.defineProperty(closeSync, previousSymbol, {
+ value: fs$closeSync
+ });
+ return closeSync;
+ })(fs9.closeSync);
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
+ process.on("exit", function() {
+ debug(fs9[gracefulQueue]);
+ require("assert").equal(fs9[gracefulQueue].length, 0);
+ });
}
- isDirty() {
- return this._dirty;
- }
- save() {
- const dump = this._getDump();
- const blobToStore = Buffer.concat(dump[0]);
- const mapToStore = JSON.stringify(dump[1]);
- try {
- mkdirpSync(this._directory);
- fs17.writeFileSync(this._lockFilename, "LOCK", { flag: "wx" });
- } catch (error) {
- return false;
+ }
+ var queue;
+ if (!global[gracefulQueue]) {
+ publishQueue(global, fs9[gracefulQueue]);
+ }
+ module2.exports = patch(clone(fs9));
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs9.__patched) {
+ module2.exports = patch(fs9);
+ fs9.__patched = true;
+ }
+ function patch(fs10) {
+ polyfills(fs10);
+ fs10.gracefulify = patch;
+ fs10.createReadStream = createReadStream;
+ fs10.createWriteStream = createWriteStream;
+ var fs$readFile = fs10.readFile;
+ fs10.readFile = readFile;
+ function readFile(path10, options, cb) {
+ if (typeof options === "function")
+ cb = options, options = null;
+ return go$readFile(path10, options, cb);
+ function go$readFile(path11, options2, cb2, startTime) {
+ return fs$readFile(path11, options2, function(err) {
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
+ enqueue([go$readFile, [path11, options2, cb2], err, startTime || Date.now(), Date.now()]);
+ else {
+ if (typeof cb2 === "function")
+ cb2.apply(this, arguments);
+ }
+ });
}
- try {
- fs17.writeFileSync(this._blobFilename, blobToStore);
- fs17.writeFileSync(this._mapFilename, mapToStore);
- } finally {
- fs17.unlinkSync(this._lockFilename);
+ }
+ var fs$writeFile = fs10.writeFile;
+ fs10.writeFile = writeFile;
+ function writeFile(path10, data, options, cb) {
+ if (typeof options === "function")
+ cb = options, options = null;
+ return go$writeFile(path10, data, options, cb);
+ function go$writeFile(path11, data2, options2, cb2, startTime) {
+ return fs$writeFile(path11, data2, options2, function(err) {
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
+ enqueue([go$writeFile, [path11, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
+ else {
+ if (typeof cb2 === "function")
+ cb2.apply(this, arguments);
+ }
+ });
}
- return true;
}
- _load() {
- try {
- this._storedBlob = fs17.readFileSync(this._blobFilename);
- this._storedMap = JSON.parse(fs17.readFileSync(this._mapFilename));
- } catch (e) {
- this._storedBlob = Buffer.alloc(0);
- this._storedMap = {};
+ var fs$appendFile = fs10.appendFile;
+ if (fs$appendFile)
+ fs10.appendFile = appendFile;
+ function appendFile(path10, data, options, cb) {
+ if (typeof options === "function")
+ cb = options, options = null;
+ return go$appendFile(path10, data, options, cb);
+ function go$appendFile(path11, data2, options2, cb2, startTime) {
+ return fs$appendFile(path11, data2, options2, function(err) {
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
+ enqueue([go$appendFile, [path11, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
+ else {
+ if (typeof cb2 === "function")
+ cb2.apply(this, arguments);
+ }
+ });
}
- this._dirty = false;
- this._memoryBlobs = {};
- this._invalidationKeys = {};
}
- _getDump() {
- const buffers = [];
- const newMap = {};
- let offset = 0;
- function push2(key, invalidationKey, buffer) {
- buffers.push(buffer);
- newMap[key] = [invalidationKey, offset, offset + buffer.length];
- offset += buffer.length;
+ var fs$copyFile = fs10.copyFile;
+ if (fs$copyFile)
+ fs10.copyFile = copyFile;
+ function copyFile(src, dest, flags, cb) {
+ if (typeof flags === "function") {
+ cb = flags;
+ flags = 0;
}
- for (const key of Object.keys(this._memoryBlobs)) {
- const buffer = this._memoryBlobs[key];
- const invalidationKey = this._invalidationKeys[key];
- push2(key, invalidationKey, buffer);
+ 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);
+ }
+ });
}
- for (const key of Object.keys(this._storedMap)) {
- if (hasOwnProperty.call(newMap, key)) continue;
- const mapping = this._storedMap[key];
- const buffer = this._storedBlob.slice(mapping[1], mapping[2]);
- push2(key, mapping[0], buffer);
+ }
+ var fs$readdir = fs10.readdir;
+ fs10.readdir = readdir;
+ var noReaddirOptionVersions = /^v[0-5]\./;
+ function readdir(path10, options, cb) {
+ if (typeof options === "function")
+ cb = options, options = null;
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path11, options2, cb2, startTime) {
+ return fs$readdir(path11, fs$readdirCallback(
+ path11,
+ options2,
+ cb2,
+ startTime
+ ));
+ } : function go$readdir2(path11, options2, cb2, startTime) {
+ return fs$readdir(path11, options2, fs$readdirCallback(
+ path11,
+ options2,
+ cb2,
+ startTime
+ ));
+ };
+ return go$readdir(path10, options, cb);
+ function fs$readdirCallback(path11, options2, cb2, startTime) {
+ return function(err, files) {
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
+ enqueue([
+ go$readdir,
+ [path11, options2, cb2],
+ err,
+ startTime || Date.now(),
+ Date.now()
+ ]);
+ else {
+ if (files && files.sort)
+ files.sort();
+ if (typeof cb2 === "function")
+ cb2.call(this, err, files);
+ }
+ };
}
- return [buffers, newMap];
}
- };
- var NativeCompileCache = class {
- constructor() {
- this._cacheStore = null;
- this._previousModuleCompile = null;
+ if (process.version.substr(0, 4) === "v0.8") {
+ var legStreams = legacy(fs10);
+ ReadStream = legStreams.ReadStream;
+ WriteStream = legStreams.WriteStream;
}
- setCacheStore(cacheStore) {
- this._cacheStore = cacheStore;
+ var fs$ReadStream = fs10.ReadStream;
+ if (fs$ReadStream) {
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
+ ReadStream.prototype.open = ReadStream$open;
}
- install() {
- const self2 = this;
- const hasRequireResolvePaths = typeof require.resolve.paths === "function";
- this._previousModuleCompile = Module2.prototype._compile;
- Module2.prototype._compile = function(content, filename) {
- const mod = this;
- function require2(id) {
- return mod.require(id);
- }
- function resolve(request, options) {
- return Module2._resolveFilename(request, mod, false, options);
- }
- require2.resolve = resolve;
- if (hasRequireResolvePaths) {
- resolve.paths = function paths(request) {
- return Module2._resolveLookupPaths(request, mod, true);
- };
- }
- require2.main = process.mainModule;
- require2.extensions = Module2._extensions;
- require2.cache = Module2._cache;
- const dirname2 = path16.dirname(filename);
- const compiledWrapper = self2._moduleCompile(filename, content);
- const args = [mod.exports, require2, mod, filename, dirname2, process, global, Buffer];
- return compiledWrapper.apply(mod.exports, args);
- };
+ var fs$WriteStream = fs10.WriteStream;
+ if (fs$WriteStream) {
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
+ WriteStream.prototype.open = WriteStream$open;
}
- uninstall() {
- Module2.prototype._compile = this._previousModuleCompile;
+ Object.defineProperty(fs10, "ReadStream", {
+ get: function() {
+ return ReadStream;
+ },
+ set: function(val) {
+ ReadStream = val;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ Object.defineProperty(fs10, "WriteStream", {
+ get: function() {
+ return WriteStream;
+ },
+ set: function(val) {
+ WriteStream = val;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ var FileReadStream = ReadStream;
+ Object.defineProperty(fs10, "FileReadStream", {
+ get: function() {
+ return FileReadStream;
+ },
+ set: function(val) {
+ FileReadStream = val;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ var FileWriteStream = WriteStream;
+ Object.defineProperty(fs10, "FileWriteStream", {
+ get: function() {
+ return FileWriteStream;
+ },
+ set: function(val) {
+ FileWriteStream = val;
+ },
+ enumerable: true,
+ configurable: true
+ });
+ function ReadStream(path10, options) {
+ if (this instanceof ReadStream)
+ return fs$ReadStream.apply(this, arguments), this;
+ else
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
}
- _moduleCompile(filename, content) {
- var contLen = content.length;
- if (contLen >= 2) {
- if (content.charCodeAt(0) === 35 && content.charCodeAt(1) === 33) {
- if (contLen === 2) {
- content = "";
- } else {
- var i = 2;
- for (; i < contLen; ++i) {
- var code2 = content.charCodeAt(i);
- if (code2 === 10 || code2 === 13) break;
- }
- if (i === contLen) {
- content = "";
- } else {
- content = content.slice(i);
- }
- }
+ 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();
}
- }
- var wrapper = Module2.wrap(content);
- var invalidationKey = crypto.createHash("sha1").update(content, "utf8").digest("hex");
- var buffer = this._cacheStore.get(filename, invalidationKey);
- var script = new vm.Script(wrapper, {
- filename,
- lineOffset: 0,
- displayErrors: true,
- cachedData: buffer,
- produceCachedData: true
});
- if (script.cachedDataProduced) {
- this._cacheStore.set(filename, invalidationKey, script.cachedData);
- } else if (script.cachedDataRejected) {
- this._cacheStore.delete(filename);
- }
- var compiledWrapper = script.runInThisContext({
- filename,
- lineOffset: 0,
- columnOffset: 0,
- displayErrors: true
+ }
+ function WriteStream(path10, 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);
+ }
});
- return compiledWrapper;
}
- };
- function mkdirpSync(p_) {
- _mkdirpSync(path16.resolve(p_), 511);
- }
- function _mkdirpSync(p, mode) {
- try {
- fs17.mkdirSync(p, mode);
- } catch (err0) {
- if (err0.code === "ENOENT") {
- _mkdirpSync(path16.dirname(p));
- _mkdirpSync(p);
- } else {
- try {
- const stat = fs17.statSync(p);
- if (!stat.isDirectory()) {
- throw err0;
+ function createReadStream(path10, options) {
+ return new fs10.ReadStream(path10, options);
+ }
+ function createWriteStream(path10, options) {
+ return new fs10.WriteStream(path10, options);
+ }
+ var fs$open = fs10.open;
+ fs10.open = open;
+ function open(path10, flags, mode, cb) {
+ if (typeof mode === "function")
+ cb = mode, mode = null;
+ return go$open(path10, flags, mode, cb);
+ function go$open(path11, flags2, mode2, cb2, startTime) {
+ return fs$open(path11, flags2, mode2, function(err, fd) {
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
+ enqueue([go$open, [path11, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
+ else {
+ if (typeof cb2 === "function")
+ cb2.apply(this, arguments);
}
- } catch (err1) {
- throw err0;
- }
+ });
}
}
+ return fs10;
}
- function slashEscape(str) {
- const ESCAPE_LOOKUP = {
- "\\": "zB",
- ":": "zC",
- "/": "zS",
- "\0": "z0",
- "z": "zZ"
- };
- const ESCAPE_REGEX = /[\\:/\x00z]/g;
- return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
- }
- function supportsCachedData() {
- const script = new vm.Script('""', { produceCachedData: true });
- return script.cachedDataProduced === true;
+ function enqueue(elem) {
+ debug("ENQUEUE", elem[0].name, elem[1]);
+ fs9[gracefulQueue].push(elem);
+ retry();
}
- function getCacheDir() {
- const v8_compile_cache_cache_dir = process.env.V8_COMPILE_CACHE_CACHE_DIR;
- if (v8_compile_cache_cache_dir) {
- return v8_compile_cache_cache_dir;
+ var retryTimer;
+ function resetQueue() {
+ var now = Date.now();
+ for (var i2 = 0; i2 < fs9[gracefulQueue].length; ++i2) {
+ if (fs9[gracefulQueue][i2].length > 2) {
+ fs9[gracefulQueue][i2][3] = now;
+ fs9[gracefulQueue][i2][4] = now;
+ }
}
- const dirname2 = typeof process.getuid === "function" ? "v8-compile-cache-" + process.getuid() : "v8-compile-cache";
- const arch = process.arch;
- const version = typeof process.versions.v8 === "string" ? process.versions.v8 : typeof process.versions.chakracore === "string" ? "chakracore-" + process.versions.chakracore : "node-" + process.version;
- const cacheDir = path16.join(os3.tmpdir(), dirname2, arch, version);
- return cacheDir;
+ retry();
}
- function getMainName() {
- const mainName = require.main && typeof require.main.filename === "string" ? require.main.filename : process.cwd();
- return mainName;
- }
- if (!process.env.DISABLE_V8_COMPILE_CACHE && supportsCachedData()) {
- const cacheDir = getCacheDir();
- const prefix = getMainName();
- const blobStore = new FileSystemBlobStore(cacheDir, prefix);
- const nativeCompileCache = new NativeCompileCache();
- nativeCompileCache.setCacheStore(blobStore);
- nativeCompileCache.install();
- process.once("exit", () => {
- if (blobStore.isDirty()) {
- blobStore.save();
- }
- nativeCompileCache.uninstall();
- });
- }
- module2.exports.__TEST__ = {
- FileSystemBlobStore,
- NativeCompileCache,
- mkdirpSync,
- slashEscape,
- supportsCachedData,
- getCacheDir,
- getMainName
- };
- }
-});
-
-// node_modules/semver/functions/satisfies.js
-var require_satisfies = __commonJS({
- "node_modules/semver/functions/satisfies.js"(exports2, module2) {
- "use strict";
- var Range3 = require_range();
- var satisfies = (version, range, options) => {
- try {
- range = new Range3(range, options);
- } catch (er) {
- return false;
- }
- return range.test(version);
- };
- module2.exports = satisfies;
- }
-});
-
-// node_modules/which/node_modules/isexe/dist/commonjs/index.min.js
-var require_index_min = __commonJS({
- "node_modules/which/node_modules/isexe/dist/commonjs/index.min.js"(exports2) {
- "use strict";
- var a = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
- var _ = a((i) => {
- "use strict";
- Object.defineProperty(i, "__esModule", { value: true });
- i.sync = i.isexe = void 0;
- var M = require("node:fs"), x = require("node:fs/promises"), q = async (t, e = {}) => {
- let { ignoreErrors: r = false } = e;
- try {
- return d(await (0, x.stat)(t), e);
- } catch (s) {
- let n = s;
- if (r || n.code === "EACCES") return false;
- throw n;
- }
- };
- i.isexe = q;
- var m = (t, e = {}) => {
- let { ignoreErrors: r = false } = e;
- try {
- return d((0, M.statSync)(t), e);
- } catch (s) {
- let n = s;
- if (r || n.code === "EACCES") return false;
- throw n;
- }
- };
- i.sync = m;
- var d = (t, e) => t.isFile() && A(t, e), A = (t, e) => {
- let r = e.uid ?? process.getuid?.(), s = e.groups ?? process.getgroups?.() ?? [], n = e.gid ?? process.getgid?.() ?? s[0];
- if (r === void 0 || n === void 0) throw new Error("cannot get uid or gid");
- let u = /* @__PURE__ */ new Set([n, ...s]), c = t.mode, S = t.uid, P = t.gid, f = parseInt("100", 8), l = parseInt("010", 8), j = parseInt("001", 8), C = f | l;
- return !!(c & j || c & l && u.has(P) || c & f && S === r || c & C && r === 0);
- };
- });
- var g = a((o) => {
- "use strict";
- Object.defineProperty(o, "__esModule", { value: true });
- o.sync = o.isexe = void 0;
- var T = require("node:fs"), I = require("node:fs/promises"), D = require("node:path"), F = async (t, e = {}) => {
- let { ignoreErrors: r = false } = e;
- try {
- return y(await (0, I.stat)(t), t, e);
- } catch (s) {
- let n = s;
- if (r || n.code === "EACCES") return false;
- throw n;
- }
- };
- o.isexe = F;
- var L = (t, e = {}) => {
- let { ignoreErrors: r = false } = e;
- try {
- return y((0, T.statSync)(t), t, e);
- } catch (s) {
- let n = s;
- if (r || n.code === "EACCES") return false;
- throw n;
- }
- };
- o.sync = L;
- var B = (t, e) => {
- let { pathExt: r = process.env.PATHEXT || "" } = e, s = r.split(D.delimiter);
- if (s.indexOf("") !== -1) return true;
- for (let n of s) {
- let u = n.toLowerCase(), c = t.substring(t.length - u.length).toLowerCase();
- if (u && c === u) return true;
- }
- return false;
- }, y = (t, e, r) => t.isFile() && B(e, r);
- });
- var p = a((h) => {
- "use strict";
- Object.defineProperty(h, "__esModule", { value: true });
- });
- var v = exports2 && exports2.__createBinding || (Object.create ? (function(t, e, r, s) {
- s === void 0 && (s = r);
- var n = Object.getOwnPropertyDescriptor(e, r);
- (!n || ("get" in n ? !e.__esModule : n.writable || n.configurable)) && (n = { enumerable: true, get: function() {
- return e[r];
- } }), Object.defineProperty(t, s, n);
- }) : (function(t, e, r, s) {
- s === void 0 && (s = r), t[s] = e[r];
- }));
- var G = exports2 && exports2.__setModuleDefault || (Object.create ? (function(t, e) {
- Object.defineProperty(t, "default", { enumerable: true, value: e });
- }) : function(t, e) {
- t.default = e;
- });
- var w = exports2 && exports2.__importStar || /* @__PURE__ */ (function() {
- var t = function(e) {
- return t = Object.getOwnPropertyNames || function(r) {
- var s = [];
- for (var n in r) Object.prototype.hasOwnProperty.call(r, n) && (s[s.length] = n);
- return s;
- }, t(e);
- };
- return function(e) {
- if (e && e.__esModule) return e;
- var r = {};
- if (e != null) for (var s = t(e), n = 0; n < s.length; n++) s[n] !== "default" && v(r, e, s[n]);
- return G(r, e), r;
- };
- })();
- var X = exports2 && exports2.__exportStar || function(t, e) {
- for (var r in t) r !== "default" && !Object.prototype.hasOwnProperty.call(e, r) && v(e, t, r);
- };
- Object.defineProperty(exports2, "__esModule", { value: true });
- exports2.sync = exports2.isexe = exports2.posix = exports2.win32 = void 0;
- var E = w(_());
- exports2.posix = E;
- var O = w(g());
- exports2.win32 = O;
- X(p(), exports2);
- var H = process.env._ISEXE_TEST_PLATFORM_ || process.platform;
- var b = H === "win32" ? O : E;
- exports2.isexe = b.isexe;
- exports2.sync = b.sync;
- }
-});
-
-// node_modules/which/lib/index.js
-var require_lib = __commonJS({
- "node_modules/which/lib/index.js"(exports2, module2) {
- var { isexe, sync: isexeSync } = require_index_min();
- var { join: join3, delimiter, sep, posix } = require("path");
- var isWindows4 = 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
- ...isWindows4 ? [process.cwd()] : [],
- ...(optPath || /* istanbul ignore next: very unusual */
- "").split(optDelimiter)
- ];
- if (isWindows4) {
- const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
- const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]);
- if (cmd.includes(".") && pathExt[0] !== "") {
- pathExt.unshift("");
- }
- return { pathEnv, pathExt, pathExtExe };
- }
- return { pathEnv, pathExt: [""] };
- };
- var getPathPart = (raw2, cmd) => {
- const pathPart = /^".*"$/.test(raw2) ? raw2.slice(1, -1) : raw2;
- const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
- return prefix + join3(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 = isexeSync(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/is-windows/index.js
-var require_is_windows = __commonJS({
- "node_modules/is-windows/index.js"(exports2, module2) {
- (function(factory) {
- if (exports2 && typeof exports2 === "object" && typeof module2 !== "undefined") {
- module2.exports = factory();
- } else if (typeof define === "function" && define.amd) {
- define([], factory);
- } else if (typeof window !== "undefined") {
- window.isWindows = factory();
- } else if (typeof global !== "undefined") {
- global.isWindows = factory();
- } else if (typeof self !== "undefined") {
- self.isWindows = factory();
- } else {
- this.isWindows = factory();
- }
- })(function() {
- "use strict";
- return function isWindows4() {
- return process && (process.platform === "win32" || /^(msys|cygwin)$/.test(process.env.OSTYPE));
- };
- });
- }
-});
-
-// node_modules/cmd-extension/index.js
-var require_cmd_extension = __commonJS({
- "node_modules/cmd-extension/index.js"(exports2, module2) {
- "use strict";
- var path16 = require("path");
- var cmdExtension;
- if (process.env.PATHEXT) {
- cmdExtension = process.env.PATHEXT.split(path16.delimiter).find((ext) => ext.toUpperCase() === ".CMD");
- }
- module2.exports = cmdExtension || ".cmd";
- }
-});
-
-// node_modules/graceful-fs/polyfills.js
-var require_polyfills = __commonJS({
- "node_modules/graceful-fs/polyfills.js"(exports2, module2) {
- var constants2 = require("constants");
- var origCwd = process.cwd;
- var cwd = null;
- var platform5 = 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(fs17) {
- if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
- patchLchmod(fs17);
- }
- if (!fs17.lutimes) {
- patchLutimes(fs17);
- }
- fs17.chown = chownFix(fs17.chown);
- fs17.fchown = chownFix(fs17.fchown);
- fs17.lchown = chownFix(fs17.lchown);
- fs17.chmod = chmodFix(fs17.chmod);
- fs17.fchmod = chmodFix(fs17.fchmod);
- fs17.lchmod = chmodFix(fs17.lchmod);
- fs17.chownSync = chownFixSync(fs17.chownSync);
- fs17.fchownSync = chownFixSync(fs17.fchownSync);
- fs17.lchownSync = chownFixSync(fs17.lchownSync);
- fs17.chmodSync = chmodFixSync(fs17.chmodSync);
- fs17.fchmodSync = chmodFixSync(fs17.fchmodSync);
- fs17.lchmodSync = chmodFixSync(fs17.lchmodSync);
- fs17.stat = statFix(fs17.stat);
- fs17.fstat = statFix(fs17.fstat);
- fs17.lstat = statFix(fs17.lstat);
- fs17.statSync = statFixSync(fs17.statSync);
- fs17.fstatSync = statFixSync(fs17.fstatSync);
- fs17.lstatSync = statFixSync(fs17.lstatSync);
- if (fs17.chmod && !fs17.lchmod) {
- fs17.lchmod = function(path16, mode, cb) {
- if (cb) process.nextTick(cb);
- };
- fs17.lchmodSync = function() {
- };
- }
- if (fs17.chown && !fs17.lchown) {
- fs17.lchown = function(path16, uid, gid, cb) {
- if (cb) process.nextTick(cb);
- };
- fs17.lchownSync = function() {
- };
- }
- if (platform5 === "win32") {
- fs17.rename = typeof fs17.rename !== "function" ? fs17.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() {
- fs17.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;
- })(fs17.rename);
- }
- fs17.read = typeof fs17.read !== "function" ? fs17.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(fs17, fd, buffer, offset, length, position, callback);
- }
- callback_.apply(this, arguments);
- };
- }
- return fs$read.call(fs17, fd, buffer, offset, length, position, callback);
- }
- if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
- return read;
- })(fs17.read);
- fs17.readSync = typeof fs17.readSync !== "function" ? fs17.readSync : /* @__PURE__ */ (function(fs$readSync) {
- return function(fd, buffer, offset, length, position) {
- var eagCounter = 0;
- while (true) {
- try {
- return fs$readSync.call(fs17, fd, buffer, offset, length, position);
- } catch (er) {
- if (er.code === "EAGAIN" && eagCounter < 10) {
- eagCounter++;
- continue;
- }
- throw er;
- }
- }
- };
- })(fs17.readSync);
- function patchLchmod(fs18) {
- fs18.lchmod = function(path16, mode, callback) {
- fs18.open(
- path16,
- constants2.O_WRONLY | constants2.O_SYMLINK,
- mode,
- function(err, fd) {
- if (err) {
- if (callback) callback(err);
- return;
- }
- fs18.fchmod(fd, mode, function(err2) {
- fs18.close(fd, function(err22) {
- if (callback) callback(err2 || err22);
- });
- });
- }
- );
- };
- fs18.lchmodSync = function(path16, mode) {
- var fd = fs18.openSync(path16, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
- var threw = true;
- var ret;
- try {
- ret = fs18.fchmodSync(fd, mode);
- threw = false;
- } finally {
- if (threw) {
- try {
- fs18.closeSync(fd);
- } catch (er) {
- }
- } else {
- fs18.closeSync(fd);
- }
- }
- return ret;
- };
- }
- function patchLutimes(fs18) {
- if (constants2.hasOwnProperty("O_SYMLINK") && fs18.futimes) {
- fs18.lutimes = function(path16, at, mt, cb) {
- fs18.open(path16, constants2.O_SYMLINK, function(er, fd) {
- if (er) {
- if (cb) cb(er);
- return;
- }
- fs18.futimes(fd, at, mt, function(er2) {
- fs18.close(fd, function(er22) {
- if (cb) cb(er2 || er22);
- });
- });
- });
- };
- fs18.lutimesSync = function(path16, at, mt) {
- var fd = fs18.openSync(path16, constants2.O_SYMLINK);
- var ret;
- var threw = true;
- try {
- ret = fs18.futimesSync(fd, at, mt);
- threw = false;
- } finally {
- if (threw) {
- try {
- fs18.closeSync(fd);
- } catch (er) {
- }
- } else {
- fs18.closeSync(fd);
- }
- }
- return ret;
- };
- } else if (fs18.futimes) {
- fs18.lutimes = function(_a, _b, _c, cb) {
- if (cb) process.nextTick(cb);
- };
- fs18.lutimesSync = function() {
- };
- }
- }
- function chmodFix(orig) {
- if (!orig) return orig;
- return function(target, mode, cb) {
- return orig.call(fs17, 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(fs17, 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(fs17, 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(fs17, 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(fs17, target, options, callback) : orig.call(fs17, target, callback);
- };
- }
- function statFixSync(orig) {
- if (!orig) return orig;
- return function(target, options) {
- var stats = options ? orig.call(fs17, target, options) : orig.call(fs17, 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/graceful-fs/legacy-streams.js
-var require_legacy_streams = __commonJS({
- "node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
- var Stream2 = require("stream").Stream;
- module2.exports = legacy;
- function legacy(fs17) {
- return {
- ReadStream: ReadStream2,
- WriteStream: WriteStream2
- };
- function ReadStream2(path16, options) {
- if (!(this instanceof ReadStream2)) return new ReadStream2(path16, options);
- Stream2.call(this);
- var self2 = this;
- this.path = path16;
- 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() {
- self2._read();
- });
- return;
- }
- fs17.open(this.path, this.flags, this.mode, function(err, fd) {
- if (err) {
- self2.emit("error", err);
- self2.readable = false;
- return;
- }
- self2.fd = fd;
- self2.emit("open", fd);
- self2._read();
- });
- }
- function WriteStream2(path16, options) {
- if (!(this instanceof WriteStream2)) return new WriteStream2(path16, options);
- Stream2.call(this);
- this.path = path16;
- 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 = fs17.open;
- this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
- this.flush();
- }
- }
- }
- }
-});
-
-// node_modules/graceful-fs/clone.js
-var require_clone = __commonJS({
- "node_modules/graceful-fs/clone.js"(exports2, 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/graceful-fs/graceful-fs.js
-var require_graceful_fs = __commonJS({
- "node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
- var fs17 = 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 = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
- previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
- } else {
- gracefulQueue = "___graceful-fs.queue";
- previousSymbol = "___graceful-fs.previous";
- }
- function noop3() {
- }
- function publishQueue(context, queue2) {
- Object.defineProperty(context, gracefulQueue, {
- get: function() {
- return queue2;
- }
- });
- }
- var debug = noop3;
- if (util.debuglog)
- debug = util.debuglog("gfs4");
- else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
- debug = function() {
- var m = util.format.apply(util, arguments);
- m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
- console.error(m);
- };
- if (!fs17[gracefulQueue]) {
- queue = global[gracefulQueue] || [];
- publishQueue(fs17, queue);
- fs17.close = (function(fs$close) {
- function close(fd, cb) {
- return fs$close.call(fs17, fd, function(err) {
- if (!err) {
- resetQueue();
- }
- if (typeof cb === "function")
- cb.apply(this, arguments);
- });
- }
- Object.defineProperty(close, previousSymbol, {
- value: fs$close
- });
- return close;
- })(fs17.close);
- fs17.closeSync = (function(fs$closeSync) {
- function closeSync(fd) {
- fs$closeSync.apply(fs17, arguments);
- resetQueue();
- }
- Object.defineProperty(closeSync, previousSymbol, {
- value: fs$closeSync
- });
- return closeSync;
- })(fs17.closeSync);
- if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
- process.on("exit", function() {
- debug(fs17[gracefulQueue]);
- require("assert").equal(fs17[gracefulQueue].length, 0);
- });
- }
- }
- var queue;
- if (!global[gracefulQueue]) {
- publishQueue(global, fs17[gracefulQueue]);
- }
- module2.exports = patch(clone(fs17));
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs17.__patched) {
- module2.exports = patch(fs17);
- fs17.__patched = true;
- }
- function patch(fs18) {
- polyfills(fs18);
- fs18.gracefulify = patch;
- fs18.createReadStream = createReadStream;
- fs18.createWriteStream = createWriteStream;
- var fs$readFile = fs18.readFile;
- fs18.readFile = readFile;
- function readFile(path16, options, cb) {
- if (typeof options === "function")
- cb = options, options = null;
- return go$readFile(path16, options, cb);
- function go$readFile(path17, options2, cb2, startTime) {
- return fs$readFile(path17, options2, function(err) {
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$readFile, [path17, options2, cb2], err, startTime || Date.now(), Date.now()]);
- else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
- }
- });
- }
- }
- var fs$writeFile = fs18.writeFile;
- fs18.writeFile = writeFile;
- function writeFile(path16, data, options, cb) {
- if (typeof options === "function")
- cb = options, options = null;
- return go$writeFile(path16, data, options, cb);
- function go$writeFile(path17, data2, options2, cb2, startTime) {
- return fs$writeFile(path17, data2, options2, function(err) {
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$writeFile, [path17, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
- else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
- }
- });
- }
- }
- var fs$appendFile = fs18.appendFile;
- if (fs$appendFile)
- fs18.appendFile = appendFile;
- function appendFile(path16, data, options, cb) {
- if (typeof options === "function")
- cb = options, options = null;
- return go$appendFile(path16, data, options, cb);
- function go$appendFile(path17, data2, options2, cb2, startTime) {
- return fs$appendFile(path17, data2, options2, function(err) {
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$appendFile, [path17, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
- else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
- }
- });
- }
- }
- var fs$copyFile = fs18.copyFile;
- if (fs$copyFile)
- fs18.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 = fs18.readdir;
- fs18.readdir = readdir;
- var noReaddirOptionVersions = /^v[0-5]\./;
- function readdir(path16, options, cb) {
- if (typeof options === "function")
- cb = options, options = null;
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path17, options2, cb2, startTime) {
- return fs$readdir(path17, fs$readdirCallback(
- path17,
- options2,
- cb2,
- startTime
- ));
- } : function go$readdir2(path17, options2, cb2, startTime) {
- return fs$readdir(path17, options2, fs$readdirCallback(
- path17,
- options2,
- cb2,
- startTime
- ));
- };
- return go$readdir(path16, options, cb);
- function fs$readdirCallback(path17, options2, cb2, startTime) {
- return function(err, files) {
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([
- go$readdir,
- [path17, 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(fs18);
- ReadStream2 = legStreams.ReadStream;
- WriteStream2 = legStreams.WriteStream;
- }
- var fs$ReadStream = fs18.ReadStream;
- if (fs$ReadStream) {
- ReadStream2.prototype = Object.create(fs$ReadStream.prototype);
- ReadStream2.prototype.open = ReadStream$open;
- }
- var fs$WriteStream = fs18.WriteStream;
- if (fs$WriteStream) {
- WriteStream2.prototype = Object.create(fs$WriteStream.prototype);
- WriteStream2.prototype.open = WriteStream$open;
- }
- Object.defineProperty(fs18, "ReadStream", {
- get: function() {
- return ReadStream2;
- },
- set: function(val) {
- ReadStream2 = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(fs18, "WriteStream", {
- get: function() {
- return WriteStream2;
- },
- set: function(val) {
- WriteStream2 = val;
- },
- enumerable: true,
- configurable: true
- });
- var FileReadStream = ReadStream2;
- Object.defineProperty(fs18, "FileReadStream", {
- get: function() {
- return FileReadStream;
- },
- set: function(val) {
- FileReadStream = val;
- },
- enumerable: true,
- configurable: true
- });
- var FileWriteStream = WriteStream2;
- Object.defineProperty(fs18, "FileWriteStream", {
- get: function() {
- return FileWriteStream;
- },
- set: function(val) {
- FileWriteStream = val;
- },
- enumerable: true,
- configurable: true
- });
- function ReadStream2(path16, options) {
- if (this instanceof ReadStream2)
- return fs$ReadStream.apply(this, arguments), this;
- else
- return ReadStream2.apply(Object.create(ReadStream2.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 WriteStream2(path16, options) {
- if (this instanceof WriteStream2)
- return fs$WriteStream.apply(this, arguments), this;
- else
- return WriteStream2.apply(Object.create(WriteStream2.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(path16, options) {
- return new fs18.ReadStream(path16, options);
- }
- function createWriteStream(path16, options) {
- return new fs18.WriteStream(path16, options);
- }
- var fs$open = fs18.open;
- fs18.open = open;
- function open(path16, flags, mode, cb) {
- if (typeof mode === "function")
- cb = mode, mode = null;
- return go$open(path16, flags, mode, cb);
- function go$open(path17, flags2, mode2, cb2, startTime) {
- return fs$open(path17, flags2, mode2, function(err, fd) {
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
- enqueue([go$open, [path17, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
- else {
- if (typeof cb2 === "function")
- cb2.apply(this, arguments);
- }
- });
- }
- }
- return fs18;
- }
- function enqueue(elem) {
- debug("ENQUEUE", elem[0].name, elem[1]);
- fs17[gracefulQueue].push(elem);
- retry();
- }
- var retryTimer;
- function resetQueue() {
- var now = Date.now();
- for (var i = 0; i < fs17[gracefulQueue].length; ++i) {
- if (fs17[gracefulQueue][i].length > 2) {
- fs17[gracefulQueue][i][3] = now;
- fs17[gracefulQueue][i][4] = now;
- }
- }
- retry();
- }
- function retry() {
- clearTimeout(retryTimer);
- retryTimer = void 0;
- if (fs17[gracefulQueue].length === 0)
- return;
- var elem = fs17[gracefulQueue].shift();
- var fn2 = elem[0];
- var args = elem[1];
- var err = elem[2];
- var startTime = elem[3];
- var lastTime = elem[4];
- if (startTime === void 0) {
- debug("RETRY", fn2.name, args);
- fn2.apply(null, args);
- } else if (Date.now() - startTime >= 6e4) {
- debug("TIMEOUT", fn2.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) {
- debug("RETRY", fn2.name, args);
- fn2.apply(null, args.concat([startTime]));
- } else {
- fs17[gracefulQueue].push(elem);
- }
- }
- if (retryTimer === void 0) {
- retryTimer = setTimeout(retry, 0);
- }
- }
- }
-});
-
-// node_modules/@zkochan/cmd-shim/index.js
-var require_cmd_shim = __commonJS({
- "node_modules/@zkochan/cmd-shim/index.js"(exports2, module2) {
- "use strict";
- cmdShim2.ifExists = cmdShimIfExists;
- var util_1 = require("util");
- var path16 = require("path");
- var isWindows4 = require_is_windows();
- var CMD_EXTENSION = require_cmd_extension();
- var shebangExpr = /^#!\s*(?:\/usr\/bin\/env(?:\s+-S\s*)?)?\s*([^ \t]+)(.*)$/;
- var DEFAULT_OPTIONS = {
- // Create PowerShell file by default if the option hasn't been specified
- createPwshFile: true,
- createCmdFile: isWindows4(),
- fs: require_graceful_fs()
- };
- var extensionToProgramMap = /* @__PURE__ */ new Map([
- [".js", "node"],
- [".cjs", "node"],
- [".mjs", "node"],
- [".cmd", "cmd"],
- [".bat", "cmd"],
- [".ps1", "pwsh"],
- [".sh", "sh"]
- ]);
- function ingestOptions(opts) {
- const opts_ = { ...DEFAULT_OPTIONS, ...opts };
- const fs17 = opts_.fs;
- opts_.fs_ = {
- chmod: fs17.chmod ? (0, util_1.promisify)(fs17.chmod) : (async () => {
- }),
- mkdir: (0, util_1.promisify)(fs17.mkdir),
- readFile: (0, util_1.promisify)(fs17.readFile),
- stat: (0, util_1.promisify)(fs17.stat),
- unlink: (0, util_1.promisify)(fs17.unlink),
- writeFile: (0, util_1.promisify)(fs17.writeFile)
- };
- return opts_;
- }
- async function cmdShim2(src, to, opts) {
- const opts_ = ingestOptions(opts);
- await cmdShim_(src, to, opts_);
- }
- function cmdShimIfExists(src, to, opts) {
- return cmdShim2(src, to, opts).catch(() => {
- });
- }
- function rm(path17, opts) {
- return opts.fs_.unlink(path17).catch(() => {
- });
- }
- async function cmdShim_(src, to, opts) {
- const srcRuntimeInfo = await searchScriptRuntime(src, opts);
- await writeShimsPreCommon(to, opts);
- return writeAllShims(src, to, srcRuntimeInfo, opts);
- }
- function writeShimsPreCommon(target, opts) {
- return opts.fs_.mkdir(path16.dirname(target), { recursive: true });
- }
- function writeAllShims(src, to, srcRuntimeInfo, opts) {
- const opts_ = ingestOptions(opts);
- const generatorAndExts = [{ generator: generateShShim, extension: "" }];
- if (opts_.createCmdFile) {
- generatorAndExts.push({ generator: generateCmdShim, extension: CMD_EXTENSION });
- }
- if (opts_.createPwshFile) {
- generatorAndExts.push({ generator: generatePwshShim, extension: ".ps1" });
- }
- return Promise.all(generatorAndExts.map((generatorAndExt) => writeShim(src, to + generatorAndExt.extension, srcRuntimeInfo, generatorAndExt.generator, opts_)));
- }
- function writeShimPre(target, opts) {
- return rm(target, opts);
- }
- function writeShimPost(target, opts) {
- return chmodShim(target, opts);
- }
- async function searchScriptRuntime(target, opts) {
- try {
- const data = await opts.fs_.readFile(target, "utf8");
- const firstLine = data.trim().split(/\r*\n/)[0];
- const shebang = firstLine.match(shebangExpr);
- if (!shebang) {
- const targetExtension = path16.extname(target).toLowerCase();
- return {
- // undefined if extension is unknown but it's converted to null.
- program: extensionToProgramMap.get(targetExtension) || null,
- additionalArgs: ""
- };
- }
- return {
- program: shebang[1],
- additionalArgs: shebang[2]
- };
- } catch (err) {
- if (!isWindows4() || err.code !== "ENOENT")
- throw err;
- if (await opts.fs_.stat(`${target}${getExeExtension()}`)) {
- return {
- program: null,
- additionalArgs: ""
- };
- }
- throw err;
- }
- }
- function getExeExtension() {
- let cmdExtension;
- if (process.env.PATHEXT) {
- cmdExtension = process.env.PATHEXT.split(path16.delimiter).find((ext) => ext.toLowerCase() === ".exe");
- }
- return cmdExtension || ".exe";
- }
- async function writeShim(src, to, srcRuntimeInfo, generateShimScript, opts) {
- const defaultArgs = opts.preserveSymlinks ? "--preserve-symlinks" : "";
- const args = [srcRuntimeInfo.additionalArgs, defaultArgs].filter((arg) => arg).join(" ");
- opts = Object.assign({}, opts, {
- prog: srcRuntimeInfo.program,
- args
- });
- await writeShimPre(to, opts);
- await opts.fs_.writeFile(to, generateShimScript(src, to, opts), "utf8");
- return writeShimPost(to, opts);
- }
- function generateCmdShim(src, to, opts) {
- const shTarget = path16.relative(path16.dirname(to), src);
- let target = shTarget.split("/").join("\\");
- const quotedPathToTarget = path16.isAbsolute(target) ? `"${target}"` : `"%~dp0\\${target}"`;
- let longProg;
- let prog = opts.prog;
- let args = opts.args || "";
- const nodePath = normalizePathEnvVar(opts.nodePath).win32;
- const prependToPath = normalizePathEnvVar(opts.prependToPath).win32;
- if (!prog) {
- prog = quotedPathToTarget;
- args = "";
- target = "";
- } else if (prog === "node" && opts.nodeExecPath) {
- prog = `"${opts.nodeExecPath}"`;
- target = quotedPathToTarget;
- } else {
- longProg = `"%~dp0\\${prog}.exe"`;
- target = quotedPathToTarget;
- }
- let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : "";
- let cmd = "@SETLOCAL\r\n";
- if (prependToPath) {
- cmd += `@SET "PATH=${prependToPath}:%PATH%"\r
-`;
- }
- if (nodePath) {
- cmd += `@IF NOT DEFINED NODE_PATH (\r
- @SET "NODE_PATH=${nodePath}"\r
-) ELSE (\r
- @SET "NODE_PATH=${nodePath};%NODE_PATH%"\r
-)\r
-`;
- }
- if (longProg) {
- cmd += `@IF EXIST ${longProg} (\r
- ${longProg} ${args} ${target} ${progArgs}%*\r
-) ELSE (\r
- @SET PATHEXT=%PATHEXT:;.JS;=;%\r
- ${prog} ${args} ${target} ${progArgs}%*\r
-)\r
-`;
- } else {
- cmd += `@${prog} ${args} ${target} ${progArgs}%*\r
-`;
- }
- return cmd;
- }
- function generateShShim(src, to, opts) {
- let shTarget = path16.relative(path16.dirname(to), src);
- let shProg = opts.prog && opts.prog.split("\\").join("/");
- let shLongProg;
- shTarget = shTarget.split("\\").join("/");
- const quotedPathToTarget = path16.isAbsolute(shTarget) ? `"${shTarget}"` : `"$basedir/${shTarget}"`;
- let args = opts.args || "";
- const shNodePath = normalizePathEnvVar(opts.nodePath).posix;
- if (!shProg) {
- shProg = quotedPathToTarget;
- args = "";
- shTarget = "";
- } else if (opts.prog === "node" && opts.nodeExecPath) {
- shProg = `"${opts.nodeExecPath}"`;
- shTarget = quotedPathToTarget;
- } else {
- shLongProg = `"$basedir/${opts.prog}"`;
- shTarget = quotedPathToTarget;
- }
- let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : "";
- let sh = `#!/bin/sh
-basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
-
-case \`uname\` in
- *CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
-esac
-
-`;
- if (opts.prependToPath) {
- sh += `export PATH="${opts.prependToPath}:$PATH"
-`;
- }
- if (shNodePath) {
- sh += `if [ -z "$NODE_PATH" ]; then
- export NODE_PATH="${shNodePath}"
-else
- export NODE_PATH="${shNodePath}:$NODE_PATH"
-fi
-`;
- }
- if (shLongProg) {
- sh += `if [ -x ${shLongProg} ]; then
- exec ${shLongProg} ${args} ${shTarget} ${progArgs}"$@"
-else
- exec ${shProg} ${args} ${shTarget} ${progArgs}"$@"
-fi
-`;
- } else {
- sh += `${shProg} ${args} ${shTarget} ${progArgs}"$@"
-exit $?
-`;
- }
- return sh;
- }
- function generatePwshShim(src, to, opts) {
- let shTarget = path16.relative(path16.dirname(to), src);
- const shProg = opts.prog && opts.prog.split("\\").join("/");
- let pwshProg = shProg && `"${shProg}$exe"`;
- let pwshLongProg;
- shTarget = shTarget.split("\\").join("/");
- const quotedPathToTarget = path16.isAbsolute(shTarget) ? `"${shTarget}"` : `"$basedir/${shTarget}"`;
- let args = opts.args || "";
- let normalizedNodePathEnvVar = normalizePathEnvVar(opts.nodePath);
- const nodePath = normalizedNodePathEnvVar.win32;
- const shNodePath = normalizedNodePathEnvVar.posix;
- let normalizedPrependPathEnvVar = normalizePathEnvVar(opts.prependToPath);
- const prependPath = normalizedPrependPathEnvVar.win32;
- const shPrependPath = normalizedPrependPathEnvVar.posix;
- if (!pwshProg) {
- pwshProg = quotedPathToTarget;
- args = "";
- shTarget = "";
- } else if (opts.prog === "node" && opts.nodeExecPath) {
- pwshProg = `"${opts.nodeExecPath}"`;
- shTarget = quotedPathToTarget;
- } else {
- pwshLongProg = `"$basedir/${opts.prog}$exe"`;
- shTarget = quotedPathToTarget;
- }
- let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : "";
- let pwsh = `#!/usr/bin/env pwsh
-$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
-
-$exe=""
-${nodePath || prependPath ? '$pathsep=":"\n' : ""}${nodePath ? `$env_node_path=$env:NODE_PATH
-$new_node_path="${nodePath}"
-` : ""}${prependPath ? `$env_path=$env:PATH
-$prepend_path="${prependPath}"
-` : ""}if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
- # Fix case when both the Windows and Linux builds of Node
- # are installed in the same directory
- $exe=".exe"
-${nodePath || prependPath ? ' $pathsep=";"\n' : ""}}`;
- if (shNodePath || shPrependPath) {
- pwsh += ` else {
-${shNodePath ? ` $new_node_path="${shNodePath}"
-` : ""}${shPrependPath ? ` $prepend_path="${shPrependPath}"
-` : ""}}
-`;
- }
- if (shNodePath) {
- pwsh += `if ([string]::IsNullOrEmpty($env_node_path)) {
- $env:NODE_PATH=$new_node_path
-} else {
- $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
-}
-`;
- }
- if (opts.prependToPath) {
- pwsh += `
-$env:PATH="$prepend_path$pathsep$env:PATH"
-`;
- }
- if (pwshLongProg) {
- pwsh += `
-$ret=0
-if (Test-Path ${pwshLongProg}) {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args
- } else {
- & ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args
- }
- $ret=$LASTEXITCODE
-} else {
- # Support pipeline input
- if ($MyInvocation.ExpectingInput) {
- $input | & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
- } else {
- & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
- }
- $ret=$LASTEXITCODE
-}
-${nodePath ? "$env:NODE_PATH=$env_node_path\n" : ""}${prependPath ? "$env:PATH=$env_path\n" : ""}exit $ret
-`;
- } else {
- pwsh += `
-# Support pipeline input
-if ($MyInvocation.ExpectingInput) {
- $input | & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
-} else {
- & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
-}
-${nodePath ? "$env:NODE_PATH=$env_node_path\n" : ""}${prependPath ? "$env:PATH=$env_path\n" : ""}exit $LASTEXITCODE
-`;
- }
- return pwsh;
- }
- function chmodShim(to, opts) {
- return opts.fs_.chmod(to, 493);
- }
- function normalizePathEnvVar(nodePath) {
- if (!nodePath || !nodePath.length) {
- return {
- win32: "",
- posix: ""
- };
- }
- let split = typeof nodePath === "string" ? nodePath.split(path16.delimiter) : Array.from(nodePath);
- let result = {};
- for (let i = 0; i < split.length; i++) {
- const win322 = split[i].split("/").join("\\");
- const posix = isWindows4() ? split[i].split("\\").join("/").replace(/^([^:\\/]*):/, (_, $1) => `/mnt/${$1.toLowerCase()}`) : split[i];
- result.win32 = result.win32 ? `${result.win32};${win322}` : win322;
- result.posix = result.posix ? `${result.posix}:${posix}` : posix;
- result[i] = { win32: win322, posix };
- }
- return result;
- }
- module2.exports = cmdShim2;
- }
-});
-
-// node_modules/tar/dist/esm/mode-fix.js
-var modeFix;
-var init_mode_fix = __esm({
- "node_modules/tar/dist/esm/mode-fix.js"() {
- modeFix = (mode, isDir, portable) => {
- mode &= 4095;
- if (portable) {
- mode = (mode | 384) & ~18;
- }
- if (isDir) {
- if (mode & 256) {
- mode |= 64;
- }
- if (mode & 32) {
- mode |= 8;
- }
- if (mode & 4) {
- mode |= 1;
- }
- }
- return mode;
- };
- }
-});
-
-// node_modules/tar/dist/esm/write-entry.js
-var import_fs11, import_path9, prefixPath, maxReadSize, PROCESS, FILE2, DIRECTORY2, SYMLINK2, HARDLINK2, HEADER, READ2, LSTAT, ONLSTAT, ONREAD, ONREADLINK, OPENFILE, ONOPENFILE, CLOSE, MODE, AWAITDRAIN, ONDRAIN, PREFIX, WriteEntry, WriteEntrySync, WriteEntryTar, getType;
-var init_write_entry = __esm({
- "node_modules/tar/dist/esm/write-entry.js"() {
- import_fs11 = __toESM(require("fs"), 1);
- init_esm();
- import_path9 = __toESM(require("path"), 1);
- init_header();
- init_mode_fix();
- init_normalize_windows_path();
- init_options();
- init_pax();
- init_strip_absolute_path();
- init_strip_trailing_slashes();
- init_warn_method();
- init_winchars();
- prefixPath = (path16, prefix) => {
- if (!prefix) {
- return normalizeWindowsPath(path16);
- }
- path16 = normalizeWindowsPath(path16).replace(/^\.(\/|$)/, "");
- return stripTrailingSlashes(prefix) + "/" + path16;
- };
- maxReadSize = 16 * 1024 * 1024;
- PROCESS = /* @__PURE__ */ Symbol("process");
- FILE2 = /* @__PURE__ */ Symbol("file");
- DIRECTORY2 = /* @__PURE__ */ Symbol("directory");
- SYMLINK2 = /* @__PURE__ */ Symbol("symlink");
- HARDLINK2 = /* @__PURE__ */ Symbol("hardlink");
- HEADER = /* @__PURE__ */ Symbol("header");
- READ2 = /* @__PURE__ */ Symbol("read");
- LSTAT = /* @__PURE__ */ Symbol("lstat");
- ONLSTAT = /* @__PURE__ */ Symbol("onlstat");
- ONREAD = /* @__PURE__ */ Symbol("onread");
- ONREADLINK = /* @__PURE__ */ Symbol("onreadlink");
- OPENFILE = /* @__PURE__ */ Symbol("openfile");
- ONOPENFILE = /* @__PURE__ */ Symbol("onopenfile");
- CLOSE = /* @__PURE__ */ Symbol("close");
- MODE = /* @__PURE__ */ Symbol("mode");
- AWAITDRAIN = /* @__PURE__ */ Symbol("awaitDrain");
- ONDRAIN = /* @__PURE__ */ Symbol("ondrain");
- PREFIX = /* @__PURE__ */ Symbol("prefix");
- WriteEntry = class extends Minipass {
- path;
- portable;
- myuid = process.getuid && process.getuid() || 0;
- // until node has builtin pwnam functions, this'll have to do
- myuser = process.env.USER || "";
- maxReadSize;
- linkCache;
- statCache;
- preservePaths;
- cwd;
- strict;
- mtime;
- noPax;
- noMtime;
- prefix;
- fd;
- blockLen = 0;
- blockRemain = 0;
- buf;
- pos = 0;
- remain = 0;
- length = 0;
- offset = 0;
- win32;
- absolute;
- header;
- type;
- linkpath;
- stat;
- onWriteEntry;
- #hadError = false;
- constructor(p, opt_ = {}) {
- const opt = dealias(opt_);
- super();
- this.path = normalizeWindowsPath(p);
- this.portable = !!opt.portable;
- this.maxReadSize = opt.maxReadSize || maxReadSize;
- this.linkCache = opt.linkCache || /* @__PURE__ */ new Map();
- this.statCache = opt.statCache || /* @__PURE__ */ new Map();
- this.preservePaths = !!opt.preservePaths;
- this.cwd = normalizeWindowsPath(opt.cwd || process.cwd());
- this.strict = !!opt.strict;
- this.noPax = !!opt.noPax;
- this.noMtime = !!opt.noMtime;
- this.mtime = opt.mtime;
- this.prefix = opt.prefix ? normalizeWindowsPath(opt.prefix) : void 0;
- this.onWriteEntry = opt.onWriteEntry;
- if (typeof opt.onwarn === "function") {
- this.on("warn", opt.onwarn);
- }
- let pathWarn = false;
- if (!this.preservePaths) {
- const [root, stripped] = stripAbsolutePath(this.path);
- if (root && typeof stripped === "string") {
- this.path = stripped;
- pathWarn = root;
- }
- }
- this.win32 = !!opt.win32 || process.platform === "win32";
- if (this.win32) {
- this.path = decode(this.path.replaceAll(/\\/g, "/"));
- p = p.replaceAll(/\\/g, "/");
- }
- this.absolute = normalizeWindowsPath(opt.absolute || import_path9.default.resolve(this.cwd, p));
- if (this.path === "") {
- this.path = "./";
- }
- if (pathWarn) {
- this.warn("TAR_ENTRY_INFO", `stripping ${pathWarn} from absolute path`, {
- entry: this,
- path: pathWarn + this.path
- });
- }
- const cs = this.statCache.get(this.absolute);
- if (cs) {
- this[ONLSTAT](cs);
- } else {
- this[LSTAT]();
- }
- }
- warn(code2, message, data = {}) {
- return warnMethod(this, code2, message, data);
- }
- emit(ev, ...data) {
- if (ev === "error") {
- this.#hadError = true;
- }
- return super.emit(ev, ...data);
- }
- [LSTAT]() {
- import_fs11.default.lstat(this.absolute, (er, stat) => {
- if (er) {
- return this.emit("error", er);
- }
- this[ONLSTAT](stat);
- });
- }
- [ONLSTAT](stat) {
- this.statCache.set(this.absolute, stat);
- this.stat = stat;
- if (!stat.isFile()) {
- stat.size = 0;
- }
- this.type = getType(stat);
- this.emit("stat", stat);
- this[PROCESS]();
- }
- [PROCESS]() {
- switch (this.type) {
- case "File":
- return this[FILE2]();
- case "Directory":
- return this[DIRECTORY2]();
- case "SymbolicLink":
- return this[SYMLINK2]();
- // unsupported types are ignored.
- default:
- return this.end();
- }
- }
- [MODE](mode) {
- return modeFix(mode, this.type === "Directory", this.portable);
- }
- [PREFIX](path16) {
- return prefixPath(path16, this.prefix);
- }
- [HEADER]() {
- if (!this.stat) {
- throw new Error("cannot write header before stat");
- }
- if (this.type === "Directory" && this.portable) {
- this.noMtime = true;
- }
- this.onWriteEntry?.(this);
- this.header = new Header({
- path: this[PREFIX](this.path),
- // only apply the prefix to hard links.
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
- // only the permissions and setuid/setgid/sticky bitflags
- // not the higher-order bits that specify file type
- mode: this[MODE](this.stat.mode),
- uid: this.portable ? void 0 : this.stat.uid,
- gid: this.portable ? void 0 : this.stat.gid,
- size: this.stat.size,
- mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
- /* c8 ignore next */
- type: this.type === "Unsupported" ? void 0 : this.type,
- uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
- atime: this.portable ? void 0 : this.stat.atime,
- ctime: this.portable ? void 0 : this.stat.ctime
- });
- if (this.header.encode() && !this.noPax) {
- super.write(new Pax({
- atime: this.portable ? void 0 : this.header.atime,
- ctime: this.portable ? void 0 : this.header.ctime,
- gid: this.portable ? void 0 : this.header.gid,
- mtime: this.noMtime ? void 0 : this.mtime || this.header.mtime,
- path: this[PREFIX](this.path),
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
- size: this.header.size,
- uid: this.portable ? void 0 : this.header.uid,
- uname: this.portable ? void 0 : this.header.uname,
- dev: this.portable ? void 0 : this.stat.dev,
- ino: this.portable ? void 0 : this.stat.ino,
- nlink: this.portable ? void 0 : this.stat.nlink
- }).encode());
- }
- const block = this.header?.block;
- if (!block) {
- throw new Error("failed to encode header");
- }
- super.write(block);
- }
- [DIRECTORY2]() {
- if (!this.stat) {
- throw new Error("cannot create directory entry without stat");
- }
- if (this.path.slice(-1) !== "/") {
- this.path += "/";
- }
- this.stat.size = 0;
- this[HEADER]();
- this.end();
- }
- [SYMLINK2]() {
- import_fs11.default.readlink(this.absolute, (er, linkpath) => {
- if (er) {
- return this.emit("error", er);
- }
- this[ONREADLINK](linkpath);
- });
- }
- [ONREADLINK](linkpath) {
- this.linkpath = normalizeWindowsPath(linkpath);
- this[HEADER]();
- this.end();
- }
- [HARDLINK2](linkpath) {
- if (!this.stat) {
- throw new Error("cannot create link entry without stat");
- }
- this.type = "Link";
- this.linkpath = normalizeWindowsPath(import_path9.default.relative(this.cwd, linkpath));
- this.stat.size = 0;
- this[HEADER]();
- this.end();
- }
- [FILE2]() {
- if (!this.stat) {
- throw new Error("cannot create file entry without stat");
- }
- if (this.stat.nlink > 1) {
- const linkKey = `${this.stat.dev}:${this.stat.ino}`;
- const linkpath = this.linkCache.get(linkKey);
- if (linkpath?.indexOf(this.cwd) === 0) {
- return this[HARDLINK2](linkpath);
- }
- this.linkCache.set(linkKey, this.absolute);
- }
- this[HEADER]();
- if (this.stat.size === 0) {
- return this.end();
- }
- this[OPENFILE]();
- }
- [OPENFILE]() {
- import_fs11.default.open(this.absolute, "r", (er, fd) => {
- if (er) {
- return this.emit("error", er);
- }
- this[ONOPENFILE](fd);
- });
- }
- [ONOPENFILE](fd) {
- this.fd = fd;
- if (this.#hadError) {
- return this[CLOSE]();
- }
- if (!this.stat) {
- throw new Error("should stat before calling onopenfile");
- }
- this.blockLen = 512 * Math.ceil(this.stat.size / 512);
- this.blockRemain = this.blockLen;
- const bufLen = Math.min(this.blockLen, this.maxReadSize);
- this.buf = Buffer.allocUnsafe(bufLen);
- this.offset = 0;
- this.pos = 0;
- this.remain = this.stat.size;
- this.length = this.buf.length;
- this[READ2]();
- }
- [READ2]() {
- const { fd, buf, offset, length, pos: pos2 } = this;
- if (fd === void 0 || buf === void 0) {
- throw new Error("cannot read file without first opening");
- }
- import_fs11.default.read(fd, buf, offset, length, pos2, (er, bytesRead) => {
- if (er) {
- return this[CLOSE](() => this.emit("error", er));
- }
- this[ONREAD](bytesRead);
- });
- }
- /* c8 ignore start */
- [CLOSE](cb = () => {
- }) {
- if (this.fd !== void 0)
- import_fs11.default.close(this.fd, cb);
- }
- [ONREAD](bytesRead) {
- if (bytesRead <= 0 && this.remain > 0) {
- const er = Object.assign(new Error("encountered unexpected EOF"), {
- path: this.absolute,
- syscall: "read",
- code: "EOF"
- });
- return this[CLOSE](() => this.emit("error", er));
- }
- if (bytesRead > this.remain) {
- const er = Object.assign(new Error("did not encounter expected EOF"), {
- path: this.absolute,
- syscall: "read",
- code: "EOF"
- });
- return this[CLOSE](() => this.emit("error", er));
- }
- if (!this.buf) {
- throw new Error("should have created buffer prior to reading");
- }
- if (bytesRead === this.remain) {
- for (let i = bytesRead; i < this.length && bytesRead < this.blockRemain; i++) {
- this.buf[i + this.offset] = 0;
- bytesRead++;
- this.remain++;
- }
- }
- const chunk = this.offset === 0 && bytesRead === this.buf.length ? this.buf : this.buf.subarray(this.offset, this.offset + bytesRead);
- const flushed = this.write(chunk);
- if (!flushed) {
- this[AWAITDRAIN](() => this[ONDRAIN]());
- } else {
- this[ONDRAIN]();
- }
- }
- [AWAITDRAIN](cb) {
- this.once("drain", cb);
- }
- write(chunk, encoding, cb) {
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
- }
- if (typeof chunk === "string") {
- chunk = Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
- }
- if (this.blockRemain < chunk.length) {
- const er = Object.assign(new Error("writing more data than expected"), {
- path: this.absolute
- });
- return this.emit("error", er);
- }
- this.remain -= chunk.length;
- this.blockRemain -= chunk.length;
- this.pos += chunk.length;
- this.offset += chunk.length;
- return super.write(chunk, null, cb);
- }
- [ONDRAIN]() {
- if (!this.remain) {
- if (this.blockRemain) {
- super.write(Buffer.alloc(this.blockRemain));
- }
- return this[CLOSE]((er) => er ? this.emit("error", er) : this.end());
- }
- if (!this.buf) {
- throw new Error("buffer lost somehow in ONDRAIN");
- }
- if (this.offset >= this.length) {
- this.buf = Buffer.allocUnsafe(Math.min(this.blockRemain, this.buf.length));
- this.offset = 0;
- }
- this.length = this.buf.length - this.offset;
- this[READ2]();
- }
- };
- WriteEntrySync = class extends WriteEntry {
- sync = true;
- [LSTAT]() {
- this[ONLSTAT](import_fs11.default.lstatSync(this.absolute));
- }
- [SYMLINK2]() {
- this[ONREADLINK](import_fs11.default.readlinkSync(this.absolute));
- }
- [OPENFILE]() {
- this[ONOPENFILE](import_fs11.default.openSync(this.absolute, "r"));
- }
- [READ2]() {
- let threw = true;
- try {
- const { fd, buf, offset, length, pos: pos2 } = this;
- if (fd === void 0 || buf === void 0) {
- throw new Error("fd and buf must be set in READ method");
- }
- const bytesRead = import_fs11.default.readSync(fd, buf, offset, length, pos2);
- this[ONREAD](bytesRead);
- threw = false;
- } finally {
- if (threw) {
- try {
- this[CLOSE](() => {
- });
- } catch {
- }
- }
- }
- }
- [AWAITDRAIN](cb) {
- cb();
- }
- /* c8 ignore start */
- [CLOSE](cb = () => {
- }) {
- if (this.fd !== void 0)
- import_fs11.default.closeSync(this.fd);
- cb();
- }
- };
- WriteEntryTar = class extends Minipass {
- blockLen = 0;
- blockRemain = 0;
- buf = 0;
- pos = 0;
- remain = 0;
- length = 0;
- preservePaths;
- portable;
- strict;
- noPax;
- noMtime;
- readEntry;
- type;
- prefix;
- path;
- mode;
- uid;
- gid;
- uname;
- gname;
- header;
- mtime;
- atime;
- ctime;
- linkpath;
- size;
- onWriteEntry;
- warn(code2, message, data = {}) {
- return warnMethod(this, code2, message, data);
- }
- constructor(readEntry, opt_ = {}) {
- const opt = dealias(opt_);
- super();
- this.preservePaths = !!opt.preservePaths;
- this.portable = !!opt.portable;
- this.strict = !!opt.strict;
- this.noPax = !!opt.noPax;
- this.noMtime = !!opt.noMtime;
- this.onWriteEntry = opt.onWriteEntry;
- this.readEntry = readEntry;
- const { type } = readEntry;
- if (type === "Unsupported") {
- throw new Error("writing entry that should be ignored");
- }
- this.type = type;
- if (this.type === "Directory" && this.portable) {
- this.noMtime = true;
- }
- this.prefix = opt.prefix;
- this.path = normalizeWindowsPath(readEntry.path);
- this.mode = readEntry.mode !== void 0 ? this[MODE](readEntry.mode) : void 0;
- this.uid = this.portable ? void 0 : readEntry.uid;
- this.gid = this.portable ? void 0 : readEntry.gid;
- this.uname = this.portable ? void 0 : readEntry.uname;
- this.gname = this.portable ? void 0 : readEntry.gname;
- this.size = readEntry.size;
- this.mtime = this.noMtime ? void 0 : opt.mtime || readEntry.mtime;
- this.atime = this.portable ? void 0 : readEntry.atime;
- this.ctime = this.portable ? void 0 : readEntry.ctime;
- this.linkpath = readEntry.linkpath !== void 0 ? normalizeWindowsPath(readEntry.linkpath) : void 0;
- if (typeof opt.onwarn === "function") {
- this.on("warn", opt.onwarn);
- }
- let pathWarn = false;
- if (!this.preservePaths) {
- const [root, stripped] = stripAbsolutePath(this.path);
- if (root && typeof stripped === "string") {
- this.path = stripped;
- pathWarn = root;
- }
- }
- this.remain = readEntry.size;
- this.blockRemain = readEntry.startBlockSize;
- this.onWriteEntry?.(this);
- this.header = new Header({
- path: this[PREFIX](this.path),
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
- // only the permissions and setuid/setgid/sticky bitflags
- // not the higher-order bits that specify file type
- mode: this.mode,
- uid: this.portable ? void 0 : this.uid,
- gid: this.portable ? void 0 : this.gid,
- size: this.size,
- mtime: this.noMtime ? void 0 : this.mtime,
- type: this.type,
- uname: this.portable ? void 0 : this.uname,
- atime: this.portable ? void 0 : this.atime,
- ctime: this.portable ? void 0 : this.ctime
- });
- if (pathWarn) {
- this.warn("TAR_ENTRY_INFO", `stripping ${pathWarn} from absolute path`, {
- entry: this,
- path: pathWarn + this.path
- });
- }
- if (this.header.encode() && !this.noPax) {
- super.write(new Pax({
- atime: this.portable ? void 0 : this.atime,
- ctime: this.portable ? void 0 : this.ctime,
- gid: this.portable ? void 0 : this.gid,
- mtime: this.noMtime ? void 0 : this.mtime,
- path: this[PREFIX](this.path),
- linkpath: this.type === "Link" && this.linkpath !== void 0 ? this[PREFIX](this.linkpath) : this.linkpath,
- size: this.size,
- uid: this.portable ? void 0 : this.uid,
- uname: this.portable ? void 0 : this.uname,
- dev: this.portable ? void 0 : this.readEntry.dev,
- ino: this.portable ? void 0 : this.readEntry.ino,
- nlink: this.portable ? void 0 : this.readEntry.nlink
- }).encode());
- }
- const b = this.header?.block;
- if (!b)
- throw new Error("failed to encode header");
- super.write(b);
- readEntry.pipe(this);
- }
- [PREFIX](path16) {
- return prefixPath(path16, this.prefix);
- }
- [MODE](mode) {
- return modeFix(mode, this.type === "Directory", this.portable);
- }
- write(chunk, encoding, cb) {
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
- }
- if (typeof chunk === "string") {
- chunk = Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8");
- }
- const writeLen = chunk.length;
- if (writeLen > this.blockRemain) {
- throw new Error("writing more to entry than is appropriate");
- }
- this.blockRemain -= writeLen;
- return super.write(chunk, cb);
- }
- end(chunk, encoding, cb) {
- if (this.blockRemain) {
- super.write(Buffer.alloc(this.blockRemain));
- }
- if (typeof chunk === "function") {
- cb = chunk;
- encoding = void 0;
- chunk = void 0;
- }
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
- }
- if (typeof chunk === "string") {
- chunk = Buffer.from(chunk, encoding ?? "utf8");
- }
- if (cb)
- this.once("finish", cb);
- if (chunk)
- super.end(chunk, cb);
- else
- super.end(cb);
- return this;
- }
- };
- getType = (stat) => stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : "Unsupported";
- }
-});
-
-// node_modules/yallist/dist/esm/index.js
-function insertAfter(self2, node, value) {
- const prev = node;
- const next = node ? node.next : self2.head;
- const inserted = new Node(value, prev, next, self2);
- if (inserted.next === void 0) {
- self2.tail = inserted;
- }
- if (inserted.prev === void 0) {
- self2.head = inserted;
- }
- self2.length++;
- return inserted;
-}
-function push(self2, item) {
- self2.tail = new Node(item, self2.tail, void 0, self2);
- if (!self2.head) {
- self2.head = self2.tail;
- }
- self2.length++;
-}
-function unshift(self2, item) {
- self2.head = new Node(item, void 0, self2.head, self2);
- if (!self2.tail) {
- self2.tail = self2.head;
- }
- self2.length++;
-}
-var Yallist, Node;
-var init_esm5 = __esm({
- "node_modules/yallist/dist/esm/index.js"() {
- Yallist = class _Yallist {
- tail;
- head;
- length = 0;
- static create(list2 = []) {
- return new _Yallist(list2);
- }
- constructor(list2 = []) {
- for (const item of list2) {
- this.push(item);
- }
- }
- *[Symbol.iterator]() {
- for (let walker = this.head; walker; walker = walker.next) {
- yield walker.value;
- }
- }
- removeNode(node) {
- if (node.list !== this) {
- throw new Error("removing node which does not belong to this list");
- }
- const next = node.next;
- const prev = node.prev;
- if (next) {
- next.prev = prev;
- }
- if (prev) {
- prev.next = next;
- }
- if (node === this.head) {
- this.head = next;
- }
- if (node === this.tail) {
- this.tail = prev;
- }
- this.length--;
- node.next = void 0;
- node.prev = void 0;
- node.list = void 0;
- return next;
- }
- unshiftNode(node) {
- if (node === this.head) {
- return;
- }
- if (node.list) {
- node.list.removeNode(node);
- }
- const head = this.head;
- node.list = this;
- node.next = head;
- if (head) {
- head.prev = node;
- }
- this.head = node;
- if (!this.tail) {
- this.tail = node;
- }
- this.length++;
- }
- pushNode(node) {
- if (node === this.tail) {
- return;
- }
- if (node.list) {
- node.list.removeNode(node);
- }
- const tail = this.tail;
- node.list = this;
- node.prev = tail;
- if (tail) {
- tail.next = node;
- }
- this.tail = node;
- if (!this.head) {
- this.head = node;
- }
- this.length++;
- }
- push(...args) {
- for (let i = 0, l = args.length; i < l; i++) {
- push(this, args[i]);
- }
- return this.length;
- }
- unshift(...args) {
- for (var i = 0, l = args.length; i < l; i++) {
- unshift(this, args[i]);
- }
- return this.length;
- }
- pop() {
- if (!this.tail) {
- return void 0;
- }
- const res = this.tail.value;
- const t = this.tail;
- this.tail = this.tail.prev;
- if (this.tail) {
- this.tail.next = void 0;
- } else {
- this.head = void 0;
- }
- t.list = void 0;
- this.length--;
- return res;
- }
- shift() {
- if (!this.head) {
- return void 0;
- }
- const res = this.head.value;
- const h = this.head;
- this.head = this.head.next;
- if (this.head) {
- this.head.prev = void 0;
- } else {
- this.tail = void 0;
- }
- h.list = void 0;
- this.length--;
- return res;
- }
- forEach(fn2, thisp) {
- thisp = thisp || this;
- for (let walker = this.head, i = 0; !!walker; i++) {
- fn2.call(thisp, walker.value, i, this);
- walker = walker.next;
- }
- }
- forEachReverse(fn2, thisp) {
- thisp = thisp || this;
- for (let walker = this.tail, i = this.length - 1; !!walker; i--) {
- fn2.call(thisp, walker.value, i, this);
- walker = walker.prev;
- }
- }
- get(n) {
- let i = 0;
- let walker = this.head;
- for (; !!walker && i < n; i++) {
- walker = walker.next;
- }
- if (i === n && !!walker) {
- return walker.value;
- }
- }
- getReverse(n) {
- let i = 0;
- let walker = this.tail;
- for (; !!walker && i < n; i++) {
- walker = walker.prev;
- }
- if (i === n && !!walker) {
- return walker.value;
- }
- }
- map(fn2, thisp) {
- thisp = thisp || this;
- const res = new _Yallist();
- for (let walker = this.head; !!walker; ) {
- res.push(fn2.call(thisp, walker.value, this));
- walker = walker.next;
- }
- return res;
- }
- mapReverse(fn2, thisp) {
- thisp = thisp || this;
- var res = new _Yallist();
- for (let walker = this.tail; !!walker; ) {
- res.push(fn2.call(thisp, walker.value, this));
- walker = walker.prev;
- }
- return res;
- }
- reduce(fn2, initial) {
- let acc;
- let walker = this.head;
- if (arguments.length > 1) {
- acc = initial;
- } else if (this.head) {
- walker = this.head.next;
- acc = this.head.value;
- } else {
- throw new TypeError("Reduce of empty list with no initial value");
- }
- for (var i = 0; !!walker; i++) {
- acc = fn2(acc, walker.value, i);
- walker = walker.next;
- }
- return acc;
- }
- reduceReverse(fn2, initial) {
- let acc;
- let walker = this.tail;
- if (arguments.length > 1) {
- acc = initial;
- } else if (this.tail) {
- walker = this.tail.prev;
- acc = this.tail.value;
+ function retry() {
+ clearTimeout(retryTimer);
+ retryTimer = void 0;
+ if (fs9[gracefulQueue].length === 0)
+ return;
+ var elem = fs9[gracefulQueue].shift();
+ var fn2 = elem[0];
+ var args = elem[1];
+ var err = elem[2];
+ var startTime = elem[3];
+ var lastTime = elem[4];
+ if (startTime === void 0) {
+ debug("RETRY", fn2.name, args);
+ fn2.apply(null, args);
+ } else if (Date.now() - startTime >= 6e4) {
+ debug("TIMEOUT", fn2.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) {
+ debug("RETRY", fn2.name, args);
+ fn2.apply(null, args.concat([startTime]));
} else {
- throw new TypeError("Reduce of empty list with no initial value");
- }
- for (let i = this.length - 1; !!walker; i--) {
- acc = fn2(acc, walker.value, i);
- walker = walker.prev;
- }
- return acc;
- }
- toArray() {
- const arr = new Array(this.length);
- for (let i = 0, walker = this.head; !!walker; i++) {
- arr[i] = walker.value;
- walker = walker.next;
- }
- return arr;
- }
- toArrayReverse() {
- const arr = new Array(this.length);
- for (let i = 0, walker = this.tail; !!walker; i++) {
- arr[i] = walker.value;
- walker = walker.prev;
- }
- return arr;
- }
- slice(from = 0, to = this.length) {
- if (to < 0) {
- to += this.length;
- }
- if (from < 0) {
- from += this.length;
- }
- const ret = new _Yallist();
- if (to < from || to < 0) {
- return ret;
- }
- if (from < 0) {
- from = 0;
- }
- if (to > this.length) {
- to = this.length;
- }
- let walker = this.head;
- let i = 0;
- for (i = 0; !!walker && i < from; i++) {
- walker = walker.next;
- }
- for (; !!walker && i < to; i++, walker = walker.next) {
- ret.push(walker.value);
- }
- return ret;
- }
- sliceReverse(from = 0, to = this.length) {
- if (to < 0) {
- to += this.length;
- }
- if (from < 0) {
- from += this.length;
- }
- const ret = new _Yallist();
- if (to < from || to < 0) {
- return ret;
- }
- if (from < 0) {
- from = 0;
- }
- if (to > this.length) {
- to = this.length;
- }
- let i = this.length;
- let walker = this.tail;
- for (; !!walker && i > to; i--) {
- walker = walker.prev;
- }
- for (; !!walker && i > from; i--, walker = walker.prev) {
- ret.push(walker.value);
- }
- return ret;
- }
- splice(start, deleteCount = 0, ...nodes) {
- if (start > this.length) {
- start = this.length - 1;
- }
- if (start < 0) {
- start = this.length + start;
- }
- let walker = this.head;
- for (let i = 0; !!walker && i < start; i++) {
- walker = walker.next;
+ fs9[gracefulQueue].push(elem);
}
- const ret = [];
- for (let i = 0; !!walker && i < deleteCount; i++) {
- ret.push(walker.value);
- walker = this.removeNode(walker);
- }
- if (!walker) {
- walker = this.tail;
- } else if (walker !== this.tail) {
- walker = walker.prev;
- }
- for (const v of nodes) {
- walker = insertAfter(this, walker, v);
- }
- return ret;
}
- reverse() {
- const head = this.head;
- const tail = this.tail;
- for (let walker = head; !!walker; walker = walker.prev) {
- const p = walker.prev;
- walker.prev = walker.next;
- walker.next = p;
- }
- this.head = tail;
- this.tail = head;
- return this;
- }
- };
- Node = class {
- list;
- next;
- prev;
- value;
- constructor(value, prev, next, list2) {
- this.list = list2;
- this.value = value;
- if (prev) {
- prev.next = this;
- this.prev = prev;
- } else {
- this.prev = void 0;
- }
- if (next) {
- next.prev = this;
- this.next = next;
- } else {
- this.next = void 0;
- }
+ if (retryTimer === void 0) {
+ retryTimer = setTimeout(retry, 0);
}
- };
+ }
}
});
-// node_modules/tar/dist/esm/pack.js
-var import_fs12, import_path10, PackJob, EOF2, ONSTAT, ENDED3, QUEUE2, PENDINGLINKS, CURRENT, PROCESS2, PROCESSING, PROCESSJOB, JOBS, JOBDONE, ADDFSENTRY, ADDTARENTRY, STAT, READDIR, ONREADDIR, PIPE, ENTRY, ENTRYOPT, WRITEENTRYCLASS, WRITE, ONDRAIN2, Pack, PackSync;
-var init_pack = __esm({
- "node_modules/tar/dist/esm/pack.js"() {
- import_fs12 = __toESM(require("fs"), 1);
- init_write_entry();
- init_esm();
- init_esm3();
- init_esm5();
- init_warn_method();
- import_path10 = __toESM(require("path"), 1);
- init_normalize_windows_path();
- PackJob = class {
- path;
- absolute;
- entry;
- stat;
- readdir;
- pending = false;
- pendingLink = false;
- ignore = false;
- piped = false;
- constructor(path16, absolute) {
- this.path = path16 || "./";
- this.absolute = absolute;
- }
- };
- EOF2 = Buffer.alloc(1024);
- ONSTAT = /* @__PURE__ */ Symbol("onStat");
- ENDED3 = /* @__PURE__ */ Symbol("ended");
- QUEUE2 = /* @__PURE__ */ Symbol("queue");
- PENDINGLINKS = /* @__PURE__ */ Symbol("pendingLinks");
- CURRENT = /* @__PURE__ */ Symbol("current");
- PROCESS2 = /* @__PURE__ */ Symbol("process");
- PROCESSING = /* @__PURE__ */ Symbol("processing");
- PROCESSJOB = /* @__PURE__ */ Symbol("processJob");
- JOBS = /* @__PURE__ */ Symbol("jobs");
- JOBDONE = /* @__PURE__ */ Symbol("jobDone");
- ADDFSENTRY = /* @__PURE__ */ Symbol("addFSEntry");
- ADDTARENTRY = /* @__PURE__ */ Symbol("addTarEntry");
- STAT = /* @__PURE__ */ Symbol("stat");
- READDIR = /* @__PURE__ */ Symbol("readdir");
- ONREADDIR = /* @__PURE__ */ Symbol("onreaddir");
- PIPE = /* @__PURE__ */ Symbol("pipe");
- ENTRY = /* @__PURE__ */ Symbol("entry");
- ENTRYOPT = /* @__PURE__ */ Symbol("entryOpt");
- WRITEENTRYCLASS = /* @__PURE__ */ Symbol("writeEntryClass");
- WRITE = /* @__PURE__ */ Symbol("write");
- ONDRAIN2 = /* @__PURE__ */ Symbol("ondrain");
- Pack = class extends Minipass {
- sync = false;
- opt;
- cwd;
- maxReadSize;
- preservePaths;
- strict;
- noPax;
- prefix;
- linkCache;
- statCache;
- file;
- portable;
- zip;
- readdirCache;
- noDirRecurse;
- follow;
- noMtime;
- mtime;
- filter;
- jobs;
- [WRITEENTRYCLASS];
- onWriteEntry;
- // Note: we actually DO need a linked list here, because we
- // shift() to update the head of the list where we start, but still
- // while that happens, need to know what the next item in the queue
- // will be. Since we do multiple jobs in parallel, it's not as simple
- // as just an Array.shift(), since that would lose the information about
- // the next job in the list. We could add a .next field on the PackJob
- // class, but then we'd have to be tracking the tail of the queue the
- // whole time, and Yallist just does that for us anyway.
- [QUEUE2];
- [PENDINGLINKS] = /* @__PURE__ */ new Map();
- [JOBS] = 0;
- [PROCESSING] = false;
- [ENDED3] = false;
- constructor(opt = {}) {
- super();
- this.opt = opt;
- this.file = opt.file || "";
- this.cwd = opt.cwd || process.cwd();
- this.maxReadSize = opt.maxReadSize;
- this.preservePaths = !!opt.preservePaths;
- this.strict = !!opt.strict;
- this.noPax = !!opt.noPax;
- this.prefix = normalizeWindowsPath(opt.prefix || "");
- this.linkCache = opt.linkCache || /* @__PURE__ */ new Map();
- this.statCache = opt.statCache || /* @__PURE__ */ new Map();
- this.readdirCache = opt.readdirCache || /* @__PURE__ */ new Map();
- this.onWriteEntry = opt.onWriteEntry;
- this[WRITEENTRYCLASS] = WriteEntry;
- if (typeof opt.onwarn === "function") {
- this.on("warn", opt.onwarn);
- }
- this.portable = !!opt.portable;
- if (opt.gzip || opt.brotli || opt.zstd) {
- if ((opt.gzip ? 1 : 0) + (opt.brotli ? 1 : 0) + (opt.zstd ? 1 : 0) > 1) {
- throw new TypeError("gzip, brotli, zstd are mutually exclusive");
- }
- if (opt.gzip) {
- if (typeof opt.gzip !== "object") {
- opt.gzip = {};
- }
- if (this.portable) {
- opt.gzip.portable = true;
- }
- this.zip = new Gzip(opt.gzip);
- }
- if (opt.brotli) {
- if (typeof opt.brotli !== "object") {
- opt.brotli = {};
- }
- this.zip = new BrotliCompress(opt.brotli);
- }
- if (opt.zstd) {
- if (typeof opt.zstd !== "object") {
- opt.zstd = {};
- }
- this.zip = new ZstdCompress(opt.zstd);
- }
- if (!this.zip)
- throw new Error("impossible");
- const zip = this.zip;
- zip.on("data", (chunk) => super.write(chunk));
- zip.on("end", () => super.end());
- zip.on("drain", () => this[ONDRAIN2]());
- this.on("resume", () => zip.resume());
- } else {
- this.on("drain", this[ONDRAIN2]);
- }
- this.noDirRecurse = !!opt.noDirRecurse;
- this.follow = !!opt.follow;
- this.noMtime = !!opt.noMtime;
- if (opt.mtime)
- this.mtime = opt.mtime;
- this.filter = typeof opt.filter === "function" ? opt.filter : () => true;
- this[QUEUE2] = new Yallist();
- this[JOBS] = 0;
- this.jobs = Number(opt.jobs) || 4;
- this[PROCESSING] = false;
- this[ENDED3] = false;
- }
- [WRITE](chunk) {
- return super.write(chunk);
- }
- add(path16) {
- this.write(path16);
- return this;
- }
- end(path16, encoding, cb) {
- if (typeof path16 === "function") {
- cb = path16;
- path16 = void 0;
- }
- if (typeof encoding === "function") {
- cb = encoding;
- encoding = void 0;
- }
- if (path16) {
- this.add(path16);
- }
- this[ENDED3] = true;
- this[PROCESS2]();
- if (cb)
- cb();
- return this;
- }
- write(path16) {
- if (this[ENDED3]) {
- throw new Error("write after end");
- }
- if (typeof path16 === "string") {
- this[ADDFSENTRY](path16);
- } else {
- this[ADDTARENTRY](path16);
- }
- return this.flowing;
- }
- [ADDTARENTRY](p) {
- const absolute = normalizeWindowsPath(import_path10.default.resolve(this.cwd, p.path));
- if (!this.filter(p.path, p)) {
- p.resume();
- } else {
- const job = new PackJob(p.path, absolute);
- job.entry = new WriteEntryTar(p, this[ENTRYOPT](job));
- job.entry.on("end", () => this[JOBDONE](job));
- this[JOBS] += 1;
- this[QUEUE2].push(job);
- }
- this[PROCESS2]();
- }
- [ADDFSENTRY](p) {
- const absolute = normalizeWindowsPath(import_path10.default.resolve(this.cwd, p));
- this[QUEUE2].push(new PackJob(p, absolute));
- this[PROCESS2]();
- }
- [STAT](job) {
- job.pending = true;
- this[JOBS] += 1;
- const stat = this.follow ? "stat" : "lstat";
- import_fs12.default[stat](job.absolute, (er, stat2) => {
- job.pending = false;
- this[JOBS] -= 1;
- if (er) {
- this.emit("error", er);
- } else {
- this[ONSTAT](job, stat2);
- }
- });
- }
- [ONSTAT](job, stat) {
- this.statCache.set(job.absolute, stat);
- job.stat = stat;
- if (!this.filter(job.path, stat)) {
- job.ignore = true;
- } else if (stat.isFile() && stat.nlink > 1 && !this.linkCache.get(`${stat.dev}:${stat.ino}`) && !this.sync) {
- if (job === this[CURRENT]) {
- this[PROCESSJOB](job);
- } else {
- const key = `${stat.dev}:${stat.ino}`;
- const pending = this[PENDINGLINKS].get(key);
- if (pending)
- pending.push(job);
- else
- this[PENDINGLINKS].set(key, [job]);
- job.pendingLink = true;
- job.pending = true;
- }
- }
- this[PROCESS2]();
- }
- [READDIR](job) {
- job.pending = true;
- this[JOBS] += 1;
- import_fs12.default.readdir(job.absolute, (er, entries) => {
- job.pending = false;
- this[JOBS] -= 1;
- if (er) {
- return this.emit("error", er);
- }
- this[ONREADDIR](job, entries);
- });
+// node_modules/@zkochan/cmd-shim/index.js
+var require_cmd_shim = __commonJS({
+ "node_modules/@zkochan/cmd-shim/index.js"(exports2, module2) {
+ "use strict";
+ cmdShim2.ifExists = cmdShimIfExists;
+ var util_1 = require("util");
+ var path10 = require("path");
+ var isWindows = require_is_windows();
+ var CMD_EXTENSION = require_cmd_extension();
+ var shebangExpr = /^#!\s*(?:\/usr\/bin\/env(?:\s+-S\s*)?)?\s*([^ \t]+)(.*)$/;
+ var DEFAULT_OPTIONS = {
+ // Create PowerShell file by default if the option hasn't been specified
+ createPwshFile: true,
+ createCmdFile: isWindows(),
+ fs: require_graceful_fs()
+ };
+ var extensionToProgramMap = /* @__PURE__ */ new Map([
+ [".js", "node"],
+ [".cjs", "node"],
+ [".mjs", "node"],
+ [".cmd", "cmd"],
+ [".bat", "cmd"],
+ [".ps1", "pwsh"],
+ [".sh", "sh"]
+ ]);
+ function ingestOptions(opts) {
+ const opts_ = { ...DEFAULT_OPTIONS, ...opts };
+ const fs9 = opts_.fs;
+ opts_.fs_ = {
+ chmod: fs9.chmod ? (0, util_1.promisify)(fs9.chmod) : (async () => {
+ }),
+ mkdir: (0, util_1.promisify)(fs9.mkdir),
+ readFile: (0, util_1.promisify)(fs9.readFile),
+ stat: (0, util_1.promisify)(fs9.stat),
+ unlink: (0, util_1.promisify)(fs9.unlink),
+ writeFile: (0, util_1.promisify)(fs9.writeFile)
+ };
+ return opts_;
+ }
+ async function cmdShim2(src, to, opts) {
+ const opts_ = ingestOptions(opts);
+ await cmdShim_(src, to, opts_);
+ }
+ function cmdShimIfExists(src, to, opts) {
+ return cmdShim2(src, to, opts).catch(() => {
+ });
+ }
+ function rm(path11, opts) {
+ return opts.fs_.unlink(path11).catch(() => {
+ });
+ }
+ async function cmdShim_(src, to, opts) {
+ const srcRuntimeInfo = await searchScriptRuntime(src, opts);
+ await writeShimsPreCommon(to, opts);
+ return writeAllShims(src, to, srcRuntimeInfo, opts);
+ }
+ function writeShimsPreCommon(target, opts) {
+ return opts.fs_.mkdir(path10.dirname(target), { recursive: true });
+ }
+ function writeAllShims(src, to, srcRuntimeInfo, opts) {
+ const opts_ = ingestOptions(opts);
+ const generatorAndExts = [{ generator: generateShShim, extension: "" }];
+ if (opts_.createCmdFile) {
+ generatorAndExts.push({ generator: generateCmdShim, extension: CMD_EXTENSION });
}
- [ONREADDIR](job, entries) {
- this.readdirCache.set(job.absolute, entries);
- job.readdir = entries;
- this[PROCESS2]();
+ if (opts_.createPwshFile) {
+ generatorAndExts.push({ generator: generatePwshShim, extension: ".ps1" });
}
- [PROCESS2]() {
- if (this[PROCESSING]) {
- return;
- }
- this[PROCESSING] = true;
- for (let w = this[QUEUE2].head; !!w && this[JOBS] < this.jobs; w = w.next) {
- this[PROCESSJOB](w.value);
- if (w.value.ignore) {
- const p = w.next;
- this[QUEUE2].removeNode(w);
- w.next = p;
- }
+ return Promise.all(generatorAndExts.map((generatorAndExt) => writeShim(src, to + generatorAndExt.extension, srcRuntimeInfo, generatorAndExt.generator, opts_)));
+ }
+ function writeShimPre(target, opts) {
+ return rm(target, opts);
+ }
+ function writeShimPost(target, opts) {
+ return chmodShim(target, opts);
+ }
+ async function searchScriptRuntime(target, opts) {
+ try {
+ const data = await opts.fs_.readFile(target, "utf8");
+ const firstLine = data.trim().split(/\r*\n/)[0];
+ const shebang = firstLine.match(shebangExpr);
+ if (!shebang) {
+ const targetExtension = path10.extname(target).toLowerCase();
+ return {
+ // undefined if extension is unknown but it's converted to null.
+ program: extensionToProgramMap.get(targetExtension) || null,
+ additionalArgs: ""
+ };
}
- this[PROCESSING] = false;
- if (this[ENDED3] && this[QUEUE2].length === 0 && this[JOBS] === 0) {
- if (this.zip) {
- this.zip.end(EOF2);
- } else {
- super.write(EOF2);
- super.end();
- }
- }
- }
- get [CURRENT]() {
- return this[QUEUE2] && this[QUEUE2].head && this[QUEUE2].head.value;
- }
- [JOBDONE](job) {
- this[QUEUE2].shift();
- this[JOBS] -= 1;
- const { stat } = job;
- if (stat && stat.isFile() && stat.nlink > 1) {
- const key = `${stat.dev}:${stat.ino}`;
- const pending = this[PENDINGLINKS].get(key);
- if (pending) {
- this[PENDINGLINKS].delete(key);
- for (const job2 of pending) {
- job2.pending = false;
- this[PROCESSJOB](job2);
- }
- }
+ return {
+ program: shebang[1],
+ additionalArgs: shebang[2]
+ };
+ } catch (err) {
+ if (!isWindows() || err.code !== "ENOENT")
+ throw err;
+ if (await opts.fs_.stat(`${target}${getExeExtension()}`)) {
+ return {
+ program: null,
+ additionalArgs: ""
+ };
}
- this[PROCESS2]();
+ throw err;
}
- [PROCESSJOB](job) {
- if (job.pending && job.pendingLink && job === this[CURRENT]) {
- job.pending = false;
- job.pendingLink = false;
- }
- if (job.pending) {
- return;
- }
- if (job.entry) {
- if (job === this[CURRENT] && !job.piped) {
- this[PIPE](job);
- }
- return;
- }
- if (!job.stat) {
- const sc = this.statCache.get(job.absolute);
- if (sc) {
- this[ONSTAT](job, sc);
- } else {
- this[STAT](job);
- }
- }
- if (!job.stat) {
- return;
- }
- if (job.ignore) {
- return;
- }
- if (!this.noDirRecurse && job.stat.isDirectory() && !job.readdir) {
- const rc = this.readdirCache.get(job.absolute);
- if (rc) {
- this[ONREADDIR](job, rc);
- } else {
- this[READDIR](job);
- }
- if (!job.readdir) {
- return;
- }
- }
- job.entry = this[ENTRY](job);
- if (!job.entry) {
- job.ignore = true;
- return;
- }
- if (job === this[CURRENT] && !job.piped) {
- this[PIPE](job);
- }
+ }
+ function getExeExtension() {
+ let cmdExtension;
+ if (process.env.PATHEXT) {
+ cmdExtension = process.env.PATHEXT.split(path10.delimiter).find((ext) => ext.toLowerCase() === ".exe");
}
- [ENTRYOPT](job) {
- return {
- onwarn: (code2, msg, data) => this.warn(code2, msg, data),
- noPax: this.noPax,
- cwd: this.cwd,
- absolute: job.absolute,
- preservePaths: this.preservePaths,
- maxReadSize: this.maxReadSize,
- strict: this.strict,
- portable: this.portable,
- linkCache: this.linkCache,
- statCache: this.statCache,
- noMtime: this.noMtime,
- mtime: this.mtime,
- prefix: this.prefix,
- onWriteEntry: this.onWriteEntry
- };
+ return cmdExtension || ".exe";
+ }
+ async function writeShim(src, to, srcRuntimeInfo, generateShimScript, opts) {
+ const defaultArgs = opts.preserveSymlinks ? "--preserve-symlinks" : "";
+ const args = [srcRuntimeInfo.additionalArgs, defaultArgs].filter((arg) => arg).join(" ");
+ opts = Object.assign({}, opts, {
+ prog: srcRuntimeInfo.program,
+ args
+ });
+ await writeShimPre(to, opts);
+ await opts.fs_.writeFile(to, generateShimScript(src, to, opts), "utf8");
+ return writeShimPost(to, opts);
+ }
+ function generateCmdShim(src, to, opts) {
+ const shTarget = path10.relative(path10.dirname(to), src);
+ let target = shTarget.split("/").join("\\");
+ const quotedPathToTarget = path10.isAbsolute(target) ? `"${target}"` : `"%~dp0\\${target}"`;
+ let longProg;
+ let prog = opts.prog;
+ let args = opts.args || "";
+ const nodePath = normalizePathEnvVar(opts.nodePath).win32;
+ const prependToPath = normalizePathEnvVar(opts.prependToPath).win32;
+ if (!prog) {
+ prog = quotedPathToTarget;
+ args = "";
+ target = "";
+ } else if (prog === "node" && opts.nodeExecPath) {
+ prog = `"${opts.nodeExecPath}"`;
+ target = quotedPathToTarget;
+ } else {
+ longProg = `"%~dp0\\${prog}.exe"`;
+ target = quotedPathToTarget;
}
- [ENTRY](job) {
- this[JOBS] += 1;
- try {
- const e = new this[WRITEENTRYCLASS](job.path, this[ENTRYOPT](job));
- return e.on("end", () => this[JOBDONE](job)).on("error", (er) => this.emit("error", er));
- } catch (er) {
- this.emit("error", er);
- }
+ let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : "";
+ let cmd = "@SETLOCAL\r\n";
+ if (prependToPath) {
+ cmd += `@SET "PATH=${prependToPath}:%PATH%"\r
+`;
}
- [ONDRAIN2]() {
- if (this[CURRENT] && this[CURRENT].entry) {
- this[CURRENT].entry.resume();
- }
+ if (nodePath) {
+ cmd += `@IF NOT DEFINED NODE_PATH (\r
+ @SET "NODE_PATH=${nodePath}"\r
+) ELSE (\r
+ @SET "NODE_PATH=${nodePath};%NODE_PATH%"\r
+)\r
+`;
}
- // like .pipe() but using super, because our write() is special
- [PIPE](job) {
- job.piped = true;
- if (job.readdir) {
- job.readdir.forEach((entry) => {
- const p = job.path;
- const base = p === "./" ? "" : p.replace(/\/*$/, "/");
- this[ADDFSENTRY](base + entry);
- });
- }
- const source = job.entry;
- const zip = this.zip;
- if (!source)
- throw new Error("cannot pipe without source");
- if (zip) {
- source.on("data", (chunk) => {
- if (!zip.write(chunk)) {
- source.pause();
- }
- });
- } else {
- source.on("data", (chunk) => {
- if (!super.write(chunk)) {
- source.pause();
- }
- });
- }
+ if (longProg) {
+ cmd += `@IF EXIST ${longProg} (\r
+ ${longProg} ${args} ${target} ${progArgs}%*\r
+) ELSE (\r
+ @SET PATHEXT=%PATHEXT:;.JS;=;%\r
+ ${prog} ${args} ${target} ${progArgs}%*\r
+)\r
+`;
+ } else {
+ cmd += `@${prog} ${args} ${target} ${progArgs}%*\r
+`;
}
- pause() {
- if (this.zip) {
- this.zip.pause();
- }
- return super.pause();
+ return cmd;
+ }
+ function generateShShim(src, to, opts) {
+ let shTarget = path10.relative(path10.dirname(to), src);
+ let shProg = opts.prog && opts.prog.split("\\").join("/");
+ let shLongProg;
+ shTarget = shTarget.split("\\").join("/");
+ const quotedPathToTarget = path10.isAbsolute(shTarget) ? `"${shTarget}"` : `"$basedir/${shTarget}"`;
+ let args = opts.args || "";
+ const shNodePath = normalizePathEnvVar(opts.nodePath).posix;
+ if (!shProg) {
+ shProg = quotedPathToTarget;
+ args = "";
+ shTarget = "";
+ } else if (opts.prog === "node" && opts.nodeExecPath) {
+ shProg = `"${opts.nodeExecPath}"`;
+ shTarget = quotedPathToTarget;
+ } else {
+ shLongProg = `"$basedir/${opts.prog}"`;
+ shTarget = quotedPathToTarget;
}
- warn(code2, message, data = {}) {
- warnMethod(this, code2, message, data);
+ let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : "";
+ let sh = `#!/bin/sh
+basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")
+
+case \`uname\` in
+ *CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
+esac
+
+`;
+ if (opts.prependToPath) {
+ sh += `export PATH="${opts.prependToPath}:$PATH"
+`;
}
- };
- PackSync = class extends Pack {
- sync = true;
- constructor(opt) {
- super(opt);
- this[WRITEENTRYCLASS] = WriteEntrySync;
+ if (shNodePath) {
+ sh += `if [ -z "$NODE_PATH" ]; then
+ export NODE_PATH="${shNodePath}"
+else
+ export NODE_PATH="${shNodePath}:$NODE_PATH"
+fi
+`;
}
- // pause/resume are no-ops in sync streams.
- pause() {
+ if (shLongProg) {
+ sh += `if [ -x ${shLongProg} ]; then
+ exec ${shLongProg} ${args} ${shTarget} ${progArgs}"$@"
+else
+ exec ${shProg} ${args} ${shTarget} ${progArgs}"$@"
+fi
+`;
+ } else {
+ sh += `${shProg} ${args} ${shTarget} ${progArgs}"$@"
+exit $?
+`;
}
- resume() {
+ return sh;
+ }
+ function generatePwshShim(src, to, opts) {
+ let shTarget = path10.relative(path10.dirname(to), src);
+ const shProg = opts.prog && opts.prog.split("\\").join("/");
+ let pwshProg = shProg && `"${shProg}$exe"`;
+ let pwshLongProg;
+ shTarget = shTarget.split("\\").join("/");
+ const quotedPathToTarget = path10.isAbsolute(shTarget) ? `"${shTarget}"` : `"$basedir/${shTarget}"`;
+ let args = opts.args || "";
+ let normalizedNodePathEnvVar = normalizePathEnvVar(opts.nodePath);
+ const nodePath = normalizedNodePathEnvVar.win32;
+ const shNodePath = normalizedNodePathEnvVar.posix;
+ let normalizedPrependPathEnvVar = normalizePathEnvVar(opts.prependToPath);
+ const prependPath = normalizedPrependPathEnvVar.win32;
+ const shPrependPath = normalizedPrependPathEnvVar.posix;
+ if (!pwshProg) {
+ pwshProg = quotedPathToTarget;
+ args = "";
+ shTarget = "";
+ } else if (opts.prog === "node" && opts.nodeExecPath) {
+ pwshProg = `"${opts.nodeExecPath}"`;
+ shTarget = quotedPathToTarget;
+ } else {
+ pwshLongProg = `"$basedir/${opts.prog}$exe"`;
+ shTarget = quotedPathToTarget;
}
- [STAT](job) {
- const stat = this.follow ? "statSync" : "lstatSync";
- this[ONSTAT](job, import_fs12.default[stat](job.absolute));
+ let progArgs = opts.progArgs ? `${opts.progArgs.join(` `)} ` : "";
+ let pwsh = `#!/usr/bin/env pwsh
+$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
+
+$exe=""
+${nodePath || prependPath ? '$pathsep=":"\n' : ""}${nodePath ? `$env_node_path=$env:NODE_PATH
+$new_node_path="${nodePath}"
+` : ""}${prependPath ? `$env_path=$env:PATH
+$prepend_path="${prependPath}"
+` : ""}if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
+ # Fix case when both the Windows and Linux builds of Node
+ # are installed in the same directory
+ $exe=".exe"
+${nodePath || prependPath ? ' $pathsep=";"\n' : ""}}`;
+ if (shNodePath || shPrependPath) {
+ pwsh += ` else {
+${shNodePath ? ` $new_node_path="${shNodePath}"
+` : ""}${shPrependPath ? ` $prepend_path="${shPrependPath}"
+` : ""}}
+`;
}
- [READDIR](job) {
- this[ONREADDIR](job, import_fs12.default.readdirSync(job.absolute));
+ if (shNodePath) {
+ pwsh += `if ([string]::IsNullOrEmpty($env_node_path)) {
+ $env:NODE_PATH=$new_node_path
+} else {
+ $env:NODE_PATH="$new_node_path$pathsep$env_node_path"
+}
+`;
}
- // gotta get it all in this tick
- [PIPE](job) {
- const source = job.entry;
- const zip = this.zip;
- if (job.readdir) {
- job.readdir.forEach((entry) => {
- const p = job.path;
- const base = p === "./" ? "" : p.replace(/\/*$/, "/");
- this[ADDFSENTRY](base + entry);
- });
- }
- if (!source)
- throw new Error("Cannot pipe without source");
- if (zip) {
- source.on("data", (chunk) => {
- zip.write(chunk);
- });
- } else {
- source.on("data", (chunk) => {
- super[WRITE](chunk);
- });
- }
+ if (opts.prependToPath) {
+ pwsh += `
+$env:PATH="$prepend_path$pathsep$env:PATH"
+`;
}
- };
+ if (pwshLongProg) {
+ pwsh += `
+$ret=0
+if (Test-Path ${pwshLongProg}) {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args
+ } else {
+ & ${pwshLongProg} ${args} ${shTarget} ${progArgs}$args
}
-});
-
-// node_modules/tar/dist/esm/create.js
-var create_exports = {};
-__export(create_exports, {
- create: () => create
-});
-var import_node_path8, createFileSync, createFile, addFilesSync, addFilesAsync, createSync, createAsync, create;
-var init_create = __esm({
- "node_modules/tar/dist/esm/create.js"() {
- init_esm2();
- import_node_path8 = __toESM(require("node:path"), 1);
- init_list();
- init_make_command();
- init_pack();
- createFileSync = (opt, files) => {
- const p = new PackSync(opt);
- const stream = new WriteStreamSync(opt.file, {
- mode: opt.mode || 438
- });
- p.pipe(stream);
- addFilesSync(p, files);
- };
- createFile = (opt, files) => {
- const p = new Pack(opt);
- const stream = new WriteStream(opt.file, {
- mode: opt.mode || 438
- });
- p.pipe(stream);
- const promise = new Promise((res, rej) => {
- stream.on("error", rej);
- stream.on("close", res);
- p.on("error", rej);
- });
- addFilesAsync(p, files).catch((er) => p.emit("error", er));
- return promise;
- };
- addFilesSync = (p, files) => {
- files.forEach((file) => {
- if (file.charAt(0) === "@") {
- list({
- file: import_node_path8.default.resolve(p.cwd, file.slice(1)),
- sync: true,
- noResume: true,
- onReadEntry: (entry) => p.add(entry)
- });
- } else {
- p.add(file);
- }
- });
- p.end();
- };
- addFilesAsync = async (p, files) => {
- for (const file of files) {
- if (file.charAt(0) === "@") {
- await list({
- file: import_node_path8.default.resolve(String(p.cwd), file.slice(1)),
- noResume: true,
- onReadEntry: (entry) => {
- p.add(entry);
- }
- });
- } else {
- p.add(file);
- }
+ $ret=$LASTEXITCODE
+} else {
+ # Support pipeline input
+ if ($MyInvocation.ExpectingInput) {
+ $input | & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
+ } else {
+ & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
+ }
+ $ret=$LASTEXITCODE
+}
+${nodePath ? "$env:NODE_PATH=$env_node_path\n" : ""}${prependPath ? "$env:PATH=$env_path\n" : ""}exit $ret
+`;
+ } else {
+ pwsh += `
+# Support pipeline input
+if ($MyInvocation.ExpectingInput) {
+ $input | & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
+} else {
+ & ${pwshProg} ${args} ${shTarget} ${progArgs}$args
+}
+${nodePath ? "$env:NODE_PATH=$env_node_path\n" : ""}${prependPath ? "$env:PATH=$env_path\n" : ""}exit $LASTEXITCODE
+`;
}
- p.end();
- };
- createSync = (opt, files) => {
- const p = new PackSync(opt);
- addFilesSync(p, files);
- return p;
- };
- createAsync = (opt, files) => {
- const p = new Pack(opt);
- addFilesAsync(p, files).catch((er) => p.emit("error", er));
- return p;
- };
- create = makeCommand(createFileSync, createFile, createSync, createAsync, (_opt, files) => {
- if (!files?.length) {
- throw new TypeError("no paths specified to add to archive");
+ return pwsh;
+ }
+ function chmodShim(to, opts) {
+ return opts.fs_.chmod(to, 493);
+ }
+ function normalizePathEnvVar(nodePath) {
+ if (!nodePath || !nodePath.length) {
+ return {
+ win32: "",
+ posix: ""
+ };
}
- });
+ let split = typeof nodePath === "string" ? nodePath.split(path10.delimiter) : Array.from(nodePath);
+ let result = {};
+ for (let i2 = 0; i2 < split.length; i2++) {
+ const win32 = split[i2].split("/").join("\\");
+ const posix = isWindows() ? split[i2].split("\\").join("/").replace(/^([^:\\/]*):/, (_2, $1) => `/mnt/${$1.toLowerCase()}`) : split[i2];
+ result.win32 = result.win32 ? `${result.win32};${win32}` : win32;
+ result.posix = result.posix ? `${result.posix}:${posix}` : posix;
+ result[i2] = { win32, posix };
+ }
+ return result;
+ }
+ module2.exports = cmdShim2;
}
});
@@ -12688,7 +9525,7 @@ var import_clipanion17 = __toESM(require_advanced());
// package.json
var package_default = {
name: "corepack",
- version: "0.36.0",
+ version: "0.37.0",
homepage: "https://github.com/nodejs/corepack#readme",
bugs: {
url: "https://github.com/nodejs/corepack/issues"
@@ -12704,7 +9541,7 @@ var package_default = {
"./package.json": "./package.json"
},
license: "MIT",
- packageManager: "yarn@4.18.0+sha224.5707fce90df5d8720fae4e85a07ab55e90aa20fded8914893e2ba225",
+ packageManager: "yarn@4.19.0+sha512.2cb9e5a36f7f11f2bc6ff444830d87368d419e0d83b6a0fb6077d3e6fed0f476c9514dff4ba4d84b049bd34ef32954e550f264ad2fbbfebcba6c89e869530bba",
devDependencies: {
"@types/debug": "^4.1.5",
"@types/node": "^22.0.0",
@@ -12720,7 +9557,7 @@ var package_default = {
eslint: "^10.8.1",
semver: "^7.6.3",
"supports-color": "^11.0.0",
- tar: "^7.5.11",
+ tar: "^8.1.3",
typescript: "^5.7.3",
"v8-compile-cache": "^2.3.0",
vitest: "^4.0.5",
@@ -12782,8 +9619,8 @@ var package_default = {
// sources/Engine.ts
var import_clipanion5 = __toESM(require_advanced());
-var import_fs6 = __toESM(require("fs"));
-var import_path5 = __toESM(require("path"));
+var import_fs4 = __toESM(require("fs"));
+var import_path4 = __toESM(require("path"));
var import_process3 = __toESM(require("process"));
var import_rcompare = __toESM(require_rcompare());
var import_valid3 = __toESM(require_valid());
@@ -12793,7 +9630,7 @@ var import_valid4 = __toESM(require_valid2());
var config_default = {
definitions: {
npm: {
- default: "12.0.2+sha1.788d93dc8869000b1078e0395c60748a0aadc4f1",
+ default: "12.2.3+sha1.89b6df9d73dd53916e4a0ccbc01d6f9ce8837933",
fetchLatestFrom: {
type: "npm",
package: "npm"
@@ -12830,7 +9667,7 @@ var config_default = {
}
},
pnpm: {
- default: "11.24.0+sha1.a042a648b5e519c43c5b2c3ff99901448190cd66",
+ default: "11.29.0+sha1.030b6075c741e7dccb6ea1fcb2516cbecdb61885",
fetchLatestFrom: {
type: "npm",
package: "pnpm"
@@ -12911,7 +9748,7 @@ var config_default = {
package: "yarn"
},
transparent: {
- default: "4.18.0+sha224.5707fce90df5d8720fae4e85a07ab55e90aa20fded8914893e2ba225",
+ default: "4.19.0+sha224.7c7b647034fc301880fd77a79fdde08096c017d18e9aaff6aa182bad",
commands: [
[
"yarn",
@@ -12993,14 +9830,16 @@ var config_default = {
// sources/corepackUtils.ts
var import_crypto2 = require("crypto");
-var import_events4 = require("events");
-var import_fs4 = __toESM(require("fs"));
+var import_events2 = require("events");
+var import_fs2 = __toESM(require("fs"));
var import_module = __toESM(require("module"));
-var import_path3 = __toESM(require("path"));
+var import_path2 = __toESM(require("path"));
var import_range = __toESM(require_range());
var import_semver = __toESM(require_semver());
var import_lt = __toESM(require_lt());
-var import_parse3 = __toESM(require_parse());
+var import_parse = __toESM(require_parse());
+var import_promises = require("stream/promises");
+var import_stream2 = require("stream");
var import_promises2 = require("timers/promises");
// sources/debugUtils.ts
@@ -13031,10 +9870,10 @@ function getTemporaryFolder(target = (0, import_os.tmpdir)()) {
while (true) {
const rnd = Math.random() * 4294967296;
const hex = rnd.toString(16).padStart(8, `0`);
- const path16 = (0, import_path.join)(target, `corepack-${import_process.default.pid}-${hex}`);
+ const path10 = (0, import_path.join)(target, `corepack-${import_process.default.pid}-${hex}`);
try {
- (0, import_fs.mkdirSync)(path16);
- return path16;
+ (0, import_fs.mkdirSync)(path10);
+ return path10;
} catch (error) {
if (error.code === `EEXIST`) {
continue;
@@ -13066,7 +9905,7 @@ async function fetchAsJson2(packageName, version) {
if (process.env.COREPACK_ENABLE_NETWORK === `0`)
throw new import_clipanion2.UsageError(`Network access disabled by the environment; can't reach npm repository ${npmRegistryUrl}`);
const headers = { ...DEFAULT_HEADERS };
- if (`COREPACK_NPM_TOKEN` in process.env) {
+ if (process.env.COREPACK_NPM_TOKEN) {
headers.authorization = `Bearer ${process.env.COREPACK_NPM_TOKEN}`;
} else if (`COREPACK_NPM_USERNAME` in process.env && `COREPACK_NPM_PASSWORD` in process.env) {
const encodedCreds = Buffer.from(`${process.env.COREPACK_NPM_USERNAME}:${process.env.COREPACK_NPM_PASSWORD}`, `utf8`).toString(`base64`);
@@ -13083,10 +9922,10 @@ async function verifySignature({ signatures, integrity, packageName, version })
const { npm: trustedKeys } = process.env.COREPACK_INTEGRITY_KEYS ? JSON.parse(process.env.COREPACK_INTEGRITY_KEYS) : config_default.keys;
let signature;
let key;
- for (const k of trustedKeys) {
- signature = signatures.find(({ keyid }) => keyid === k.keyid);
+ for (const k2 of trustedKeys) {
+ signature = signatures.find(({ keyid }) => keyid === k2.keyid);
if (signature != null) {
- key = k.key;
+ key = k2.key;
break;
}
}
@@ -13144,8 +9983,9 @@ async function fetch(input, init) {
if (typeof input === `string`)
input = new URL(input);
let headers = init?.headers;
- const username = input.username || process.env.COREPACK_NPM_USERNAME;
- const password = input.password || process.env.COREPACK_NPM_PASSWORD;
+ const isRegistryRequest = input.origin === URL.parse(process.env.COREPACK_NPM_REGISTRY || DEFAULT_NPM_REGISTRY_URL)?.origin;
+ const username = input.username || (isRegistryRequest ? process.env.COREPACK_NPM_USERNAME : void 0);
+ const password = input.password || (isRegistryRequest ? process.env.COREPACK_NPM_PASSWORD : void 0);
if (username || password) {
headers = {
...headers,
@@ -13153,8 +9993,7 @@ async function fetch(input, init) {
};
input.username = input.password = ``;
}
- const registry = process.env.COREPACK_NPM_TOKEN && new URL(process.env.COREPACK_NPM_REGISTRY || DEFAULT_NPM_REGISTRY_URL);
- if (registry && input.origin === registry.origin) {
+ if (process.env.COREPACK_NPM_TOKEN && isRegistryRequest) {
headers = {
...headers,
authorization: `Bearer ${process.env.COREPACK_NPM_TOKEN}`
@@ -13300,10 +10139,10 @@ async function fetchAvailableVersions2(spec) {
}
}
async function findInstalledVersion(installTarget, descriptor) {
- const installFolder = import_path3.default.join(installTarget, descriptor.name);
+ const installFolder = import_path2.default.join(installTarget, descriptor.name);
let cacheDirectory;
try {
- cacheDirectory = await import_fs4.default.promises.opendir(installFolder);
+ cacheDirectory = await import_fs2.default.promises.opendir(installFolder);
} catch (error) {
if (isNodeError(error) && error.code === `ENOENT`) {
return null;
@@ -13314,11 +10153,11 @@ async function findInstalledVersion(installTarget, descriptor) {
const range = new import_range.default(descriptor.range);
let bestMatch = null;
let maxSV = void 0;
- for await (const { name: name2 } of cacheDirectory) {
- if (name2.startsWith(`.`))
+ for await (const { name } of cacheDirectory) {
+ if (name.startsWith(`.`))
continue;
- if (range.test(name2) && maxSV?.compare(name2) !== 1) {
- bestMatch = name2;
+ if (range.test(name) && maxSV?.compare(name) !== 1) {
+ bestMatch = name;
maxSV = new import_semver.default(bestMatch);
}
}
@@ -13340,54 +10179,56 @@ function parseURLReference(locator) {
}
return { version: encodeURIComponent(href), build: [] };
}
-function isValidBinList(x) {
- return Array.isArray(x) && x.length > 0;
+function isValidBinList(x2) {
+ return Array.isArray(x2) && x2.length > 0;
}
-function isValidBinSpec(x) {
- return typeof x === `object` && x !== null && !Array.isArray(x) && Object.keys(x).length > 0;
+function isValidBinSpec(x2) {
+ return typeof x2 === `object` && x2 !== null && !Array.isArray(x2) && Object.keys(x2).length > 0;
}
async function download(installTarget, url, algo, binPath = null) {
const tmpFolder = getTemporaryFolder(installTarget);
log(`Downloading to ${tmpFolder}`);
const stream = await fetchUrlStream(url);
const parsedUrl = new URL(url);
- const ext = import_path3.default.posix.extname(parsedUrl.pathname);
+ const ext = import_path2.default.posix.extname(parsedUrl.pathname);
let outputFile = null;
- let sendTo;
+ let done;
if (ext === `.tgz`) {
- const { extract: tarX } = await Promise.resolve().then(() => (init_extract(), extract_exports));
- sendTo = tarX({
+ const { extract: tarX } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
+ done = tarX({
+ input: stream.pipe(new import_stream2.PassThrough()),
strip: 1,
cwd: tmpFolder,
- filter: binPath ? (path16) => {
- const pos2 = path16.indexOf(`/`);
- return pos2 !== -1 && path16.slice(pos2 + 1) === binPath;
+ filter: binPath ? (path10) => {
+ const pos = path10.indexOf(`/`);
+ return pos !== -1 && path10.slice(pos + 1) === binPath;
} : void 0
});
} else if (ext === `.js`) {
- outputFile = import_path3.default.join(tmpFolder, import_path3.default.posix.basename(parsedUrl.pathname));
- sendTo = import_fs4.default.createWriteStream(outputFile);
+ outputFile = import_path2.default.join(tmpFolder, import_path2.default.posix.basename(parsedUrl.pathname));
+ done = (0, import_events2.once)(stream.pipe(import_fs2.default.createWriteStream(outputFile)), `finish`);
+ } else {
+ throw new Error(`Unsupported file extension '${ext}' in ${url}`);
}
- stream.pipe(sendTo);
let hash = !binPath ? stream.pipe((0, import_crypto2.createHash)(algo)) : null;
- await (0, import_events4.once)(sendTo, `finish`);
+ await Promise.all([done.then(() => stream.resume()), (0, import_promises.finished)(stream)]);
if (binPath) {
- const downloadedBin = import_path3.default.join(tmpFolder, binPath);
- outputFile = import_path3.default.join(tmpFolder, import_path3.default.basename(downloadedBin));
+ const downloadedBin = import_path2.default.join(tmpFolder, binPath);
+ outputFile = import_path2.default.join(tmpFolder, import_path2.default.basename(downloadedBin));
try {
await renameSafe(downloadedBin, outputFile);
} catch (err) {
if (isNodeError(err) && err.code === `ENOENT`)
throw new Error(`Cannot locate '${binPath}' in downloaded tarball`, { cause: err });
if (isNodeError(err) && isExistError(err)) {
- await import_fs4.default.promises.rm(downloadedBin);
+ await import_fs2.default.promises.rm(downloadedBin);
} else {
throw err;
}
}
- const fileStream = import_fs4.default.createReadStream(outputFile);
+ const fileStream = import_fs2.default.createReadStream(outputFile);
hash = fileStream.pipe((0, import_crypto2.createHash)(algo));
- await (0, import_events4.once)(fileStream, `close`);
+ await (0, import_events2.once)(fileStream, `close`);
}
return {
tmpFolder,
@@ -13397,12 +10238,12 @@ async function download(installTarget, url, algo, binPath = null) {
}
async function installVersion(installTarget, locator, { spec }) {
const locatorIsASupportedPackageManager = isSupportedPackageManagerLocator(locator);
- const locatorReference = locatorIsASupportedPackageManager ? (0, import_parse3.default)(locator.reference) : parseURLReference(locator);
+ const locatorReference = locatorIsASupportedPackageManager ? (0, import_parse.default)(locator.reference) : parseURLReference(locator);
const { version, build } = locatorReference;
- const installFolder = import_path3.default.join(installTarget, locator.name, version);
+ const installFolder = import_path2.default.join(installTarget, locator.name, version);
try {
- const corepackFile = import_path3.default.join(installFolder, `.corepack`);
- const corepackContent = await import_fs4.default.promises.readFile(corepackFile, `utf8`);
+ const corepackFile = import_path2.default.join(installFolder, `.corepack`);
+ const corepackContent = await import_fs2.default.promises.readFile(corepackFile, `utf8`);
const corepackData = JSON.parse(corepackContent);
log(`Reusing ${locator.name}@${locator.reference} found in ${installFolder}`);
return {
@@ -13476,7 +10317,7 @@ async function installVersion(installTarget, locator, { spec }) {
if (locatorIsASupportedPackageManager && isValidBinSpec(spec.bin)) {
bin = spec.bin;
} else {
- const { name: packageName, bin: packageBin } = require(import_path3.default.join(tmpFolder, `package.json`));
+ const { name: packageName, bin: packageBin } = require(import_path2.default.join(tmpFolder, `package.json`));
if (typeof packageBin === `string`) {
bin = { [packageName]: packageBin };
} else if (isValidBinSpec(packageBin)) {
@@ -13493,23 +10334,23 @@ async function installVersion(installTarget, locator, { spec }) {
build[1] = Buffer.from(integrity.slice(`sha512-`.length), `base64`).toString(`hex`);
}
if (build[1] && actualHash !== build[1]) {
- await import_fs4.default.promises.rm(tmpFolder, { recursive: true, force: true });
+ await import_fs2.default.promises.rm(tmpFolder, { recursive: true, force: true });
throw new Error(`Mismatch hashes. Expected ${build[1]}, got ${actualHash}`);
}
const serializedHash = `${algo}.${actualHash}`;
- await import_fs4.default.promises.writeFile(import_path3.default.join(tmpFolder, `.corepack`), JSON.stringify({
+ await import_fs2.default.promises.writeFile(import_path2.default.join(tmpFolder, `.corepack`), JSON.stringify({
locator,
bin,
hash: serializedHash
}));
- await import_fs4.default.promises.mkdir(import_path3.default.dirname(installFolder), { recursive: true });
+ await import_fs2.default.promises.mkdir(import_path2.default.dirname(installFolder), { recursive: true });
try {
await renameSafe(tmpFolder, installFolder);
} catch (err) {
if (isNodeError(err) && (isExistError(err) || // On Windows the error code is EPERM so we check if it is a directory
- err.code === `EPERM` && (await import_fs4.default.promises.stat(installFolder)).isDirectory())) {
+ err.code === `EPERM` && (await import_fs2.default.promises.stat(installFolder)).isDirectory())) {
log(`Another instance of corepack installed ${locator.name}@${locator.reference}`);
- await import_fs4.default.promises.rm(tmpFolder, { recursive: true, force: true });
+ await import_fs2.default.promises.rm(tmpFolder, { recursive: true, force: true });
} else {
throw err;
}
@@ -13518,7 +10359,7 @@ async function installVersion(installTarget, locator, { spec }) {
const lastKnownGood = await getLastKnownGood();
const defaultVersion = getLastKnownGoodFromFileContent(lastKnownGood, locator.name);
if (defaultVersion) {
- const currentDefault = (0, import_parse3.default)(defaultVersion);
+ const currentDefault = (0, import_parse.default)(defaultVersion);
const downloadedVersion = locatorReference;
if (currentDefault.major === downloadedVersion.major && (0, import_lt.default)(currentDefault, downloadedVersion)) {
await activatePackageManager(lastKnownGood, locator);
@@ -13536,18 +10377,18 @@ async function renameSafe(oldPath, newPath) {
if (process.platform === `win32`) {
await renameUnderWindows(oldPath, newPath);
} else {
- await import_fs4.default.promises.rename(oldPath, newPath);
+ await import_fs2.default.promises.rename(oldPath, newPath);
}
}
async function renameUnderWindows(oldPath, newPath) {
const retries = 5;
- for (let i = 0; i < retries; i++) {
+ for (let i2 = 0; i2 < retries; i2++) {
try {
- await import_fs4.default.promises.rename(oldPath, newPath);
+ await import_fs2.default.promises.rename(oldPath, newPath);
break;
} catch (err) {
- if (isNodeError(err) && (err.code === `ENOENT` || err.code === `EPERM`) && i < retries - 1) {
- await (0, import_promises2.setTimeout)(100 * 2 ** i);
+ if (isNodeError(err) && (err.code === `ENOENT` || err.code === `EPERM`) && i2 < retries - 1) {
+ await (0, import_promises2.setTimeout)(100 * 2 ** i2);
continue;
} else {
throw err;
@@ -13559,17 +10400,17 @@ async function runVersion(locator, installSpec, binName, args) {
let binPath = null;
const bin = installSpec.bin ?? installSpec.spec.bin;
if (Array.isArray(bin)) {
- if (bin.some((name2) => name2 === binName)) {
+ if (bin.some((name) => name === binName)) {
const parsedUrl = new URL(installSpec.spec.url);
- const ext = import_path3.default.posix.extname(parsedUrl.pathname);
+ const ext = import_path2.default.posix.extname(parsedUrl.pathname);
if (ext === `.js`) {
- binPath = import_path3.default.join(installSpec.location, import_path3.default.posix.basename(parsedUrl.pathname));
+ binPath = import_path2.default.join(installSpec.location, import_path2.default.posix.basename(parsedUrl.pathname));
}
}
} else {
- for (const [name2, dest] of Object.entries(bin)) {
- if (name2 === binName) {
- binPath = import_path3.default.join(installSpec.location, dest);
+ for (const [name, dest] of Object.entries(bin)) {
+ if (name === binName) {
+ binPath = import_path2.default.join(installSpec.location, dest);
break;
}
}
@@ -13581,7 +10422,7 @@ async function runVersion(locator, installSpec, binName, args) {
await Promise.resolve().then(() => __toESM(require_v8_compile_cache()));
}
}
- process.env.COREPACK_ROOT = import_path3.default.dirname(require.resolve("corepack/package.json"));
+ process.env.COREPACK_ROOT = import_path2.default.dirname(require.resolve("corepack/package.json"));
process.argv = [
process.execPath,
binPath,
@@ -13631,8 +10472,8 @@ function satisfiesWithPrereleases(version, range, loose = false) {
// sources/specUtils.ts
var import_clipanion4 = __toESM(require_advanced());
-var import_fs5 = __toESM(require("fs"));
-var import_path4 = __toESM(require("path"));
+var import_fs3 = __toESM(require("fs"));
+var import_path3 = __toESM(require("path"));
var import_satisfies = __toESM(require_satisfies());
var import_valid = __toESM(require_valid());
var import_valid2 = __toESM(require_valid2());
@@ -13652,40 +10493,40 @@ function isSupportedPackageManager(value) {
// sources/specUtils.ts
var nodeModulesRegExp = /[\\/]node_modules[\\/](@[^\\/]*[\\/])?([^@\\/][^\\/]*)$/;
-function parseSpec(raw2, source, { enforceExactVersion = true } = {}) {
- if (typeof raw2 !== `string`)
+function parseSpec(raw, source, { enforceExactVersion = true } = {}) {
+ if (typeof raw !== `string`)
throw new import_clipanion4.UsageError(`Invalid package manager specification in ${source}; expected a string`);
- const atIndex = raw2.indexOf(`@`);
- if (atIndex === -1 || atIndex === raw2.length - 1) {
+ const atIndex = raw.indexOf(`@`);
+ if (atIndex === -1 || atIndex === raw.length - 1) {
if (enforceExactVersion)
- throw new import_clipanion4.UsageError(`No version specified for ${raw2} in "packageManager" of ${source}`);
- const name3 = atIndex === -1 ? raw2 : raw2.slice(0, -1);
- if (!isSupportedPackageManager(name3))
- throw new import_clipanion4.UsageError(`Unsupported package manager specification (${name3})`);
+ throw new import_clipanion4.UsageError(`No version specified for ${raw} in "packageManager" of ${source}`);
+ const name2 = atIndex === -1 ? raw : raw.slice(0, -1);
+ if (!isSupportedPackageManager(name2))
+ throw new import_clipanion4.UsageError(`Unsupported package manager specification (${name2})`);
return {
- name: name3,
+ name: name2,
range: `*`
};
}
- const name2 = raw2.slice(0, atIndex);
- const range = raw2.slice(atIndex + 1);
+ const name = raw.slice(0, atIndex);
+ const range = raw.slice(atIndex + 1);
const isURL = URL.canParse(range);
if (!isURL) {
if (enforceExactVersion && !(0, import_valid.default)(range))
- throw new import_clipanion4.UsageError(`Invalid package manager specification in ${source} (${raw2}); expected a semver version${enforceExactVersion ? `` : `, range, or tag`}`);
- if (!isSupportedPackageManager(name2)) {
- throw new import_clipanion4.UsageError(`Unsupported package manager specification (${raw2})`);
+ throw new import_clipanion4.UsageError(`Invalid package manager specification in ${source} (${raw}); expected a semver version${enforceExactVersion ? `` : `, range, or tag`}`);
+ if (!isSupportedPackageManager(name)) {
+ throw new import_clipanion4.UsageError(`Unsupported package manager specification (${raw})`);
}
- } else if (isSupportedPackageManager(name2) && process.env.COREPACK_ENABLE_UNSAFE_CUSTOM_URLS !== `1`) {
- throw new import_clipanion4.UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1 in your environment (${raw2})`);
+ } else if (isSupportedPackageManager(name) && process.env.COREPACK_ENABLE_UNSAFE_CUSTOM_URLS !== `1`) {
+ throw new import_clipanion4.UsageError(`Illegal use of URL for known package manager. Instead, select a specific version, or set COREPACK_ENABLE_UNSAFE_CUSTOM_URLS=1 in your environment (${raw})`);
}
return {
- name: name2,
+ name,
range
};
}
-function devEnginesToDescriptor({ name: name2, version }) {
- return { name: name2, range: version ?? `*` };
+function devEnginesToDescriptor({ name, version }) {
+ return { name, range: version ?? `*` };
}
function warnOrThrow(errorMessage, onFail) {
switch (onFail) {
@@ -13710,24 +10551,24 @@ function parsePackageJSON(packageJSONContent) {
console.warn(`! Corepack does not currently support array values for devEngines.packageManager`);
return { packageManagerField: pm };
}
- const { name: name2, version, onFail } = packageManager;
- if (typeof name2 !== `string` || name2.includes(`@`)) {
- warnOrThrow(`The value of devEngines.packageManager.name ${JSON.stringify(name2)} is not a supported string value`, onFail);
+ const { name, version, onFail } = packageManager;
+ if (typeof name !== `string` || name.includes(`@`)) {
+ warnOrThrow(`The value of devEngines.packageManager.name ${JSON.stringify(name)} is not a supported string value`, onFail);
return { packageManagerField: pm };
}
if (version != null && (typeof version !== `string` || !(0, import_valid2.default)(version))) {
warnOrThrow(`The value of devEngines.packageManager.version ${JSON.stringify(version)} is not a valid semver range`, onFail);
return { packageManagerField: pm };
}
- log(`devEngines.packageManager defines that ${name2}${version ? `@${version}` : ``} should be the local package manager`);
+ log(`devEngines.packageManager defines that ${name}${version ? `@${version}` : ``} should be the local package manager`);
if (pm) {
- if (!pm.startsWith?.(`${name2}@`)) {
- warnOrThrow(`"packageManager" field is set to ${JSON.stringify(pm)} which does not match the "devEngines.packageManager" field set to ${JSON.stringify(name2)}`, onFail);
- } else if (version != null && !(0, import_satisfies.default)(pm.slice(name2.length + 1), version)) {
- warnOrThrow(`"packageManager" field is set to ${JSON.stringify(pm)} which does not match the value defined in "devEngines.packageManager" for ${JSON.stringify(name2)} of ${JSON.stringify(version)}`, onFail);
+ if (!pm.startsWith?.(`${name}@`)) {
+ warnOrThrow(`"packageManager" field is set to ${JSON.stringify(pm)} which does not match the "devEngines.packageManager" field set to ${JSON.stringify(name)}`, onFail);
+ } else if (version != null && !(0, import_satisfies.default)(pm.slice(name.length + 1), version)) {
+ warnOrThrow(`"packageManager" field is set to ${JSON.stringify(pm)} which does not match the value defined in "devEngines.packageManager" for ${JSON.stringify(name)} of ${JSON.stringify(version)}`, onFail);
}
}
- return { packageManagerField: pm, devEnginesPackageManager: { name: name2, version, onFail } };
+ return { packageManagerField: pm, devEnginesPackageManager: { name, version, onFail } };
}
return { packageManagerField: pm };
}
@@ -13740,37 +10581,46 @@ async function setLocalPackageManager(cwd, info) {
warnOrThrow(`The requested version of ${info.locator.name}@${info.locator.reference} does not match the devEngines specification (${devEnginesValue.name}@${devEnginesValue.version ?? `*`})`, devEnginesValue.onFail);
}
}
- const content = projectFound ? await import_fs5.default.promises.readFile(lookup.target, `utf8`) : ``;
+ const content = projectFound ? await import_fs3.default.promises.readFile(lookup.target, `utf8`) : ``;
const { data, indent } = readPackageJson(content);
const previousPackageManager = data.packageManager ?? (devEnginesValue ? `${devEnginesValue.name}@${devEnginesValue.version ?? `*`}` : `unknown`);
data.packageManager = `${info.locator.name}@${info.locator.reference}`;
const newContent = normalizeLineEndings(content, `${JSON.stringify(data, null, indent)}
`);
- await import_fs5.default.promises.writeFile(lookup.target, newContent, `utf8`);
+ await import_fs3.default.promises.writeFile(lookup.target, newContent, `utf8`);
return {
previousPackageManager
};
}
+var NPM_CREDENTIALS_ENV_VARS = [`COREPACK_NPM_TOKEN`, `COREPACK_NPM_USERNAME`, `COREPACK_NPM_PASSWORD`];
async function loadEnvFileIfExists(cwd) {
- const envFilePath = import_path4.default.resolve(cwd, process.env.COREPACK_ENV_FILE ?? `.corepack.env`);
+ const envFilePath = import_path3.default.resolve(cwd, process.env.COREPACK_ENV_FILE ?? `.corepack.env`);
if (process.env.COREPACK_ENV_FILE == `0`) {
log(`Skipping env file as configured with COREPACK_ENV_FILE`);
return void 0;
}
log(`Checking ${envFilePath}`);
+ let envFromLocalFile;
try {
- const localEnv = {
- ...Object.fromEntries(Object.entries((0, import_util.parseEnv)(await import_fs5.default.promises.readFile(envFilePath, `utf8`))).filter((e) => e[0].startsWith(`COREPACK_`))),
- ...process.env
- };
- log(`Successfully loaded env file found at ${envFilePath}`);
- return { env: localEnv, path: envFilePath };
+ envFromLocalFile = (0, import_util.parseEnv)(await import_fs3.default.promises.readFile(envFilePath, `utf8`));
} catch (err) {
if (err?.code !== `ENOENT`)
throw err;
log(`No env file found at ${envFilePath}`);
+ return void 0;
}
- return void 0;
+ if (envFromLocalFile.COREPACK_NPM_REGISTRY && !Object.hasOwn(process.env, `COREPACK_NPM_REGISTRY`)) {
+ const exposedCredentials = NPM_CREDENTIALS_ENV_VARS.filter((name) => process.env[name]).join(`, `);
+ if (exposedCredentials) {
+ throw new import_clipanion4.UsageError(`${envFilePath} sets COREPACK_NPM_REGISTRY=${envFromLocalFile.COREPACK_NPM_REGISTRY}, which would receive the value of ${exposedCredentials} from your environment. If you trust this registry, set COREPACK_NPM_REGISTRY to the same value in your environment. Otherwise, set ${exposedCredentials} to an empty string.`);
+ }
+ }
+ const localEnv = {
+ ...Object.fromEntries(Object.entries(envFromLocalFile).filter((e) => e[0].startsWith(`COREPACK_`))),
+ ...process.env
+ };
+ log(`Successfully loaded env file found at ${envFilePath}`);
+ return { env: localEnv, path: envFilePath };
}
async function loadSpecAndEnv(initialCwd, { envOnly } = { envOnly: false }) {
let nextCwd = initialCwd;
@@ -13779,7 +10629,7 @@ async function loadSpecAndEnv(initialCwd, { envOnly } = { envOnly: false }) {
let localEnv = void 0;
while (nextCwd !== currCwd && (!selection || !selection.data.packageManager)) {
currCwd = nextCwd;
- nextCwd = import_path4.default.dirname(currCwd);
+ nextCwd = import_path3.default.dirname(currCwd);
if (nodeModulesRegExp.test(currCwd))
continue;
if (process.env.COREPACK_ENV_FILE !== `0` && !localEnv)
@@ -13788,11 +10638,11 @@ async function loadSpecAndEnv(initialCwd, { envOnly } = { envOnly: false }) {
if (localEnv) break;
continue;
}
- const manifestPath = import_path4.default.join(currCwd, `package.json`);
+ const manifestPath = import_path3.default.join(currCwd, `package.json`);
log(`Checking ${manifestPath}`);
let content;
try {
- content = await import_fs5.default.promises.readFile(manifestPath, `utf8`);
+ content = await import_fs3.default.promises.readFile(manifestPath, `utf8`);
} catch (err) {
if (err?.code === `ENOENT`) continue;
throw err;
@@ -13803,21 +10653,21 @@ async function loadSpecAndEnv(initialCwd, { envOnly } = { envOnly: false }) {
} catch {
}
if (typeof data !== `object` || data === null)
- throw new import_clipanion4.UsageError(`Invalid package.json in ${import_path4.default.relative(currCwd, manifestPath)}`);
+ throw new import_clipanion4.UsageError(`Invalid package.json in ${import_path3.default.relative(currCwd, manifestPath)}`);
selection = { data, manifestPath };
}
if (localEnv)
process.env = localEnv.env;
if (selection === null)
- return { type: `NoProject`, target: import_path4.default.join(initialCwd, `package.json`), envFilePath: localEnv?.path };
+ return { type: `NoProject`, target: import_path3.default.join(initialCwd, `package.json`), envFilePath: localEnv?.path };
const { packageManagerField, devEnginesPackageManager } = parsePackageJSON(selection.data);
if (devEnginesPackageManager != null && !packageManagerField) {
- const { name: name2, version } = devEnginesPackageManager;
+ const { name, version } = devEnginesPackageManager;
if (!version || !(0, import_valid.default)(version)) {
- log(`${selection.manifestPath} defines ${name2} as local package manager using devEngines.packageManager, without an exact version`);
+ log(`${selection.manifestPath} defines ${name} as local package manager using devEngines.packageManager, without an exact version`);
return { type: `NoSpec`, target: selection.manifestPath, envFilePath: localEnv?.path, devEnginesValue: devEnginesPackageManager };
}
- log(`${selection.manifestPath} defines ${name2}@${version} as local package manager using devEngines.packageManager`);
+ log(`${selection.manifestPath} defines ${name}@${version} as local package manager using devEngines.packageManager`);
return {
type: `Found`,
target: selection.manifestPath,
@@ -13825,7 +10675,7 @@ async function loadSpecAndEnv(initialCwd, { envOnly } = { envOnly: false }) {
envFilePath: localEnv?.path,
devEnginesValue: devEnginesPackageManager,
// Lazy-loading it so we do not throw errors on commands that do not need valid spec.
- getSpec: ({ enforceExactVersion = true } = {}) => parseSpec(`${name2}@${version}`, import_path4.default.relative(initialCwd, selection.manifestPath), { enforceExactVersion })
+ getSpec: ({ enforceExactVersion = true } = {}) => parseSpec(`${name}@${version}`, import_path3.default.relative(initialCwd, selection.manifestPath), { enforceExactVersion })
};
}
if (packageManagerField === void 0)
@@ -13838,20 +10688,20 @@ async function loadSpecAndEnv(initialCwd, { envOnly } = { envOnly: false }) {
envFilePath: localEnv?.path,
devEnginesValue: devEnginesPackageManager,
// Lazy-loading it so we do not throw errors on commands that do not need valid spec.
- getSpec: ({ enforceExactVersion = true } = {}) => parseSpec(packageManagerField, import_path4.default.relative(initialCwd, selection.manifestPath), { enforceExactVersion })
+ getSpec: ({ enforceExactVersion = true } = {}) => parseSpec(packageManagerField, import_path3.default.relative(initialCwd, selection.manifestPath), { enforceExactVersion })
};
}
// sources/Engine.ts
function getLastKnownGoodFilePath() {
- const lkg = import_path5.default.join(getCorepackHomeFolder(), `lastKnownGood.json`);
+ const lkg = import_path4.default.join(getCorepackHomeFolder(), `lastKnownGood.json`);
log(`LastKnownGood file would be located at ${lkg}`);
return lkg;
}
async function getLastKnownGood() {
- let raw2;
+ let raw;
try {
- raw2 = await import_fs6.default.promises.readFile(getLastKnownGoodFilePath(), `utf8`);
+ raw = await import_fs4.default.promises.readFile(getLastKnownGoodFilePath(), `utf8`);
} catch (err) {
if (err?.code === `ENOENT`) {
log(`No LastKnownGood version found in Corepack home.`);
@@ -13860,7 +10710,7 @@ async function getLastKnownGood() {
throw err;
}
try {
- const parsed = JSON.parse(raw2);
+ const parsed = JSON.parse(raw);
if (!parsed) {
log(`Invalid LastKnowGood file in Corepack home (JSON parsable, but falsy)`);
return {};
@@ -13884,8 +10734,8 @@ async function getLastKnownGood() {
async function createLastKnownGoodFile(lastKnownGood) {
const content = `${JSON.stringify(lastKnownGood, null, 2)}
`;
- await import_fs6.default.promises.mkdir(getCorepackHomeFolder(), { recursive: true });
- await import_fs6.default.promises.writeFile(getLastKnownGoodFilePath(), content, `utf8`);
+ await import_fs4.default.promises.mkdir(getCorepackHomeFolder(), { recursive: true });
+ await import_fs4.default.promises.writeFile(getLastKnownGoodFilePath(), content, `utf8`);
}
function getLastKnownGoodFromFileContent(lastKnownGood, packageManager) {
if (Object.hasOwn(lastKnownGood, packageManager))
@@ -13943,20 +10793,20 @@ var Engine = class {
throw new Error(`Assertion failed: Specified resolution (${locator.reference}) isn't supported by any of ${ranges.join(`, `)}`);
return definition.ranges[range];
}
- getBinariesFor(name2) {
+ getBinariesFor(name) {
const binNames = /* @__PURE__ */ new Set();
- for (const rangeDefinition of Object.values(this.config.definitions[name2].ranges)) {
+ for (const rangeDefinition of Object.values(this.config.definitions[name].ranges)) {
const bins = Array.isArray(rangeDefinition.bin) ? rangeDefinition.bin : Object.keys(rangeDefinition.bin);
- for (const name3 of bins) {
- binNames.add(name3);
+ for (const name2 of bins) {
+ binNames.add(name2);
}
}
return binNames;
}
async getDefaultDescriptors() {
const locators = [];
- for (const name2 of SupportedPackageManagerSet)
- locators.push({ name: name2, range: await this.getDefaultVersion(name2) });
+ for (const name of SupportedPackageManagerSet)
+ locators.push({ name, range: await this.getDefaultVersion(name) });
return locators;
}
async getDefaultVersion(packageManager) {
@@ -14057,7 +10907,7 @@ var Engine = class {
console.error(`! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing ${installSpec.locator.name}@${installSpec.locator.reference}.`);
console.error(`! For more details about this field, consult the documentation at https://nodejs.org/api/packages.html#packagemanager`);
console.error();
- await setLocalPackageManager(import_path5.default.dirname(result.target), installSpec);
+ await setLocalPackageManager(import_path4.default.dirname(result.target), installSpec);
}
log(`Falling back to ${fallbackDescriptor.name}@${fallbackDescriptor.range} in the absence of "packageManager" field in ${result.target}`);
return fallbackDescriptor;
@@ -14159,7 +11009,7 @@ var Engine = class {
// sources/commands/Cache.ts
var import_clipanion6 = __toESM(require_advanced());
-var import_fs7 = __toESM(require("fs"));
+var import_fs5 = __toESM(require("fs"));
var CacheCommand = class extends import_clipanion6.Command {
static paths = [
[`cache`, `clean`],
@@ -14172,14 +11022,14 @@ var CacheCommand = class extends import_clipanion6.Command {
`
});
async execute() {
- await import_fs7.default.promises.rm(getInstallFolder(), { recursive: true, force: true });
+ await import_fs5.default.promises.rm(getInstallFolder(), { recursive: true, force: true });
}
};
// sources/commands/Disable.ts
var import_clipanion7 = __toESM(require_advanced());
-var import_fs8 = __toESM(require("fs"));
-var import_path6 = __toESM(require("path"));
+var import_fs6 = __toESM(require("fs"));
+var import_path5 = __toESM(require("path"));
var import_which = __toESM(require_lib());
var DisableCommand = class extends import_clipanion7.Command {
static paths = [
@@ -14210,26 +11060,26 @@ var DisableCommand = class extends import_clipanion7.Command {
async execute() {
let installDirectory = this.installDirectory;
if (typeof installDirectory === `undefined`)
- installDirectory = import_path6.default.dirname(await (0, import_which.default)(`corepack`));
+ installDirectory = import_path5.default.dirname(await (0, import_which.default)(`corepack`));
const names = this.names.length === 0 ? SupportedPackageManagerSetWithoutNpm : this.names;
const allBinNames = [];
- for (const name2 of new Set(names)) {
- if (!isSupportedPackageManager(name2))
- throw new import_clipanion7.UsageError(`Invalid package manager name '${name2}'`);
- const binNames = this.context.engine.getBinariesFor(name2);
+ for (const name of new Set(names)) {
+ if (!isSupportedPackageManager(name))
+ throw new import_clipanion7.UsageError(`Invalid package manager name '${name}'`);
+ const binNames = this.context.engine.getBinariesFor(name);
allBinNames.push(...binNames);
}
const removeLink = process.platform === `win32` ? (binName) => this.removeWin32Link(installDirectory, binName) : (binName) => this.removePosixLink(installDirectory, binName);
await Promise.all(allBinNames.map(removeLink));
}
async removePosixLink(installDirectory, binName) {
- const file = import_path6.default.join(installDirectory, binName);
+ const file = import_path5.default.join(installDirectory, binName);
try {
- if (binName.includes(`yarn`) && isYarnSwitchPath(await import_fs8.default.promises.realpath(file))) {
+ if (binName.includes(`yarn`) && isYarnSwitchPath(await import_fs6.default.promises.realpath(file))) {
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
return;
}
- await import_fs8.default.promises.unlink(file);
+ await import_fs6.default.promises.unlink(file);
} catch (err) {
if (err.code !== `ENOENT`) {
throw err;
@@ -14238,9 +11088,9 @@ var DisableCommand = class extends import_clipanion7.Command {
}
async removeWin32Link(installDirectory, binName) {
for (const ext of [``, `.ps1`, `.cmd`]) {
- const file = import_path6.default.join(installDirectory, `${binName}${ext}`);
+ const file = import_path5.default.join(installDirectory, `${binName}${ext}`);
try {
- await import_fs8.default.promises.unlink(file);
+ await import_fs6.default.promises.unlink(file);
} catch (err) {
if (err.code !== `ENOENT`) {
throw err;
@@ -14253,8 +11103,8 @@ var DisableCommand = class extends import_clipanion7.Command {
// sources/commands/Enable.ts
var import_cmd_shim = __toESM(require_cmd_shim());
var import_clipanion8 = __toESM(require_advanced());
-var import_fs9 = __toESM(require("fs"));
-var import_path7 = __toESM(require("path"));
+var import_fs7 = __toESM(require("fs"));
+var import_path6 = __toESM(require("path"));
var import_which2 = __toESM(require_lib());
var EnableCommand = class extends import_clipanion8.Command {
static paths = [
@@ -14285,31 +11135,31 @@ var EnableCommand = class extends import_clipanion8.Command {
async execute() {
let installDirectory = this.installDirectory;
if (typeof installDirectory === `undefined`)
- installDirectory = import_path7.default.dirname(await (0, import_which2.default)(`corepack`));
- installDirectory = import_fs9.default.realpathSync(installDirectory);
+ installDirectory = import_path6.default.dirname(await (0, import_which2.default)(`corepack`));
+ installDirectory = import_fs7.default.realpathSync(installDirectory);
const manifestPath = require.resolve("corepack/package.json");
- const distFolder = import_path7.default.join(import_path7.default.dirname(manifestPath), `dist`);
- if (!import_fs9.default.existsSync(distFolder))
+ const distFolder = import_path6.default.join(import_path6.default.dirname(manifestPath), `dist`);
+ if (!import_fs7.default.existsSync(distFolder))
throw new Error(`Assertion failed: The stub folder doesn't exist`);
const names = this.names.length === 0 ? SupportedPackageManagerSetWithoutNpm : this.names;
const allBinNames = [];
- for (const name2 of new Set(names)) {
- if (!isSupportedPackageManager(name2))
- throw new import_clipanion8.UsageError(`Invalid package manager name '${name2}'`);
- const binNames = this.context.engine.getBinariesFor(name2);
+ for (const name of new Set(names)) {
+ if (!isSupportedPackageManager(name))
+ throw new import_clipanion8.UsageError(`Invalid package manager name '${name}'`);
+ const binNames = this.context.engine.getBinariesFor(name);
allBinNames.push(...binNames);
}
const generateLink = process.platform === `win32` ? (binName) => this.generateWin32Link(installDirectory, distFolder, binName) : (binName) => this.generatePosixLink(installDirectory, distFolder, binName);
await Promise.all(allBinNames.map(generateLink));
}
async generatePosixLink(installDirectory, distFolder, binName) {
- const file = import_path7.default.join(installDirectory, binName);
- const symlink = import_path7.default.relative(installDirectory, import_path7.default.join(distFolder, `${binName}.js`));
- const stats = import_fs9.default.lstatSync(file, { throwIfNoEntry: false });
+ const file = import_path6.default.join(installDirectory, binName);
+ const symlink = import_path6.default.relative(installDirectory, import_path6.default.join(distFolder, `${binName}.js`));
+ const stats = import_fs7.default.lstatSync(file, { throwIfNoEntry: false });
if (stats) {
if (stats.isSymbolicLink()) {
- const currentSymlink = await import_fs9.default.promises.readlink(file);
- if (binName.includes(`yarn`) && isYarnSwitchPath(await import_fs9.default.promises.realpath(file))) {
+ const currentSymlink = await import_fs7.default.promises.readlink(file);
+ if (binName.includes(`yarn`) && isYarnSwitchPath(await import_fs7.default.promises.realpath(file))) {
console.warn(`${binName} is already installed in ${file} and points to a Yarn Switch install - skipping`);
return;
}
@@ -14317,13 +11167,13 @@ var EnableCommand = class extends import_clipanion8.Command {
return;
}
}
- await import_fs9.default.promises.unlink(file);
+ await import_fs7.default.promises.unlink(file);
}
- await import_fs9.default.promises.symlink(symlink, file);
+ await import_fs7.default.promises.symlink(symlink, file);
}
async generateWin32Link(installDirectory, distFolder, binName) {
- const file = import_path7.default.join(installDirectory, binName);
- await (0, import_cmd_shim.default)(import_path7.default.join(distFolder, `${binName}.js`), file, {
+ const file = import_path6.default.join(installDirectory, binName);
+ await (0, import_cmd_shim.default)(import_path6.default.join(distFolder, `${binName}.js`), file, {
createCmdFile: true
});
}
@@ -14331,8 +11181,8 @@ var EnableCommand = class extends import_clipanion8.Command {
// sources/commands/InstallGlobal.ts
var import_clipanion10 = __toESM(require_advanced());
-var import_fs10 = __toESM(require("fs"));
-var import_path8 = __toESM(require("path"));
+var import_fs8 = __toESM(require("fs"));
+var import_path7 = __toESM(require("path"));
// sources/commands/Base.ts
var import_clipanion9 = __toESM(require_advanced());
@@ -14407,7 +11257,7 @@ var InstallGlobalCommand = class extends BaseCommand {
throw new import_clipanion10.UsageError(`No package managers specified`);
await Promise.all(this.args.map((arg) => {
if (arg.endsWith(`.tgz`)) {
- return this.installFromTarball(import_path8.default.resolve(this.context.cwd, arg));
+ return this.installFromTarball(import_path7.default.resolve(this.context.cwd, arg));
} else {
return this.installFromDescriptor(parseSpec(arg, `CLI arguments`, { enforceExactVersion: false }));
}
@@ -14435,7 +11285,7 @@ var InstallGlobalCommand = class extends BaseCommand {
async installFromTarball(p) {
const installFolder = getInstallFolder();
const archiveEntries = /* @__PURE__ */ new Map();
- const { list: tarT } = await Promise.resolve().then(() => (init_list(), list_exports));
+ const { list: tarT } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
let hasShortEntries = false;
await tarT({ file: p, onentry: (entry) => {
const segments = entry.path.split(/\//g);
@@ -14452,16 +11302,16 @@ var InstallGlobalCommand = class extends BaseCommand {
} });
if (hasShortEntries || archiveEntries.size < 1)
throw new import_clipanion10.UsageError(`Invalid archive format; did it get generated by 'corepack pack'?`);
- const { extract: tarX } = await Promise.resolve().then(() => (init_extract(), extract_exports));
- for (const [name2, references] of archiveEntries) {
+ const { extract: tarX } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
+ for (const [name, references] of archiveEntries) {
for (const reference of references) {
- if (!isSupportedPackageManager(name2))
- throw new import_clipanion10.UsageError(`Unsupported package manager '${name2}'`);
- this.log({ name: name2, reference });
- await import_fs10.default.promises.mkdir(installFolder, { recursive: true });
- await tarX({ file: p, cwd: installFolder }, [`${name2}/${reference}`]);
+ if (!isSupportedPackageManager(name))
+ throw new import_clipanion10.UsageError(`Unsupported package manager '${name}'`);
+ this.log({ name, reference });
+ await import_fs8.default.promises.mkdir(installFolder, { recursive: true });
+ await tarX({ file: p, cwd: installFolder }, [`${name}/${reference}`]);
if (!this.cacheOnly) {
- await this.context.engine.activatePackageManager({ name: name2, reference });
+ await this.context.engine.activatePackageManager({ name, reference });
}
}
}
@@ -14500,7 +11350,7 @@ var InstallLocalCommand = class extends BaseCommand {
// sources/commands/Pack.ts
var import_clipanion12 = __toESM(require_advanced());
var import_promises3 = require("fs/promises");
-var import_path11 = __toESM(require("path"));
+var import_path8 = __toESM(require("path"));
var PackCommand = class extends BaseCommand {
static paths = [
[`pack`]
@@ -14541,17 +11391,17 @@ var PackCommand = class extends BaseCommand {
installLocations.push(packageManagerInfo.location);
}
const baseInstallFolder = getInstallFolder();
- const outputPath = import_path11.default.resolve(this.context.cwd, this.output ?? `corepack.tgz`);
+ const outputPath = import_path8.default.resolve(this.context.cwd, this.output ?? `corepack.tgz`);
if (!this.json) {
this.context.stdout.write(`
`);
- this.context.stdout.write(`Packing the selected tools in ${import_path11.default.basename(outputPath)}...
+ this.context.stdout.write(`Packing the selected tools in ${import_path8.default.basename(outputPath)}...
`);
}
- const { create: tarC } = await Promise.resolve().then(() => (init_create(), create_exports));
+ const { create: tarC } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
await (0, import_promises3.mkdir)(baseInstallFolder, { recursive: true });
- await tarC({ gzip: true, cwd: baseInstallFolder, file: import_path11.default.resolve(outputPath) }, installLocations.map((location) => {
- return import_path11.default.relative(baseInstallFolder, location);
+ await tarC({ gzip: true, cwd: baseInstallFolder, file: import_path8.default.resolve(outputPath) }, installLocations.map((location) => {
+ return import_path8.default.relative(baseInstallFolder, location);
}));
if (this.json) {
this.context.stdout.write(`${JSON.stringify(outputPath)}
@@ -14646,7 +11496,7 @@ var UseCommand = class extends BaseCommand {
// sources/commands/deprecated/Hydrate.ts
var import_clipanion15 = __toESM(require_advanced());
var import_promises4 = require("fs/promises");
-var import_path12 = __toESM(require("path"));
+var import_path9 = __toESM(require("path"));
var HydrateCommand = class extends import_clipanion15.Command {
static paths = [
[`hydrate`]
@@ -14657,10 +11507,10 @@ var HydrateCommand = class extends import_clipanion15.Command {
fileName = import_clipanion15.Option.String();
async execute() {
const installFolder = getInstallFolder();
- const fileName = import_path12.default.resolve(this.context.cwd, this.fileName);
+ const fileName = import_path9.default.resolve(this.context.cwd, this.fileName);
const archiveEntries = /* @__PURE__ */ new Map();
let hasShortEntries = false;
- const { list: tarT } = await Promise.resolve().then(() => (init_list(), list_exports));
+ const { list: tarT } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
await tarT({ file: fileName, onentry: (entry) => {
const segments = entry.path.split(/\//g);
if (segments.length < 3) {
@@ -14674,21 +11524,21 @@ var HydrateCommand = class extends import_clipanion15.Command {
} });
if (hasShortEntries || archiveEntries.size < 1)
throw new import_clipanion15.UsageError(`Invalid archive format; did it get generated by 'corepack prepare'?`);
- const { extract: tarX } = await Promise.resolve().then(() => (init_extract(), extract_exports));
- for (const [name2, references] of archiveEntries) {
+ const { extract: tarX } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
+ for (const [name, references] of archiveEntries) {
for (const reference of references) {
- if (!isSupportedPackageManager(name2))
- throw new import_clipanion15.UsageError(`Unsupported package manager '${name2}'`);
+ if (!isSupportedPackageManager(name))
+ throw new import_clipanion15.UsageError(`Unsupported package manager '${name}'`);
if (this.activate)
- this.context.stdout.write(`Hydrating ${name2}@${reference} for immediate activation...
+ this.context.stdout.write(`Hydrating ${name}@${reference} for immediate activation...
`);
else
- this.context.stdout.write(`Hydrating ${name2}@${reference}...
+ this.context.stdout.write(`Hydrating ${name}@${reference}...
`);
await (0, import_promises4.mkdir)(installFolder, { recursive: true });
- await tarX({ file: fileName, cwd: installFolder }, [`${name2}/${reference}`]);
+ await tarX({ file: fileName, cwd: installFolder }, [`${name}/${reference}`]);
if (this.activate) {
- await this.context.engine.activatePackageManager({ name: name2, reference });
+ await this.context.engine.activatePackageManager({ name, reference });
}
}
}
@@ -14700,7 +11550,7 @@ var HydrateCommand = class extends import_clipanion15.Command {
// sources/commands/deprecated/Prepare.ts
var import_clipanion16 = __toESM(require_advanced());
var import_promises5 = require("fs/promises");
-var import_path13 = __toESM(require("path"));
+var import_path10 = __toESM(require("path"));
var PrepareCommand = class extends import_clipanion16.Command {
static paths = [
[`prepare`]
@@ -14762,14 +11612,14 @@ var PrepareCommand = class extends import_clipanion16.Command {
if (this.output) {
const outputName = typeof this.output === `string` ? this.output : `corepack.tgz`;
const baseInstallFolder = getInstallFolder();
- const outputPath = import_path13.default.resolve(this.context.cwd, outputName);
+ const outputPath = import_path10.default.resolve(this.context.cwd, outputName);
if (!this.json)
- this.context.stdout.write(`Packing the selected tools in ${import_path13.default.basename(outputPath)}...
+ this.context.stdout.write(`Packing the selected tools in ${import_path10.default.basename(outputPath)}...
`);
- const { create: tarC } = await Promise.resolve().then(() => (init_create(), create_exports));
+ const { create: tarC } = await Promise.resolve().then(() => (init_index_min(), index_min_exports));
await (0, import_promises5.mkdir)(baseInstallFolder, { recursive: true });
- await tarC({ gzip: true, cwd: baseInstallFolder, file: import_path13.default.resolve(outputPath) }, installLocations.map((location) => {
- return import_path13.default.relative(baseInstallFolder, location);
+ await tarC({ gzip: true, cwd: baseInstallFolder, file: import_path10.default.resolve(outputPath) }, installLocations.map((location) => {
+ return import_path10.default.relative(baseInstallFolder, location);
}));
if (this.json) {
this.context.stdout.write(`${JSON.stringify(outputPath)}
@@ -14829,9 +11679,9 @@ async function runMain(argv) {
cwd: process.cwd(),
engine
};
- const code2 = await cli.run(argv, context);
- if (code2 !== 0) {
- process.exitCode ??= code2;
+ const code = await cli.run(argv, context);
+ if (code !== 0) {
+ process.exitCode ??= code;
}
} else {
try {
diff --git a/deps/corepack/package.json b/deps/corepack/package.json
index 170b48449fc..f456c175830 100644
--- a/deps/corepack/package.json
+++ b/deps/corepack/package.json
@@ -1,6 +1,6 @@
{
"name": "corepack",
- "version": "0.36.0",
+ "version": "0.37.0",
"homepage": "https://github.com/nodejs/corepack#readme",
"bugs": {
"url": "https://github.com/nodejs/corepack/issues"
@@ -16,7 +16,7 @@
"./package.json": "./package.json"
},
"license": "MIT",
- "packageManager": "yarn@4.18.0+sha224.5707fce90df5d8720fae4e85a07ab55e90aa20fded8914893e2ba225",
+ "packageManager": "yarn@4.19.0+sha512.2cb9e5a36f7f11f2bc6ff444830d87368d419e0d83b6a0fb6077d3e6fed0f476c9514dff4ba4d84b049bd34ef32954e550f264ad2fbbfebcba6c89e869530bba",
"devDependencies": {
"@types/debug": "^4.1.5",
"@types/node": "^22.0.0",
@@ -32,7 +32,7 @@
"eslint": "^10.8.1",
"semver": "^7.6.3",
"supports-color": "^11.0.0",
- "tar": "^7.5.11",
+ "tar": "^8.1.3",
"typescript": "^5.7.3",
"v8-compile-cache": "^2.3.0",
"vitest": "^4.0.5",