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.
- package/package.json +1 -1
- package/src/scanner.ts +10 -12
package/package.json
CHANGED
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
|