pruny 1.43.4 → 1.43.5
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/dist/index.js +48 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16485,6 +16485,20 @@ async function scan(config) {
|
|
|
16485
16485
|
}
|
|
16486
16486
|
} catch {}
|
|
16487
16487
|
}
|
|
16488
|
+
const existingNextApiPaths = new Set;
|
|
16489
|
+
for (const nr of nextRoutes) {
|
|
16490
|
+
existingNextApiPaths.add(normalizeNextPath(nr.path));
|
|
16491
|
+
}
|
|
16492
|
+
if (config.appSpecificScan) {
|
|
16493
|
+
const monorepoNextFiles = await import_fast_glob10.default(nextPatterns, {
|
|
16494
|
+
cwd: config.appSpecificScan.rootDir,
|
|
16495
|
+
ignore: config.ignore.folders
|
|
16496
|
+
});
|
|
16497
|
+
for (const f of monorepoNextFiles) {
|
|
16498
|
+
const apiPath = extractRoutePath(f);
|
|
16499
|
+
existingNextApiPaths.add(normalizeNextPath(apiPath));
|
|
16500
|
+
}
|
|
16501
|
+
}
|
|
16488
16502
|
for (const route of routes) {
|
|
16489
16503
|
if (shouldIgnore(route.path, config.ignore.routes) || shouldIgnore(route.filePath, config.ignore.routes)) {
|
|
16490
16504
|
route.used = true;
|
|
@@ -16512,6 +16526,40 @@ async function scan(config) {
|
|
|
16512
16526
|
}
|
|
16513
16527
|
}
|
|
16514
16528
|
}
|
|
16529
|
+
for (const route of routes) {
|
|
16530
|
+
if (route.type !== "nestjs" || !route.used)
|
|
16531
|
+
continue;
|
|
16532
|
+
const apiVariation = route.path.startsWith("/api/") ? normalizeNestPath(route.path) : normalizeNestPath("/api" + route.path);
|
|
16533
|
+
const hasNextReplacement = existingNextApiPaths.has(apiVariation) || [...existingNextApiPaths].some((np) => np.startsWith(apiVariation + "/") || apiVariation.startsWith(np + "/"));
|
|
16534
|
+
if (hasNextReplacement) {
|
|
16535
|
+
const nestPathDirect = normalizeNestPath(route.path);
|
|
16536
|
+
let hasDirectReference = false;
|
|
16537
|
+
for (const ref of allReferences) {
|
|
16538
|
+
if (ref.source !== "http-client")
|
|
16539
|
+
continue;
|
|
16540
|
+
let normalizedRef = ref.path.replace(/\s+/g, "").replace(/\$\{[^}]+\}/g, "*").replace(/\/$/, "").replace(/\?.*$/, "").replace(/\/+/g, "/").toLowerCase();
|
|
16541
|
+
if (normalizedRef.startsWith("*")) {
|
|
16542
|
+
const firstSlash = normalizedRef.indexOf("/");
|
|
16543
|
+
if (firstSlash !== -1)
|
|
16544
|
+
normalizedRef = normalizedRef.substring(firstSlash);
|
|
16545
|
+
}
|
|
16546
|
+
if (!normalizedRef.startsWith("/api/") && !normalizedRef.startsWith("/api?")) {
|
|
16547
|
+
if (normalizedRef === nestPathDirect || normalizedRef.startsWith(nestPathDirect + "/") || minimatch(normalizedRef, nestPathDirect)) {
|
|
16548
|
+
hasDirectReference = true;
|
|
16549
|
+
break;
|
|
16550
|
+
}
|
|
16551
|
+
}
|
|
16552
|
+
}
|
|
16553
|
+
if (!hasDirectReference) {
|
|
16554
|
+
if (process.env.DEBUG_PRUNY) {
|
|
16555
|
+
console.log(`[DEBUG] NestJS route ${route.path} de-marked: Next.js replacement exists at ${apiVariation}`);
|
|
16556
|
+
}
|
|
16557
|
+
route.used = false;
|
|
16558
|
+
route.references = [];
|
|
16559
|
+
route.unusedMethods = [...route.methods];
|
|
16560
|
+
}
|
|
16561
|
+
}
|
|
16562
|
+
}
|
|
16515
16563
|
let publicAssets;
|
|
16516
16564
|
if (!config.excludePublic) {
|
|
16517
16565
|
publicAssets = await scanPublicAssets(config);
|