pruny 1.1.17 → 1.1.20

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 +16 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9136,7 +9136,6 @@ async function scanPublicAssets(config) {
9136
9136
  }
9137
9137
  const assetFiles = await import_fast_glob.default("**/*", {
9138
9138
  cwd: publicDir,
9139
- ignore: config.ignore.folders || [],
9140
9139
  onlyFiles: true
9141
9140
  });
9142
9141
  if (assetFiles.length === 0) {
@@ -9147,7 +9146,10 @@ async function scanPublicAssets(config) {
9147
9146
  relativePath: "/" + file,
9148
9147
  used: false,
9149
9148
  references: []
9150
- }));
9149
+ })).filter((asset) => {
9150
+ const publicPath = join("public", asset.relativePath.substring(1));
9151
+ return !shouldIgnore(publicPath, [...config.ignore.folders || [], ...config.ignore.files || []]);
9152
+ });
9151
9153
  const extGlob = `**/*{${config.extensions.join(",")}}`;
9152
9154
  const sourceFiles = await import_fast_glob.default(extGlob, {
9153
9155
  cwd,
@@ -9193,8 +9195,17 @@ function extractExportedMethods(content) {
9193
9195
  }
9194
9196
  return methods;
9195
9197
  }
9196
- function shouldIgnoreRoute(routePath, ignorePatterns) {
9197
- return ignorePatterns.some((pattern) => minimatch(routePath, pattern));
9198
+ function shouldIgnore(path2, ignorePatterns) {
9199
+ const normalizedPath = path2.replace(/\\/g, "/").replace(/^\.\//, "");
9200
+ return ignorePatterns.some((pattern) => {
9201
+ const normalizedPattern = pattern.replace(/\\/g, "/").replace(/^\.\//, "");
9202
+ if (minimatch(normalizedPath, normalizedPattern))
9203
+ return true;
9204
+ const folderPattern = normalizedPattern.endsWith("/") ? normalizedPattern : normalizedPattern + "/";
9205
+ if (normalizedPath.startsWith(folderPattern))
9206
+ return true;
9207
+ return false;
9208
+ });
9198
9209
  }
9199
9210
  function normalizeApiPath(path2) {
9200
9211
  return path2.replace(/\/$/, "").replace(/\?.*$/, "").replace(/\$\{[^}]+\}/g, "*").replace(/\[[^\]]+\]/g, "*").toLowerCase();
@@ -9289,7 +9300,7 @@ async function scan(config) {
9289
9300
  } catch {}
9290
9301
  }
9291
9302
  for (const route of routes) {
9292
- if (shouldIgnoreRoute(route.path, config.ignore.routes)) {
9303
+ if (shouldIgnore(route.path, config.ignore.routes)) {
9293
9304
  route.used = true;
9294
9305
  route.references.push("(ignored by config)");
9295
9306
  route.unusedMethods = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.1.17",
3
+ "version": "1.1.20",
4
4
  "description": "Find and remove unused Next.js API routes",
5
5
  "type": "module",
6
6
  "files": [