-
Notifications
You must be signed in to change notification settings - Fork 7
/
lockfile-v2.ts
71 lines (66 loc) · 1.99 KB
/
lockfile-v2.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as fs from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { format, parse, parseAuditReport } from '../../main/ts/lockfile/v2'
const __dirname = dirname(fileURLToPath(import.meta.url))
const fixtures = resolve(__dirname, '../fixtures')
describe('reader', () => {
it('provides parse/format interop', () => {
const contents = fs.readFileSync(
join(fixtures, 'lockfile/v2/yarn.lock'),
'utf-8',
)
expect(format(parse(contents))).toEqual(contents)
// fs.writeFileSync('foo.yaml', format(parse(contents)))
})
})
describe('parseReport', () => {
it('processes yarn2 audit report', () => {
const input = fs.readFileSync(
join(fixtures, 'lockfile/v2/yarn-audit-report.json'),
'utf-8',
)
expect(parseAuditReport(input)).toEqual({
'ansi-regex': {
patched_versions: '>=5.0.1',
vulnerable_versions: '>2.1.1 <5.0.1',
module_name: 'ansi-regex',
},
immer: {
patched_versions: '>=9.0.6',
vulnerable_versions: '<9.0.6',
module_name: 'immer',
},
'trim-off-newlines': {
patched_versions: '<0.0.0',
vulnerable_versions: '<=1.0.1',
module_name: 'trim-off-newlines',
},
'ansi-html': {
patched_versions: '<0.0.0',
vulnerable_versions: '<=0.0.7',
module_name: 'ansi-html',
},
'@npmcli/git': {
patched_versions: '>=2.0.8',
vulnerable_versions: '<2.0.8',
module_name: '@npmcli/git',
},
'glob-parent': {
patched_versions: '>=5.1.2',
vulnerable_versions: '<5.1.2',
module_name: 'glob-parent',
},
browserslist: {
patched_versions: '>=4.16.5',
vulnerable_versions: '>=4.0.0 <4.16.5',
module_name: 'browserslist',
},
'trim-newlines': {
patched_versions: '>=3.0.1',
vulnerable_versions: '<3.0.1',
module_name: 'trim-newlines',
},
})
})
})