flatlock 1.1.0 → 1.2.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/README.md +54 -1
- package/bin/flatlock-cmp.js +71 -45
- package/dist/compare.d.ts +25 -3
- package/dist/compare.d.ts.map +1 -1
- package/dist/detect.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/parsers/index.d.ts +2 -2
- package/dist/parsers/npm.d.ts +64 -37
- package/dist/parsers/npm.d.ts.map +1 -1
- package/dist/parsers/pnpm/detect.d.ts +136 -0
- package/dist/parsers/pnpm/detect.d.ts.map +1 -0
- package/dist/parsers/pnpm/index.d.ts +120 -0
- package/dist/parsers/pnpm/index.d.ts.map +1 -0
- package/dist/parsers/pnpm/internal.d.ts +5 -0
- package/dist/parsers/pnpm/internal.d.ts.map +1 -0
- package/dist/parsers/pnpm/shrinkwrap.d.ts +129 -0
- package/dist/parsers/pnpm/shrinkwrap.d.ts.map +1 -0
- package/dist/parsers/pnpm/v5.d.ts +139 -0
- package/dist/parsers/pnpm/v5.d.ts.map +1 -0
- package/dist/parsers/pnpm/v6plus.d.ts +212 -0
- package/dist/parsers/pnpm/v6plus.d.ts.map +1 -0
- package/dist/parsers/pnpm.d.ts +1 -59
- package/dist/parsers/pnpm.d.ts.map +1 -1
- package/dist/parsers/types.d.ts +23 -0
- package/dist/parsers/types.d.ts.map +1 -0
- package/dist/parsers/yarn-berry.d.ts +141 -52
- package/dist/parsers/yarn-berry.d.ts.map +1 -1
- package/dist/parsers/yarn-classic.d.ts +79 -33
- package/dist/parsers/yarn-classic.d.ts.map +1 -1
- package/dist/set.d.ts +189 -0
- package/dist/set.d.ts.map +1 -0
- package/package.json +7 -5
- package/src/compare.js +385 -28
- package/src/detect.js +3 -4
- package/src/index.js +9 -2
- package/src/parsers/index.js +10 -2
- package/src/parsers/npm.js +64 -16
- package/src/parsers/pnpm/detect.js +198 -0
- package/src/parsers/pnpm/index.js +289 -0
- package/src/parsers/pnpm/internal.js +41 -0
- package/src/parsers/pnpm/shrinkwrap.js +241 -0
- package/src/parsers/pnpm/v5.js +225 -0
- package/src/parsers/pnpm/v6plus.js +290 -0
- package/src/parsers/pnpm.js +11 -89
- package/src/parsers/types.js +10 -0
- package/src/parsers/yarn-berry.js +183 -36
- package/src/parsers/yarn-classic.js +81 -21
- package/src/set.js +618 -0
package/dist/parsers/pnpm.d.ts
CHANGED
|
@@ -1,60 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* @typedef {Object} Dependency
|
|
3
|
-
* @property {string} name - Package name
|
|
4
|
-
* @property {string} version - Resolved version
|
|
5
|
-
* @property {string} [integrity] - Integrity hash
|
|
6
|
-
* @property {string} [resolved] - Resolution URL
|
|
7
|
-
* @property {boolean} [link] - True if this is a symlink
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Parse pnpm package spec to extract name and version
|
|
11
|
-
* Examples:
|
|
12
|
-
* "/@babel/core@7.23.0" → { name: "@babel/core", version: "7.23.0" }
|
|
13
|
-
* "/lodash@4.17.21" → { name: "lodash", version: "4.17.21" }
|
|
14
|
-
* "link:packages/foo" → { name: null, version: null } (skip these)
|
|
15
|
-
*
|
|
16
|
-
* @param {string} spec - Package spec from pnpm lockfile
|
|
17
|
-
* @returns {{ name: string | null, version: string | null }}
|
|
18
|
-
*/
|
|
19
|
-
export function parseSpec(spec: string): {
|
|
20
|
-
name: string | null;
|
|
21
|
-
version: string | null;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Extract package name from pnpm lockfile key.
|
|
25
|
-
* Wraps parseSpec to return just the name (consistent with other parsers).
|
|
26
|
-
*
|
|
27
|
-
* @param {string} key - pnpm lockfile key
|
|
28
|
-
* @returns {string | null} Package name
|
|
29
|
-
*/
|
|
30
|
-
export function parseLockfileKey(key: string): string | null;
|
|
31
|
-
/**
|
|
32
|
-
* Parse pnpm-lock.yaml (v5.4, v6, v9)
|
|
33
|
-
* @param {string} content - Lockfile content
|
|
34
|
-
* @param {Object} [_options] - Parser options (unused, reserved for future use)
|
|
35
|
-
* @returns {Generator<Dependency>}
|
|
36
|
-
*/
|
|
37
|
-
export function fromPnpmLock(content: string, _options?: Object): Generator<Dependency>;
|
|
38
|
-
export type Dependency = {
|
|
39
|
-
/**
|
|
40
|
-
* - Package name
|
|
41
|
-
*/
|
|
42
|
-
name: string;
|
|
43
|
-
/**
|
|
44
|
-
* - Resolved version
|
|
45
|
-
*/
|
|
46
|
-
version: string;
|
|
47
|
-
/**
|
|
48
|
-
* - Integrity hash
|
|
49
|
-
*/
|
|
50
|
-
integrity?: string;
|
|
51
|
-
/**
|
|
52
|
-
* - Resolution URL
|
|
53
|
-
*/
|
|
54
|
-
resolved?: string;
|
|
55
|
-
/**
|
|
56
|
-
* - True if this is a symlink
|
|
57
|
-
*/
|
|
58
|
-
link?: boolean;
|
|
59
|
-
};
|
|
1
|
+
export * from "./pnpm/index.js";
|
|
60
2
|
//# sourceMappingURL=pnpm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpm.d.ts","sourceRoot":"","sources":["../../src/parsers/pnpm.js"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,65 +1,154 @@
|
|
|
1
|
+
/** @typedef {import('./types.js').Dependency} Dependency */
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Extract package name from yarn berry resolution field.
|
|
4
|
+
*
|
|
5
|
+
* The resolution field is the CANONICAL identifier and should be used instead of the key.
|
|
6
|
+
* Keys can contain npm aliases (e.g., "string-width-cjs@npm:string-width@^4.2.0") while
|
|
7
|
+
* the resolution always contains the actual package name (e.g., "string-width@npm:4.2.3").
|
|
8
|
+
*
|
|
9
|
+
* @param {string} resolution - Resolution field from lockfile entry
|
|
10
|
+
* @returns {string | null} Package name or null if parsing fails
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // Unscoped npm package
|
|
14
|
+
* parseResolution('lodash@npm:4.17.21')
|
|
15
|
+
* // => 'lodash'
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Scoped npm package
|
|
19
|
+
* parseResolution('@babel/core@npm:7.24.0')
|
|
20
|
+
* // => '@babel/core'
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Aliased package - resolution shows the REAL package name
|
|
24
|
+
* // (key was "string-width-cjs@npm:string-width@^4.2.0")
|
|
25
|
+
* parseResolution('string-width@npm:4.2.3')
|
|
26
|
+
* // => 'string-width'
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Scoped aliased package - resolution shows the REAL package name
|
|
30
|
+
* // (key was "@babel-baseline/core@npm:@babel/core@7.24.4")
|
|
31
|
+
* parseResolution('@babel/core@npm:7.24.4')
|
|
32
|
+
* // => '@babel/core'
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Patch protocol (nested protocols)
|
|
36
|
+
* parseResolution('pkg@patch:pkg@npm:1.0.0#./patch')
|
|
37
|
+
* // => 'pkg'
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Scoped package with patch protocol
|
|
41
|
+
* parseResolution('@scope/pkg@patch:@scope/pkg@npm:1.0.0#./fix.patch')
|
|
42
|
+
* // => '@scope/pkg'
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // Workspace protocol
|
|
46
|
+
* parseResolution('my-pkg@workspace:packages/my-pkg')
|
|
47
|
+
* // => 'my-pkg'
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* // Scoped workspace package
|
|
51
|
+
* parseResolution('@myorg/utils@workspace:packages/utils')
|
|
52
|
+
* // => '@myorg/utils'
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* // Git protocol
|
|
56
|
+
* parseResolution('my-lib@git:github.com/user/repo#commit-hash')
|
|
57
|
+
* // => 'my-lib'
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* // Null/empty input
|
|
61
|
+
* parseResolution(null)
|
|
62
|
+
* // => null
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Empty string
|
|
66
|
+
* parseResolution('')
|
|
67
|
+
* // => null
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Portal protocol (symlink to external package)
|
|
71
|
+
* parseResolution('@scope/external@portal:../external-pkg')
|
|
72
|
+
* // => '@scope/external'
|
|
8
73
|
*/
|
|
74
|
+
export function parseResolution(resolution: string): string | null;
|
|
9
75
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* !! This is YARN BERRY LOCKFILE KEY parsing, NOT npm spec parsing. !!
|
|
15
|
-
* !! Yarn berry lockfile keys have their own format: !!
|
|
16
|
-
* !! - Protocol markers: @npm:, @workspace:, @patch:, @portal:, @link: !!
|
|
17
|
-
* !! - Nested protocols: @patch:pkg@npm:version#hash !!
|
|
18
|
-
* !! - Multiple comma-separated entries !!
|
|
19
|
-
* !! !!
|
|
20
|
-
* !! npm-package-arg (npa) does NOT understand these formats. !!
|
|
21
|
-
* !! Do not "improve" this with npa. !!
|
|
22
|
-
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
23
|
-
*
|
|
24
|
-
* Extract package name from yarn berry key.
|
|
25
|
-
*
|
|
26
|
-
* Examples:
|
|
27
|
-
* "lodash@npm:^4.17.21" → "lodash"
|
|
28
|
-
* "@babel/core@npm:^7.0.0" → "@babel/core"
|
|
29
|
-
* "@babel/core@npm:^7.0.0, @babel/core@npm:^7.12.3" → "@babel/core"
|
|
30
|
-
* "@ngageoint/simple-features-js@patch:@ngageoint/simple-features-js@npm:1.1.0#..." → "@ngageoint/simple-features-js"
|
|
76
|
+
* Extract package name from yarn berry key (fallback for when resolution is unavailable).
|
|
77
|
+
*
|
|
78
|
+
* WARNING: Keys can contain npm aliases. Prefer parseResolution() when possible.
|
|
79
|
+
* The key may return an alias name instead of the real package name.
|
|
31
80
|
*
|
|
32
81
|
* @param {string} key - Lockfile entry key
|
|
33
|
-
* @returns {string} Package name
|
|
82
|
+
* @returns {string} Package name (may be alias name, not canonical name)
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* // Simple unscoped package
|
|
86
|
+
* parseLockfileKey('lodash@npm:^4.17.21')
|
|
87
|
+
* // => 'lodash'
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Scoped package
|
|
91
|
+
* parseLockfileKey('@babel/core@npm:^7.24.0')
|
|
92
|
+
* // => '@babel/core'
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* // Multiple version ranges (comma-separated) - takes first entry
|
|
96
|
+
* parseLockfileKey('@types/node@npm:^18.0.0, @types/node@npm:^20.0.0')
|
|
97
|
+
* // => '@types/node'
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* // npm alias - returns the ALIAS name (not real package)
|
|
101
|
+
* // Use parseResolution() for the real package name
|
|
102
|
+
* parseLockfileKey('string-width-cjs@npm:string-width@^4.2.0')
|
|
103
|
+
* // => 'string-width-cjs'
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Scoped npm alias
|
|
107
|
+
* parseLockfileKey('@babel-baseline/core@npm:@babel/core@7.24.4')
|
|
108
|
+
* // => '@babel-baseline/core'
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // Workspace protocol
|
|
112
|
+
* parseLockfileKey('my-pkg@workspace:packages/my-pkg')
|
|
113
|
+
* // => 'my-pkg'
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* // Scoped workspace package
|
|
117
|
+
* parseLockfileKey('@myorg/utils@workspace:.')
|
|
118
|
+
* // => '@myorg/utils'
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* // Portal protocol
|
|
122
|
+
* parseLockfileKey('external-pkg@portal:../some/path')
|
|
123
|
+
* // => 'external-pkg'
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // Link protocol
|
|
127
|
+
* parseLockfileKey('linked-pkg@link:./local')
|
|
128
|
+
* // => 'linked-pkg'
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* // Patch protocol (complex nested format)
|
|
132
|
+
* parseLockfileKey('pkg@patch:pkg@npm:1.0.0#./patches/fix.patch')
|
|
133
|
+
* // => 'pkg'
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // Scoped patch
|
|
137
|
+
* parseLockfileKey('@scope/pkg@patch:@scope/pkg@npm:1.0.0#./fix.patch')
|
|
138
|
+
* // => '@scope/pkg'
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* // File protocol
|
|
142
|
+
* parseLockfileKey('local-pkg@file:../local-package')
|
|
143
|
+
* // => 'local-pkg'
|
|
34
144
|
*/
|
|
35
145
|
export function parseLockfileKey(key: string): string;
|
|
36
146
|
/**
|
|
37
147
|
* Parse yarn.lock v2+ (berry)
|
|
38
|
-
* @param {string}
|
|
148
|
+
* @param {string | object} input - Lockfile content string or pre-parsed object
|
|
39
149
|
* @param {Object} [_options] - Parser options (unused, reserved for future use)
|
|
40
150
|
* @returns {Generator<Dependency>}
|
|
41
151
|
*/
|
|
42
|
-
export function fromYarnBerryLock(
|
|
43
|
-
export type Dependency =
|
|
44
|
-
/**
|
|
45
|
-
* - Package name
|
|
46
|
-
*/
|
|
47
|
-
name: string;
|
|
48
|
-
/**
|
|
49
|
-
* - Resolved version
|
|
50
|
-
*/
|
|
51
|
-
version: string;
|
|
52
|
-
/**
|
|
53
|
-
* - Integrity hash
|
|
54
|
-
*/
|
|
55
|
-
integrity?: string;
|
|
56
|
-
/**
|
|
57
|
-
* - Resolution URL
|
|
58
|
-
*/
|
|
59
|
-
resolved?: string;
|
|
60
|
-
/**
|
|
61
|
-
* - True if this is a symlink
|
|
62
|
-
*/
|
|
63
|
-
link?: boolean;
|
|
64
|
-
};
|
|
152
|
+
export function fromYarnBerryLock(input: string | object, _options?: Object): Generator<Dependency>;
|
|
153
|
+
export type Dependency = import("./types.js").Dependency;
|
|
65
154
|
//# sourceMappingURL=yarn-berry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yarn-berry.d.ts","sourceRoot":"","sources":["../../src/parsers/yarn-berry.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"yarn-berry.d.ts","sourceRoot":"","sources":["../../src/parsers/yarn-berry.js"],"names":[],"mappings":"AAEA,4DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;yBA3Pa,OAAO,YAAY,EAAE,UAAU"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} Dependency
|
|
3
|
-
* @property {string} name - Package name
|
|
4
|
-
* @property {string} version - Resolved version
|
|
5
|
-
* @property {string} [integrity] - Integrity hash
|
|
6
|
-
* @property {string} [resolved] - Resolution URL
|
|
7
|
-
* @property {boolean} [link] - True if this is a symlink
|
|
8
|
-
*/
|
|
9
1
|
/**
|
|
10
2
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
3
|
* !! WARNING: DO NOT MODIFY THIS FUNCTION !!
|
|
@@ -22,43 +14,97 @@
|
|
|
22
14
|
*
|
|
23
15
|
* Extract package name from yarn classic key.
|
|
24
16
|
*
|
|
25
|
-
* Examples:
|
|
26
|
-
* "lodash@^4.17.21" → "lodash"
|
|
27
|
-
* "@babel/core@^7.0.0" → "@babel/core"
|
|
28
|
-
* "lodash@^4.17.21, lodash@^4.0.0" → "lodash" (multiple version ranges)
|
|
29
|
-
* "@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3" → "@babel/traverse--for-generate-function-map"
|
|
30
|
-
*
|
|
31
17
|
* @param {string} key - Lockfile entry key
|
|
32
18
|
* @returns {string} Package name
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Simple unscoped package with semver range
|
|
22
|
+
* parseLockfileKey('lodash@^4.17.21')
|
|
23
|
+
* // => 'lodash'
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Scoped package
|
|
27
|
+
* parseLockfileKey('@babel/core@^7.0.0')
|
|
28
|
+
* // => '@babel/core'
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // Multiple version ranges (comma-separated) - takes first entry
|
|
32
|
+
* parseLockfileKey('lodash@^4.17.21, lodash@^4.0.0')
|
|
33
|
+
* // => 'lodash'
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // Multiple ranges for scoped package
|
|
37
|
+
* parseLockfileKey('@types/node@^18.0.0, @types/node@^20.0.0')
|
|
38
|
+
* // => '@types/node'
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* // npm: alias protocol - returns the ALIAS name
|
|
42
|
+
* parseLockfileKey('@babel/traverse--for-generate-function-map@npm:@babel/traverse@^7.25.3')
|
|
43
|
+
* // => '@babel/traverse--for-generate-function-map'
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Unscoped alias
|
|
47
|
+
* parseLockfileKey('string-width-cjs@npm:string-width@^4.2.0')
|
|
48
|
+
* // => 'string-width-cjs'
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Exact version
|
|
52
|
+
* parseLockfileKey('typescript@5.3.3')
|
|
53
|
+
* // => 'typescript'
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Git URL specifier
|
|
57
|
+
* parseLockfileKey('my-lib@github:user/repo#v1.0.0')
|
|
58
|
+
* // => 'my-lib'
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* // Tarball URL
|
|
62
|
+
* parseLockfileKey('custom-pkg@https://example.com/pkg.tgz')
|
|
63
|
+
* // => 'custom-pkg'
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* // Package with prerelease version
|
|
67
|
+
* parseLockfileKey('@next/env@^14.0.0-canary.0')
|
|
68
|
+
* // => '@next/env'
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* // Package without @ (bare name, edge case)
|
|
72
|
+
* parseLockfileKey('lodash')
|
|
73
|
+
* // => 'lodash'
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* // Deeply scoped alias pointing to scoped package
|
|
77
|
+
* parseLockfileKey('@myorg/my-alias@npm:@original/package@^1.0.0')
|
|
78
|
+
* // => '@myorg/my-alias'
|
|
33
79
|
*/
|
|
34
80
|
export function parseLockfileKey(key: string): string;
|
|
35
81
|
/**
|
|
36
82
|
* Parse yarn.lock v1 (classic)
|
|
37
|
-
* @param {string}
|
|
83
|
+
* @param {string | object} input - Lockfile content string or pre-parsed object
|
|
38
84
|
* @param {Object} [_options] - Parser options (unused, reserved for future use)
|
|
39
85
|
* @returns {Generator<Dependency>}
|
|
40
86
|
*/
|
|
41
|
-
export function fromYarnClassicLock(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
87
|
+
export function fromYarnClassicLock(input: string | object, _options?: Object): Generator<Dependency>;
|
|
88
|
+
/** @typedef {import('./types.js').Dependency} Dependency */
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {Object} YarnClassicParseResult
|
|
91
|
+
* @property {'success' | 'merge' | 'conflict'} type - Parse result type
|
|
92
|
+
* @property {Record<string, any>} object - Parsed lockfile object
|
|
93
|
+
*/
|
|
94
|
+
/**
|
|
95
|
+
* The yarn classic parse function (handles CJS/ESM interop)
|
|
96
|
+
* @type {(content: string) => YarnClassicParseResult}
|
|
97
|
+
*/
|
|
98
|
+
export const parseYarnClassic: (content: string) => YarnClassicParseResult;
|
|
99
|
+
export type Dependency = import("./types.js").Dependency;
|
|
100
|
+
export type YarnClassicParseResult = {
|
|
55
101
|
/**
|
|
56
|
-
* -
|
|
102
|
+
* - Parse result type
|
|
57
103
|
*/
|
|
58
|
-
|
|
104
|
+
type: "success" | "merge" | "conflict";
|
|
59
105
|
/**
|
|
60
|
-
* -
|
|
106
|
+
* - Parsed lockfile object
|
|
61
107
|
*/
|
|
62
|
-
|
|
108
|
+
object: Record<string, any>;
|
|
63
109
|
};
|
|
64
110
|
//# sourceMappingURL=yarn-classic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yarn-classic.d.ts","sourceRoot":"","sources":["../../src/parsers/yarn-classic.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"yarn-classic.d.ts","sourceRoot":"","sources":["../../src/parsers/yarn-classic.js"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,sCA/DW,MAAM,GACJ,MAAM,CA8FlB;AAED;;;;;GAKG;AACH,2CAJW,MAAM,GAAG,MAAM,aACf,MAAM,GACJ,SAAS,CAAC,UAAU,CAAC,CAgCjC;AAnKD,4DAA4D;AAE5D;;;;GAIG;AAEH;;;GAGG;AACH,+BAFU,CAAC,OAAO,EAAE,MAAM,KAAK,sBAAsB,CAE6B;yBAZpE,OAAO,YAAY,EAAE,UAAU;;;;;UAI/B,SAAS,GAAG,OAAO,GAAG,UAAU;;;;YAChC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC"}
|
package/dist/set.d.ts
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Set-like container for lockfile dependencies.
|
|
3
|
+
*
|
|
4
|
+
* Identity is determined by name@version. Two dependencies with the same
|
|
5
|
+
* name and version are considered equal, regardless of integrity or resolved URL.
|
|
6
|
+
*
|
|
7
|
+
* All set operations return new FlatlockSet instances (immutable pattern).
|
|
8
|
+
*
|
|
9
|
+
* NOTE: Set operations (union, intersection, difference) return sets that
|
|
10
|
+
* cannot use dependenciesOf() because they lack lockfile traversal data.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const set = await FlatlockSet.fromPath('./package-lock.json');
|
|
14
|
+
* console.log(set.size); // 1234
|
|
15
|
+
* console.log(set.has('lodash@4.17.21')); // true
|
|
16
|
+
*
|
|
17
|
+
* // Get dependencies for a specific workspace
|
|
18
|
+
* const pkg = JSON.parse(await readFile('./packages/foo/package.json'));
|
|
19
|
+
* const subset = set.dependenciesOf(pkg, { workspacePath: 'packages/foo' });
|
|
20
|
+
*
|
|
21
|
+
* // Set operations
|
|
22
|
+
* const other = await FlatlockSet.fromPath('./other-lock.json');
|
|
23
|
+
* const common = set.intersection(other);
|
|
24
|
+
*/
|
|
25
|
+
export class FlatlockSet {
|
|
26
|
+
/**
|
|
27
|
+
* Create FlatlockSet from lockfile path (auto-detect type)
|
|
28
|
+
* @param {string} path - Path to lockfile
|
|
29
|
+
* @param {FromStringOptions} [options] - Parser options
|
|
30
|
+
* @returns {Promise<FlatlockSet>}
|
|
31
|
+
*/
|
|
32
|
+
static fromPath(path: string, options?: FromStringOptions): Promise<FlatlockSet>;
|
|
33
|
+
/**
|
|
34
|
+
* Create FlatlockSet from lockfile string
|
|
35
|
+
* @param {string} content - Lockfile content
|
|
36
|
+
* @param {FromStringOptions} [options] - Parser options
|
|
37
|
+
* @returns {FlatlockSet}
|
|
38
|
+
*/
|
|
39
|
+
static fromString(content: string, options?: FromStringOptions): FlatlockSet;
|
|
40
|
+
/**
|
|
41
|
+
* Parse lockfile once, returning both processed deps and raw data
|
|
42
|
+
* @param {string} content
|
|
43
|
+
* @param {LockfileType} type
|
|
44
|
+
* @param {FromStringOptions} options
|
|
45
|
+
* @returns {{ deps: Map<string, Dependency>, packages: LockfilePackages, importers: LockfileImporters | null }}
|
|
46
|
+
*/
|
|
47
|
+
static "__#private@#parseAll"(content: string, type: LockfileType, options: FromStringOptions): {
|
|
48
|
+
deps: Map<string, Dependency>;
|
|
49
|
+
packages: LockfilePackages;
|
|
50
|
+
importers: LockfileImporters | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* @param {symbol} internal - Must be INTERNAL symbol
|
|
54
|
+
* @param {Map<string, Dependency>} deps
|
|
55
|
+
* @param {LockfilePackages | null} packages
|
|
56
|
+
* @param {LockfileImporters | null} importers
|
|
57
|
+
* @param {LockfileType | null} type
|
|
58
|
+
*/
|
|
59
|
+
constructor(internal: symbol, deps: Map<string, Dependency>, packages: LockfilePackages | null, importers: LockfileImporters | null, type: LockfileType | null);
|
|
60
|
+
/** @returns {number} */
|
|
61
|
+
get size(): number;
|
|
62
|
+
/** @returns {LockfileType | null} */
|
|
63
|
+
get type(): LockfileType | null;
|
|
64
|
+
/** @returns {boolean} */
|
|
65
|
+
get canTraverse(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a dependency exists
|
|
68
|
+
* @param {string} nameAtVersion - e.g., "lodash@4.17.21"
|
|
69
|
+
* @returns {boolean}
|
|
70
|
+
*/
|
|
71
|
+
has(nameAtVersion: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Get a dependency by name@version
|
|
74
|
+
* @param {string} nameAtVersion
|
|
75
|
+
* @returns {Dependency | undefined}
|
|
76
|
+
*/
|
|
77
|
+
get(nameAtVersion: string): Dependency | undefined;
|
|
78
|
+
/** @returns {IterableIterator<Dependency>} */
|
|
79
|
+
values(): IterableIterator<Dependency>;
|
|
80
|
+
/** @returns {IterableIterator<string>} */
|
|
81
|
+
keys(): IterableIterator<string>;
|
|
82
|
+
/** @returns {IterableIterator<[string, Dependency]>} */
|
|
83
|
+
entries(): IterableIterator<[string, Dependency]>;
|
|
84
|
+
/**
|
|
85
|
+
* Execute a callback for each dependency
|
|
86
|
+
* @param {(dep: Dependency, key: string, set: FlatlockSet) => void} callback
|
|
87
|
+
* @param {any} [thisArg]
|
|
88
|
+
*/
|
|
89
|
+
forEach(callback: (dep: Dependency, key: string, set: FlatlockSet) => void, thisArg?: any): void;
|
|
90
|
+
/**
|
|
91
|
+
* Union of this set with another
|
|
92
|
+
* @param {FlatlockSet} other
|
|
93
|
+
* @returns {FlatlockSet}
|
|
94
|
+
*/
|
|
95
|
+
union(other: FlatlockSet): FlatlockSet;
|
|
96
|
+
/**
|
|
97
|
+
* Intersection of this set with another
|
|
98
|
+
* @param {FlatlockSet} other
|
|
99
|
+
* @returns {FlatlockSet}
|
|
100
|
+
*/
|
|
101
|
+
intersection(other: FlatlockSet): FlatlockSet;
|
|
102
|
+
/**
|
|
103
|
+
* Difference: elements in this set but not in other
|
|
104
|
+
* @param {FlatlockSet} other
|
|
105
|
+
* @returns {FlatlockSet}
|
|
106
|
+
*/
|
|
107
|
+
difference(other: FlatlockSet): FlatlockSet;
|
|
108
|
+
/**
|
|
109
|
+
* Check if this set is a subset of another
|
|
110
|
+
* @param {FlatlockSet} other
|
|
111
|
+
* @returns {boolean}
|
|
112
|
+
*/
|
|
113
|
+
isSubsetOf(other: FlatlockSet): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Check if this set is a superset of another
|
|
116
|
+
* @param {FlatlockSet} other
|
|
117
|
+
* @returns {boolean}
|
|
118
|
+
*/
|
|
119
|
+
isSupersetOf(other: FlatlockSet): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Check if this set has no elements in common with another
|
|
122
|
+
* @param {FlatlockSet} other
|
|
123
|
+
* @returns {boolean}
|
|
124
|
+
*/
|
|
125
|
+
isDisjointFrom(other: FlatlockSet): boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Get transitive dependencies of a package.json
|
|
128
|
+
*
|
|
129
|
+
* For monorepos, provide workspacePath to get correct resolution.
|
|
130
|
+
* Without workspacePath, assumes root package (hoisted deps only).
|
|
131
|
+
*
|
|
132
|
+
* NOTE: This method is only available on sets created directly from
|
|
133
|
+
* fromPath/fromString. Sets created via union/intersection/difference
|
|
134
|
+
* cannot use this method (canTraverse will be false).
|
|
135
|
+
*
|
|
136
|
+
* @param {PackageJson} packageJson - Parsed package.json
|
|
137
|
+
* @param {DependenciesOfOptions} [options]
|
|
138
|
+
* @returns {FlatlockSet}
|
|
139
|
+
* @throws {Error} If called on a set that cannot traverse
|
|
140
|
+
*/
|
|
141
|
+
dependenciesOf(packageJson: PackageJson, options?: DependenciesOfOptions): FlatlockSet;
|
|
142
|
+
/**
|
|
143
|
+
* Convert to array
|
|
144
|
+
* @returns {Dependency[]}
|
|
145
|
+
*/
|
|
146
|
+
toArray(): Dependency[];
|
|
147
|
+
/** @returns {IterableIterator<Dependency>} */
|
|
148
|
+
[Symbol.iterator](): IterableIterator<Dependency>;
|
|
149
|
+
#private;
|
|
150
|
+
}
|
|
151
|
+
export type Dependency = import("./parsers/npm.js").Dependency;
|
|
152
|
+
export type LockfileType = import("./detect.js").LockfileType;
|
|
153
|
+
export type DependenciesOfOptions = {
|
|
154
|
+
/**
|
|
155
|
+
* - Path to workspace (e.g., 'packages/foo')
|
|
156
|
+
*/
|
|
157
|
+
workspacePath?: string;
|
|
158
|
+
/**
|
|
159
|
+
* - Include devDependencies
|
|
160
|
+
*/
|
|
161
|
+
dev?: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* - Include optionalDependencies
|
|
164
|
+
*/
|
|
165
|
+
optional?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* - Include peerDependencies (default false: peers are provided by consumer)
|
|
168
|
+
*/
|
|
169
|
+
peer?: boolean;
|
|
170
|
+
};
|
|
171
|
+
export type FromStringOptions = {
|
|
172
|
+
/**
|
|
173
|
+
* - Path hint for type detection
|
|
174
|
+
*/
|
|
175
|
+
path?: string;
|
|
176
|
+
/**
|
|
177
|
+
* - Explicit lockfile type
|
|
178
|
+
*/
|
|
179
|
+
type?: LockfileType;
|
|
180
|
+
};
|
|
181
|
+
export type PackageJson = {
|
|
182
|
+
dependencies?: Record<string, string>;
|
|
183
|
+
devDependencies?: Record<string, string>;
|
|
184
|
+
optionalDependencies?: Record<string, string>;
|
|
185
|
+
peerDependencies?: Record<string, string>;
|
|
186
|
+
};
|
|
187
|
+
export type LockfilePackages = Record<string, any>;
|
|
188
|
+
export type LockfileImporters = Record<string, any>;
|
|
189
|
+
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../src/set.js"],"names":[],"mappings":"AAoDA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH;IAoCE;;;;;OAKG;IACH,sBAJW,MAAM,YACN,iBAAiB,GACf,OAAO,CAAC,WAAW,CAAC,CAKhC;IAED;;;;;OAKG;IACH,2BAJW,MAAM,YACN,iBAAiB,GACf,WAAW,CAgBvB;IAED;;;;;;OAMG;IACH,uCALW,MAAM,QACN,YAAY,WACZ,iBAAiB,GACf;QAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAAC,QAAQ,EAAE,gBAAgB,CAAC;QAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAA;KAAE,CAmD9G;IA7GD;;;;;;OAMG;IACH,sBANW,MAAM,QACN,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,YACvB,gBAAgB,GAAG,IAAI,aACvB,iBAAiB,GAAG,IAAI,QACxB,YAAY,GAAG,IAAI,EAa7B;IA6FD,wBAAwB;IACxB,YADc,MAAM,CAGnB;IAED,qCAAqC;IACrC,YADc,YAAY,GAAG,IAAI,CAGhC;IAED,yBAAyB;IACzB,mBADc,OAAO,CAGpB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,UAAU,GAAG,SAAS,CAIlC;IAOD,8CAA8C;IAC9C,UADc,gBAAgB,CAAC,UAAU,CAAC,CAGzC;IAED,0CAA0C;IAC1C,QADc,gBAAgB,CAAC,MAAM,CAAC,CAGrC;IAED,wDAAwD;IACxD,WADc,gBAAgB,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAGnD;IAED;;;;OAIG;IACH,kBAHW,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,IAAI,YACxD,GAAG,QAMb;IAED;;;;OAIG;IACH,aAHW,WAAW,GACT,WAAW,CAUvB;IAED;;;;OAIG;IACH,oBAHW,WAAW,GACT,WAAW,CAUvB;IAED;;;;OAIG;IACH,kBAHW,WAAW,GACT,WAAW,CAUvB;IAED;;;;OAIG;IACH,kBAHW,WAAW,GACT,OAAO,CAOnB;IAED;;;;OAIG;IACH,oBAHW,WAAW,GACT,OAAO,CAInB;IAED;;;;OAIG;IACH,sBAHW,WAAW,GACT,OAAO,CAOnB;IAED;;;;;;;;;;;;;;OAcG;IACH,4BALW,WAAW,YACX,qBAAqB,GACnB,WAAW,CA4BvB;IAiOD;;;OAGG;IACH,WAFa,UAAU,EAAE,CAIxB;IA5XD,8CAA8C;IAC9C,qBADc,gBAAgB,CAAC,UAAU,CAAC,CAGzC;;CA0XF;yBA1lBY,OAAO,kBAAkB,EAAE,UAAU;2BACrC,OAAO,aAAa,EAAE,YAAY;;;;;oBAKjC,MAAM;;;;UACN,OAAO;;;;eACP,OAAO;;;;WACP,OAAO;;;;;;WAKP,MAAM;;;;WACN,YAAY;;;mBAKZ,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;;+BAIvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;gCAInB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC"}
|