@antongolub/lockfile 0.0.0-snapshot.12 → 0.0.0-snapshot.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/README.md +45 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,12 +11,12 @@ so both of them are required to build a dependency graph. We can try to convert
|
|
|
11
11
|
And then, if necessary, try convert it back to the original/another format.
|
|
12
12
|
|
|
13
13
|
## Status
|
|
14
|
-
|
|
14
|
+
Proof of concept. The API may vary significantly ⚠️
|
|
15
15
|
|
|
16
16
|
## Getting started
|
|
17
17
|
### Install
|
|
18
18
|
```shell
|
|
19
|
-
yarn add @antongolub/lockfile
|
|
19
|
+
yarn add @antongolub/lockfile@snapshot
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
@@ -28,8 +28,8 @@ import {parse, analyze} from '@antongolub/lockfile'
|
|
|
28
28
|
const lf = await fs.readFile('yarn.lock', 'utf-8')
|
|
29
29
|
const pkg = await fs.readFile('package.json', 'utf-8')
|
|
30
30
|
|
|
31
|
-
const snapshot = parse(lf, pkg)
|
|
32
|
-
const idx = analyze(snapshot)
|
|
31
|
+
const snapshot = parse(lf, pkg) // Holds JSON-friendly TEntries[]
|
|
32
|
+
const idx = analyze(snapshot) // An index to represent repo dep graphs
|
|
33
33
|
|
|
34
34
|
// idx.entries
|
|
35
35
|
// idx.prod
|
|
@@ -73,18 +73,23 @@ idx.edges
|
|
|
73
73
|
| yarn 1 (classic) | 1 | ✓ | ✓ |
|
|
74
74
|
| yarn 2, 3, 4 (berry) | 5, 6, 7 | ✓ | ✓ |
|
|
75
75
|
|
|
76
|
-
###
|
|
77
|
-
| Type | Supported |
|
|
78
|
-
|
|
79
|
-
| semver | ✓ |
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
| github |
|
|
85
|
-
|
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
### Protocols
|
|
77
|
+
| Type | Supported | Example | Description |
|
|
78
|
+
|-----------|-----------|-----------------------------------------|----------------------------------------------------------------|
|
|
79
|
+
| semver | ✓ | `^1.2.3` | Resolves from the default registry |
|
|
80
|
+
| tag | | `latest` | Resolves from the default registry |
|
|
81
|
+
| npm | ✓ | `npm:name@...` | Resolves from the npm registry |
|
|
82
|
+
| git | | `git@github.com:foo/bar.git` | Downloads a public package from a Git repository |
|
|
83
|
+
| github | | `github:foo/bar` | Downloads a public package from GitHub |
|
|
84
|
+
| github | ✓ | `foo/bar` | Alias for the github: protocol |
|
|
85
|
+
| file | | `file:./my-package` | Copies the target location into the cache |
|
|
86
|
+
| link | | `link:./my-folder` | Creates a link to the ./my-folder folder (ignore dependencies) |
|
|
87
|
+
| patch | | `patch:left-pad@1.0.0#./my-patch.patch` | Creates a patched copy of the original package |
|
|
88
|
+
| portal | | `portal:./my-folder` | Creates a link to the ./my-folder folder (follow dependencies) |
|
|
89
|
+
| workspace | _limited_ | `workspace:*` | Creates a link to a package in another workspace |
|
|
90
|
+
|
|
91
|
+
https://v3.yarnpkg.com/features/protocols
|
|
92
|
+
https://yarnpkg.com/protocols
|
|
88
93
|
|
|
89
94
|
### `TSnapshot`
|
|
90
95
|
```ts
|
|
@@ -107,17 +112,17 @@ export type TEntry = {
|
|
|
107
112
|
registry?: string
|
|
108
113
|
}
|
|
109
114
|
// optional pm-specific lockfile meta
|
|
110
|
-
manifest?:
|
|
111
|
-
conditions?:
|
|
112
|
-
dependencies?:
|
|
113
|
-
dependenciesMeta?:
|
|
114
|
-
devDependencies?:
|
|
115
|
-
optionalDependencies?:
|
|
116
|
-
peerDependencies?:
|
|
117
|
-
peerDependenciesMeta?:
|
|
118
|
-
bin?:
|
|
119
|
-
engines?:
|
|
120
|
-
funding?:
|
|
115
|
+
manifest?: TManifest
|
|
116
|
+
conditions?: string
|
|
117
|
+
dependencies?: TDependencies
|
|
118
|
+
dependenciesMeta?: TDependenciesMeta
|
|
119
|
+
devDependencies?: TDependencies
|
|
120
|
+
optionalDependencies?: TDependencies
|
|
121
|
+
peerDependencies?: TDependencies
|
|
122
|
+
peerDependenciesMeta?: TDependenciesMeta
|
|
123
|
+
bin?: Record<string, string>
|
|
124
|
+
engines?: Record<string, string>
|
|
125
|
+
funding?: Record<string, string>
|
|
121
126
|
}>
|
|
122
127
|
```
|
|
123
128
|
|
|
@@ -125,17 +130,17 @@ export type TEntry = {
|
|
|
125
130
|
```ts
|
|
126
131
|
export interface TSnapshotIndex {
|
|
127
132
|
snapshot: TSnapshot
|
|
128
|
-
entries:
|
|
129
|
-
roots:
|
|
130
|
-
edges:
|
|
131
|
-
tree:
|
|
132
|
-
key:
|
|
133
|
-
chunks:
|
|
134
|
-
parents:
|
|
135
|
-
id:
|
|
136
|
-
name:
|
|
137
|
-
version:
|
|
138
|
-
entry:
|
|
133
|
+
entries: TEntry[]
|
|
134
|
+
roots: TEntry[]
|
|
135
|
+
edges: [string, string][]
|
|
136
|
+
tree: Record<string, {
|
|
137
|
+
key: string
|
|
138
|
+
chunks: string[]
|
|
139
|
+
parents: TEntry[]
|
|
140
|
+
id: string
|
|
141
|
+
name: string
|
|
142
|
+
version: string
|
|
143
|
+
entry: TEntry
|
|
139
144
|
}>
|
|
140
145
|
prod: Set<TEntry>
|
|
141
146
|
getEntryId ({name, version}: TEntry): string
|
|
@@ -151,6 +156,8 @@ export interface TSnapshotIndex {
|
|
|
151
156
|
* yarn berry: no idea how to resolve and inject PnP patches https://github.com/yarnpkg/berry/tree/master/packages/plugin-compat
|
|
152
157
|
* npm2 and npm3 requires `engines` and `funding` data, while yarn* or npm1 does not contain it
|
|
153
158
|
* many `nmtree` projections may correspond to the specified `depgraph`
|
|
159
|
+
* pkg.json `resolutions` directive is completely ignored for now
|
|
160
|
+
* pkg aliases are not supported yet [#2](https://github.com/antongolub/lockfile/issues/2#issuecomment-1786613893)
|
|
154
161
|
|
|
155
162
|
### Inspired by
|
|
156
163
|
* [synp](https://github.com/imsnif/synp)
|