@pnpm/list 1000.3.0 → 1000.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ import { type PackageDependencyHierarchy } from './types.js';
2
+ export declare function pruneDependenciesTrees(trees: PackageDependencyHierarchy[] | null, limit: number): PackageDependencyHierarchy[];
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pruneDependenciesTrees = pruneDependenciesTrees;
4
+ function pruneDependenciesTrees(trees, limit) {
5
+ if (trees === null) {
6
+ return [];
7
+ }
8
+ return trees.map((tree) => {
9
+ const endLeafPaths = [];
10
+ const visitedNodes = new Set();
11
+ function findEndLeaves(node, path) {
12
+ if (node.circular) {
13
+ return;
14
+ }
15
+ const nodeId = `${node.name}@${node.version}`;
16
+ if (visitedNodes.has(nodeId)) {
17
+ return;
18
+ }
19
+ visitedNodes.add(nodeId);
20
+ const newPath = [...path, node];
21
+ if (!node.dependencies || node.dependencies.length === 0) {
22
+ endLeafPaths.push(newPath);
23
+ if (endLeafPaths.length >= limit) {
24
+ return;
25
+ }
26
+ }
27
+ for (const child of node.dependencies ?? []) {
28
+ findEndLeaves(child, newPath);
29
+ if (endLeafPaths.length >= limit) {
30
+ return;
31
+ }
32
+ }
33
+ visitedNodes.delete(nodeId);
34
+ }
35
+ if (tree.dependencies) {
36
+ for (const node of tree.dependencies) {
37
+ findEndLeaves(node, []);
38
+ }
39
+ }
40
+ const firstNPaths = endLeafPaths.slice(0, limit);
41
+ const map = new Map();
42
+ const newTree = { dependencies: [] };
43
+ for (const path of firstNPaths) {
44
+ let currentDependencies = newTree.dependencies;
45
+ let pathSoFar = '';
46
+ for (const node of path) {
47
+ pathSoFar += `${node.name}@${node.version},`;
48
+ let existingNode = map.get(pathSoFar);
49
+ if (!existingNode) {
50
+ existingNode = { ...node, dependencies: [] };
51
+ currentDependencies.push(existingNode);
52
+ map.set(pathSoFar, existingNode);
53
+ }
54
+ currentDependencies = existingNode.dependencies;
55
+ }
56
+ }
57
+ return {
58
+ ...tree,
59
+ dependencies: newTree.dependencies,
60
+ };
61
+ });
62
+ }
63
+ //# sourceMappingURL=pruneTree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pruneTree.js","sourceRoot":"","sources":["../src/pruneTree.ts"],"names":[],"mappings":";;AAGA,wDAwEC;AAxED,SAAgB,sBAAsB,CAAE,KAA0C,EAAE,KAAa;IAC/F,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,YAAY,GAAoB,EAAE,CAAA;QACxC,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU,CAAA;QAEtC,SAAS,aAAa,CAAE,IAAiB,EAAE,IAAmB;YAC5D,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,OAAM;YACR,CAAC;YAED,MAAM,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAA;YAC7C,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC7B,OAAM;YACR,CAAC;YAED,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACxB,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,IAAI,CAAC,CAAA;YAE/B,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzD,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;gBAC1B,IAAI,YAAY,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;oBACjC,OAAM;gBACR,CAAC;YACH,CAAC;YAED,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,IAAI,EAAE,EAAE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AG,IAAI;YACP,YAAY,EAAE,OAAO,CAAC,YAAY;SACnC,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/list",
3
- "version": "1000.3.0",
3
+ "version": "1000.3.1",
4
4
  "description": "List installed packages in a symlinked `node_modules`",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -30,17 +30,17 @@
30
30
  "chalk": "^4.1.2",
31
31
  "p-limit": "^3.1.0",
32
32
  "ramda": "npm:@pnpm/ramda@0.28.1",
33
+ "@pnpm/read-project-manifest": "1001.2.5",
34
+ "@pnpm/read-package-json": "1000.1.7",
33
35
  "@pnpm/crypto.polyfill": "1000.1.0",
34
- "@pnpm/lockfile.fs": "1001.1.29",
35
- "@pnpm/read-project-manifest": "1001.2.4",
36
- "@pnpm/reviewing.dependencies-hierarchy": "1001.3.0",
36
+ "@pnpm/reviewing.dependencies-hierarchy": "1001.3.1",
37
37
  "@pnpm/types": "1001.3.0",
38
38
  "@pnpm/text.tree-renderer": "1000.0.0",
39
- "@pnpm/read-package-json": "1000.1.7"
39
+ "@pnpm/lockfile.fs": "1001.1.30"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/ramda": "0.29.12",
43
- "@pnpm/list": "1000.3.0",
43
+ "@pnpm/list": "1000.3.1",
44
44
  "@pnpm/test-fixtures": "1000.0.0"
45
45
  },
46
46
  "engines": {