UNPKG

pncat

Version:

A unified cli tool that enhances package managers catalogs feature.

1,426 lines (1,394 loc) 170 kB
import { a as __toESM, r as __exportAll, t as __commonJSMin } from "./chunk-D1OLi6Wq.mjs"; import { a as getValueByPath, c as isDepFieldEnabled, d as require_cjs, f as toArray, i as getDepSource, l as isObject, n as cloneDeep, o as hasEslint, r as getCwd, s as hasVSCodeEngine, u as isPnpmOverridesPackageName } from "./merge-D6X7PPVO.mjs"; import process$1 from "node:process"; import { dirname, join, relative, resolve } from "pathe"; import * as p from "@clack/prompts"; import c from "ansis"; import { cac } from "cac"; import { detect, resolveCommand } from "package-manager-detector"; import { x } from "tinyexec"; import { existsSync } from "node:fs"; import { readFile, writeFile } from "node:fs/promises"; import path from "node:path"; import os from "node:os"; import { findUp } from "find-up"; import { glob } from "tinyglobby"; import { parsePnpmWorkspaceYaml } from "pnpm-workspace-yaml"; import { createConfigLoader } from "unconfig"; //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js var Diff = class { diff(oldStr, newStr, options = {}) { let callback; if (typeof options === "function") { callback = options; options = {}; } else if ("callback" in options) callback = options.callback; const oldString = this.castInput(oldStr, options); const newString = this.castInput(newStr, options); const oldTokens = this.removeEmpty(this.tokenize(oldString, options)); const newTokens = this.removeEmpty(this.tokenize(newString, options)); return this.diffWithOptionsObj(oldTokens, newTokens, options, callback); } diffWithOptionsObj(oldTokens, newTokens, options, callback) { var _a; const done = (value) => { value = this.postProcess(value, options); if (callback) { setTimeout(function() { callback(value); }, 0); return; } else return value; }; const newLen = newTokens.length, oldLen = oldTokens.length; let editLength = 1; let maxEditLength = newLen + oldLen; if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength); const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity; const abortAfterTimestamp = Date.now() + maxExecutionTime; const bestPath = [{ oldPos: -1, lastComponent: void 0 }]; let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options); if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens)); let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity; const execEditLength = () => { for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) { let basePath; const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1]; if (removePath) bestPath[diagonalPath - 1] = void 0; let canAdd = false; if (addPath) { const addPathNewPos = addPath.oldPos - diagonalPath; canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen; } const canRemove = removePath && removePath.oldPos + 1 < oldLen; if (!canAdd && !canRemove) { bestPath[diagonalPath] = void 0; continue; } if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options); else basePath = this.addToPath(removePath, false, true, 1, options); newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options); if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true; else { bestPath[diagonalPath] = basePath; if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1); if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1); } } editLength++; }; if (callback) (function exec() { setTimeout(function() { if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0); if (!execEditLength()) exec(); }, 0); })(); else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) { const ret = execEditLength(); if (ret) return ret; } } addToPath(path, added, removed, oldPosInc, options) { const last = path.lastComponent; if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return { oldPos: path.oldPos + oldPosInc, lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent } }; else return { oldPos: path.oldPos + oldPosInc, lastComponent: { count: 1, added, removed, previousComponent: last } }; } extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) { const newLen = newTokens.length, oldLen = oldTokens.length; let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0; while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) { newPos++; oldPos++; commonCount++; if (options.oneChangePerToken) basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false }; } if (commonCount && !options.oneChangePerToken) basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false }; basePath.oldPos = oldPos; return newPos; } equals(left, right, options) { if (options.comparator) return options.comparator(left, right); else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase(); } removeEmpty(array) { const ret = []; for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]); return ret; } castInput(value, options) { return value; } tokenize(value, options) { return Array.from(value); } join(chars) { return chars.join(""); } postProcess(changeObjects, options) { return changeObjects; } get useLongestToken() { return false; } buildValues(lastComponent, newTokens, oldTokens) { const components = []; let nextComponent; while (lastComponent) { components.push(lastComponent); nextComponent = lastComponent.previousComponent; delete lastComponent.previousComponent; lastComponent = nextComponent; } components.reverse(); const componentLen = components.length; let componentPos = 0, newPos = 0, oldPos = 0; for (; componentPos < componentLen; componentPos++) { const component = components[componentPos]; if (!component.removed) { if (!component.added && this.useLongestToken) { let value = newTokens.slice(newPos, newPos + component.count); value = value.map(function(value, i) { const oldValue = oldTokens[oldPos + i]; return oldValue.length > value.length ? oldValue : value; }); component.value = this.join(value); } else component.value = this.join(newTokens.slice(newPos, newPos + component.count)); newPos += component.count; if (!component.added) oldPos += component.count; } else { component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count)); oldPos += component.count; } } return components; } }; //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js var CharacterDiff = class extends Diff {}; const characterDiff = new CharacterDiff(); //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/util/string.js function longestCommonPrefix(str1, str2) { let i; for (i = 0; i < str1.length && i < str2.length; i++) if (str1[i] != str2[i]) return str1.slice(0, i); return str1.slice(0, i); } function longestCommonSuffix(str1, str2) { let i; if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) return ""; for (i = 0; i < str1.length && i < str2.length; i++) if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) return str1.slice(-i); return str1.slice(-i); } function replacePrefix(string, oldPrefix, newPrefix) { if (string.slice(0, oldPrefix.length) != oldPrefix) throw Error(`string ${JSON.stringify(string)} doesn't start with prefix ${JSON.stringify(oldPrefix)}; this is a bug`); return newPrefix + string.slice(oldPrefix.length); } function replaceSuffix(string, oldSuffix, newSuffix) { if (!oldSuffix) return string + newSuffix; if (string.slice(-oldSuffix.length) != oldSuffix) throw Error(`string ${JSON.stringify(string)} doesn't end with suffix ${JSON.stringify(oldSuffix)}; this is a bug`); return string.slice(0, -oldSuffix.length) + newSuffix; } function removePrefix(string, oldPrefix) { return replacePrefix(string, oldPrefix, ""); } function removeSuffix(string, oldSuffix) { return replaceSuffix(string, oldSuffix, ""); } function maximumOverlap(string1, string2) { return string2.slice(0, overlapCount(string1, string2)); } function overlapCount(a, b) { let startA = 0; if (a.length > b.length) startA = a.length - b.length; let endB = b.length; if (a.length < b.length) endB = a.length; const map = Array(endB); let k = 0; map[0] = 0; for (let j = 1; j < endB; j++) { if (b[j] == b[k]) map[j] = map[k]; else map[j] = k; while (k > 0 && b[j] != b[k]) k = map[k]; if (b[j] == b[k]) k++; } k = 0; for (let i = startA; i < a.length; i++) { while (k > 0 && a[i] != b[k]) k = map[k]; if (a[i] == b[k]) k++; } return k; } function trailingWs(string) { let i; for (i = string.length - 1; i >= 0; i--) if (!string[i].match(/\s/)) break; return string.substring(i + 1); } function leadingWs(string) { const match = string.match(/^\s*/); return match ? match[0] : ""; } //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/word.js const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}"; const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug"); var WordDiff = class extends Diff { equals(left, right, options) { if (options.ignoreCase) { left = left.toLowerCase(); right = right.toLowerCase(); } return left.trim() === right.trim(); } tokenize(value, options = {}) { let parts; if (options.intlSegmenter) { const segmenter = options.intlSegmenter; if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\""); parts = []; for (const segmentObj of Array.from(segmenter.segment(value))) { const segment = segmentObj.segment; if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment; else parts.push(segment); } } else parts = value.match(tokenizeIncludingWhitespace) || []; const tokens = []; let prevPart = null; parts.forEach((part) => { if (/\s/.test(part)) if (prevPart == null) tokens.push(part); else tokens.push(tokens.pop() + part); else if (prevPart != null && /\s/.test(prevPart)) if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part); else tokens.push(prevPart + part); else tokens.push(part); prevPart = part; }); return tokens; } join(tokens) { return tokens.map((token, i) => { if (i == 0) return token; else return token.replace(/^\s+/, ""); }).join(""); } postProcess(changes, options) { if (!changes || options.oneChangePerToken) return changes; let lastKeep = null; let insertion = null; let deletion = null; changes.forEach((change) => { if (change.added) insertion = change; else if (change.removed) deletion = change; else { if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change); lastKeep = change; insertion = null; deletion = null; } }); if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null); return changes; } }; const wordDiff = new WordDiff(); function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) { if (deletion && insertion) { const oldWsPrefix = leadingWs(deletion.value); const oldWsSuffix = trailingWs(deletion.value); const newWsPrefix = leadingWs(insertion.value); const newWsSuffix = trailingWs(insertion.value); if (startKeep) { const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix); startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix); deletion.value = removePrefix(deletion.value, commonWsPrefix); insertion.value = removePrefix(insertion.value, commonWsPrefix); } if (endKeep) { const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix); endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix); deletion.value = removeSuffix(deletion.value, commonWsSuffix); insertion.value = removeSuffix(insertion.value, commonWsSuffix); } } else if (insertion) { if (startKeep) { const ws = leadingWs(insertion.value); insertion.value = insertion.value.substring(ws.length); } if (endKeep) { const ws = leadingWs(endKeep.value); endKeep.value = endKeep.value.substring(ws.length); } } else if (startKeep && endKeep) { const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value); const newWsStart = longestCommonPrefix(newWsFull, delWsStart); deletion.value = removePrefix(deletion.value, newWsStart); const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd); deletion.value = removeSuffix(deletion.value, newWsEnd); endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd); startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length)); } else if (endKeep) { const endKeepWsPrefix = leadingWs(endKeep.value); const overlap = maximumOverlap(trailingWs(deletion.value), endKeepWsPrefix); deletion.value = removeSuffix(deletion.value, overlap); } else if (startKeep) { const overlap = maximumOverlap(trailingWs(startKeep.value), leadingWs(deletion.value)); deletion.value = removePrefix(deletion.value, overlap); } } var WordsWithSpaceDiff = class extends Diff { tokenize(value) { const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug"); return value.match(regex) || []; } }; const wordsWithSpaceDiff = new WordsWithSpaceDiff(); //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/line.js var LineDiff = class extends Diff { constructor() { super(...arguments); this.tokenize = tokenize; } equals(left, right, options) { if (options.ignoreWhitespace) { if (!options.newlineIsToken || !left.includes("\n")) left = left.trim(); if (!options.newlineIsToken || !right.includes("\n")) right = right.trim(); } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) { if (left.endsWith("\n")) left = left.slice(0, -1); if (right.endsWith("\n")) right = right.slice(0, -1); } return super.equals(left, right, options); } }; const lineDiff = new LineDiff(); function diffLines(oldStr, newStr, options) { return lineDiff.diff(oldStr, newStr, options); } function tokenize(value, options) { if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n"); const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/); if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop(); for (let i = 0; i < linesAndNewlines.length; i++) { const line = linesAndNewlines[i]; if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line; else retLines.push(line); } return retLines; } //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js function isSentenceEndPunct(char) { return char == "." || char == "!" || char == "?"; } var SentenceDiff = class extends Diff { tokenize(value) { var _a; const result = []; let tokenStartI = 0; for (let i = 0; i < value.length; i++) { if (i == value.length - 1) { result.push(value.slice(tokenStartI)); break; } if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) { result.push(value.slice(tokenStartI, i + 1)); i = tokenStartI = i + 1; while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++; result.push(value.slice(tokenStartI, i + 1)); tokenStartI = i + 1; } } return result; } }; const sentenceDiff = new SentenceDiff(); //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/css.js var CssDiff = class extends Diff { tokenize(value) { return value.split(/([{}:;,]|\s+)/); } }; const cssDiff = new CssDiff(); //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/json.js var JsonDiff = class extends Diff { constructor() { super(...arguments); this.tokenize = tokenize; } get useLongestToken() { return true; } castInput(value, options) { const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options; return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " "); } equals(left, right, options) { return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options); } }; const jsonDiff = new JsonDiff(); function canonicalize(obj, stack, replacementStack, replacer, key) { stack = stack || []; replacementStack = replacementStack || []; if (replacer) obj = replacer(key === void 0 ? "" : key, obj); let i; for (i = 0; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i]; let canonicalizedObj; if ("[object Array]" === Object.prototype.toString.call(obj)) { stack.push(obj); canonicalizedObj = new Array(obj.length); replacementStack.push(canonicalizedObj); for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i)); stack.pop(); replacementStack.pop(); return canonicalizedObj; } if (obj && obj.toJSON) obj = obj.toJSON(); if (typeof obj === "object" && obj !== null) { stack.push(obj); canonicalizedObj = {}; replacementStack.push(canonicalizedObj); const sortedKeys = []; let key; for (key in obj) /* istanbul ignore else */ if (Object.prototype.hasOwnProperty.call(obj, key)) sortedKeys.push(key); sortedKeys.sort(); for (i = 0; i < sortedKeys.length; i += 1) { key = sortedKeys[i]; canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key); } stack.pop(); replacementStack.pop(); } else canonicalizedObj = obj; return canonicalizedObj; } //#endregion //#region node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js var ArrayDiff = class extends Diff { tokenize(value) { return value.slice(); } join(value) { return value; } removeEmpty(value) { return value; } }; const arrayDiff = new ArrayDiff(); //#endregion //#region src/commands/shared/diff.ts function diffHighlight(original, updated, options = {}) { const { indentSize = 2, verbose = false } = options; const changed = diffLines(original, updated, { ignoreNewlineAtEof: true }); const diffs = []; for (const part of changed) { const lines = part.value.split("\n"); if (lines[lines.length - 1] === "") lines.pop(); for (const line of lines) diffs.push({ content: line, type: part.added ? "added" : part.removed ? "removed" : "unchanged" }); } const changedLines = /* @__PURE__ */ new Set(); for (const [index, line] of diffs.entries()) if (line.type === "added" || line.type === "removed") changedLines.add(index); const lineHierarchy = []; for (const [index, line] of diffs.entries()) { if (line.content.trim() === "") { lineHierarchy.push({ indentLevel: -1, parentIndices: [] }); continue; } const currentIndent = line.content.search(/\S/); const indentLevel = Math.floor(currentIndent / indentSize); const parentIndices = []; for (let i = index - 1; i >= 0; i--) { const prevLine = diffs[i]; const prevHierarchy = lineHierarchy[i]; if (prevLine.content.trim() === "") continue; const prevIndent = prevLine.content.search(/\S/); const prevIndentLevel = Math.floor(prevIndent / indentSize); if (prevIndentLevel < indentLevel) { parentIndices.unshift(i); if (prevIndentLevel === indentLevel - 1) { parentIndices.unshift(...prevHierarchy.parentIndices); break; } } } lineHierarchy.push({ indentLevel, parentIndices }); } const linesToKeep = /* @__PURE__ */ new Set(); if (verbose) for (const [index] of diffs.entries()) linesToKeep.add(index); else for (const lineIndex of changedLines) { linesToKeep.add(lineIndex); for (const parentIndex of lineHierarchy[lineIndex].parentIndices) linesToKeep.add(parentIndex); } let addedCount = 0; let removedCount = 0; for (const line of diffs) { if (line.type !== "added" && line.type !== "removed") continue; if (!isDependencyEntryLine(line.content, indentSize)) continue; if (line.type === "added") addedCount++; else removedCount++; } const summaryParts = []; if (addedCount > 0) summaryParts.push(`${c.yellow(addedCount)} added`); if (removedCount > 0) summaryParts.push(`${c.yellow(removedCount)} removed`); const result = []; let lastKeptIndex = -1; for (const [index, line] of diffs.entries()) { if (!linesToKeep.has(index)) continue; if (!verbose && lastKeptIndex !== -1 && index > lastKeptIndex + 1) { const skippedCount = index - lastKeptIndex - 1; result.push(c.dim`${c.yellow(skippedCount)} unchanged line${skippedCount > 1 ? "s" : ""}`); } const highlighted = highlightLine(line.content, indentSize, verbose); if (line.type === "added") result.push(c.green(`+ ${highlighted}`)); else if (line.type === "removed") result.push(c.red(`- ${highlighted}`)); else result.push(` ${highlighted}`); lastKeptIndex = index; } if (summaryParts.length > 0) { result.push(""); result.push(summaryParts.join(" ")); } return result.join("\n"); } function highlightLine(content, indentSize, highlightRoot = false) { if (content.trim() === "") return content; const currentIndent = content.search(/\S/); const indentLevel = Math.floor(currentIndent / indentSize); const colonIndex = content.indexOf(":"); if (colonIndex === -1) return content; const beforeColon = content.substring(0, colonIndex); const afterColon = content.substring(colonIndex); const rootStyle = highlightRoot ? c.cyan : c.reset; const versionMatch = afterColon.match(/:\s*(.+)/); const hasValue = !!(versionMatch && versionMatch[1].trim()); if (indentLevel <= 1) { const key = beforeColon.trim(); return content.substring(0, content.indexOf(key)) + rootStyle(key) + c.dim(hasValue ? afterColon : ":"); } return beforeColon + c.dim(hasValue ? afterColon : ":"); } function isDependencyEntryLine(content, indentSize) { if (content.trim() === "") return false; const currentIndent = content.search(/\S/); if (Math.floor(currentIndent / indentSize) < 2) return false; if (!content.includes(":")) return false; const colonIndex = content.indexOf(":"); const versionMatch = content.substring(colonIndex).match(/:\s*(.+)/); return !!(versionMatch && versionMatch[1].trim()); } //#endregion //#region src/commands/shared/error.ts const COMMAND_ERROR_CODES = { ABORT: "abort", INVALID_INPUT: "invalid_input", NOT_FOUND: "not_found" }; const COMMAND_ERROR_MESSAGES = { [COMMAND_ERROR_CODES.ABORT]: "aborting", [COMMAND_ERROR_CODES.INVALID_INPUT]: "invalid input", [COMMAND_ERROR_CODES.NOT_FOUND]: "resource not found" }; function createCommandError(code, message) { const error = new Error(message ?? COMMAND_ERROR_MESSAGES[code]); error.name = "CommandError"; error.code = code; return error; } function isCommandError(error) { const code = error?.code; return error instanceof Error && typeof code === "string" && Object.values(COMMAND_ERROR_CODES).includes(code); } function reportCommandError(error) { if (isCommandError(error)) { p.outro(c.red(error.message || COMMAND_ERROR_MESSAGES[error.code])); return; } console.error(error); } //#endregion //#region src/commands/shared/package.ts async function selectTargetProjectPackages(options) { const { projectPackages, targetPackages = projectPackages, currentPackagePath, promptMessage, yes = false } = options; if (targetPackages.length === 0) throw createCommandError(COMMAND_ERROR_CODES.INVALID_INPUT, "no matching package.json found, aborting"); const defaultTargetPackage = findDefaultTargetPackage(targetPackages, currentPackagePath); const isMonorepo = projectPackages.length > 1; const isOnlyAndCurrent = targetPackages.length === 1 && defaultTargetPackage.filepath === currentPackagePath; if (!isMonorepo || yes || isOnlyAndCurrent) return [defaultTargetPackage]; const selected = await p.multiselect({ message: promptMessage, options: targetPackages.map((pkg) => ({ label: pkg.name, value: pkg.filepath, hint: pkg.relative })), initialValues: [defaultTargetPackage.filepath] }); if (!selected || p.isCancel(selected)) throw createCommandError(COMMAND_ERROR_CODES.ABORT); if (selected.length === 0) throw createCommandError(COMMAND_ERROR_CODES.INVALID_INPUT, "no package selected, aborting"); const selectedPackages = targetPackages.filter((pkg) => selected.includes(pkg.filepath)); if (selectedPackages.length === 0) throw createCommandError(COMMAND_ERROR_CODES.INVALID_INPUT, "no matching package selected, aborting"); return selectedPackages; } function findDefaultTargetPackage(targetPackages, currentPackagePath) { return targetPackages.find((pkg) => pkg.filepath === currentPackagePath) || targetPackages[0]; } //#endregion //#region package.json var name = "pncat"; var version = "0.10.2"; //#endregion //#region src/constants/app.ts const NAME = name; const VERSION = version; //#endregion //#region src/constants/cli.ts const MODE_CHOICES = [ "init", "detect", "migrate", "add", "remove", "clean", "revert" ]; const MODE_ALIASES = { init: [ "create", "setup", "config", "conf" ], detect: [ "scan", "check", "find", "d" ], migrate: [ "move", "mv", "mig", "m" ], add: [ "install", "in", "i" ], remove: [ "uninstall", "rm", "r", "un", "u" ], clean: [ "prune", "cl", "c" ], revert: [ "restore", "undo", "rev" ] }; //#endregion //#region src/constants/core.ts const DEFAULT_CATALOG_OPTIONS = { mode: "detect", recursive: true, force: false, ignoreOtherWorkspaces: true, depFields: { "dependencies": true, "devDependencies": true, "peerDependencies": true, "optionalDependencies": true, "resolutions": true, "overrides": true, "pnpm.overrides": true }, allowedProtocols: [ "workspace", "link", "file" ], specifierOptions: { skipComplexRanges: true, allowPreReleases: true, allowWildcards: false, allowNpmAliases: true }, yes: false, saveExact: false, install: true }; const DEFAULT_IGNORE_PATHS = [ "**/node_modules/**", "**/dist/**", "**/public/**", "**/fixture/**", "**/fixtures/**" ]; //#endregion //#region src/constants/package-manager.ts const PACKAGE_MANAGERS = [ "pnpm", "yarn", "bun", "vlt" ]; const COMMON_DEPS_FIELDS = [ "dependencies", "devDependencies", "peerDependencies", "optionalDependencies" ]; const OVERRIDE_DEPS_FIELDS = [ "pnpm.overrides", "resolutions", "overrides" ]; const WORKSPACE_DEPS_FIELDS = [ "pnpm-workspace", "yarn-workspace", "bun-workspace", "vlt-workspace" ]; const DEPS_FIELDS = [ ...COMMON_DEPS_FIELDS, ...OVERRIDE_DEPS_FIELDS, ...WORKSPACE_DEPS_FIELDS ]; const DEPS_TYPE_CATALOG_MAP = { "dependencies": "prod", "devDependencies": "dev", "peerDependencies": "peer", "optionalDependencies": "optional", "overrides": "override", "yarn-workspace": "override", "bun-workspace": "override", "vlt-workspace": "override", "pnpm.overrides": "override", "resolutions": "override", "pnpm-workspace": "override" }; const DEPS_TYPE_SHORT_MAP = { "dependencies": "", "devDependencies": "dev", "peerDependencies": "peer", "optionalDependencies": "optional", "resolutions": "resolutions", "overrides": "overrides", "pnpm.overrides": "pnpm-overrides", "pnpm-workspace": "pnpm-workspace", "yarn-workspace": "yarn-workspace", "bun-workspace": "bun-workspace", "vlt-workspace": "vlt-workspace" }; const PACKAGE_MANAGER_CONFIG = { pnpm: { type: "pnpm-workspace.yaml", depType: "pnpm-workspace", filename: "pnpm-workspace.yaml", locks: ["pnpm-lock.yaml"], defaultContent: "packages: []" }, yarn: { type: ".yarnrc.yml", depType: "yarn-workspace", filename: ".yarnrc.yml", locks: ["yarn.lock"], defaultContent: "defaultProtocol: \"npm:\"" }, bun: { type: "bun-workspace", depType: "bun-workspace", filename: "package.json", locks: ["bun.lockb", "bun.lock"], defaultContent: "" }, vlt: { type: "vlt.json", depType: "vlt-workspace", filename: "vlt.json", locks: ["vlt-lock.json"], defaultContent: "{}" } }; //#endregion //#region src/constants/process.ts const CMD_BOOL_FLAGS = new Set([ "save-dev", "save-peer", "save-optional", "save-exact", "recursive" ]); const CMD_BOOL_SHORT_FLAGS = new Set([ "D", "P", "O", "E", "r" ]); //#endregion //#region src/constants/rules.ts const COMPLEX_SPECIFIER_RANGE_TYPES = [ "||", "-", ">=", "<=", ">", "<" ]; const SPECIFIER_RANGE_TYPES = [ ...COMPLEX_SPECIFIER_RANGE_TYPES, "x", "*", "pre-release" ]; //#endregion //#region src/commands/shared/process.ts async function runAgentInstall(options = {}) { const { agent = "pnpm", cwd = process$1.cwd(), stdio = "inherit", silent = false } = options; if (!silent) p.outro(`running ${agent} install`); const execOptions = { nodeOptions: { cwd, stdio } }; const fallbackInstall = async () => await x(agent, ["install"], execOptions); try { const resolved = resolveCommand(agent, "install", []); if (resolved) await x(resolved.command, resolved.args, execOptions); else await fallbackInstall(); } catch { await fallbackInstall(); } } async function runAgentRemove(dependencies, options = {}) { const { agent = "pnpm", cwd = process$1.cwd(), recursive = false, stdio = "inherit" } = options; if (dependencies.length === 0) return; const args = [...dependencies]; if (recursive) args.push("--recursive"); const execOptions = { nodeOptions: { cwd, stdio } }; const fallbackRemove = async () => await x(agent, ["remove", ...args], execOptions); try { const resolved = resolveCommand(agent, "uninstall", args); if (resolved) await x(resolved.command, resolved.args, execOptions); else await fallbackRemove(); } catch { await fallbackRemove(); } } async function runHooks(hooks, options = {}) { const { cwd = process$1.cwd() } = options; for (const hook of toArray(hooks)) try { if (typeof hook === "string") { p.log.info(`running hook: ${hook}`); await x(hook, [], { nodeOptions: { cwd, stdio: "inherit", shell: true } }); } else { p.log.info("running custom hook function"); await hook(); } } catch { p.log.warn(`hook failed: ${typeof hook === "string" ? hook : "custom function"}`); } } function parseCommandOptions(args, options = {}) { const deps = parseArgs(args); const isRecursive = ["--recursive", "-r"].some((flag) => args.includes(flag)); const isProd = ["--save-prod", "-P"].some((flag) => args.includes(flag)); const isDev = ["--save-dev", "-D"].some((flag) => args.includes(flag)); const isOptional = ["--save-optional", "-O"].some((flag) => args.includes(flag)); const isPeer = ["--save-peer"].some((flag) => args.includes(flag)); const isExact = ["--save-exact", "-E"].some((flag) => args.includes(flag)); return { deps, isRecursive, isDev: !isProd && isDev, isOptional: !isProd && isOptional, isPeer: !isProd && isPeer, isExact: !!options.saveExact || isExact }; } function parseArgs(args) { const deps = []; let index = 0; while (index < args.length) { const arg = args[index]; if (arg === "--") { deps.push(...args.slice(index + 1)); break; } if (arg.startsWith("--")) { const key = arg.slice(2); if (key.startsWith("no-")) { index++; continue; } if (CMD_BOOL_FLAGS.has(key)) { index++; continue; } if (index + 1 < args.length && !args[index + 1].startsWith("-")) index += 2; else index++; continue; } if (arg.startsWith("-") && arg.length === 2) { const key = arg.slice(1); if (CMD_BOOL_SHORT_FLAGS.has(key)) { index++; continue; } if (index + 1 < args.length && !args[index + 1].startsWith("-")) index += 2; else index++; continue; } deps.push(arg); index++; } return deps; } //#endregion //#region src/commands/shared/render.ts const MIN_DEP_NAME_WIDTH = 12; const MIN_DEP_TYPE_WIDTH = 6; const MIN_SPECIFIER_WIDTH = 10; const MIN_CATALOG_WIDTH = 10; function renderChanges(deps, updatedPackages) { if (deps.length === 0) return ""; const packageMetas = Object.values(updatedPackages); let depNameWidth = MIN_DEP_NAME_WIDTH; let depTypeWidth = MIN_DEP_TYPE_WIDTH; let specifierWidth = MIN_SPECIFIER_WIDTH; let catalogWidth = MIN_CATALOG_WIDTH; for (const dep of deps) { depNameWidth = Math.max(depNameWidth, dep.name.length); depTypeWidth = Math.max(depTypeWidth, DEPS_TYPE_SHORT_MAP[dep.source].length); specifierWidth = Math.max(specifierWidth, dep.specifier.length); catalogWidth = Math.max(catalogWidth, dep.catalogName.length); } const packageDepsMap = /* @__PURE__ */ new Map(); for (const dep of deps) for (const pkgMeta of packageMetas) { const isWorkspaceOverridesPackage = pkgMeta.name.endsWith("-workspace:overrides"); if (!pkgMeta.deps.some((entry) => entry.name === dep.name && (entry.source === dep.source || isWorkspaceOverridesPackage))) continue; packageDepsMap.set(pkgMeta.filepath, [...packageDepsMap.get(pkgMeta.filepath) || [], dep]); } const lines = []; for (const pkgMeta of packageMetas) { const packageDeps = packageDepsMap.get(pkgMeta.filepath) || []; if (packageDeps.length === 0) continue; lines.push(`${c.cyan(pkgMeta.name)} ${c.dim(pkgMeta.relative)}`); lines.push(""); for (const dep of packageDeps) { const depName = dep.name.padEnd(depNameWidth); const depType = DEPS_TYPE_SHORT_MAP[dep.source].padEnd(depTypeWidth); const specifier = dep.specifier.padStart(specifierWidth); const catalogName = (dep.catalogName === "default" ? "" : dep.catalogName).padEnd(catalogWidth); lines.push(` ${depName} ${c.dim(depType)} ${c.red(specifier)} ${c.dim("→")} catalog:${c.reset(c.green(catalogName))}`); } lines.push(""); } const packageCount = packageMetas.length; const packageLabel = packageCount === 1 ? "package" : "packages"; const depLabel = deps.length === 1 ? "dependency" : "dependencies"; lines.push(`${c.yellow(packageCount)} ${packageLabel} ${c.yellow(deps.length)} ${depLabel}`); return lines.join("\n"); } //#endregion //#region node_modules/.pnpm/tildify@3.0.0/node_modules/tildify/index.js const homeDirectory = os.homedir(); function tildify(absolutePath) { const normalizedPath = path.normalize(absolutePath) + path.sep; return (normalizedPath.startsWith(homeDirectory) ? normalizedPath.replace(homeDirectory + path.sep, `~${path.sep}`) : normalizedPath).slice(0, -1); } //#endregion //#region node_modules/.pnpm/detect-indent@7.0.2/node_modules/detect-indent/index.js const INDENT_REGEX = /^(?:( )+|\t+)/; const INDENT_TYPE_SPACE = "space"; const INDENT_TYPE_TAB = "tab"; function shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, value) { return ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && value === 1; } /** Make a Map that counts how many indents/unindents have occurred for a given size and how many lines follow a given indentation. The key is a concatenation of the indentation type (s = space and t = tab) and the size of the indents/unindents. ``` indents = { t3: [1, 0], t4: [1, 5], s5: [1, 0], s12: [1, 0], } ``` */ function makeIndentsMap(string, ignoreSingleSpaces) { const indents = /* @__PURE__ */ new Map(); let previousSize = 0; let previousIndentType; let key; for (const line of string.split(/\n/g)) { if (!line) continue; const matches = line.match(INDENT_REGEX); if (matches === null) { previousSize = 0; previousIndentType = ""; } else { const indent = matches[0].length; const indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB; if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, indent)) continue; if (indentType !== previousIndentType) previousSize = 0; previousIndentType = indentType; let use = 1; let weight = 0; const indentDifference = indent - previousSize; previousSize = indent; if (indentDifference === 0) { use = 0; weight = 1; } else { const absoluteIndentDifference = Math.abs(indentDifference); if (shouldIgnoreSingleSpace(ignoreSingleSpaces, indentType, absoluteIndentDifference)) continue; key = encodeIndentsKey(indentType, absoluteIndentDifference); } const entry = indents.get(key); indents.set(key, entry === void 0 ? [1, 0] : [entry[0] + use, entry[1] + weight]); } } return indents; } function encodeIndentsKey(indentType, indentAmount) { return (indentType === INDENT_TYPE_SPACE ? "s" : "t") + String(indentAmount); } function decodeIndentsKey(indentsKey) { return { type: indentsKey[0] === "s" ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB, amount: Number(indentsKey.slice(1)) }; } function getMostUsedKey(indents) { let result; let maxUsed = 0; let maxWeight = 0; for (const [key, [usedCount, weight]] of indents) if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) { maxUsed = usedCount; maxWeight = weight; result = key; } return result; } function makeIndentString(type, amount) { return (type === INDENT_TYPE_SPACE ? " " : " ").repeat(amount); } function detectIndent$1(string) { if (typeof string !== "string") throw new TypeError("Expected a string"); let indents = makeIndentsMap(string, true); if (indents.size === 0) indents = makeIndentsMap(string, false); const keyOfMostUsedIndent = getMostUsedKey(indents); let type; let amount = 0; let indent = ""; if (keyOfMostUsedIndent !== void 0) { ({type, amount} = decodeIndentsKey(keyOfMostUsedIndent)); indent = makeIndentString(type, amount); } return { amount, type, indent }; } //#endregion //#region src/io/json.ts const DEFAULT_INDENT = " "; async function detectIndent(filepath) { try { return detectIndent$1(await readFile(filepath, "utf-8")).indent || DEFAULT_INDENT; } catch { return DEFAULT_INDENT; } } async function readJsonFile(filepath) { const rawText = await readFile(filepath, "utf-8"); return JSON.parse(rawText); } async function writeJsonFile(filepath, data) { const indent = await detectIndent(filepath); await writeFile(filepath, `${JSON.stringify(data, null, indent)}\n`, "utf-8"); } //#endregion //#region node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => { const SEMVER_SPEC_VERSION = "2.0.0"; const MAX_LENGTH = 256; const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991; const MAX_SAFE_COMPONENT_LENGTH = 16; const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6; const RELEASE_TYPES = [ "major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease" ]; module.exports = { MAX_LENGTH, MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_SAFE_INTEGER, RELEASE_TYPES, SEMVER_SPEC_VERSION, FLAG_INCLUDE_PRERELEASE: 1, FLAG_LOOSE: 2 }; })); //#endregion //#region node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/debug.js var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => { const debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {}; module.exports = debug; })); //#endregion //#region node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/re.js var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => { const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants(); const debug = require_debug(); exports = module.exports = {}; const re = exports.re = []; const safeRe = exports.safeRe = []; const src = exports.src = []; const safeSrc = exports.safeSrc = []; const t = exports.t = {}; let R = 0; const LETTERDASHNUMBER = "[a-zA-Z0-9-]"; const safeRegexReplacements = [ ["\\s", 1], ["\\d", MAX_LENGTH], [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH] ]; const makeSafeRegex = (value) => { for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`); return value; }; const createToken = (name, value, isGlobal) => { const safe = makeSafeRegex(value); const index = R++; debug(name, index, value); t[name] = index; src[index] = value; safeSrc[index] = safe; re[index] = new RegExp(value, isGlobal ? "g" : void 0); safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0); }; createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*"); createToken("NUMERICIDENTIFIERLOOSE", "\\d+"); createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`); createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`); createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`); createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`); createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`); createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`); createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`); createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`); createToken("FULL", `^${src[t.FULLPLAIN]}$`); createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`); createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`); createToken("GTLT", "((?:<|>)?=?)"); createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`); createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`); createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`); createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`); createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`); createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`); createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`); createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`); createToken("COERCERTL", src[t.COERCE], true); createToken("COERCERTLFULL", src[t.COERCEFULL], true); createToken("LONETILDE", "(?:~>?)"); createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true); exports.tildeTrimReplace = "$1~"; createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`); createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); createToken("LONECARET", "(?:\\^)"); createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true); exports.caretTrimReplace = "$1^"; createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`); createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`); createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true); exports.comparatorTrimReplace = "$1$2$3"; createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`); createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`); createToken("STAR", "(<|>)?=?\\s*\\*"); createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"); createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$"); })); //#endregion //#region node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/parse-options.js var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => { const looseOption = Object.freeze({ loose: true }); const emptyOpts = Object.freeze({}); const parseOptions = (options) => { if (!options) return emptyOpts; if (typeof options !== "object") return looseOption; return options; }; module.exports = parseOptions; })); //#endregion //#region node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/identifiers.js var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => { const numeric = /^[0-9]+$/; const compareIdentifiers = (a, b) => { if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1; const anum = numeric.test(a); const bnum = numeric.test(b); if (anum && bnum) { a = +a; b = +b; } return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1; }; const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a); module.exports = { compareIdentifiers, rcompareIdentifiers }; })); //#endregion //#region node_modules/.pnpm/semver@7.7.4/node_modules/semver/classes/semver.js var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => { const debug = require_debug(); const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants(); const { safeRe: re, t } = require_re(); const parseOptions = require_parse_options(); const { compareIdentifiers } = require_identifiers(); var SemVer = class SemVer { constructor(version, options) { options = parseOptions(options); if (version instanceof SemVer) if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version; else version = version.version; else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`); if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`); debug("SemVer", version, options); this.options = options; this.loose = !!options.loose; this.includePrerelease = !!options.includePrerelease; const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]); if (!m) throw new TypeError(`Invalid Version: ${version}`); this.raw = version; this.major = +m[1]; this.minor = +m[2]; this.patch = +m[3]; if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version"); if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version"); if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version"); if (!m[4]) this.prerelease = []; else this.prerelease = m[4].split(".").map((id) => { if (/^[0-9]+$/.test(id)) { const num = +id; if (num >= 0 && num < MAX_SAFE_INTEGER) return num; } return id; }); this.build = m[5] ? m[5].split(".") : []; this.format(); } format() { this.version = `${this.major}.${this.minor}.${this.patch}`; if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`; return this.version; } toString() { return this.version; } compare(other) { debug("SemVer.compare", this.version, this.options, other); if (!(other instanceof SemVer)) { if (typeof other === "string" && other === this.version) return 0; other = new SemVer(other, this.options); } if (other.version === this.version) return 0; return this.compareMain(other) || this.comparePre(other); } compareMain(other) { if (!(other instanceof SemVer)) other = new SemVer(other, this.options); if (this.major < other.major) return -1; if (this.major > other.major) return 1; if (this.minor < other.minor) return -1; if (this.minor > other.minor) return 1; if (this.patch < other.patch) return -1; if (this.patch > other.patch) return 1; return 0; } comparePre(other) { if (!(other instanceof SemVer)) other = new SemVer(other, this.options); if (this.prerelease.length && !other.prerelease.length) return -1; else if (!this.prerelease.length && other.prerelease.length) return 1; else if (!this.prerelease.length && !other.prerelease.length) return 0; let i = 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) return 0; else if (b === void 0) return 1; else if (a === void 0) return -1; else if (a === b) continue; else