@lockfile-affected/core 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +87 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @lockfile-affected/core
2
+
3
+ Pure diff engine and affected-package resolver for `lockfile-affected`.
4
+
5
+ This package contains all domain logic with no I/O. It is format-agnostic —
6
+ lockfile parsers live in separate adapter packages.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ npm install @lockfile-affected/core
12
+ ```
13
+
14
+ ## API
15
+
16
+ ### `diffLockfileSnapshots(before, after)`
17
+
18
+ Compares two lockfile snapshots and returns what changed.
19
+
20
+ ```ts
21
+ import { diffLockfileSnapshots } from '@lockfile-affected/core';
22
+
23
+ const diff = diffLockfileSnapshots(snapshotBefore, snapshotAfter);
24
+ // diff.added — Map<name, newVersion>
25
+ // diff.removed — Map<name, oldVersion>
26
+ // diff.changed — Map<name, { from, to }>
27
+ ```
28
+
29
+ ### `resolveAffectedPackages(diff, workspaceGraph, filter?)`
30
+
31
+ Returns the names of workspace packages that depend on any package in the diff.
32
+
33
+ ```ts
34
+ import { resolveAffectedPackages, ALL_DEPENDENCY_TYPES } from '@lockfile-affected/core';
35
+
36
+ const affected = resolveAffectedPackages(diff, workspaceGraph, ALL_DEPENDENCY_TYPES);
37
+ // Set<string> of affected package names
38
+ ```
39
+
40
+ The optional `filter` is a `DependencyFilter` controlling which dependency types
41
+ are considered. Omitting a field (or setting it to `false`) excludes that type.
42
+ When omitted entirely, all types are included.
43
+
44
+ ```ts
45
+ type DependencyFilter = {
46
+ dependencies?: boolean;
47
+ devDependencies?: boolean;
48
+ peerDependencies?: boolean;
49
+ optionalDependencies?: boolean;
50
+ };
51
+ ```
52
+
53
+ ### `buildWorkspaceGraph(manifests)`
54
+
55
+ Builds a workspace graph from an array of parsed `package.json` objects.
56
+
57
+ ```ts
58
+ import { buildWorkspaceGraph } from '@lockfile-affected/core';
59
+
60
+ const graph = buildWorkspaceGraph(manifests);
61
+ // ReadonlyMap<name, WorkspacePackage>
62
+ ```
63
+
64
+ ## Types
65
+
66
+ ```ts
67
+ type LockfileSnapshot = ReadonlyMap<string, string>;
68
+
69
+ type LockfileDiff = {
70
+ added: ReadonlyMap<string, string>;
71
+ removed: ReadonlyMap<string, string>;
72
+ changed: ReadonlyMap<string, { from: string; to: string }>;
73
+ };
74
+
75
+ type LockfileParser = {
76
+ format: string;
77
+ lockfileNames: readonly string[];
78
+ parse: (content: string) => Promise<LockfileSnapshot>;
79
+ };
80
+ ```
81
+
82
+ ## Related packages
83
+
84
+ - [`lockfile-affected`](https://www.npmjs.com/package/lockfile-affected) — CLI
85
+ - [`@lockfile-affected/lockfile-pnpm`](https://www.npmjs.com/package/@lockfile-affected/lockfile-pnpm) — pnpm adapter
86
+ - [`@lockfile-affected/lockfile-npm`](https://www.npmjs.com/package/@lockfile-affected/lockfile-npm) — npm adapter
87
+ - [`@lockfile-affected/lockfile-yarn`](https://www.npmjs.com/package/@lockfile-affected/lockfile-yarn) — yarn adapter
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@lockfile-affected/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Core diff engine and affected package resolver",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=18"
8
8
  },
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "README.md"
11
12
  ],
12
13
  "publishConfig": {
13
14
  "access": "public"