New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dependencies-hierarchy

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependencies-hierarchy - npm Package Compare versions

Comparing version 9.0.4 to 9.0.5

7

CHANGELOG.md
# dependencies-hierarchy
## 9.0.5
### Patch Changes
- @pnpm/lockfile-file@3.0.14
- @pnpm/read-package-json@3.1.5
## 9.0.4

@@ -4,0 +11,0 @@

4

lib/index.d.ts

@@ -21,3 +21,3 @@ import { DependenciesField, Registries } from '@pnpm/types';

}
export declare type DependenciesHierarchy = {
export interface DependenciesHierarchy {
dependencies?: PackageNode[];

@@ -27,3 +27,3 @@ devDependencies?: PackageNode[];

unsavedDependencies?: PackageNode[];
};
}
export default function dependenciesHierarchy(projectPaths: string[], maybeOpts: {

@@ -30,0 +30,0 @@ depth: number;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,13 +9,14 @@ const lockfile_file_1 = require("@pnpm/lockfile-file");

const modules_yaml_1 = require("@pnpm/modules-yaml");
const normalize_registries_1 = require("@pnpm/normalize-registries");
const pkgid_to_filename_1 = require("@pnpm/pkgid-to-filename");
const read_modules_dir_1 = require("@pnpm/read-modules-dir");
const normalize_registries_1 = __importDefault(require("@pnpm/normalize-registries"));
const pkgid_to_filename_1 = __importDefault(require("@pnpm/pkgid-to-filename"));
const read_modules_dir_1 = __importDefault(require("@pnpm/read-modules-dir"));
const read_package_json_1 = require("@pnpm/read-package-json");
const types_1 = require("@pnpm/types");
const dependency_path_1 = require("dependency-path");
const path = require("path");
const normalizePath = require("normalize-path");
const path = require("path");
const realpathMissing = require("realpath-missing");
const resolveLinkTarget = require("resolve-link-target");
async function dependenciesHierarchy(projectPaths, maybeOpts) {
var _a, _b, _c;
if (!maybeOpts || !maybeOpts.lockfileDir) {

@@ -24,9 +28,9 @@ throw new TypeError('opts.lockfileDir is required');

const registries = normalize_registries_1.default({
...maybeOpts && maybeOpts.registries,
...modules && modules.registries,
...maybeOpts === null || maybeOpts === void 0 ? void 0 : maybeOpts.registries,
...modules === null || modules === void 0 ? void 0 : modules.registries,
});
const currentLockfile = (modules === null || modules === void 0 ? void 0 : modules.virtualStoreDir) && await lockfile_file_1.readCurrentLockfile(modules.virtualStoreDir, { ignoreIncompatible: false }) || null;
const currentLockfile = (_a = ((modules === null || modules === void 0 ? void 0 : modules.virtualStoreDir) && await lockfile_file_1.readCurrentLockfile(modules.virtualStoreDir, { ignoreIncompatible: false }))) !== null && _a !== void 0 ? _a : null;
const result = {};
if (!currentLockfile) {
for (let projectPath of projectPaths) {
for (const projectPath of projectPaths) {
result[projectPath] = {};

@@ -38,3 +42,3 @@ }

depth: maybeOpts.depth || 0,
include: maybeOpts.include || {
include: (_b = maybeOpts.include) !== null && _b !== void 0 ? _b : {
dependencies: true,

@@ -47,3 +51,3 @@ devDependencies: true,

search: maybeOpts.search,
skipped: new Set(modules && modules.skipped || []),
skipped: new Set((_c = modules === null || modules === void 0 ? void 0 : modules.skipped) !== null && _c !== void 0 ? _c : []),
};

@@ -62,2 +66,3 @@ (await Promise.all(projectPaths.map(async (projectPath) => {

async function dependenciesHierarchyForPackage(projectPath, currentLockfile, opts) {
var _a, _b, _c, _d, _e;
const importerId = lockfile_file_1.getLockfileImporterId(opts.lockfileDir, projectPath);

@@ -68,9 +73,9 @@ if (!currentLockfile.importers[importerId])

const savedDeps = getAllDirectDependencies(currentLockfile.importers[importerId]);
const allDirectDeps = await read_modules_dir_1.default(modulesDir) || [];
const allDirectDeps = (_a = await read_modules_dir_1.default(modulesDir)) !== null && _a !== void 0 ? _a : [];
const unsavedDeps = allDirectDeps.filter((directDep) => !savedDeps[directDep]);
const wantedLockfile = await lockfile_file_1.readWantedLockfile(opts.lockfileDir, { ignoreIncompatible: false }) || { packages: {} };
const wantedLockfile = (_b = await lockfile_file_1.readWantedLockfile(opts.lockfileDir, { ignoreIncompatible: false })) !== null && _b !== void 0 ? _b : { packages: {} };
const getChildrenTree = getTree.bind(null, {
currentDepth: 1,
currentPackages: currentLockfile.packages || {},
includeOptionalDependencies: opts.include.optionalDependencies === true,
currentPackages: (_c = currentLockfile.packages) !== null && _c !== void 0 ? _c : {},
includeOptionalDependencies: opts.include.optionalDependencies,
lockfileDir: opts.lockfileDir,

@@ -82,12 +87,13 @@ maxDepth: opts.depth,

skipped: opts.skipped,
wantedPackages: wantedLockfile.packages || {},
wantedPackages: (_d = wantedLockfile.packages) !== null && _d !== void 0 ? _d : {},
});
const result = {};
for (const dependenciesField of types_1.DEPENDENCIES_FIELDS.sort().filter(dependenciedField => opts.include[dependenciedField])) {
const topDeps = currentLockfile.importers[importerId][dependenciesField] || {};
const topDeps = (_e = currentLockfile.importers[importerId][dependenciesField]) !== null && _e !== void 0 ? _e : {};
result[dependenciesField] = [];
Object.keys(topDeps).forEach((alias) => {
var _a, _b, _c;
const { packageInfo, packageAbsolutePath } = getPkgInfo({
alias,
currentPackages: currentLockfile.packages || {},
currentPackages: (_a = currentLockfile.packages) !== null && _a !== void 0 ? _a : {},
lockfileDir: opts.lockfileDir,

@@ -98,6 +104,6 @@ modulesDir,

skipped: opts.skipped,
wantedPackages: wantedLockfile.packages || {},
wantedPackages: (_b = wantedLockfile.packages) !== null && _b !== void 0 ? _b : {},
});
let newEntry = null;
const matchedSearched = opts.search && opts.search(packageInfo);
const matchedSearched = (_c = opts.search) === null || _c === void 0 ? void 0 : _c.call(opts, packageInfo);
if (packageAbsolutePath === null) {

@@ -132,2 +138,3 @@ if (opts.search && !matchedSearched)

await Promise.all(unsavedDeps.map(async (unsavedDep) => {
var _a, _b, _c;
let pkgPath = path.join(modulesDir, unsavedDep);

@@ -142,3 +149,3 @@ let version;

const pkg = await read_package_json_1.safeReadPackageFromDir(pkgPath);
version = pkg && pkg.version || 'undefined';
version = (_a = pkg === null || pkg === void 0 ? void 0 : pkg.version) !== null && _a !== void 0 ? _a : 'undefined';
}

@@ -154,3 +161,3 @@ const pkg = {

};
const matchedSearched = opts.search && opts.search(pkg);
const matchedSearched = (_b = opts.search) === null || _b === void 0 ? void 0 : _b.call(opts, pkg);
if (opts.search && !matchedSearched)

@@ -162,3 +169,3 @@ return;

}
result.unsavedDependencies = result.unsavedDependencies || [];
result.unsavedDependencies = (_c = result.unsavedDependencies) !== null && _c !== void 0 ? _c : [];
result.unsavedDependencies.push(newEntry);

@@ -180,6 +187,7 @@ }));

function getTreeHelper(dependenciesCache, opts, keypath, parentId) {
var _a;
const result = { dependencies: [] };
if (opts.currentDepth > opts.maxDepth || !opts.currentPackages || !opts.currentPackages[parentId])
return result;
const deps = opts.includeOptionalDependencies === false
const deps = !opts.includeOptionalDependencies
? opts.currentPackages[parentId].dependencies

@@ -196,4 +204,5 @@ : {

});
const peers = new Set(Object.keys(opts.currentPackages[parentId].peerDependencies || {}));
const peers = new Set(Object.keys((_a = opts.currentPackages[parentId].peerDependencies) !== null && _a !== void 0 ? _a : {}));
Object.keys(deps).forEach((alias) => {
var _a;
const { packageInfo, packageAbsolutePath } = getPkgInfo({

@@ -211,3 +220,3 @@ alias,

let circular;
const matchedSearched = opts.search && opts.search(packageInfo);
const matchedSearched = (_a = opts.search) === null || _a === void 0 ? void 0 : _a.call(opts, packageInfo);
let newEntry = null;

@@ -262,7 +271,8 @@ if (packageAbsolutePath === null) {

function getPkgInfo(opts) {
var _a;
let name;
let version;
let resolved = undefined;
let dev = undefined;
let optional = undefined;
let resolved;
let dev;
let optional;
let isSkipped = false;

@@ -305,3 +315,3 @@ let isMissing = false;

isMissing,
isPeer: Boolean(opts.peers && opts.peers.has(opts.alias)),
isPeer: Boolean((_a = opts.peers) === null || _a === void 0 ? void 0 : _a.has(opts.alias)),
isSkipped,

@@ -308,0 +318,0 @@ name,

{
"name": "dependencies-hierarchy",
"version": "9.0.4",
"version": "9.0.5",
"description": "Creates a dependencies hierarchy for a symlinked `node_modules`",

@@ -12,3 +12,3 @@ "main": "lib/index.js",

"scripts": {
"lint": "tslint -c ../../tslint.json src/**/*.ts test/**/*.ts",
"lint": "eslint -c ../../eslint.json src/**/*.ts test/**/*.ts",
"_test": "cd ../.. && c8 --reporter lcov --reports-dir packages/dependencies-hierarchy/coverage ts-node packages/dependencies-hierarchy/test --type-check",

@@ -36,3 +36,3 @@ "test": "pnpm run compile && pnpm run _test",

"dependencies": {
"@pnpm/lockfile-file": "3.0.13",
"@pnpm/lockfile-file": "3.0.14",
"@pnpm/lockfile-utils": "2.0.16",

@@ -43,3 +43,3 @@ "@pnpm/modules-yaml": "8.0.2",

"@pnpm/read-modules-dir": "2.0.3",
"@pnpm/read-package-json": "3.1.4",
"@pnpm/read-package-json": "3.1.5",
"@pnpm/types": "6.2.0",

@@ -46,0 +46,0 @@ "dependency-path": "5.0.3",

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