flatlock 1.3.0 → 1.4.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.
Files changed (38) hide show
  1. package/bin/flatcover.js +191 -42
  2. package/bin/flatlock-cmp.js +2 -2
  3. package/dist/compare.d.ts +85 -0
  4. package/dist/compare.d.ts.map +1 -0
  5. package/dist/detect.d.ts +33 -0
  6. package/dist/detect.d.ts.map +1 -0
  7. package/dist/index.d.ts +72 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/parsers/index.d.ts +5 -0
  10. package/dist/parsers/index.d.ts.map +1 -0
  11. package/dist/parsers/npm.d.ts +154 -0
  12. package/dist/parsers/npm.d.ts.map +1 -0
  13. package/dist/parsers/pnpm/detect.d.ts +136 -0
  14. package/dist/parsers/pnpm/detect.d.ts.map +1 -0
  15. package/dist/parsers/pnpm/index.d.ts +154 -0
  16. package/dist/parsers/pnpm/index.d.ts.map +1 -0
  17. package/dist/parsers/pnpm/internal.d.ts +5 -0
  18. package/dist/parsers/pnpm/internal.d.ts.map +1 -0
  19. package/dist/parsers/pnpm/shrinkwrap.d.ts +129 -0
  20. package/dist/parsers/pnpm/shrinkwrap.d.ts.map +1 -0
  21. package/dist/parsers/pnpm/v5.d.ts +139 -0
  22. package/dist/parsers/pnpm/v5.d.ts.map +1 -0
  23. package/dist/parsers/pnpm/v6plus.d.ts +212 -0
  24. package/dist/parsers/pnpm/v6plus.d.ts.map +1 -0
  25. package/dist/parsers/pnpm.d.ts +2 -0
  26. package/dist/parsers/pnpm.d.ts.map +1 -0
  27. package/dist/parsers/types.d.ts +23 -0
  28. package/dist/parsers/types.d.ts.map +1 -0
  29. package/dist/parsers/yarn-berry.d.ts +197 -0
  30. package/dist/parsers/yarn-berry.d.ts.map +1 -0
  31. package/dist/parsers/yarn-classic.d.ts +110 -0
  32. package/dist/parsers/yarn-classic.d.ts.map +1 -0
  33. package/dist/result.d.ts +12 -0
  34. package/dist/result.d.ts.map +1 -0
  35. package/dist/set.d.ts +238 -0
  36. package/dist/set.d.ts.map +1 -0
  37. package/package.json +9 -4
  38. package/src/compare.js +5 -7
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @fileoverview Parser for pnpm-lock.yaml v5.x format
3
+ *
4
+ * pnpm-lock.yaml v5.x format (2019-2022) characteristics:
5
+ * - File: pnpm-lock.yaml
6
+ * - Version field: lockfileVersion (number like 5, 5.1, 5.2, 5.3, 5.4)
7
+ * - Package key format: /name/version or /@scope/name/version
8
+ * - Peer dependency suffix: _peer@ver with + escaping for scoped packages
9
+ * Example: /foo/1.0.0_bar@2.0.0+@scope+qar@3.0.0
10
+ *
11
+ * Key differences from shrinkwrap v3/v4:
12
+ * - Peer suffix uses _ instead of /
13
+ * - Scoped peer packages escape @ with + instead of !
14
+ *
15
+ * @module flatlock/parsers/pnpm/v5
16
+ */
17
+ /**
18
+ * @typedef {Object} ParsedSpec
19
+ * @property {string|null} name - The package name (null if unparseable)
20
+ * @property {string|null} version - The package version (null if unparseable)
21
+ */
22
+ /**
23
+ * Parse a pnpm-lock.yaml v5.x package spec.
24
+ *
25
+ * v5 format uses:
26
+ * - Slash separator between name and version: /name/version
27
+ * - Peer dependencies after underscore: /name/version_peer@ver
28
+ * - Scoped packages: /@scope/name/version
29
+ * - Multiple peers joined with +: /name/1.0.0_peer1@2.0.0+peer2@3.0.0
30
+ * - Scoped peer dependencies use + to escape the /: _@scope+pkg@1.0.0
31
+ *
32
+ * @param {string} spec - Package spec from pnpm-lock.yaml packages section
33
+ * @returns {ParsedSpec} Parsed name and version
34
+ *
35
+ * @example
36
+ * // Unscoped package
37
+ * parseSpecV5('/lodash/4.17.21')
38
+ * // => { name: 'lodash', version: '4.17.21' }
39
+ *
40
+ * @example
41
+ * // Scoped package
42
+ * parseSpecV5('/@babel/core/7.23.0')
43
+ * // => { name: '@babel/core', version: '7.23.0' }
44
+ *
45
+ * @example
46
+ * // With peer dependency suffix
47
+ * parseSpecV5('/styled-jsx/3.0.9_react@17.0.2')
48
+ * // => { name: 'styled-jsx', version: '3.0.9' }
49
+ *
50
+ * @example
51
+ * // With multiple peer dependencies
52
+ * parseSpecV5('/pkg/1.0.0_react-dom@17.0.2+react@17.0.2')
53
+ * // => { name: 'pkg', version: '1.0.0' }
54
+ *
55
+ * @example
56
+ * // Scoped package with peer deps
57
+ * parseSpecV5('/@emotion/styled/10.0.27_react@17.0.2')
58
+ * // => { name: '@emotion/styled', version: '10.0.27' }
59
+ *
60
+ * @example
61
+ * // Prerelease version
62
+ * parseSpecV5('/@verdaccio/ui-theme/6.0.0-6-next.50')
63
+ * // => { name: '@verdaccio/ui-theme', version: '6.0.0-6-next.50' }
64
+ *
65
+ * @example
66
+ * // Package with hyphenated name
67
+ * parseSpecV5('/string-width/4.2.3')
68
+ * // => { name: 'string-width', version: '4.2.3' }
69
+ *
70
+ * @example
71
+ * // Scoped package with hyphenated name
72
+ * parseSpecV5('/@babel/helper-compilation-targets/7.23.6')
73
+ * // => { name: '@babel/helper-compilation-targets', version: '7.23.6' }
74
+ *
75
+ * @example
76
+ * // Complex peer suffix with scoped peer
77
+ * parseSpecV5('/styled-components/5.3.6_@babel+core@7.23.0+react@18.2.0')
78
+ * // => { name: 'styled-components', version: '5.3.6' }
79
+ *
80
+ * @example
81
+ * // link: protocol - skipped
82
+ * parseSpecV5('link:packages/my-pkg')
83
+ * // => { name: null, version: null }
84
+ *
85
+ * @example
86
+ * // file: protocol - skipped
87
+ * parseSpecV5('file:../local-package')
88
+ * // => { name: null, version: null }
89
+ *
90
+ * @example
91
+ * // Null input
92
+ * parseSpecV5(null)
93
+ * // => { name: null, version: null }
94
+ *
95
+ * @example
96
+ * // Build metadata version
97
+ * parseSpecV5('/esbuild/0.19.12+sha512.abc123')
98
+ * // => { name: 'esbuild', version: '0.19.12+sha512.abc123' }
99
+ */
100
+ export function parseSpecV5(spec: string): ParsedSpec;
101
+ /**
102
+ * Check if a spec has peer dependency suffix (v5 format).
103
+ *
104
+ * In v5, peer dependencies are appended after the version
105
+ * with an underscore: /name/version_peer@ver+peer2@ver
106
+ *
107
+ * @param {string} spec - Package spec from pnpm-lock.yaml
108
+ * @returns {boolean} True if the spec has peer dependency suffix
109
+ *
110
+ * @example
111
+ * hasPeerSuffixV5('/lodash/4.17.21') // => false
112
+ * hasPeerSuffixV5('/foo/1.0.0_bar@2.0.0') // => true
113
+ * hasPeerSuffixV5('/@babel/core/7.23.0') // => false
114
+ * hasPeerSuffixV5('/@emotion/styled/10.0.27_react@17.0.2') // => true
115
+ */
116
+ export function hasPeerSuffixV5(spec: string): boolean;
117
+ /**
118
+ * Extract the peer dependency suffix from a v5 spec.
119
+ *
120
+ * @param {string} spec - Package spec from pnpm-lock.yaml v5
121
+ * @returns {string|null} The peer suffix or null if none
122
+ *
123
+ * @example
124
+ * extractPeerSuffixV5('/lodash/4.17.21') // => null
125
+ * extractPeerSuffixV5('/foo/1.0.0_bar@2.0.0') // => 'bar@2.0.0'
126
+ * extractPeerSuffixV5('/foo/1.0.0_bar@2.0.0+@scope+qar@3.0.0') // => 'bar@2.0.0+@scope+qar@3.0.0'
127
+ */
128
+ export function extractPeerSuffixV5(spec: string): string | null;
129
+ export type ParsedSpec = {
130
+ /**
131
+ * - The package name (null if unparseable)
132
+ */
133
+ name: string | null;
134
+ /**
135
+ * - The package version (null if unparseable)
136
+ */
137
+ version: string | null;
138
+ };
139
+ //# sourceMappingURL=v5.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v5.d.ts","sourceRoot":"","sources":["../../../src/parsers/pnpm/v5.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AACH,kCApEW,MAAM,GACJ,UAAU,CA+ItB;AAED;;;;;;;;;;;;;;GAcG;AACH,sCATW,MAAM,GACJ,OAAO,CAcnB;AAED;;;;;;;;;;GAUG;AACH,0CARW,MAAM,GACJ,MAAM,GAAC,IAAI,CAkBvB;;;;;UA7Ma,MAAM,GAAC,IAAI;;;;aACX,MAAM,GAAC,IAAI"}
@@ -0,0 +1,212 @@
1
+ /**
2
+ * @fileoverview Parser for pnpm-lock.yaml v6+ format (v6.0 and v9.0)
3
+ *
4
+ * pnpm-lock.yaml v6+ format (2023+) characteristics:
5
+ * - File: pnpm-lock.yaml
6
+ * - Version field: lockfileVersion (string like '6.0', '9.0')
7
+ * - Package key format:
8
+ * - v6: /name@version or /@scope/name@version (with leading slash)
9
+ * - v9: name@version or @scope/name@version (no leading slash)
10
+ * - Peer dependency suffix: (peer@ver) in parentheses
11
+ * Example: /@babel/core@7.23.0(@types/node@20.0.0)
12
+ *
13
+ * Key differences from v5:
14
+ * - Uses @ separator between name and version instead of /
15
+ * - Peer suffix uses parentheses () instead of underscore _
16
+ * - Peer names are human-readable (no hashing)
17
+ * - v9 additionally removes leading slash from keys
18
+ *
19
+ * @module flatlock/parsers/pnpm/v6plus
20
+ */
21
+ /**
22
+ * @typedef {Object} ParsedSpec
23
+ * @property {string|null} name - The package name (null if unparseable)
24
+ * @property {string|null} version - The package version (null if unparseable)
25
+ */
26
+ /**
27
+ * Parse a pnpm-lock.yaml v6+ package spec.
28
+ *
29
+ * v6/v9 format uses:
30
+ * - @ separator between name and version: name@version
31
+ * - Leading slash in v6: /name@version, no slash in v9: name@version
32
+ * - Peer dependencies in parentheses: name@version(peer@ver)
33
+ * - Scoped packages: @scope/name@version
34
+ * - Multiple peers: name@version(peer1@ver)(peer2@ver)
35
+ *
36
+ * @param {string} spec - Package spec from pnpm-lock.yaml packages section
37
+ * @returns {ParsedSpec} Parsed name and version
38
+ *
39
+ * @example
40
+ * // Unscoped package (v6 format with leading slash)
41
+ * parseSpecV6Plus('/lodash@4.17.21')
42
+ * // => { name: 'lodash', version: '4.17.21' }
43
+ *
44
+ * @example
45
+ * // Unscoped package (v9 format without leading slash)
46
+ * parseSpecV6Plus('lodash@4.17.21')
47
+ * // => { name: 'lodash', version: '4.17.21' }
48
+ *
49
+ * @example
50
+ * // Scoped package (v6)
51
+ * parseSpecV6Plus('/@babel/core@7.23.0')
52
+ * // => { name: '@babel/core', version: '7.23.0' }
53
+ *
54
+ * @example
55
+ * // Scoped package (v9)
56
+ * parseSpecV6Plus('@babel/core@7.23.0')
57
+ * // => { name: '@babel/core', version: '7.23.0' }
58
+ *
59
+ * @example
60
+ * // With peer dependency suffix
61
+ * parseSpecV6Plus('/@babel/core@7.23.0(@types/node@20.0.0)')
62
+ * // => { name: '@babel/core', version: '7.23.0' }
63
+ *
64
+ * @example
65
+ * // With multiple peer dependencies
66
+ * parseSpecV6Plus('/@aleph-alpha/config-css@0.18.4(@unocss/core@66.5.2)(postcss@8.5.6)')
67
+ * // => { name: '@aleph-alpha/config-css', version: '0.18.4' }
68
+ *
69
+ * @example
70
+ * // Prerelease version
71
+ * parseSpecV6Plus('/unusual-pkg@1.0.0-beta.1')
72
+ * // => { name: 'unusual-pkg', version: '1.0.0-beta.1' }
73
+ *
74
+ * @example
75
+ * // Package with hyphenated name
76
+ * parseSpecV6Plus('/string-width@4.2.3')
77
+ * // => { name: 'string-width', version: '4.2.3' }
78
+ *
79
+ * @example
80
+ * // Scoped package with hyphenated name
81
+ * parseSpecV6Plus('@babel/helper-compilation-targets@7.23.6')
82
+ * // => { name: '@babel/helper-compilation-targets', version: '7.23.6' }
83
+ *
84
+ * @example
85
+ * // Complex nested peer dependencies (v9)
86
+ * parseSpecV6Plus('@testing-library/react@14.0.0(react-dom@18.2.0)(react@18.2.0)')
87
+ * // => { name: '@testing-library/react', version: '14.0.0' }
88
+ *
89
+ * @example
90
+ * // link: protocol - skipped
91
+ * parseSpecV6Plus('link:packages/my-pkg')
92
+ * // => { name: null, version: null }
93
+ *
94
+ * @example
95
+ * // file: protocol - skipped
96
+ * parseSpecV6Plus('file:../local-package')
97
+ * // => { name: null, version: null }
98
+ *
99
+ * @example
100
+ * // Null input
101
+ * parseSpecV6Plus(null)
102
+ * // => { name: null, version: null }
103
+ *
104
+ * @example
105
+ * // Build metadata version
106
+ * parseSpecV6Plus('esbuild@0.19.12+sha512.abc123')
107
+ * // => { name: 'esbuild', version: '0.19.12+sha512.abc123' }
108
+ */
109
+ export function parseSpecV6Plus(spec: string): ParsedSpec;
110
+ /**
111
+ * Check if a spec has peer dependency suffix (v6+ format).
112
+ *
113
+ * In v6+, peer dependencies are in parentheses: name@version(peer@ver)
114
+ *
115
+ * @param {string} spec - Package spec from pnpm-lock.yaml
116
+ * @returns {boolean} True if the spec has peer dependency suffix
117
+ *
118
+ * @example
119
+ * hasPeerSuffixV6Plus('/lodash@4.17.21') // => false
120
+ * hasPeerSuffixV6Plus('/@babel/core@7.23.0(@types/node@20.0.0)') // => true
121
+ * hasPeerSuffixV6Plus('lodash@4.17.21') // => false
122
+ * hasPeerSuffixV6Plus('@emotion/styled@10.0.27(react@17.0.2)') // => true
123
+ */
124
+ export function hasPeerSuffixV6Plus(spec: string): boolean;
125
+ /**
126
+ * Extract the peer dependency suffix from a v6+ spec.
127
+ *
128
+ * @param {string} spec - Package spec from pnpm-lock.yaml v6+
129
+ * @returns {string|null} The peer suffix (including parentheses) or null if none
130
+ *
131
+ * @example
132
+ * extractPeerSuffixV6Plus('/lodash@4.17.21') // => null
133
+ * extractPeerSuffixV6Plus('/@babel/core@7.23.0(@types/node@20.0.0)') // => '(@types/node@20.0.0)'
134
+ * extractPeerSuffixV6Plus('/@pkg@1.0.0(peer1@2.0.0)(peer2@3.0.0)') // => '(peer1@2.0.0)(peer2@3.0.0)'
135
+ */
136
+ export function extractPeerSuffixV6Plus(spec: string): string | null;
137
+ /**
138
+ * Parse peer dependencies from a v6+ peer suffix.
139
+ *
140
+ * @param {string} peerSuffix - The peer suffix like '(peer1@1.0.0)(peer2@2.0.0)'
141
+ * @returns {Array<{name: string, version: string}>} Array of parsed peer dependencies
142
+ *
143
+ * @example
144
+ * // Single scoped peer
145
+ * parsePeerDependencies('(@types/node@20.0.0)')
146
+ * // => [{ name: '@types/node', version: '20.0.0' }]
147
+ *
148
+ * @example
149
+ * // Multiple unscoped peers
150
+ * parsePeerDependencies('(react@18.2.0)(typescript@5.3.3)')
151
+ * // => [{ name: 'react', version: '18.2.0' }, { name: 'typescript', version: '5.3.3' }]
152
+ *
153
+ * @example
154
+ * // Single unscoped peer
155
+ * parsePeerDependencies('(lodash@4.17.21)')
156
+ * // => [{ name: 'lodash', version: '4.17.21' }]
157
+ *
158
+ * @example
159
+ * // Multiple scoped peers
160
+ * parsePeerDependencies('(@babel/core@7.23.0)(@types/react@18.2.0)')
161
+ * // => [{ name: '@babel/core', version: '7.23.0' }, { name: '@types/react', version: '18.2.0' }]
162
+ *
163
+ * @example
164
+ * // Mixed scoped and unscoped peers
165
+ * parsePeerDependencies('(react@18.2.0)(@types/react@18.2.0)')
166
+ * // => [{ name: 'react', version: '18.2.0' }, { name: '@types/react', version: '18.2.0' }]
167
+ *
168
+ * @example
169
+ * // React ecosystem peers (common pattern)
170
+ * parsePeerDependencies('(react-dom@18.2.0)(react@18.2.0)')
171
+ * // => [{ name: 'react-dom', version: '18.2.0' }, { name: 'react', version: '18.2.0' }]
172
+ *
173
+ * @example
174
+ * // Many peers (complex component library)
175
+ * parsePeerDependencies('(@unocss/core@66.5.2)(postcss@8.5.6)(typescript@5.3.3)')
176
+ * // => [{ name: '@unocss/core', version: '66.5.2' }, { name: 'postcss', version: '8.5.6' }, { name: 'typescript', version: '5.3.3' }]
177
+ *
178
+ * @example
179
+ * // Prerelease peer version
180
+ * parsePeerDependencies('(next@14.0.0-canary.0)')
181
+ * // => [{ name: 'next', version: '14.0.0-canary.0' }]
182
+ *
183
+ * @example
184
+ * // Empty/null input
185
+ * parsePeerDependencies(null)
186
+ * // => []
187
+ *
188
+ * @example
189
+ * // No parentheses (invalid)
190
+ * parsePeerDependencies('react@18.2.0')
191
+ * // => []
192
+ *
193
+ * @example
194
+ * // Deeply scoped peer
195
+ * parsePeerDependencies('(@babel/helper-compilation-targets@7.23.6)')
196
+ * // => [{ name: '@babel/helper-compilation-targets', version: '7.23.6' }]
197
+ */
198
+ export function parsePeerDependencies(peerSuffix: string): Array<{
199
+ name: string;
200
+ version: string;
201
+ }>;
202
+ export type ParsedSpec = {
203
+ /**
204
+ * - The package name (null if unparseable)
205
+ */
206
+ name: string | null;
207
+ /**
208
+ * - The package version (null if unparseable)
209
+ */
210
+ version: string | null;
211
+ };
212
+ //# sourceMappingURL=v6plus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v6plus.d.ts","sourceRoot":"","sources":["../../../src/parsers/pnpm/v6plus.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,sCAzEW,MAAM,GACJ,UAAU,CAqHtB;AAED;;;;;;;;;;;;;GAaG;AACH,0CATW,MAAM,GACJ,OAAO,CAcnB;AAED;;;;;;;;;;GAUG;AACH,8CARW,MAAM,GACJ,MAAM,GAAC,IAAI,CAkBvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,kDA1DW,MAAM,GACJ,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC,CAkFlD;;;;;UA1Qa,MAAM,GAAC,IAAI;;;;aACX,MAAM,GAAC,IAAI"}
@@ -0,0 +1,2 @@
1
+ export * from "./pnpm/index.js";
2
+ //# sourceMappingURL=pnpm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm.d.ts","sourceRoot":"","sources":["../../src/parsers/pnpm.js"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ export type Dependency = {
2
+ /**
3
+ * - Package name
4
+ */
5
+ name: string;
6
+ /**
7
+ * - Resolved version
8
+ */
9
+ version: string;
10
+ /**
11
+ * - Integrity hash
12
+ */
13
+ integrity?: string;
14
+ /**
15
+ * - Resolution URL
16
+ */
17
+ resolved?: string;
18
+ /**
19
+ * - True if this is a symlink
20
+ */
21
+ link?: boolean;
22
+ };
23
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/parsers/types.js"],"names":[],"mappings":";;;;UAEc,MAAM;;;;aACN,MAAM;;;;gBACN,MAAM;;;;eACN,MAAM;;;;WACN,OAAO"}
@@ -0,0 +1,197 @@
1
+ /** @typedef {import('./types.js').Dependency} Dependency */
2
+ /**
3
+ * @typedef {Object} WorkspacePackage
4
+ * @property {string} name
5
+ * @property {string} version
6
+ * @property {Record<string, string>} [dependencies]
7
+ * @property {Record<string, string>} [devDependencies]
8
+ * @property {Record<string, string>} [optionalDependencies]
9
+ * @property {Record<string, string>} [peerDependencies]
10
+ */
11
+ /**
12
+ * Extract package name from yarn berry resolution field.
13
+ *
14
+ * The resolution field is the CANONICAL identifier and should be used instead of the key.
15
+ * Keys can contain npm aliases (e.g., "string-width-cjs@npm:string-width@^4.2.0") while
16
+ * the resolution always contains the actual package name (e.g., "string-width@npm:4.2.3").
17
+ *
18
+ * @param {string} resolution - Resolution field from lockfile entry
19
+ * @returns {string | null} Package name or null if parsing fails
20
+ *
21
+ * @example
22
+ * // Unscoped npm package
23
+ * parseResolution('lodash@npm:4.17.21')
24
+ * // => 'lodash'
25
+ *
26
+ * @example
27
+ * // Scoped npm package
28
+ * parseResolution('@babel/core@npm:7.24.0')
29
+ * // => '@babel/core'
30
+ *
31
+ * @example
32
+ * // Aliased package - resolution shows the REAL package name
33
+ * // (key was "string-width-cjs@npm:string-width@^4.2.0")
34
+ * parseResolution('string-width@npm:4.2.3')
35
+ * // => 'string-width'
36
+ *
37
+ * @example
38
+ * // Scoped aliased package - resolution shows the REAL package name
39
+ * // (key was "@babel-baseline/core@npm:@babel/core@7.24.4")
40
+ * parseResolution('@babel/core@npm:7.24.4')
41
+ * // => '@babel/core'
42
+ *
43
+ * @example
44
+ * // Patch protocol (nested protocols)
45
+ * parseResolution('pkg@patch:pkg@npm:1.0.0#./patch')
46
+ * // => 'pkg'
47
+ *
48
+ * @example
49
+ * // Scoped package with patch protocol
50
+ * parseResolution('@scope/pkg@patch:@scope/pkg@npm:1.0.0#./fix.patch')
51
+ * // => '@scope/pkg'
52
+ *
53
+ * @example
54
+ * // Workspace protocol
55
+ * parseResolution('my-pkg@workspace:packages/my-pkg')
56
+ * // => 'my-pkg'
57
+ *
58
+ * @example
59
+ * // Scoped workspace package
60
+ * parseResolution('@myorg/utils@workspace:packages/utils')
61
+ * // => '@myorg/utils'
62
+ *
63
+ * @example
64
+ * // Git protocol
65
+ * parseResolution('my-lib@git:github.com/user/repo#commit-hash')
66
+ * // => 'my-lib'
67
+ *
68
+ * @example
69
+ * // Null/empty input
70
+ * parseResolution(null)
71
+ * // => null
72
+ *
73
+ * @example
74
+ * // Empty string
75
+ * parseResolution('')
76
+ * // => null
77
+ *
78
+ * @example
79
+ * // Portal protocol (symlink to external package)
80
+ * parseResolution('@scope/external@portal:../external-pkg')
81
+ * // => '@scope/external'
82
+ */
83
+ export function parseResolution(resolution: string): string | null;
84
+ /**
85
+ * Extract package name from yarn berry key (fallback for when resolution is unavailable).
86
+ *
87
+ * WARNING: Keys can contain npm aliases. Prefer parseResolution() when possible.
88
+ * The key may return an alias name instead of the real package name.
89
+ *
90
+ * @param {string} key - Lockfile entry key
91
+ * @returns {string} Package name (may be alias name, not canonical name)
92
+ *
93
+ * @example
94
+ * // Simple unscoped package
95
+ * parseLockfileKey('lodash@npm:^4.17.21')
96
+ * // => 'lodash'
97
+ *
98
+ * @example
99
+ * // Scoped package
100
+ * parseLockfileKey('@babel/core@npm:^7.24.0')
101
+ * // => '@babel/core'
102
+ *
103
+ * @example
104
+ * // Multiple version ranges (comma-separated) - takes first entry
105
+ * parseLockfileKey('@types/node@npm:^18.0.0, @types/node@npm:^20.0.0')
106
+ * // => '@types/node'
107
+ *
108
+ * @example
109
+ * // npm alias - returns the ALIAS name (not real package)
110
+ * // Use parseResolution() for the real package name
111
+ * parseLockfileKey('string-width-cjs@npm:string-width@^4.2.0')
112
+ * // => 'string-width-cjs'
113
+ *
114
+ * @example
115
+ * // Scoped npm alias
116
+ * parseLockfileKey('@babel-baseline/core@npm:@babel/core@7.24.4')
117
+ * // => '@babel-baseline/core'
118
+ *
119
+ * @example
120
+ * // Workspace protocol
121
+ * parseLockfileKey('my-pkg@workspace:packages/my-pkg')
122
+ * // => 'my-pkg'
123
+ *
124
+ * @example
125
+ * // Scoped workspace package
126
+ * parseLockfileKey('@myorg/utils@workspace:.')
127
+ * // => '@myorg/utils'
128
+ *
129
+ * @example
130
+ * // Portal protocol
131
+ * parseLockfileKey('external-pkg@portal:../some/path')
132
+ * // => 'external-pkg'
133
+ *
134
+ * @example
135
+ * // Link protocol
136
+ * parseLockfileKey('linked-pkg@link:./local')
137
+ * // => 'linked-pkg'
138
+ *
139
+ * @example
140
+ * // Patch protocol (complex nested format)
141
+ * parseLockfileKey('pkg@patch:pkg@npm:1.0.0#./patches/fix.patch')
142
+ * // => 'pkg'
143
+ *
144
+ * @example
145
+ * // Scoped patch
146
+ * parseLockfileKey('@scope/pkg@patch:@scope/pkg@npm:1.0.0#./fix.patch')
147
+ * // => '@scope/pkg'
148
+ *
149
+ * @example
150
+ * // File protocol
151
+ * parseLockfileKey('local-pkg@file:../local-package')
152
+ * // => 'local-pkg'
153
+ */
154
+ export function parseLockfileKey(key: string): string;
155
+ /**
156
+ * Parse yarn.lock v2+ (berry)
157
+ * @param {string | object} input - Lockfile content string or pre-parsed object
158
+ * @param {Object} [_options] - Parser options (unused, reserved for future use)
159
+ * @returns {Generator<Dependency>}
160
+ */
161
+ export function fromYarnBerryLock(input: string | object, _options?: Object): Generator<Dependency>;
162
+ /**
163
+ * Extract workspace paths from yarn berry lockfile.
164
+ *
165
+ * Yarn berry workspace entries use `@workspace:` protocol in keys.
166
+ * Keys can have multiple comma-separated descriptors.
167
+ *
168
+ * @param {string | object} input - Lockfile content string or pre-parsed object
169
+ * @returns {string[]} Array of workspace paths (e.g., ['packages/foo', 'packages/bar'])
170
+ *
171
+ * @example
172
+ * extractWorkspacePaths(lockfile)
173
+ * // => ['packages/babel-core', 'packages/babel-parser', ...]
174
+ */
175
+ export function extractWorkspacePaths(input: string | object): string[];
176
+ /**
177
+ * Build workspace packages map by reading package.json files.
178
+ *
179
+ * @param {string | object} input - Lockfile content string or pre-parsed object
180
+ * @param {string} repoDir - Path to repository root
181
+ * @returns {Promise<Record<string, WorkspacePackage>>} Map of workspace path to package info
182
+ *
183
+ * @example
184
+ * const workspaces = await buildWorkspacePackages(lockfile, '/path/to/repo');
185
+ * // => { 'packages/foo': { name: '@scope/foo', version: '1.0.0', dependencies: {...} } }
186
+ */
187
+ export function buildWorkspacePackages(input: string | object, repoDir: string): Promise<Record<string, WorkspacePackage>>;
188
+ export type Dependency = import("./types.js").Dependency;
189
+ export type WorkspacePackage = {
190
+ name: string;
191
+ version: string;
192
+ dependencies?: Record<string, string>;
193
+ devDependencies?: Record<string, string>;
194
+ optionalDependencies?: Record<string, string>;
195
+ peerDependencies?: Record<string, string>;
196
+ };
197
+ //# sourceMappingURL=yarn-berry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarn-berry.d.ts","sourceRoot":"","sources":["../../src/parsers/yarn-berry.js"],"names":[],"mappings":"AAIA,4DAA4D;AAE5D;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AACH,4CAjEW,MAAM,GACJ,MAAM,GAAG,IAAI,CA4FzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqEG;AACH,sCAhEW,MAAM,GACJ,MAAM,CAiGlB;AAED;;;;;GAKG;AACH,yCAJW,MAAM,GAAG,MAAM,aACf,MAAM,GACJ,SAAS,CAAC,UAAU,CAAC,CAqCjC;AAED;;;;;;;;;;;;GAYG;AACH,6CAPW,MAAM,GAAG,MAAM,GACb,MAAM,EAAE,CA+BpB;AAED;;;;;;;;;;GAUG;AACH,8CARW,MAAM,GAAG,MAAM,WACf,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CA6BrD;yBAjVa,OAAO,YAAY,EAAE,UAAU;;UAI/B,MAAM;aACN,MAAM;mBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;sBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;2BACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;uBACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC"}