@pnpm/installing.dedupe.check 1100.0.11 → 1100.1.0
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/lib/dedupeDiffCheck.d.ts +17 -1
- package/lib/dedupeDiffCheck.js +33 -6
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/package.json +3 -3
package/lib/dedupeDiffCheck.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import type { SnapshotsChanges } from '@pnpm/installing.dedupe.types';
|
|
1
|
+
import type { DedupeCheckIssues, SnapshotsChanges } from '@pnpm/installing.dedupe.types';
|
|
2
2
|
import type { LockfileObject } from '@pnpm/lockfile.types';
|
|
3
|
+
/**
|
|
4
|
+
* Compute the changes between two lockfiles, as added/removed/updated
|
|
5
|
+
* importer and package snapshots. Unlike {@link dedupeDiffCheck} this never
|
|
6
|
+
* throws — callers that only want to report the diff (e.g. `install
|
|
7
|
+
* --dry-run`) consume the result directly.
|
|
8
|
+
*
|
|
9
|
+
* `includeImporterSpecifiers` also diffs each importer's direct-dependency
|
|
10
|
+
* `specifier`s, not just their resolved versions. `pnpm install --dry-run`
|
|
11
|
+
* sets it so a specifier-only manifest edit (which a real install would
|
|
12
|
+
* persist to the lockfile) is reported; `dedupe --check` leaves it off
|
|
13
|
+
* because a specifier change is irrelevant to deduplication.
|
|
14
|
+
*/
|
|
15
|
+
export declare function calcDedupeCheckIssues(prev: LockfileObject, next: LockfileObject, opts?: {
|
|
16
|
+
includeImporterSpecifiers?: boolean;
|
|
17
|
+
}): DedupeCheckIssues;
|
|
18
|
+
export declare function countDedupeCheckIssues(issues: DedupeCheckIssues): number;
|
|
3
19
|
export declare function dedupeDiffCheck(prev: LockfileObject, next: LockfileObject): void;
|
|
4
20
|
export declare function countChangedSnapshots(snapshotChanges: SnapshotsChanges): number;
|
package/lib/dedupeDiffCheck.js
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
1
|
import { DEPENDENCIES_FIELDS } from '@pnpm/types';
|
|
2
2
|
import { DedupeCheckIssuesError } from './DedupeCheckIssuesError.js';
|
|
3
3
|
const PACKAGE_SNAPSHOT_DEP_FIELDS = ['dependencies', 'optionalDependencies'];
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// Dry-run diffs importers by both the per-group dependency fields and the
|
|
5
|
+
// flat `specifiers` map, so it catches every importer rewrite a real install
|
|
6
|
+
// would persist: the per-group fields surface a dependency moving between
|
|
7
|
+
// `dependencies`/`devDependencies`/`optionalDependencies`, while `specifiers`
|
|
8
|
+
// surfaces a specifier-only edit (same resolved version). `specifiers` is
|
|
9
|
+
// last so that on a per-alias collision its update wins — rendering the
|
|
10
|
+
// specifier delta rather than the re-resolved version, which is cleared in
|
|
11
|
+
// memory for a specifier-mismatched dep.
|
|
12
|
+
const IMPORTER_DRY_RUN_FIELDS = [...DEPENDENCIES_FIELDS, 'specifiers'];
|
|
13
|
+
/**
|
|
14
|
+
* Compute the changes between two lockfiles, as added/removed/updated
|
|
15
|
+
* importer and package snapshots. Unlike {@link dedupeDiffCheck} this never
|
|
16
|
+
* throws — callers that only want to report the diff (e.g. `install
|
|
17
|
+
* --dry-run`) consume the result directly.
|
|
18
|
+
*
|
|
19
|
+
* `includeImporterSpecifiers` also diffs each importer's direct-dependency
|
|
20
|
+
* `specifier`s, not just their resolved versions. `pnpm install --dry-run`
|
|
21
|
+
* sets it so a specifier-only manifest edit (which a real install would
|
|
22
|
+
* persist to the lockfile) is reported; `dedupe --check` leaves it off
|
|
23
|
+
* because a specifier change is irrelevant to deduplication.
|
|
24
|
+
*/
|
|
25
|
+
export function calcDedupeCheckIssues(prev, next, opts) {
|
|
26
|
+
const importerFields = opts?.includeImporterSpecifiers ? IMPORTER_DRY_RUN_FIELDS : DEPENDENCIES_FIELDS;
|
|
27
|
+
return {
|
|
28
|
+
importerIssuesByImporterId: diffSnapshots(prev.importers, next.importers, importerFields),
|
|
7
29
|
packageIssuesByDepPath: diffSnapshots(prev.packages ?? {}, next.packages ?? {}, PACKAGE_SNAPSHOT_DEP_FIELDS),
|
|
8
30
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
31
|
+
}
|
|
32
|
+
export function countDedupeCheckIssues(issues) {
|
|
33
|
+
return (countChangedSnapshots(issues.importerIssuesByImporterId) +
|
|
34
|
+
countChangedSnapshots(issues.packageIssuesByDepPath));
|
|
35
|
+
}
|
|
36
|
+
export function dedupeDiffCheck(prev, next) {
|
|
37
|
+
const issues = calcDedupeCheckIssues(prev, next);
|
|
38
|
+
if (countDedupeCheckIssues(issues) > 0) {
|
|
12
39
|
throw new DedupeCheckIssuesError(issues);
|
|
13
40
|
}
|
|
14
41
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { DedupeCheckIssuesError } from './DedupeCheckIssuesError.js';
|
|
2
|
-
export { countChangedSnapshots, dedupeDiffCheck } from './dedupeDiffCheck.js';
|
|
2
|
+
export { calcDedupeCheckIssues, countChangedSnapshots, countDedupeCheckIssues, dedupeDiffCheck } from './dedupeDiffCheck.js';
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { DedupeCheckIssuesError } from './DedupeCheckIssuesError.js';
|
|
2
|
-
export { countChangedSnapshots, dedupeDiffCheck } from './dedupeDiffCheck.js';
|
|
2
|
+
export { calcDedupeCheckIssues, countChangedSnapshots, countDedupeCheckIssues, dedupeDiffCheck } from './dedupeDiffCheck.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/installing.dedupe.check",
|
|
3
|
-
"version": "1100.0
|
|
3
|
+
"version": "1100.1.0",
|
|
4
4
|
"description": "Visualize pnpm dedupe --check issues.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@pnpm/error": "1100.0.0",
|
|
31
|
-
"@pnpm/lockfile.types": "1100.0.11",
|
|
32
31
|
"@pnpm/installing.dedupe.types": "1100.0.1",
|
|
32
|
+
"@pnpm/lockfile.types": "1100.0.11",
|
|
33
33
|
"@pnpm/types": "1101.3.2"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@jest/globals": "30.4.1",
|
|
37
|
-
"@pnpm/installing.dedupe.check": "1100.0
|
|
37
|
+
"@pnpm/installing.dedupe.check": "1100.1.0"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=22.13"
|