diff --git a/package.json b/package.json index fc7e202e3d..6e1e059fd3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/depcheck.js b/scripts/depcheck.js new file mode 100755 index 0000000000..a60bd9e580 --- /dev/null +++ b/scripts/depcheck.js @@ -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.") + } +})