package.dist.PackageDetails.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of patch-package Show documentation
Show all versions of patch-package Show documentation
Fix broken node modules with no fuss
The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPatchDetailsFromCliString = exports.getPackageDetailsFromPatchFilename = exports.parseNameAndVersion = void 0;
const path_1 = require("./path");
function parseNameAndVersion(str) {
const parts = str
.split("+")
.map((s) => s.trim())
.filter(Boolean);
if (parts.length === 0) {
return null;
}
if (parts.length === 1) {
return { packageName: str };
}
const versionIndex = parts.findIndex((part) => part.match(/^\d+\.\d+\.\d+.*$/));
if (versionIndex === -1) {
const [scope, name] = parts;
return { packageName: `${scope}/${name}` };
}
const nameParts = parts.slice(0, versionIndex);
let packageName;
switch (nameParts.length) {
case 0:
return null;
case 1:
packageName = nameParts[0];
break;
case 2:
const [scope, name] = nameParts;
packageName = `${scope}/${name}`;
break;
default:
return null;
}
const version = parts[versionIndex];
const sequenceParts = parts.slice(versionIndex + 1);
if (sequenceParts.length === 0) {
return { packageName, version };
}
// expect sequenceParts[0] to be a number, strip leading 0s
const sequenceNumber = parseInt(sequenceParts[0].replace(/^0+/, ""), 10);
if (isNaN(sequenceNumber)) {
return null;
}
switch (sequenceParts.length) {
case 1: {
return { packageName, version, sequenceNumber };
}
case 2: {
return {
packageName,
version,
sequenceName: sequenceParts[1],
sequenceNumber,
};
}
default: {
return null;
}
}
return null;
}
exports.parseNameAndVersion = parseNameAndVersion;
function getPackageDetailsFromPatchFilename(patchFilename) {
const parts = patchFilename
.replace(/(\.dev)?\.patch$/, "")
.split("++")
.map(parseNameAndVersion)
.filter((x) => x !== null);
if (parts.length === 0) {
return null;
}
const lastPart = parts[parts.length - 1];
if (!lastPart.version) {
return null;
}
return {
name: lastPart.packageName,
version: lastPart.version,
path: path_1.join("node_modules", parts.map(({ packageName: name }) => name).join("/node_modules/")),
patchFilename,
pathSpecifier: parts.map(({ packageName: name }) => name).join("/"),
humanReadablePathSpecifier: parts
.map(({ packageName: name }) => name)
.join(" => "),
isNested: parts.length > 1,
packageNames: parts.map(({ packageName: name }) => name),
isDevOnly: patchFilename.endsWith(".dev.patch"),
sequenceName: lastPart.sequenceName,
sequenceNumber: lastPart.sequenceNumber,
};
}
exports.getPackageDetailsFromPatchFilename = getPackageDetailsFromPatchFilename;
function getPatchDetailsFromCliString(specifier) {
const parts = specifier.split("/");
const packageNames = [];
let scope = null;
for (let i = 0; i < parts.length; i++) {
if (parts[i].startsWith("@")) {
if (scope) {
return null;
}
scope = parts[i];
}
else {
if (scope) {
packageNames.push(`${scope}/${parts[i]}`);
scope = null;
}
else {
packageNames.push(parts[i]);
}
}
}
const path = path_1.join("node_modules", packageNames.join("/node_modules/"));
return {
packageNames,
path,
name: packageNames[packageNames.length - 1],
humanReadablePathSpecifier: packageNames.join(" => "),
isNested: packageNames.length > 1,
pathSpecifier: specifier,
};
}
exports.getPatchDetailsFromCliString = getPatchDetailsFromCliString;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUGFja2FnZURldGFpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvUGFja2FnZURldGFpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsaUNBQTZCO0FBbUI3QixTQUFnQixtQkFBbUIsQ0FDakMsR0FBVztJQU9YLE1BQU0sS0FBSyxHQUFHLEdBQUc7U0FDZCxLQUFLLENBQUMsR0FBRyxDQUFDO1NBQ1YsR0FBRyxDQUFDLENBQUMsQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDLENBQUMsSUFBSSxFQUFFLENBQUM7U0FDcEIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ2xCLElBQUksS0FBSyxDQUFDLE1BQU0sS0FBSyxDQUFDLEVBQUU7UUFDdEIsT0FBTyxJQUFJLENBQUE7S0FDWjtJQUNELElBQUksS0FBS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