pruny 1.2.12 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +37 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9766,7 +9766,7 @@ function init(cwd = process.cwd()) {
|
|
|
9766
9766
|
|
|
9767
9767
|
// src/index.ts
|
|
9768
9768
|
var program2 = new Command;
|
|
9769
|
-
program2.name("pruny").description("Find and remove unused Next.js API routes").version("1.0.0").option("-d, --dir <path>", "Target directory to scan", "./").option("--fix", "Delete unused API routes").option("-c, --config <path>", "Path to config file").option("--json", "Output as JSON").option("--no-public", "Disable public assets scanning").option("-v, --verbose", "Show detailed info");
|
|
9769
|
+
program2.name("pruny").description("Find and remove unused Next.js API routes").version("1.0.0").option("-d, --dir <path>", "Target directory to scan", "./").option("--fix", "Delete unused API routes").option("-c, --config <path>", "Path to config file").option("--json", "Output as JSON").option("--no-public", "Disable public assets scanning").option("-v, --verbose", "Show detailed info").option("-f, --filter <pattern>", "Filter results by file path or app name");
|
|
9770
9770
|
program2.command("init").description("Create a default pruny.config.json file").action(() => {
|
|
9771
9771
|
init();
|
|
9772
9772
|
});
|
|
@@ -9788,7 +9788,42 @@ Config:`));
|
|
|
9788
9788
|
\uD83D\uDD0D Scanning for unused API routes...
|
|
9789
9789
|
`));
|
|
9790
9790
|
try {
|
|
9791
|
-
|
|
9791
|
+
let result = await scan(config);
|
|
9792
|
+
if (options.filter) {
|
|
9793
|
+
const filter2 = options.filter.toLowerCase();
|
|
9794
|
+
console.log(source_default.blue(`
|
|
9795
|
+
\uD83D\uDD0D Filtering results by "${filter2}"...
|
|
9796
|
+
`));
|
|
9797
|
+
const getAppName2 = (filePath) => {
|
|
9798
|
+
if (filePath.startsWith("apps/"))
|
|
9799
|
+
return filePath.split("/").slice(0, 2).join("/");
|
|
9800
|
+
if (filePath.startsWith("packages/"))
|
|
9801
|
+
return filePath.split("/").slice(0, 2).join("/");
|
|
9802
|
+
return "Root";
|
|
9803
|
+
};
|
|
9804
|
+
const matchesFilter = (path2) => {
|
|
9805
|
+
return path2.toLowerCase().includes(filter2) || getAppName2(path2).toLowerCase().includes(filter2);
|
|
9806
|
+
};
|
|
9807
|
+
result.routes = result.routes.filter((r) => matchesFilter(r.filePath));
|
|
9808
|
+
if (result.publicAssets) {
|
|
9809
|
+
result.publicAssets.assets = result.publicAssets.assets.filter((a) => matchesFilter(a.path));
|
|
9810
|
+
result.publicAssets.total = result.publicAssets.assets.length;
|
|
9811
|
+
result.publicAssets.used = result.publicAssets.assets.filter((a) => a.used).length;
|
|
9812
|
+
result.publicAssets.unused = result.publicAssets.assets.filter((a) => !a.used).length;
|
|
9813
|
+
}
|
|
9814
|
+
if (result.unusedFiles) {
|
|
9815
|
+
result.unusedFiles.files = result.unusedFiles.files.filter((f) => matchesFilter(f.path));
|
|
9816
|
+
result.unusedFiles.total = result.unusedFiles.files.length;
|
|
9817
|
+
result.unusedFiles.used = 0;
|
|
9818
|
+
result.unusedFiles.unused = result.unusedFiles.files.length;
|
|
9819
|
+
}
|
|
9820
|
+
if (result.unusedExports) {
|
|
9821
|
+
result.unusedExports.exports = result.unusedExports.exports.filter((e) => matchesFilter(e.file));
|
|
9822
|
+
result.unusedExports.total = result.unusedExports.exports.length;
|
|
9823
|
+
result.unusedExports.used = 0;
|
|
9824
|
+
result.unusedExports.unused = result.unusedExports.exports.length;
|
|
9825
|
+
}
|
|
9826
|
+
}
|
|
9792
9827
|
if (options.json) {
|
|
9793
9828
|
console.log(JSON.stringify(result, null, 2));
|
|
9794
9829
|
return;
|