@pnpm/lockfile.detect-dep-types 1100.0.24 → 1100.0.25
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.
- package/CHANGELOG.md +11 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +12 -4
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @pnpm/lockfile.detect-dep-types
|
|
2
2
|
|
|
3
|
+
## 1100.0.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `pnpm install --prod`, `pnpm fetch --prod` and `pnpm deploy --prod` no longer install a devDependency that is only there to satisfy an optional peer dependency of a production dependency. `pnpm list`, `pnpm why`, `pnpm licenses`, `pnpm sbom` and `pnpm audit` leave it out of `--prod` results too. The same applies to `--dev`. A peer that is not optional is still installed and audited [#15344](https://github.com/pnpm/pnpm/issues/15344).
|
|
8
|
+
|
|
9
|
+
- Updated dependencies:
|
|
10
|
+
- @pnpm/deps.path@1101.0.4
|
|
11
|
+
- @pnpm/lockfile.types@1100.1.3
|
|
12
|
+
- @pnpm/types@1102.1.1
|
|
13
|
+
|
|
3
14
|
## 1100.0.24
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PeerSatisfactionEdgesOptions } from '@pnpm/lockfile.peer-edges';
|
|
1
2
|
import type { LockfileObject } from '@pnpm/lockfile.types';
|
|
2
3
|
export declare const DepType: {
|
|
3
4
|
readonly DevOnly: 0;
|
|
@@ -6,4 +7,9 @@ export declare const DepType: {
|
|
|
6
7
|
};
|
|
7
8
|
export type DepType = (typeof DepType)[keyof typeof DepType];
|
|
8
9
|
export type DepTypes = Record<string, DepType>;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Classifies every package reachable from the importers. Peer-satisfaction
|
|
12
|
+
* edges (see `@pnpm/lockfile.peer-edges`) are not followed: a devDependency
|
|
13
|
+
* that only satisfies an optional peer of a production package is dev-only.
|
|
14
|
+
*/
|
|
15
|
+
export declare function detectDepTypes(lockfile: LockfileObject, opts?: PeerSatisfactionEdgesOptions): DepTypes;
|
package/lib/index.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import * as dp from '@pnpm/deps.path';
|
|
2
|
+
import { getPeerSatisfactionEdges, isPeerSatisfactionEdge, } from '@pnpm/lockfile.peer-edges';
|
|
2
3
|
export const DepType = {
|
|
3
4
|
DevOnly: 0,
|
|
4
5
|
DevAndProd: 1,
|
|
5
6
|
ProdOnly: 2,
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Classifies every package reachable from the importers. Peer-satisfaction
|
|
10
|
+
* edges (see `@pnpm/lockfile.peer-edges`) are not followed: a devDependency
|
|
11
|
+
* that only satisfies an optional peer of a production package is dev-only.
|
|
12
|
+
*/
|
|
13
|
+
export function detectDepTypes(lockfile, opts) {
|
|
8
14
|
const dev = {};
|
|
9
15
|
const devDepPaths = Object.values(lockfile.importers)
|
|
10
16
|
.map((deps) => resolvedDepsToDepPaths(deps.devDependencies ?? {})).flat();
|
|
@@ -17,6 +23,7 @@ export function detectDepTypes(lockfile) {
|
|
|
17
23
|
walked: new Set(),
|
|
18
24
|
notProdOnly: new Set(),
|
|
19
25
|
dev,
|
|
26
|
+
peerSatisfactionEdges: getPeerSatisfactionEdges(lockfile, opts),
|
|
20
27
|
};
|
|
21
28
|
detectDepTypesInSubGraph(ctx, devDepPaths, {
|
|
22
29
|
dev: true,
|
|
@@ -49,14 +56,15 @@ function detectDepTypesInSubGraph(ctx, depPaths, opts) {
|
|
|
49
56
|
ctx.dev[depPath] = DepType.ProdOnly;
|
|
50
57
|
}
|
|
51
58
|
const depLockfile = ctx.packages[depPath];
|
|
52
|
-
const newDependencies = resolvedDepsToDepPaths(depLockfile.dependencies ?? {});
|
|
59
|
+
const newDependencies = resolvedDepsToDepPaths(depLockfile.dependencies ?? {}, ctx.peerSatisfactionEdges, depPath);
|
|
53
60
|
detectDepTypesInSubGraph(ctx, newDependencies, opts);
|
|
54
|
-
const newOptionalDependencies = resolvedDepsToDepPaths(depLockfile.optionalDependencies ?? {});
|
|
61
|
+
const newOptionalDependencies = resolvedDepsToDepPaths(depLockfile.optionalDependencies ?? {}, ctx.peerSatisfactionEdges, depPath);
|
|
55
62
|
detectDepTypesInSubGraph(ctx, newOptionalDependencies, { dev: opts.dev });
|
|
56
63
|
}
|
|
57
64
|
}
|
|
58
|
-
function resolvedDepsToDepPaths(deps) {
|
|
65
|
+
function resolvedDepsToDepPaths(deps, peerSatisfactionEdges, parent) {
|
|
59
66
|
return Object.entries(deps)
|
|
67
|
+
.filter(([alias]) => parent == null || !isPeerSatisfactionEdge(peerSatisfactionEdges, parent, alias))
|
|
60
68
|
.map(([alias, ref]) => dp.refToRelative(ref, alias))
|
|
61
69
|
.filter((depPath) => depPath !== null);
|
|
62
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/lockfile.detect-dep-types",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.25",
|
|
4
4
|
"description": "Detect the types of dependencies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -29,12 +29,13 @@
|
|
|
29
29
|
"!*.map"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@pnpm/deps.path": "1101.0.
|
|
33
|
-
"@pnpm/lockfile.
|
|
34
|
-
"@pnpm/types": "
|
|
32
|
+
"@pnpm/deps.path": "1101.0.4",
|
|
33
|
+
"@pnpm/lockfile.peer-edges": "1100.0.0",
|
|
34
|
+
"@pnpm/lockfile.types": "1100.1.3",
|
|
35
|
+
"@pnpm/types": "1102.1.1"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@pnpm/lockfile.detect-dep-types": "1100.0.
|
|
38
|
+
"@pnpm/lockfile.detect-dep-types": "1100.0.25",
|
|
38
39
|
"tempy": "3.0.0"
|
|
39
40
|
},
|
|
40
41
|
"engines": {
|