From 0fd8436a156b753c5d97dc8d69662561fde85bd4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 19 Nov 2024 17:17:15 +0000 Subject: [PATCH] Adding dependency check scripts. --- package.json | 1 + scripts/depcheck.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 scripts/depcheck.js 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.") + } +})