pruny 1.43.8 → 1.43.9

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 +19 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14255,7 +14255,7 @@ function parseTsConfigPaths(searchDir) {
14255
14255
  function readTsConfigWithExtends(configPath) {
14256
14256
  try {
14257
14257
  const raw = readFileSync2(configPath, "utf-8");
14258
- const cleaned = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/,(\s*[}\]])/g, "$1");
14258
+ const cleaned = raw.replace(/("(?:\\.|[^"\\])*")|\/\/.*$|\/\*[\s\S]*?\*\//gm, (_m, str) => str ?? "").replace(/,(\s*[}\]])/g, "$1");
14259
14259
  const config = JSON.parse(cleaned);
14260
14260
  let basePaths = {};
14261
14261
  let baseUrl;
@@ -14290,7 +14290,7 @@ async function scanUnusedFiles(config) {
14290
14290
  process.stdout.write(` \uD83D\uDCC2 Scanning source files...`);
14291
14291
  const allFiles = await import_fast_glob2.default(extGlob, {
14292
14292
  cwd: searchDir,
14293
- ignore: [...config.ignore.folders, ...config.ignore.files],
14293
+ ignore: config.ignore.folders,
14294
14294
  absolute: true
14295
14295
  });
14296
14296
  process.stdout.write(` ${allFiles.length} files found
@@ -14299,6 +14299,15 @@ async function scanUnusedFiles(config) {
14299
14299
  return { total: 0, used: 0, unused: 0, files: [] };
14300
14300
  }
14301
14301
  const allFilesSet = new Set(allFiles);
14302
+ const ignoredFileSet = new Set;
14303
+ if (config.ignore.files.length > 0) {
14304
+ for (const file of allFiles) {
14305
+ const relPath = relative(searchDir, file);
14306
+ if (config.ignore.files.some((pattern) => minimatch(relPath, pattern, { dot: true }))) {
14307
+ ignoredFileSet.add(file);
14308
+ }
14309
+ }
14310
+ }
14302
14311
  const entryFiles = new Set;
14303
14312
  const entryPatterns = [
14304
14313
  "**/page.{ts,tsx,js,jsx}",
@@ -14367,6 +14376,8 @@ async function scanUnusedFiles(config) {
14367
14376
  if (isEntry)
14368
14377
  entryFiles.add(file);
14369
14378
  }
14379
+ for (const file of ignoredFileSet)
14380
+ entryFiles.add(file);
14370
14381
  const aliasMap = parseTsConfigPaths(searchDir);
14371
14382
  if (process.env.DEBUG_PRUNY && aliasMap.size > 0) {
14372
14383
  console.log(`[DEBUG] Loaded ${aliasMap.size} path aliases from tsconfig.json`);
@@ -14418,16 +14429,18 @@ async function scanUnusedFiles(config) {
14418
14429
  }
14419
14430
  } catch {}
14420
14431
  }
14421
- const files = allFiles.filter((f) => !usedFiles.has(f)).map((f) => {
14432
+ const files = allFiles.filter((f) => !usedFiles.has(f) && !ignoredFileSet.has(f)).map((f) => {
14422
14433
  const s = statSync(f);
14423
14434
  return {
14424
14435
  path: relative(config.dir, f),
14425
14436
  size: s.size
14426
14437
  };
14427
14438
  });
14439
+ const candidateCount = allFiles.length - ignoredFileSet.size;
14440
+ const usedCandidateCount = candidateCount - files.length;
14428
14441
  return {
14429
- total: allFiles.length,
14430
- used: usedFiles.size,
14442
+ total: candidateCount,
14443
+ used: usedCandidateCount,
14431
14444
  unused: files.length,
14432
14445
  files
14433
14446
  };
@@ -14731,7 +14744,7 @@ async function scanUnusedExports(config, routes = [], options = {}) {
14731
14744
  }
14732
14745
  const referenceFiles = await import_fast_glob3.default(extGlob, {
14733
14746
  cwd: referenceCwd,
14734
- ignore: [...DEFAULT_IGNORE, ...config.ignore.folders, ...config.ignore.files],
14747
+ ignore: [...DEFAULT_IGNORE, ...config.ignore.folders],
14735
14748
  absolute: true
14736
14749
  });
14737
14750
  if (process.env.DEBUG_PRUNY) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.43.8",
3
+ "version": "1.43.9",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [