pruny 1.17.0 → 1.17.1

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.
Files changed (2) hide show
  1. package/dist/index.js +13 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9926,7 +9926,8 @@ function loadConfig(options) {
9926
9926
  const prefixPattern = (p) => {
9927
9927
  if (p.startsWith("**/") || p.startsWith("/") || !relDir)
9928
9928
  return p;
9929
- return join5(relDir, p).replace(/\\/g, "/");
9929
+ const prefixed = join5(relDir, p).replace(/\\/g, "/");
9930
+ return prefixed.includes("/") ? `**/${prefixed}` : `**/${prefixed}`;
9930
9931
  };
9931
9932
  if (config.ignore?.routes)
9932
9933
  mergedIgnore.routes.push(...config.ignore.routes.map(prefixPattern));
@@ -10267,11 +10268,20 @@ program2.action(async (options) => {
10267
10268
  console.log(source_default.red(` Deleted File: ${route.filePath}`));
10268
10269
  }
10269
10270
  } else if (route.type === "nestjs") {
10270
- rmSync(fullPath, { force: true });
10271
- console.log(source_default.red(` Deleted File: ${route.filePath}`));
10271
+ const isInternallyUnused = result.unusedFiles?.files.some((f) => f.path === route.filePath);
10272
+ if (isInternallyUnused || route.filePath.includes("api/")) {
10273
+ rmSync(fullPath, { force: true });
10274
+ console.log(source_default.red(` Deleted File: ${route.filePath}`));
10275
+ fixedSomething = true;
10276
+ } else {
10277
+ console.log(source_default.yellow(` Skipped Deletion (internally used): ${route.filePath}`));
10278
+ console.log(source_default.dim(` → This controller is imported in another file (e.g. app.module.ts).`));
10279
+ continue;
10280
+ }
10272
10281
  } else {
10273
10282
  rmSync(fullPath, { force: true });
10274
10283
  console.log(source_default.red(` Deleted File: ${route.filePath}`));
10284
+ fixedSomething = true;
10275
10285
  }
10276
10286
  fixedSomething = true;
10277
10287
  const idx = result.routes.indexOf(route);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.17.0",
3
+ "version": "1.17.1",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [