Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pnpm/dependency-path

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/dependency-path - npm Package Compare versions

Comparing version 4.0.0 to 5.0.0

17

lib/index.d.ts

@@ -1,4 +0,7 @@

import { type Registries } from '@pnpm/types';
import { type DepPath, type PkgResolutionId, type Registries, type PkgId, type PkgIdWithPatchHash } from '@pnpm/types';
export declare function isAbsolute(dependencyPath: string): boolean;
export declare function indexOfPeersSuffix(depPath: string): number;
export declare function indexOfPeersSuffix(depPath: string): {
peersIndex: number;
patchHashIndex: number;
};
export interface ParsedDepPath {

@@ -9,6 +12,7 @@ id: string;

export declare function parseDepPath(relDepPath: string): ParsedDepPath;
export declare function removePeersSuffix(relDepPath: string): string;
export declare function tryGetPackageId(relDepPath: string): string;
export declare function removeSuffix(relDepPath: string): string;
export declare function getPkgIdWithPatchHash(depPath: DepPath): PkgIdWithPatchHash;
export declare function tryGetPackageId(relDepPath: DepPath): PkgId;
export declare function getRegistryByPackageName(registries: Registries, packageName: string): string;
export declare function refToRelative(reference: string, pkgName: string): string | null;
export declare function refToRelative(reference: string, pkgName: string): DepPath | null;
export interface DependencyPath {

@@ -18,3 +22,4 @@ name?: string;

version?: string;
nonSemverVersion?: string;
nonSemverVersion?: PkgResolutionId;
patchHash?: string;
}

@@ -21,0 +26,0 @@ export declare function parse(dependencyPath: string): DependencyPath;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createPeersDirSuffix = exports.depPathToFilename = exports.parse = exports.refToRelative = exports.getRegistryByPackageName = exports.tryGetPackageId = exports.removePeersSuffix = exports.parseDepPath = exports.indexOfPeersSuffix = exports.isAbsolute = void 0;
exports.createPeersDirSuffix = exports.depPathToFilename = exports.parse = exports.refToRelative = exports.getRegistryByPackageName = exports.tryGetPackageId = exports.getPkgIdWithPatchHash = exports.removeSuffix = exports.parseDepPath = exports.indexOfPeersSuffix = exports.isAbsolute = void 0;
const crypto_base32_hash_1 = require("@pnpm/crypto.base32-hash");

@@ -16,3 +16,3 @@ const semver_1 = __importDefault(require("semver"));

if (!depPath.endsWith(')'))
return -1;
return { peersIndex: -1, patchHashIndex: -1 };
let open = 1;

@@ -27,14 +27,23 @@ for (let i = depPath.length - 2; i >= 0; i--) {

else if (!open) {
return i + 1;
if (depPath.substring(i + 1).startsWith('(patch_hash=')) {
return {
patchHashIndex: i + 1,
peersIndex: depPath.indexOf('(', i + 2),
};
}
return {
patchHashIndex: -1,
peersIndex: i + 1,
};
}
}
return -1;
return { peersIndex: -1, patchHashIndex: -1 };
}
exports.indexOfPeersSuffix = indexOfPeersSuffix;
function parseDepPath(relDepPath) {
const sepIndex = indexOfPeersSuffix(relDepPath);
if (sepIndex !== -1) {
const { peersIndex } = indexOfPeersSuffix(relDepPath);
if (peersIndex !== -1) {
return {
id: relDepPath.substring(0, sepIndex),
peersSuffix: relDepPath.substring(sepIndex),
id: relDepPath.substring(0, peersIndex),
peersSuffix: relDepPath.substring(peersIndex),
};

@@ -48,19 +57,36 @@ }

exports.parseDepPath = parseDepPath;
function removePeersSuffix(relDepPath) {
const sepIndex = indexOfPeersSuffix(relDepPath);
if (sepIndex !== -1) {
return relDepPath.substring(0, sepIndex);
function removeSuffix(relDepPath) {
const { peersIndex, patchHashIndex } = indexOfPeersSuffix(relDepPath);
if (patchHashIndex !== -1) {
return relDepPath.substring(0, patchHashIndex);
}
if (peersIndex !== -1) {
return relDepPath.substring(0, peersIndex);
}
return relDepPath;
}
exports.removePeersSuffix = removePeersSuffix;
exports.removeSuffix = removeSuffix;
function getPkgIdWithPatchHash(depPath) {
let pkgId = depPath;
const { peersIndex: sepIndex } = indexOfPeersSuffix(pkgId);
if (sepIndex !== -1) {
pkgId = pkgId.substring(0, sepIndex);
}
if (pkgId.includes(':')) {
pkgId = pkgId.substring(pkgId.indexOf('@', 1) + 1);
}
return pkgId;
}
exports.getPkgIdWithPatchHash = getPkgIdWithPatchHash;
function tryGetPackageId(relDepPath) {
const sepIndex = indexOfPeersSuffix(relDepPath);
let pkgId = relDepPath;
const { peersIndex, patchHashIndex } = indexOfPeersSuffix(pkgId);
const sepIndex = patchHashIndex === -1 ? peersIndex : patchHashIndex;
if (sepIndex !== -1) {
relDepPath = relDepPath.substring(0, sepIndex);
pkgId = pkgId.substring(0, sepIndex);
}
if (relDepPath.includes(':')) {
relDepPath = relDepPath.substring(relDepPath.indexOf('@', 1) + 1);
if (pkgId.includes(':')) {
pkgId = pkgId.substring(pkgId.indexOf('@', 1) + 1);
}
return relDepPath;
return pkgId;
}

@@ -105,10 +131,19 @@ exports.tryGetPackageId = tryGetPackageId;

if (version) {
let peerSepIndex;
let peersSuffix;
if (version.includes('(') && version.endsWith(')')) {
peerSepIndex = version.indexOf('(');
if (peerSepIndex !== -1) {
peersSuffix = version.substring(peerSepIndex);
version = version.substring(0, peerSepIndex);
let patchHash;
const { peersIndex, patchHashIndex } = indexOfPeersSuffix(version);
if (peersIndex !== -1 || patchHashIndex !== -1) {
if (peersIndex === -1) {
patchHash = version.substring(patchHashIndex);
version = version.substring(0, patchHashIndex);
}
else if (patchHashIndex === -1) {
peersSuffix = version.substring(peersIndex);
version = version.substring(0, peersIndex);
}
else {
patchHash = version.substring(patchHashIndex, peersIndex);
peersSuffix = version.substring(peersIndex);
version = version.substring(0, patchHashIndex);
}
}

@@ -120,2 +155,3 @@ if (semver_1.default.valid(version)) {

version,
patchHash,
};

@@ -127,2 +163,3 @@ }

peersSuffix,
patchHash,
};

@@ -129,0 +166,0 @@ }

{
"name": "@pnpm/dependency-path",
"version": "4.0.0",
"version": "5.0.0",
"description": "Utilities for working with symlinked node_modules",

@@ -29,7 +29,7 @@ "main": "lib/index.js",

"@pnpm/crypto.base32-hash": "3.0.0",
"@pnpm/types": "10.0.0"
"@pnpm/types": "10.1.0"
},
"devDependencies": {
"@types/semver": "7.5.3",
"@pnpm/dependency-path": "4.0.0"
"@pnpm/dependency-path": "5.0.0"
},

@@ -36,0 +36,0 @@ "funding": "https://opencollective.com/pnpm",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc