-
Notifications
You must be signed in to change notification settings - Fork 8
/
CDVC.mts
62 lines (51 loc) · 1.42 KB
/
CDVC.mts
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
import { CDVC } from 'check-dependency-version-consistency'
import { fileURLToPath } from 'node:url'
import { dirname } from 'node:path'
// @ts-ignore
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
let mismatch = false
// === dependencies ===
const cdvcDep = new CDVC(__dirname, {
depType: ['dependencies'],
ignorePackage: ['@sandboxes/react-16'],
})
const dep = cdvcDep.hasMismatchingDependencies
if (dep) {
mismatch = true
console.log(cdvcDep.toMismatchSummary())
}
// === devDependencies ===
const cdvcDev = new CDVC(__dirname, {
depType: ['devDependencies'],
ignorePackage: ['@sandboxes/react-16'],
})
const dev = cdvcDev.hasMismatchingDependencies
if (dev) {
mismatch = true
console.log(cdvcDev.toMismatchSummary())
}
// === peerDependencies ===
const cdvcPeer = new CDVC(__dirname, {
depType: ['peerDependencies'],
})
// === optionalDependencies & resolutions ===
const cdvcOptRes = new CDVC(__dirname, {
depType: ['optionalDependencies', 'resolutions'],
})
const optRes = cdvcOptRes.hasMismatchingDependencies
if (optRes) {
mismatch = true
console.log(cdvcOptRes.toMismatchSummary())
}
const peer = cdvcPeer.hasMismatchingDependencies
if (peer) {
mismatch = true
console.log(cdvcPeer.toMismatchSummary())
}
if (mismatch) {
console.error('Dependency version mismatches found.')
process.exit(1)
} else {
console.log('No dependency version mismatches found.')
}