pruny 1.16.0 → 1.17.1
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 +28 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7644,17 +7644,18 @@ var EXPORTED_METHOD_PATTERN = /export\s+(?:async\s+)?(?:function|const)\s+(GET|P
|
|
|
7644
7644
|
var NEST_CONTROLLER_PATTERN = /@Controller\s*\(\s*(?:['"`]([^'"`]*)['"`])?\s*\)/;
|
|
7645
7645
|
var NEST_METHOD_PATTERN = /@(Get|Post|Put|Delete|Patch|Options|Head|All)\s*\(\s*(?:['"`]([^'"`]*)['"`])?\s*\)/g;
|
|
7646
7646
|
var API_METHOD_PATTERNS = [
|
|
7647
|
-
{ regex: /axios\.get\s*\(\s*['"`]\/
|
|
7648
|
-
{ regex: /axios\.post\s*\(\s*['"`]\/
|
|
7649
|
-
{ regex: /axios\.put\s*\(\s*['"`]\/
|
|
7650
|
-
{ regex: /axios\.delete\s*\(\s*['"`]\/
|
|
7651
|
-
{ regex: /axios\.patch\s*\(\s*['"`]\/
|
|
7652
|
-
{ regex: /useSWR\s*\(\s*['"`]\/
|
|
7653
|
-
{ regex: /fetch\s*\(\s*['"`]\/
|
|
7654
|
-
{ regex: /fetch\s*\(\s
|
|
7655
|
-
{ regex: /['"`]\/api\/
|
|
7656
|
-
{ regex: /['"`](?:https?:\/\/[^/]+)
|
|
7657
|
-
{ regex: /`[^`]
|
|
7647
|
+
{ regex: /axios\.get\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: "GET" },
|
|
7648
|
+
{ regex: /axios\.post\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: "POST" },
|
|
7649
|
+
{ regex: /axios\.put\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: "PUT" },
|
|
7650
|
+
{ regex: /axios\.delete\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: "DELETE" },
|
|
7651
|
+
{ regex: /axios\.patch\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: "PATCH" },
|
|
7652
|
+
{ regex: /useSWR\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: "GET" },
|
|
7653
|
+
{ regex: /fetch\s*\(\s*['"`](\/[^'"`\s)]+)['"`]/g, method: undefined },
|
|
7654
|
+
{ regex: /fetch\s*\(\s*`[^`]*(\/[^`\s)]+)`/g, method: undefined },
|
|
7655
|
+
{ regex: /['"`](\/api\/[^'"`\s]+)['"`]/g, method: undefined },
|
|
7656
|
+
{ regex: /['"`](?:https?:\/\/[^/]+)?(\/api\/[^'"`\s]+)['"`]/g, method: undefined },
|
|
7657
|
+
{ regex: /`[^`]*(\/[\w-]+\/[^`\s]+)`/g, method: undefined },
|
|
7658
|
+
{ regex: /['"`](\/[\w-]{2,}\/[\w-./]+)['"`]/g, method: undefined }
|
|
7658
7659
|
];
|
|
7659
7660
|
function extractApiReferences(content) {
|
|
7660
7661
|
const matches = [];
|
|
@@ -7664,7 +7665,7 @@ function extractApiReferences(content) {
|
|
|
7664
7665
|
while ((regexMatch = regex.exec(content)) !== null) {
|
|
7665
7666
|
if (regexMatch[1]) {
|
|
7666
7667
|
matches.push({
|
|
7667
|
-
path:
|
|
7668
|
+
path: regexMatch[1],
|
|
7668
7669
|
method,
|
|
7669
7670
|
start: regexMatch.index,
|
|
7670
7671
|
end: regexMatch.index + regexMatch[0].length
|
|
@@ -7676,7 +7677,7 @@ function extractApiReferences(content) {
|
|
|
7676
7677
|
return !matches.some((other) => {
|
|
7677
7678
|
if (match === other)
|
|
7678
7679
|
return false;
|
|
7679
|
-
return other.start <= match.start && other.end >= match.end && other.method !== undefined
|
|
7680
|
+
return other.start <= match.start && other.end >= match.end && (other.method !== undefined || match.method === undefined);
|
|
7680
7681
|
});
|
|
7681
7682
|
});
|
|
7682
7683
|
const references = [];
|
|
@@ -9226,8 +9227,7 @@ async function scanUnusedFiles(config) {
|
|
|
9226
9227
|
"**/next-env.d.ts",
|
|
9227
9228
|
"**/*.d.ts",
|
|
9228
9229
|
"**/*.config.{js,ts,mjs,cjs}",
|
|
9229
|
-
"**/*.test.{ts,tsx,js,jsx}",
|
|
9230
|
-
"**/*.spec.{ts,tsx,js,jsx}",
|
|
9230
|
+
"**/*.{test,spec,e2e-spec}.{ts,tsx,js,jsx}",
|
|
9231
9231
|
"scripts/**/*.{ts,js}",
|
|
9232
9232
|
"cypress/**/*.{ts,js,tsx}",
|
|
9233
9233
|
"**/public/sw.js",
|
|
@@ -9926,7 +9926,8 @@ function loadConfig(options) {
|
|
|
9926
9926
|
const prefixPattern = (p) => {
|
|
9927
9927
|
if (p.startsWith("**/") || p.startsWith("/") || !relDir)
|
|
9928
9928
|
return p;
|
|
9929
|
-
|
|
9929
|
+
const prefixed = join5(relDir, p).replace(/\\/g, "/");
|
|
9930
|
+
return prefixed.includes("/") ? `**/${prefixed}` : `**/${prefixed}`;
|
|
9930
9931
|
};
|
|
9931
9932
|
if (config.ignore?.routes)
|
|
9932
9933
|
mergedIgnore.routes.push(...config.ignore.routes.map(prefixPattern));
|
|
@@ -10267,11 +10268,20 @@ program2.action(async (options) => {
|
|
|
10267
10268
|
console.log(source_default.red(` Deleted File: ${route.filePath}`));
|
|
10268
10269
|
}
|
|
10269
10270
|
} else if (route.type === "nestjs") {
|
|
10270
|
-
|
|
10271
|
-
|
|
10271
|
+
const isInternallyUnused = result.unusedFiles?.files.some((f) => f.path === route.filePath);
|
|
10272
|
+
if (isInternallyUnused || route.filePath.includes("api/")) {
|
|
10273
|
+
rmSync(fullPath, { force: true });
|
|
10274
|
+
console.log(source_default.red(` Deleted File: ${route.filePath}`));
|
|
10275
|
+
fixedSomething = true;
|
|
10276
|
+
} else {
|
|
10277
|
+
console.log(source_default.yellow(` Skipped Deletion (internally used): ${route.filePath}`));
|
|
10278
|
+
console.log(source_default.dim(` → This controller is imported in another file (e.g. app.module.ts).`));
|
|
10279
|
+
continue;
|
|
10280
|
+
}
|
|
10272
10281
|
} else {
|
|
10273
10282
|
rmSync(fullPath, { force: true });
|
|
10274
10283
|
console.log(source_default.red(` Deleted File: ${route.filePath}`));
|
|
10284
|
+
fixedSomething = true;
|
|
10275
10285
|
}
|
|
10276
10286
|
fixedSomething = true;
|
|
10277
10287
|
const idx = result.routes.indexOf(route);
|