@vltpkg/query 1.5.0 → 1.6.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 (210) hide show
  1. package/package.json +10 -12
  2. package/skills/dss-query/REFERENCE.md +0 -125
  3. package/skills/dss-query/SKILL.md +0 -190
  4. package/skills/dss-query/evals/README.md +0 -81
  5. package/skills/dss-query/evals/evals.json +0 -89
  6. package/skills/dss-query/evals/grade.mjs +0 -481
  7. package/src/attribute.ts +0 -190
  8. package/src/combinator.ts +0 -135
  9. package/src/error.ts +0 -78
  10. package/src/id.ts +0 -46
  11. package/src/index.ts +0 -670
  12. package/src/parser.ts +0 -122
  13. package/src/pseudo/abandoned.ts +0 -9
  14. package/src/pseudo/attr.ts +0 -92
  15. package/src/pseudo/built.ts +0 -19
  16. package/src/pseudo/confused.ts +0 -29
  17. package/src/pseudo/cve.ts +0 -93
  18. package/src/pseudo/cwe.ts +0 -97
  19. package/src/pseudo/debug.ts +0 -9
  20. package/src/pseudo/deprecated.ts +0 -9
  21. package/src/pseudo/dev.ts +0 -18
  22. package/src/pseudo/diff.ts +0 -90
  23. package/src/pseudo/dist.ts +0 -148
  24. package/src/pseudo/dynamic.ts +0 -9
  25. package/src/pseudo/empty.ts +0 -15
  26. package/src/pseudo/entropic.ts +0 -9
  27. package/src/pseudo/env.ts +0 -6
  28. package/src/pseudo/eval.ts +0 -9
  29. package/src/pseudo/fs.ts +0 -9
  30. package/src/pseudo/helpers.ts +0 -106
  31. package/src/pseudo/host.ts +0 -111
  32. package/src/pseudo/hostname.ts +0 -156
  33. package/src/pseudo/license.ts +0 -134
  34. package/src/pseudo/link.ts +0 -30
  35. package/src/pseudo/malware.ts +0 -41
  36. package/src/pseudo/minified.ts +0 -9
  37. package/src/pseudo/missing.ts +0 -16
  38. package/src/pseudo/native.ts +0 -9
  39. package/src/pseudo/network.ts +0 -9
  40. package/src/pseudo/obfuscated.ts +0 -9
  41. package/src/pseudo/optional.ts +0 -18
  42. package/src/pseudo/outdated.ts +0 -345
  43. package/src/pseudo/overridden.ts +0 -20
  44. package/src/pseudo/path.ts +0 -146
  45. package/src/pseudo/peer.ts +0 -18
  46. package/src/pseudo/prerelease.ts +0 -47
  47. package/src/pseudo/private.ts +0 -19
  48. package/src/pseudo/prod.ts +0 -18
  49. package/src/pseudo/published.ts +0 -250
  50. package/src/pseudo/registry.ts +0 -29
  51. package/src/pseudo/root.ts +0 -19
  52. package/src/pseudo/scanned.ts +0 -20
  53. package/src/pseudo/score.ts +0 -186
  54. package/src/pseudo/scripts.ts +0 -61
  55. package/src/pseudo/semver.ts +0 -320
  56. package/src/pseudo/severity.ts +0 -231
  57. package/src/pseudo/shell.ts +0 -9
  58. package/src/pseudo/shrinkwrap.ts +0 -9
  59. package/src/pseudo/skill.ts +0 -59
  60. package/src/pseudo/skills.ts +0 -29
  61. package/src/pseudo/spec.ts +0 -131
  62. package/src/pseudo/squat.ts +0 -225
  63. package/src/pseudo/suspicious.ts +0 -9
  64. package/src/pseudo/tracker.ts +0 -9
  65. package/src/pseudo/trivial.ts +0 -9
  66. package/src/pseudo/type.ts +0 -26
  67. package/src/pseudo/undesirable.ts +0 -9
  68. package/src/pseudo/unknown.ts +0 -9
  69. package/src/pseudo/unmaintained.ts +0 -9
  70. package/src/pseudo/unpopular.ts +0 -9
  71. package/src/pseudo/unstable.ts +0 -9
  72. package/src/pseudo/vuln.ts +0 -273
  73. package/src/pseudo/workspace.ts +0 -22
  74. package/src/pseudo.ts +0 -440
  75. package/src/types.ts +0 -206
  76. package/tap-snapshots/test/attribute.ts.test.cjs +0 -304
  77. package/tap-snapshots/test/combinator.ts.test.cjs +0 -333
  78. package/tap-snapshots/test/id.ts.test.cjs +0 -118
  79. package/tap-snapshots/test/parser.ts.test.cjs +0 -344
  80. package/tap-snapshots/test/pseudo/abandoned.ts.test.cjs +0 -18
  81. package/tap-snapshots/test/pseudo/attr.ts.test.cjs +0 -161
  82. package/tap-snapshots/test/pseudo/built.ts.test.cjs +0 -70
  83. package/tap-snapshots/test/pseudo/confused.ts.test.cjs +0 -32
  84. package/tap-snapshots/test/pseudo/cve.ts.test.cjs +0 -49
  85. package/tap-snapshots/test/pseudo/cwe.ts.test.cjs +0 -49
  86. package/tap-snapshots/test/pseudo/debug.ts.test.cjs +0 -18
  87. package/tap-snapshots/test/pseudo/deprecated.ts.test.cjs +0 -18
  88. package/tap-snapshots/test/pseudo/dist.ts.test.cjs +0 -30
  89. package/tap-snapshots/test/pseudo/dynamic.ts.test.cjs +0 -18
  90. package/tap-snapshots/test/pseudo/empty.ts.test.cjs +0 -50
  91. package/tap-snapshots/test/pseudo/entropic.ts.test.cjs +0 -18
  92. package/tap-snapshots/test/pseudo/env.ts.test.cjs +0 -18
  93. package/tap-snapshots/test/pseudo/eval.ts.test.cjs +0 -18
  94. package/tap-snapshots/test/pseudo/fs.ts.test.cjs +0 -18
  95. package/tap-snapshots/test/pseudo/helpers.ts.test.cjs +0 -18
  96. package/tap-snapshots/test/pseudo/hostname.ts.test.cjs +0 -148
  97. package/tap-snapshots/test/pseudo/license.ts.test.cjs +0 -41
  98. package/tap-snapshots/test/pseudo/link.ts.test.cjs +0 -36
  99. package/tap-snapshots/test/pseudo/malware.ts.test.cjs +0 -22
  100. package/tap-snapshots/test/pseudo/minified.ts.test.cjs +0 -18
  101. package/tap-snapshots/test/pseudo/missing.ts.test.cjs +0 -30
  102. package/tap-snapshots/test/pseudo/native.ts.test.cjs +0 -18
  103. package/tap-snapshots/test/pseudo/network.ts.test.cjs +0 -18
  104. package/tap-snapshots/test/pseudo/obfuscated.ts.test.cjs +0 -18
  105. package/tap-snapshots/test/pseudo/outdated.ts.test.cjs +0 -132
  106. package/tap-snapshots/test/pseudo/overridden.ts.test.cjs +0 -75
  107. package/tap-snapshots/test/pseudo/prerelease.ts.test.cjs +0 -101
  108. package/tap-snapshots/test/pseudo/private.ts.test.cjs +0 -38
  109. package/tap-snapshots/test/pseudo/published.ts.test.cjs +0 -171
  110. package/tap-snapshots/test/pseudo/registry.ts.test.cjs +0 -68
  111. package/tap-snapshots/test/pseudo/root.ts.test.cjs +0 -24
  112. package/tap-snapshots/test/pseudo/scanned.ts.test.cjs +0 -18
  113. package/tap-snapshots/test/pseudo/score.ts.test.cjs +0 -239
  114. package/tap-snapshots/test/pseudo/scripts.ts.test.cjs +0 -62
  115. package/tap-snapshots/test/pseudo/semver.ts.test.cjs +0 -575
  116. package/tap-snapshots/test/pseudo/severity.ts.test.cjs +0 -122
  117. package/tap-snapshots/test/pseudo/shell.ts.test.cjs +0 -18
  118. package/tap-snapshots/test/pseudo/shrinkwrap.ts.test.cjs +0 -18
  119. package/tap-snapshots/test/pseudo/skills.ts.test.cjs +0 -19
  120. package/tap-snapshots/test/pseudo/spec.ts.test.cjs +0 -148
  121. package/tap-snapshots/test/pseudo/squat.ts.test.cjs +0 -129
  122. package/tap-snapshots/test/pseudo/suspicious.ts.test.cjs +0 -18
  123. package/tap-snapshots/test/pseudo/tracker.ts.test.cjs +0 -18
  124. package/tap-snapshots/test/pseudo/trivial.ts.test.cjs +0 -18
  125. package/tap-snapshots/test/pseudo/type.ts.test.cjs +0 -51
  126. package/tap-snapshots/test/pseudo/undesirable.ts.test.cjs +0 -18
  127. package/tap-snapshots/test/pseudo/unknown.ts.test.cjs +0 -18
  128. package/tap-snapshots/test/pseudo/unmaintained.ts.test.cjs +0 -18
  129. package/tap-snapshots/test/pseudo/unpopular.ts.test.cjs +0 -18
  130. package/tap-snapshots/test/pseudo/unstable.ts.test.cjs +0 -18
  131. package/tap-snapshots/test/pseudo/vuln.ts.test.cjs +0 -208
  132. package/tap-snapshots/test/pseudo/vulnerable.ts.test.cjs +0 -20
  133. package/tap-snapshots/test/pseudo/workspace.ts.test.cjs +0 -19
  134. package/tap-snapshots/test/pseudo.ts.test.cjs +0 -1247
  135. package/test/attribute.ts +0 -273
  136. package/test/combinator.ts +0 -175
  137. package/test/error.ts +0 -60
  138. package/test/fixtures/graph.ts +0 -999
  139. package/test/fixtures/selector.ts +0 -103
  140. package/test/fixtures/types.ts +0 -7
  141. package/test/id.ts +0 -102
  142. package/test/index.ts +0 -1148
  143. package/test/parser.ts +0 -117
  144. package/test/pseudo/abandoned.ts +0 -98
  145. package/test/pseudo/attr.ts +0 -298
  146. package/test/pseudo/built.ts +0 -214
  147. package/test/pseudo/confused.ts +0 -160
  148. package/test/pseudo/cve.ts +0 -249
  149. package/test/pseudo/cwe.ts +0 -255
  150. package/test/pseudo/debug.ts +0 -98
  151. package/test/pseudo/deprecated.ts +0 -98
  152. package/test/pseudo/dev.ts +0 -61
  153. package/test/pseudo/diff.ts +0 -417
  154. package/test/pseudo/dist.ts +0 -215
  155. package/test/pseudo/dynamic.ts +0 -98
  156. package/test/pseudo/empty.ts +0 -108
  157. package/test/pseudo/entropic.ts +0 -101
  158. package/test/pseudo/env.ts +0 -98
  159. package/test/pseudo/eval.ts +0 -98
  160. package/test/pseudo/fs.ts +0 -98
  161. package/test/pseudo/helpers.ts +0 -370
  162. package/test/pseudo/host-context.ts +0 -276
  163. package/test/pseudo/hostname.ts +0 -314
  164. package/test/pseudo/license.ts +0 -265
  165. package/test/pseudo/link.ts +0 -94
  166. package/test/pseudo/malware.ts +0 -184
  167. package/test/pseudo/minified.ts +0 -98
  168. package/test/pseudo/missing.ts +0 -111
  169. package/test/pseudo/native.ts +0 -98
  170. package/test/pseudo/network.ts +0 -98
  171. package/test/pseudo/obfuscated.ts +0 -98
  172. package/test/pseudo/optional.ts +0 -73
  173. package/test/pseudo/outdated.ts +0 -461
  174. package/test/pseudo/overridden.ts +0 -317
  175. package/test/pseudo/path.ts +0 -680
  176. package/test/pseudo/peer.ts +0 -101
  177. package/test/pseudo/prerelease.ts +0 -279
  178. package/test/pseudo/private.ts +0 -108
  179. package/test/pseudo/prod.ts +0 -61
  180. package/test/pseudo/published.ts +0 -557
  181. package/test/pseudo/registry.ts +0 -122
  182. package/test/pseudo/root.ts +0 -66
  183. package/test/pseudo/scanned.ts +0 -144
  184. package/test/pseudo/score.ts +0 -591
  185. package/test/pseudo/scripts.ts +0 -324
  186. package/test/pseudo/semver.ts +0 -822
  187. package/test/pseudo/severity.ts +0 -342
  188. package/test/pseudo/shell.ts +0 -98
  189. package/test/pseudo/shrinkwrap.ts +0 -98
  190. package/test/pseudo/skill.ts +0 -189
  191. package/test/pseudo/skills.ts +0 -90
  192. package/test/pseudo/spec.ts +0 -525
  193. package/test/pseudo/squat.ts +0 -565
  194. package/test/pseudo/suspicious.ts +0 -98
  195. package/test/pseudo/tracker.ts +0 -98
  196. package/test/pseudo/trivial.ts +0 -98
  197. package/test/pseudo/type.ts +0 -105
  198. package/test/pseudo/undesirable.ts +0 -98
  199. package/test/pseudo/unknown.ts +0 -98
  200. package/test/pseudo/unmaintained.ts +0 -98
  201. package/test/pseudo/unpopular.ts +0 -98
  202. package/test/pseudo/unstable.ts +0 -98
  203. package/test/pseudo/vuln.ts +0 -625
  204. package/test/pseudo/vulnerable.ts +0 -137
  205. package/test/pseudo/workspace.ts +0 -111
  206. package/test/pseudo.ts +0 -584
  207. package/tsconfig.json +0 -3
  208. package/tsconfig.publish.json +0 -19
  209. package/tsconfig.publish.tsbuildinfo +0 -1
  210. package/typedoc.mjs +0 -2
@@ -1,101 +0,0 @@
1
- import t from 'tap'
2
- import { pseudo } from '../../src/pseudo.ts'
3
- import {
4
- selectorFixture,
5
- copyGraphSelectionState,
6
- } from '../fixtures/selector.ts'
7
- import { getSimpleGraph } from '../fixtures/graph.ts'
8
- import type { TestCase } from '../fixtures/types.ts'
9
- import type { GraphSelectionState } from '../../src/types.ts'
10
-
11
- const testPseudo = selectorFixture(pseudo)
12
-
13
- t.test(':peer pseudo-selector', async t => {
14
- // Get a simple graph for testing
15
- const simpleGraph = getSimpleGraph()
16
-
17
- // Create a peer dependency edge for testing
18
- // Find an existing edge and change its type to 'peer'
19
- for (const edge of simpleGraph.edges) {
20
- if (edge.name === 'c') {
21
- edge.type = 'peer'
22
- break
23
- }
24
- }
25
-
26
- // Get the full selection state
27
- const all = {
28
- edges: new Set(simpleGraph.edges),
29
- nodes: new Set(simpleGraph.nodes.values()),
30
- }
31
-
32
- // Create an empty selection state
33
- const empty: GraphSelectionState = {
34
- edges: new Set(),
35
- nodes: new Set(),
36
- }
37
-
38
- // Run tests in the same pattern as the main pseudo.ts tests
39
- const queryToExpected = new Set<TestCase>([
40
- [':peer', all, ['c']], // Should return nodes with peer dependency edges
41
- [':peer', empty, []], // Empty input should return empty output
42
- ])
43
-
44
- const initial = copyGraphSelectionState(all)
45
- for (const [query, partial, expected] of queryToExpected) {
46
- const result = await testPseudo(
47
- query,
48
- initial,
49
- copyGraphSelectionState(partial),
50
- )
51
-
52
- t.strictSame(
53
- result.nodes.map(i => i.name),
54
- expected,
55
- `query > "${query}"`,
56
- )
57
-
58
- // Verify all edges are peer dependencies
59
- const edgeArray = [...result.edges]
60
- if (edgeArray.length > 0) {
61
- for (const edge of edgeArray) {
62
- t.ok(
63
- edge.type === 'peer' || edge.type === 'peerOptional',
64
- `edge ${edge.name} should have type 'peer' or 'peerOptional'`,
65
- )
66
- }
67
- }
68
- }
69
-
70
- // Test peerOptional type
71
- t.test('handles peerOptional dependencies', async t => {
72
- // Change an edge to peerOptional for testing
73
- for (const edge of simpleGraph.edges) {
74
- if (edge.name === 'd') {
75
- edge.type = 'peerOptional'
76
- break
77
- }
78
- }
79
-
80
- // Run the test
81
- const result = await testPseudo(
82
- ':peer',
83
- initial,
84
- copyGraphSelectionState(all),
85
- )
86
-
87
- // Result should include both peer and peerOptional dependencies
88
- const nodeArray = [...result.nodes]
89
- t.ok(
90
- nodeArray.length >= 2,
91
- 'Result should include both peer and peerOptional dependencies',
92
- )
93
-
94
- // Verify that our peerOptional dependency is included
95
- const nodeNames = nodeArray.map(n => n.name)
96
- t.ok(
97
- nodeNames.includes('d'),
98
- 'Result should include the peerOptional dependency',
99
- )
100
- })
101
- })
@@ -1,279 +0,0 @@
1
- import t from 'tap'
2
- import postcssSelectorParser from 'postcss-selector-parser'
3
- import type { ParserState } from '../../src/types.ts'
4
- import { prerelease } from '../../src/pseudo/prerelease.ts'
5
- import { parse } from '@vltpkg/semver'
6
- import {
7
- getSemverRichGraph,
8
- getSimpleGraph,
9
- newGraph,
10
- newNode,
11
- } from '../fixtures/graph.ts'
12
-
13
- t.test(':prerelease pseudo-selector', async t => {
14
- const getState = (query: string, graph = getSemverRichGraph()) => {
15
- const ast = postcssSelectorParser().astSync(query)
16
- const current = ast.first.first
17
- const state: ParserState = {
18
- comment: '',
19
- current,
20
- initial: {
21
- edges: new Set(graph.edges.values()),
22
- nodes: new Set(graph.nodes.values()),
23
- },
24
- partial: {
25
- edges: new Set(graph.edges.values()),
26
- nodes: new Set(graph.nodes.values()),
27
- },
28
- collect: {
29
- edges: new Set(),
30
- nodes: new Set(),
31
- },
32
- cancellable: async () => {},
33
- walk: async i => i,
34
- retries: 0,
35
- securityArchive: undefined,
36
- importers: new Set(graph.importers),
37
- signal: new AbortController().signal,
38
- specificity: { idCounter: 0, commonCounter: 0 },
39
- }
40
- return state
41
- }
42
-
43
- await t.test(
44
- 'selects only nodes with prerelease versions',
45
- async t => {
46
- const res = await prerelease(getState(':prerelease'))
47
-
48
- // Should only select nodes with prerelease versions
49
- const nodeNames = [...res.partial.nodes].map(n => n.name).sort()
50
- const nodeVersions = [...res.partial.nodes]
51
- .map(n => n.version)
52
- .sort()
53
-
54
- t.strictSame(
55
- nodeNames,
56
- ['e', 'g'],
57
- 'should select only nodes with prerelease versions',
58
- )
59
-
60
- t.strictSame(
61
- nodeVersions,
62
- ['1.2.3-rc.1+rev.2', '1.3.4-beta.1'],
63
- 'should select correct prerelease versions',
64
- )
65
-
66
- t.matchSnapshot({
67
- nodes: [...res.partial.nodes].map(n => ({
68
- name: n.name,
69
- version: n.version,
70
- })),
71
- edges: [...res.partial.edges].map(e => e.name),
72
- })
73
- },
74
- )
75
-
76
- await t.test('excludes non-prerelease versions', async t => {
77
- const res = await prerelease(getState(':prerelease'))
78
-
79
- // Verify that only prerelease versions remain
80
- for (const node of res.partial.nodes) {
81
- const version = node.manifest?.version
82
- if (version) {
83
- const parsed = parse(version)
84
- t.ok(
85
- parsed?.prerelease?.length,
86
- `${node.name}@${version} should have prerelease identifiers`,
87
- )
88
- }
89
- }
90
-
91
- t.matchSnapshot([...res.partial.nodes].map(n => n.version).sort())
92
- })
93
-
94
- await t.test('handles nodes without version', async t => {
95
- const graph = newGraph('test-project')
96
- const addNode = newNode(graph)
97
-
98
- // Create a node without version
99
- const nodeWithoutVersion = addNode('no-version', '1.0.0')
100
- nodeWithoutVersion.manifest = { name: 'no-version' } // No version field
101
- graph.nodes.set(nodeWithoutVersion.id, nodeWithoutVersion)
102
-
103
- const res = await prerelease(getState(':prerelease', graph))
104
-
105
- t.strictSame(
106
- [...res.partial.nodes].length,
107
- 0,
108
- 'should exclude all nodes when none have prerelease versions',
109
- )
110
-
111
- t.matchSnapshot({
112
- nodes: [...res.partial.nodes].map(n => ({
113
- name: n.name,
114
- version: n.version,
115
- })),
116
- })
117
- })
118
-
119
- await t.test('handles nodes with invalid semver', async t => {
120
- const graph = newGraph('test-project')
121
- const addNode = newNode(graph)
122
-
123
- // Create a node with invalid semver
124
- const nodeWithInvalidSemver = addNode('invalid-semver', '1.0.0')
125
- nodeWithInvalidSemver.version = 'not-a-semver'
126
- nodeWithInvalidSemver.manifest = {
127
- name: 'invalid-semver',
128
- version: 'not-a-semver',
129
- }
130
- graph.nodes.set(nodeWithInvalidSemver.id, nodeWithInvalidSemver)
131
-
132
- const res = await prerelease(getState(':prerelease', graph))
133
-
134
- t.strictSame(
135
- [...res.partial.nodes].length,
136
- 0,
137
- 'should exclude all nodes when none have valid prerelease versions',
138
- )
139
-
140
- t.matchSnapshot({
141
- nodes: [...res.partial.nodes].map(n => ({
142
- name: n.name,
143
- version: n.version,
144
- })),
145
- })
146
- })
147
-
148
- await t.test('handles various prerelease formats', async t => {
149
- const graph = newGraph('prerelease-test')
150
- const addNode = newNode(graph)
151
-
152
- // Create nodes with various prerelease formats
153
- const testCases = [
154
- { name: 'canary', version: '19.2.0-canary-fa3feba6-20250623' },
155
- { name: 'beta', version: '1.0.0-beta.0' },
156
- { name: 'alpha', version: '2.1.0-alpha.1' },
157
- { name: 'rc', version: '3.0.0-rc.2' },
158
- { name: 'dev', version: '0.0.0-16' },
159
- { name: 'next', version: '1.5.0-next.1' },
160
- { name: 'snapshot', version: '2.0.0-snapshot.20231201' },
161
- { name: 'build-meta', version: '1.2.3-alpha.1+build.123' },
162
- { name: 'stable', version: '1.0.0' }, // This should be filtered out
163
- { name: 'another-stable', version: '2.5.3' }, // This should be filtered out
164
- ]
165
-
166
- for (const testCase of testCases) {
167
- const node = addNode(testCase.name, testCase.version)
168
- node.version = testCase.version
169
- node.manifest = {
170
- name: testCase.name,
171
- version: testCase.version,
172
- }
173
- graph.nodes.set(node.id, node)
174
- }
175
-
176
- const res = await prerelease(getState(':prerelease', graph))
177
-
178
- const selectedNodes = [...res.partial.nodes]
179
- .map(n => ({ name: n.name, version: n.version }))
180
- .sort((a, b) => (a.name || '').localeCompare(b.name || ''))
181
-
182
- // Should select all prerelease versions but exclude stable ones
183
- const expectedNodes = testCases
184
- .filter(tc => tc.version.includes('-'))
185
- .map(tc => ({ name: tc.name, version: tc.version }))
186
- .sort((a, b) => a.name.localeCompare(b.name))
187
-
188
- t.strictSame(
189
- selectedNodes,
190
- expectedNodes,
191
- 'should select all prerelease versions and exclude stable ones',
192
- )
193
-
194
- t.matchSnapshot({
195
- selected: selectedNodes,
196
- total: testCases.length,
197
- })
198
- })
199
-
200
- await t.test('removes dangling edges properly', async t => {
201
- const graph = getSemverRichGraph()
202
- const initialEdgeCount = graph.edges.size
203
-
204
- const res = await prerelease(getState(':prerelease', graph))
205
-
206
- // Check that dangling edges were removed
207
- const remainingEdges = [...res.partial.edges]
208
-
209
- t.ok(
210
- remainingEdges.length <= initialEdgeCount,
211
- 'should have same or fewer edges after filtering',
212
- )
213
-
214
- // Verify all remaining edges connect to nodes that remain
215
- for (const edge of remainingEdges) {
216
- if (edge.to) {
217
- t.ok(
218
- res.partial.nodes.has(edge.to),
219
- `edge ${edge.name} should have valid to node`,
220
- )
221
- }
222
- }
223
-
224
- t.matchSnapshot({
225
- remainingEdges: remainingEdges.length,
226
- initialEdges: initialEdgeCount,
227
- edgeNames: remainingEdges.map(e => e.name).sort(),
228
- })
229
- })
230
-
231
- await t.test('works with empty graph', async t => {
232
- const emptyGraph = newGraph('empty-test')
233
- // Remove all nodes except root
234
- emptyGraph.nodes.clear()
235
- emptyGraph.edges.clear()
236
- emptyGraph.nodes.set(
237
- emptyGraph.mainImporter.id,
238
- emptyGraph.mainImporter,
239
- )
240
-
241
- const res = await prerelease(getState(':prerelease', emptyGraph))
242
-
243
- t.strictSame(
244
- [...res.partial.nodes].length,
245
- 0,
246
- 'should have no nodes when root has no prerelease version',
247
- )
248
-
249
- t.strictSame(
250
- [...res.partial.edges].length,
251
- 0,
252
- 'should have no edges',
253
- )
254
- })
255
-
256
- await t.test(
257
- 'works with simple graph (no prereleases)',
258
- async t => {
259
- const simpleGraph = getSimpleGraph()
260
- const res = await prerelease(
261
- getState(':prerelease', simpleGraph),
262
- )
263
-
264
- // Simple graph has no prerelease versions
265
- t.strictSame(
266
- [...res.partial.nodes].length,
267
- 0,
268
- 'should have no nodes when no prereleases exist',
269
- )
270
-
271
- t.matchSnapshot({
272
- nodes: [...res.partial.nodes].map(n => ({
273
- name: n.name,
274
- version: n.version,
275
- })),
276
- })
277
- },
278
- )
279
- })
@@ -1,108 +0,0 @@
1
- import t from 'tap'
2
- import postcssSelectorParser from 'postcss-selector-parser'
3
- import type { ParserState } from '../../src/types.ts'
4
- import { privateParser } from '../../src/pseudo/private.ts'
5
- import {
6
- getSimpleGraph,
7
- getSingleWorkspaceGraph,
8
- getCycleGraph,
9
- } from '../fixtures/graph.ts'
10
-
11
- t.test('selects packages with private flag', async t => {
12
- const getState = (query: string, graph = getSimpleGraph()) => {
13
- const ast = postcssSelectorParser().astSync(query)
14
- const current = ast.first.first
15
- const state: ParserState = {
16
- comment: '',
17
- current,
18
- initial: {
19
- edges: new Set(graph.edges.values()),
20
- nodes: new Set(graph.nodes.values()),
21
- },
22
- partial: {
23
- edges: new Set(graph.edges.values()),
24
- nodes: new Set(graph.nodes.values()),
25
- },
26
- collect: {
27
- edges: new Set(),
28
- nodes: new Set(),
29
- },
30
- cancellable: async () => {},
31
- walk: async i => i,
32
- retries: 0,
33
- securityArchive: undefined,
34
- importers: new Set(graph.importers),
35
- signal: new AbortController().signal,
36
- specificity: { idCounter: 0, commonCounter: 0 },
37
- }
38
- return state
39
- }
40
-
41
- await t.test(
42
- 'selects nodes with private flag in simple graph',
43
- async t => {
44
- // Based on the getSimpleGraph fixture, only the 'd' package has private: true
45
- const res = await privateParser(getState(':private'))
46
- t.strictSame(
47
- [...res.partial.nodes].map(n => n.name),
48
- ['d'],
49
- 'should select only packages with private flag set to true',
50
- )
51
- t.matchSnapshot({
52
- nodes: [...res.partial.nodes].map(n => n.name).sort(),
53
- edges: [...res.partial.edges].map(e => e.name).sort(),
54
- })
55
- },
56
- )
57
-
58
- await t.test(
59
- 'selects no nodes with private flag in workspace graph',
60
- async t => {
61
- // In getSingleWorkspaceGraph, no nodes have private flag
62
- const wsGraph = getSingleWorkspaceGraph()
63
- const res = await privateParser(getState(':private', wsGraph))
64
- t.strictSame(
65
- [...res.partial.nodes].map(n => n.name),
66
- [],
67
- 'should not select any nodes in workspace graph as none have private flag',
68
- )
69
- t.matchSnapshot({
70
- nodes: [...res.partial.nodes].map(n => n.name).sort(),
71
- edges: [...res.partial.edges].map(e => e.name).sort(),
72
- })
73
- },
74
- )
75
-
76
- await t.test('selects no nodes in cycle graph', async t => {
77
- // In getCycleGraph, no nodes have private flag
78
- const cycleGraph = getCycleGraph()
79
- const res = await privateParser(getState(':private', cycleGraph))
80
- t.strictSame(
81
- [...res.partial.nodes].map(n => n.name),
82
- [],
83
- 'should not select any packages in a cycle graph as none have private flag',
84
- )
85
- t.matchSnapshot({
86
- nodes: [...res.partial.nodes].map(n => n.name),
87
- edges: [...res.partial.edges].map(e => e.name),
88
- })
89
- })
90
-
91
- await t.test('handles an empty partial state', async t => {
92
- // Create a state with empty partial nodes
93
- const state = getState(':private')
94
- state.partial.nodes.clear()
95
- state.partial.edges.clear()
96
-
97
- const res = await privateParser(state)
98
- t.strictSame(
99
- [...res.partial.nodes].map(n => n.name),
100
- [],
101
- 'should return empty array when starting with empty partial state',
102
- )
103
- t.matchSnapshot({
104
- nodes: [...res.partial.nodes].map(n => n.name),
105
- edges: [...res.partial.edges].map(e => e.name),
106
- })
107
- })
108
- })
@@ -1,61 +0,0 @@
1
- import t from 'tap'
2
- import { pseudo } from '../../src/pseudo.ts'
3
- import {
4
- selectorFixture,
5
- copyGraphSelectionState,
6
- } from '../fixtures/selector.ts'
7
- import { getSimpleGraph } from '../fixtures/graph.ts'
8
- import type { TestCase } from '../fixtures/types.ts'
9
- import type { GraphSelectionState } from '../../src/types.ts'
10
-
11
- const testPseudo = selectorFixture(pseudo)
12
-
13
- t.test(':prod pseudo-selector', async t => {
14
- // Get a simple graph for testing
15
- const simpleGraph = getSimpleGraph()
16
-
17
- // Get the full selection state
18
- const all = {
19
- edges: new Set(simpleGraph.edges),
20
- nodes: new Set(simpleGraph.nodes.values()),
21
- }
22
-
23
- // Create an empty selection state
24
- const empty: GraphSelectionState = {
25
- edges: new Set(),
26
- nodes: new Set(),
27
- }
28
-
29
- // Run tests in the same pattern as the main pseudo.ts tests
30
- const queryToExpected = new Set<TestCase>([
31
- [':prod', all, ['a', 'c', 'd', 'e']], // Should return nodes with prod edges
32
- [':prod', empty, []], // Empty input should return empty output
33
- ])
34
-
35
- const initial = copyGraphSelectionState(all)
36
- for (const [query, partial, expected] of queryToExpected) {
37
- const result = await testPseudo(
38
- query,
39
- initial,
40
- copyGraphSelectionState(partial),
41
- )
42
-
43
- t.strictSame(
44
- result.nodes.map(i => i.name),
45
- expected,
46
- `query > "${query}"`,
47
- )
48
-
49
- // Verify all edges are of type 'prod'
50
- const edgeArray = [...result.edges]
51
- if (edgeArray.length > 0) {
52
- for (const edge of edgeArray) {
53
- t.equal(
54
- edge.type,
55
- 'prod',
56
- `edge ${edge.name} should be of type 'prod'`,
57
- )
58
- }
59
- }
60
- }
61
- })