pruny 1.0.8 → 1.0.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/package.json +1 -1
  2. package/src/scanner.ts +10 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Find and remove unused Next.js API routes",
5
5
  "type": "module",
6
6
  "bin": {
package/src/scanner.ts CHANGED
@@ -4,6 +4,7 @@ import { join, dirname } from 'node:path';
4
4
  import { extractApiPaths } from './patterns.js';
5
5
  import type { Config, ApiRoute, ScanResult, VercelConfig } from './types.js';
6
6
  import { minimatch } from 'minimatch';
7
+ import { scanPublicAssets } from './scanners/public-assets.js';
7
8
 
8
9
  /**
9
10
  * Extract route path from file path
@@ -91,6 +92,7 @@ function getVercelCronPaths(dir: string): string[] {
91
92
  * Scan for unused API routes
92
93
  */
93
94
  export async function scan(config: Config): Promise<ScanResult> {
95
+ // console.log('DEBUG: scan() called with config:', JSON.stringify(config, null, 2));
94
96
  const cwd = config.dir;
95
97
 
96
98
  // 1. Find all API route files
@@ -104,17 +106,14 @@ export async function scan(config: Config): Promise<ScanResult> {
104
106
  ignore: config.ignore.folders,
105
107
  });
106
108
 
107
- if (routeFiles.length === 0) {
108
- return { total: 0, used: 0, unused: 0, routes: [] };
109
- }
110
-
111
- // 2. Build route map
112
- const routes: ApiRoute[] = routeFiles.map((file) => ({
113
- path: extractRoutePath(file),
114
- filePath: file,
115
- used: false,
116
- references: [],
117
- }));
109
+ const routes: ApiRoute[] = routeFiles.length > 0
110
+ ? routeFiles.map((file) => ({
111
+ path: extractRoutePath(file),
112
+ filePath: file,
113
+ used: false,
114
+ references: [],
115
+ }))
116
+ : [];
118
117
 
119
118
  // 3. Mark vercel cron routes as used
120
119
  const cronPaths = getVercelCronPaths(cwd);
@@ -182,7 +181,6 @@ export async function scan(config: Config): Promise<ScanResult> {
182
181
  // 7. Scan public assets (if not excluded)
183
182
  let publicAssets;
184
183
  if (!config.excludePublic) {
185
- const { scanPublicAssets } = await import('./scanners/public-assets.js');
186
184
  publicAssets = await scanPublicAssets(config);
187
185
  }
188
186