Skip to content

Commit a7aff38

Browse files
committed
Fix eslint issues in outdated
1 parent bb12c99 commit a7aff38

File tree

1 file changed

+114
-114
lines changed

1 file changed

+114
-114
lines changed

scripts/outdated.js

Lines changed: 114 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,129 @@
11
/* eslint-disable no-console */
22
const {
3-
getInternals,
4-
npmView
5-
} = require('./helpers/versioning')
6-
const path = require('path')
7-
const fs = require('fs')
8-
9-
const latestsPath = path.join(
10-
__dirname,
11-
'..',
12-
'packages',
13-
'datadog-instrumentations',
14-
'src',
15-
'helpers',
16-
'latests.json'
17-
)
18-
19-
// Get internal package names from existing getInternals helper
20-
const internalsNames = Array.from(new Set(getInternals().map(n => n.name)))
21-
.filter(x => typeof x === 'string' && x !== 'child_process' && !x.startsWith('node:'))
22-
23-
// Initial structure with placeholder for pinned packages
24-
const initialStructure = {
25-
pinned: ['ENTER_PACKAGE_NAME_HERE'],
26-
latests: {}
27-
}
28-
29-
/**
3+
getInternals,
4+
npmView
5+
} = require('./helpers/versioning')
6+
const path = require('path')
7+
const fs = require('fs')
8+
9+
const latestsPath = path.join(
10+
__dirname,
11+
'..',
12+
'packages',
13+
'datadog-instrumentations',
14+
'src',
15+
'helpers',
16+
'latests.json'
17+
)
18+
19+
// Get internal package names from existing getInternals helper
20+
const internalsNames = Array.from(new Set(getInternals().map(n => n.name)))
21+
.filter(x => typeof x === 'string' && x !== 'child_process' && !x.startsWith('node:'))
22+
23+
// Initial structure with placeholder for pinned packages
24+
const initialStructure = {
25+
pinned: ['ENTER_PACKAGE_NAME_HERE'],
26+
latests: {}
27+
}
28+
29+
/**
3030
* Updates latests.json with the current latest versions from npm
3131
*/
32-
async function fix () {
33-
console.log('Starting fix operation...')
34-
console.log(`Found ${internalsNames.length} packages to process`)
35-
36-
let outputData = initialStructure
37-
if (fs.existsSync(latestsPath)) {
38-
console.log('Found existing latests.json, loading it...')
39-
outputData = require(latestsPath)
40-
}
41-
42-
const latests = {}
43-
let processed = 0
44-
const total = internalsNames.length
45-
46-
for (const name of internalsNames) {
47-
processed++
48-
process.stdout.write(`Processing package ${processed}/${total}: ${name}...`)
49-
50-
try {
51-
const distTags = await npmView(name + ' dist-tags')
52-
const latest = distTags.latest
53-
if (latest) {
54-
latests[name] = latest
55-
process.stdout.write(` found version ${latest}\n`)
56-
} else {
57-
process.stdout.write(' WARNING: no version found\n')
58-
console.log(`Warning: Could not fetch latest version for "${name}"`)
59-
}
60-
} catch (error) {
61-
process.stdout.write(' ERROR\n')
62-
console.error(`Error fetching version for "${name}":`, error.message)
32+
async function fix () {
33+
console.log('Starting fix operation...')
34+
console.log(`Found ${internalsNames.length} packages to process`)
35+
36+
let outputData = initialStructure
37+
if (fs.existsSync(latestsPath)) {
38+
console.log('Found existing latests.json, loading it...')
39+
outputData = require(latestsPath)
40+
}
41+
42+
const latests = {}
43+
let processed = 0
44+
const total = internalsNames.length
45+
46+
for (const name of internalsNames) {
47+
processed++
48+
process.stdout.write(`Processing package ${processed}/${total}: ${name}...`)
49+
50+
try {
51+
const distTags = await npmView(name + ' dist-tags')
52+
const latest = distTags.latest
53+
if (latest) {
54+
latests[name] = latest
55+
process.stdout.write(` found version ${latest}\n`)
56+
} else {
57+
process.stdout.write(' WARNING: no version found\n')
58+
console.log(`Warning: Could not fetch latest version for "${name}"`)
6359
}
60+
} catch (error) {
61+
process.stdout.write(' ERROR\n')
62+
console.error(`Error fetching version for "${name}":`, error.message)
6463
}
65-
66-
outputData.latests = latests
67-
console.log('\nWriting updated versions to latests.json...')
68-
fs.writeFileSync(latestsPath, JSON.stringify(outputData, null, 2))
69-
console.log('Successfully updated latests.json')
70-
console.log(`Processed ${total} packages`)
7164
}
72-
73-
/**
65+
66+
outputData.latests = latests
67+
console.log('\nWriting updated versions to latests.json...')
68+
fs.writeFileSync(latestsPath, JSON.stringify(outputData, null, 2))
69+
console.log('Successfully updated latests.json')
70+
console.log(`Processed ${total} packages`)
71+
}
72+
73+
/**
7474
* Checks if latests.json matches current npm versions
7575
*/
76-
async function check () {
77-
console.log('Starting version check...')
78-
79-
if (!fs.existsSync(latestsPath)) {
80-
console.log('latests.json does not exist. Run with "fix" to create it.')
76+
async function check () {
77+
console.log('Starting version check...')
78+
79+
if (!fs.existsSync(latestsPath)) {
80+
console.log('latests.json does not exist. Run with "fix" to create it.')
81+
process.exitCode = 1
82+
return
83+
}
84+
85+
const currentData = require(latestsPath)
86+
console.log(`Found ${internalsNames.length} packages to check`)
87+
88+
let processed = 0
89+
let mismatches = 0
90+
const total = internalsNames.length
91+
92+
for (const name of internalsNames) {
93+
processed++
94+
process.stdout.write(`Checking package ${processed}/${total}: ${name}...`)
95+
96+
const latest = currentData.latests[name]
97+
if (!latest) {
98+
process.stdout.write(' MISSING\n')
99+
console.log(`No latest version found for "${name}"`)
81100
process.exitCode = 1
82-
return
101+
continue
83102
}
84-
85-
const currentData = require(latestsPath)
86-
console.log(`Found ${internalsNames.length} packages to check`)
87-
88-
let processed = 0
89-
let mismatches = 0
90-
const total = internalsNames.length
91-
92-
for (const name of internalsNames) {
93-
processed++
94-
process.stdout.write(`Checking package ${processed}/${total}: ${name}...`)
95-
96-
const latest = currentData.latests[name]
97-
if (!latest) {
98-
process.stdout.write(' MISSING\n')
99-
console.log(`No latest version found for "${name}"`)
103+
104+
try {
105+
const distTags = await npmView(name + ' dist-tags')
106+
const npmLatest = distTags.latest
107+
if (npmLatest !== latest) {
108+
process.stdout.write(' MISMATCH\n')
109+
console.log(`"latests.json: is not up to date for "${name}": expected "${npmLatest}", got "${latest}"`)
100110
process.exitCode = 1
101-
continue
111+
mismatches++
112+
} else {
113+
process.stdout.write(' OK\n')
102114
}
103-
104-
try {
105-
const distTags = await npmView(name + ' dist-tags')
106-
const npmLatest = distTags.latest
107-
if (npmLatest !== latest) {
108-
process.stdout.write(' MISMATCH\n')
109-
console.log(`"latests.json: is not up to date for "${name}": expected "${npmLatest}", got "${latest}"`)
110-
process.exitCode = 1
111-
mismatches++
112-
} else {
113-
process.stdout.write(' OK\n')
114-
}
115-
} catch (error) {
116-
process.stdout.write(' ERROR\n')
117-
console.error(`Error checking version for "${name}":`, error.message)
118-
}
119-
}
120-
121-
console.log('\nCheck completed:')
122-
console.log(`- Total packages checked: ${total}`)
123-
console.log(`- Version mismatches found: ${mismatches}`)
124-
if (mismatches > 0) {
125-
console.log('Run with "fix" to update versions')
115+
} catch (error) {
116+
process.stdout.write(' ERROR\n')
117+
console.error(`Error checking version for "${name}":`, error.message)
126118
}
127119
}
128-
if (process.argv.includes('fix')) fix()
129-
else check()
120+
121+
console.log('\nCheck completed:')
122+
console.log(`- Total packages checked: ${total}`)
123+
console.log(`- Version mismatches found: ${mismatches}`)
124+
if (mismatches > 0) {
125+
console.log('Run with "fix" to update versions')
126+
}
127+
}
128+
if (process.argv.includes('fix')) fix()
129+
else check()

0 commit comments

Comments
 (0)