Skip to content

Commit 2b6695a

Browse files
committed
Add outdated.js
Opting to not use later version as it has too many changes focused on ranges/matrices.
1 parent aeb4a5d commit 2b6695a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

scripts/outdated.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const {
2+
getInternals,
3+
npmView
4+
} = require('./helpers/versioning')
5+
const path = require('path')
6+
const fs = require('fs')
7+
8+
const latestsPath = path.join(
9+
__dirname,
10+
'..',
11+
'packages',
12+
'datadog-instrumentations',
13+
'src',
14+
'helpers',
15+
'latests.json'
16+
)
17+
const latestsJson = require(latestsPath)
18+
const internalsNames = Array.from(new Set(getInternals().map(n => n.name)))
19+
.filter(x => typeof x === 'string' && x !== 'child_process' && !x.startsWith('node:'))
20+
21+
// TODO A lot of this can be optimized by using `npm outdated`.
22+
23+
async function fix () {
24+
const latests = {}
25+
for (const name of internalsNames) {
26+
const distTags = await npmView(name + ' dist-tags')
27+
const latest = distTags.latest
28+
latests[name] = latest
29+
}
30+
latestsJson.latests = latests
31+
fs.writeFileSync(latestsPath, JSON.stringify(latestsJson, null, 2))
32+
}
33+
34+
async function check () {
35+
for (const name of internalsNames) {
36+
const latest = latestsJson.latests[name]
37+
if (!latest) {
38+
console.log(`No latest version found for "${name}"`)
39+
process.exitCode = 1
40+
}
41+
const distTags = await npmView(name + ' dist-tags')
42+
const npmLatest = distTags.latest
43+
if (npmLatest !== latest) {
44+
console.log(`"latests.json: is not up to date for "${name}": expected "${npmLatest}", got "${latest}"`)
45+
process.exitCode = 1
46+
}
47+
}
48+
}
49+
50+
if (process.argv.includes('fix')) fix()
51+
else check()

0 commit comments

Comments
 (0)