Adding dependency check scripts.

This commit is contained in:
mike12345567 2024-11-19 17:17:15 +00:00
parent fd1dee993a
commit 0fd8436a15
2 changed files with 30 additions and 0 deletions

View File

@ -9,6 +9,7 @@
"@types/node": "20.10.0",
"@types/proper-lockfile": "^4.1.4",
"@typescript-eslint/parser": "6.9.0",
"depcheck": "^1.4.7",
"esbuild": "^0.18.17",
"esbuild-node-externals": "^1.14.0",
"eslint": "^8.52.0",

29
scripts/depcheck.js Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/node
const depcheck = require("depcheck")
function filterResults(missing) {
if (missing.src) {
delete missing.src
}
return missing
}
function printMissing(missing) {
for (let [key, value] of Object.entries(filterResults(missing))) {
console.log(`Package ${key} missing in: ${value.join(", ")}`)
}
}
depcheck(process.cwd(), {
ignorePatterns: ["dist"],
skipMissing: false,
}).then(results => {
if (Object.values(filterResults(results.missing)).length > 0) {
printMissing(results.missing)
console.error("Missing packages found - stopping.")
process.exit(-1)
} else {
console.log("No missing dependencies.")
}
})