@pnpm/installing.dedupe.check 1001.0.13

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2026 Zoltan Kochan and other contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @pnpm/dedupe.issues-renderer
2
+
3
+ > Logic for "pnpm dedupe --check"
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ pnpm add @pnpm/dedupe.check
9
+ ```
10
+
11
+ ## License
12
+
13
+ [MIT](LICENSE)
@@ -0,0 +1,6 @@
1
+ import { PnpmError } from '@pnpm/error';
2
+ import type { DedupeCheckIssues } from '@pnpm/installing.dedupe.types';
3
+ export declare class DedupeCheckIssuesError extends PnpmError {
4
+ dedupeCheckIssues: DedupeCheckIssues;
5
+ constructor(dedupeCheckIssues: DedupeCheckIssues);
6
+ }
@@ -0,0 +1,9 @@
1
+ import { PnpmError } from '@pnpm/error';
2
+ export class DedupeCheckIssuesError extends PnpmError {
3
+ dedupeCheckIssues;
4
+ constructor(dedupeCheckIssues) {
5
+ super('DEDUPE_CHECK_ISSUES', 'Dedupe --check found changes to the lockfile');
6
+ this.dedupeCheckIssues = dedupeCheckIssues;
7
+ }
8
+ }
9
+ //# sourceMappingURL=DedupeCheckIssuesError.js.map
@@ -0,0 +1,4 @@
1
+ import type { SnapshotsChanges } from '@pnpm/installing.dedupe.types';
2
+ import type { LockfileObject } from '@pnpm/lockfile.types';
3
+ export declare function dedupeDiffCheck(prev: LockfileObject, next: LockfileObject): void;
4
+ export declare function countChangedSnapshots(snapshotChanges: SnapshotsChanges): number;
@@ -0,0 +1,55 @@
1
+ import { DEPENDENCIES_FIELDS } from '@pnpm/types';
2
+ import { DedupeCheckIssuesError } from './DedupeCheckIssuesError.js';
3
+ const PACKAGE_SNAPSHOT_DEP_FIELDS = ['dependencies', 'optionalDependencies'];
4
+ export function dedupeDiffCheck(prev, next) {
5
+ const issues = {
6
+ importerIssuesByImporterId: diffSnapshots(prev.importers, next.importers, DEPENDENCIES_FIELDS),
7
+ packageIssuesByDepPath: diffSnapshots(prev.packages ?? {}, next.packages ?? {}, PACKAGE_SNAPSHOT_DEP_FIELDS),
8
+ };
9
+ const changesCount = countChangedSnapshots(issues.importerIssuesByImporterId) +
10
+ countChangedSnapshots(issues.packageIssuesByDepPath);
11
+ if (changesCount > 0) {
12
+ throw new DedupeCheckIssuesError(issues);
13
+ }
14
+ }
15
+ function diffSnapshots(prev, next, fields) {
16
+ const removed = [];
17
+ const updated = {};
18
+ for (const [id, prevSnapshot] of Object.entries(prev)) {
19
+ const nextSnapshot = next[id];
20
+ if (nextSnapshot == null) {
21
+ removed.push(id);
22
+ continue;
23
+ }
24
+ const updates = {};
25
+ for (const dependencyField of fields) {
26
+ Object.assign(updates, getResolutionUpdates(prevSnapshot[dependencyField] ?? {}, nextSnapshot[dependencyField] ?? {}));
27
+ }
28
+ if (Object.keys(updates).length > 0) {
29
+ updated[id] = updates;
30
+ }
31
+ }
32
+ const added = Object.keys(next).filter(id => prev[id] == null);
33
+ return { added, removed, updated };
34
+ }
35
+ function getResolutionUpdates(prev, next) {
36
+ const updates = {};
37
+ for (const [alias, prevResolution] of Object.entries(prev)) {
38
+ const nextResolution = next[alias];
39
+ if (prevResolution === nextResolution) {
40
+ continue;
41
+ }
42
+ updates[alias] = nextResolution == null
43
+ ? { type: 'removed', prev: prevResolution }
44
+ : { type: 'updated', prev: prevResolution, next: nextResolution };
45
+ }
46
+ const newAliases = Object.entries(next).filter(([alias]) => prev[alias] == null);
47
+ for (const [alias, nextResolution] of newAliases) {
48
+ updates[alias] = { type: 'added', next: nextResolution };
49
+ }
50
+ return updates;
51
+ }
52
+ export function countChangedSnapshots(snapshotChanges) {
53
+ return snapshotChanges.added.length + snapshotChanges.removed.length + Object.keys(snapshotChanges.updated).length;
54
+ }
55
+ //# sourceMappingURL=dedupeDiffCheck.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { DedupeCheckIssuesError } from './DedupeCheckIssuesError.js';
2
+ export { countChangedSnapshots, dedupeDiffCheck } from './dedupeDiffCheck.js';
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { DedupeCheckIssuesError } from './DedupeCheckIssuesError.js';
2
+ export { countChangedSnapshots, dedupeDiffCheck } from './dedupeDiffCheck.js';
3
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@pnpm/installing.dedupe.check",
3
+ "version": "1001.0.13",
4
+ "description": "Visualize pnpm dedupe --check issues.",
5
+ "keywords": [
6
+ "pnpm",
7
+ "pnpm11"
8
+ ],
9
+ "license": "MIT",
10
+ "funding": "https://opencollective.com/pnpm",
11
+ "repository": "https://github.com/pnpm/pnpm/tree/main/installing/dedupe/check",
12
+ "homepage": "https://github.com/pnpm/pnpm/tree/main/installing/dedupe/check#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/pnpm/pnpm/issues"
15
+ },
16
+ "type": "module",
17
+ "main": "lib/index.js",
18
+ "types": "lib/index.d.ts",
19
+ "exports": {
20
+ ".": "./lib/index.js"
21
+ },
22
+ "files": [
23
+ "lib",
24
+ "!*.map"
25
+ ],
26
+ "dependencies": {
27
+ "@pnpm/error": "1000.0.5",
28
+ "@pnpm/installing.dedupe.types": "1000.0.0",
29
+ "@pnpm/types": "1000.9.0",
30
+ "@pnpm/lockfile.types": "1002.0.2"
31
+ },
32
+ "devDependencies": {
33
+ "@pnpm/installing.dedupe.check": "1001.0.13"
34
+ },
35
+ "engines": {
36
+ "node": ">=22.13"
37
+ },
38
+ "jest": {
39
+ "preset": "@pnpm/jest-config"
40
+ },
41
+ "scripts": {
42
+ "_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
43
+ "test": "pnpm run compile && pnpm run _test",
44
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
45
+ "compile": "tsgo --build && pnpm run lint --fix"
46
+ }
47
+ }