pruny 1.43.6 → 1.43.8

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 +26 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14377,7 +14377,7 @@ async function scanUnusedFiles(config) {
14377
14377
  const usedFiles = new Set(entryFiles);
14378
14378
  const queue = Array.from(entryFiles);
14379
14379
  const visited = new Set(entryFiles);
14380
- const importRegex = /from\s+['"]([^'"]+)['"]|import\(['"]([^'"]+)['"]\)|require\(['"]([^'"]+)['"]\)/g;
14380
+ const importRegex = /from\s+['"]([^'"]+)['"]|import\(\s*(?:\/\*[\s\S]*?\*\/\s*)*['"]([^'"]+)['"]\)|require\(\s*(?:\/\*[\s\S]*?\*\/\s*)*['"]([^'"]+)['"]\)/g;
14381
14381
  while (queue.length > 0) {
14382
14382
  const currentFile = queue.shift();
14383
14383
  const currentDir = dirname2(currentFile);
@@ -15971,6 +15971,29 @@ function matchSegments(refSegments, routeSegments) {
15971
15971
  }
15972
15972
  return ri === refSegments.length && si === routeSegments.length;
15973
15973
  }
15974
+ function isGitignoredPublicFile(appDir, linkPath) {
15975
+ const publicRelPath = `public${linkPath}`;
15976
+ const dirsToCheck = [appDir];
15977
+ const parentDir = join7(appDir, "..", "..");
15978
+ if (existsSync7(join7(parentDir, ".gitignore"))) {
15979
+ dirsToCheck.push(parentDir);
15980
+ }
15981
+ for (const dir of dirsToCheck) {
15982
+ const gitignorePath = join7(dir, ".gitignore");
15983
+ if (!existsSync7(gitignorePath))
15984
+ continue;
15985
+ try {
15986
+ const patterns = readFileSync9(gitignorePath, "utf-8").split(`
15987
+ `).map((l) => l.trim()).filter((l) => l && !l.startsWith("#"));
15988
+ for (const pattern of patterns) {
15989
+ if (minimatch(publicRelPath, pattern, { dot: true }) || minimatch(linkPath.slice(1), pattern, { dot: true }) || minimatch(`**/public${linkPath}`, pattern, { dot: true })) {
15990
+ return true;
15991
+ }
15992
+ }
15993
+ } catch {}
15994
+ }
15995
+ return false;
15996
+ }
15974
15997
  async function scanBrokenLinks(config) {
15975
15998
  const appDir = config.appSpecificScan ? config.appSpecificScan.appDir : config.dir;
15976
15999
  const pagePatterns = [
@@ -16050,6 +16073,8 @@ async function scanBrokenLinks(config) {
16050
16073
  const publicPath = join7(appDir, "public", cleaned);
16051
16074
  if (existsSync7(publicPath))
16052
16075
  continue;
16076
+ if (isGitignoredPublicFile(appDir, cleaned))
16077
+ continue;
16053
16078
  const ignorePatterns = [
16054
16079
  ...config.ignore.links || [],
16055
16080
  ...config.ignore.routes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.43.6",
3
+ "version": "1.43.8",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [