pruny 1.16.0 → 1.17.0

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 +15 -15
  2. 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*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: "GET" },
7648
- { regex: /axios\.post\s*\(\s*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: "POST" },
7649
- { regex: /axios\.put\s*\(\s*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: "PUT" },
7650
- { regex: /axios\.delete\s*\(\s*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: "DELETE" },
7651
- { regex: /axios\.patch\s*\(\s*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: "PATCH" },
7652
- { regex: /useSWR\s*\(\s*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: "GET" },
7653
- { regex: /fetch\s*\(\s*['"`]\/api\/([^'"`\s)]+)['"`]/g, method: undefined },
7654
- { regex: /fetch\s*\(\s*`\/api\/([^`\s)]+)`/g, method: undefined },
7655
- { regex: /['"`]\/api\/([^'"`\s]+)['"`]/g, method: undefined },
7656
- { regex: /['"`](?:https?:\/\/[^/]+)?\/api\/([^'"`\s]+)['"`]/g, method: undefined },
7657
- { regex: /`[^`]*\/api\/([^`\s]+)`/g, method: undefined }
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: "/api/" + regexMatch[1],
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 && match.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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.16.0",
3
+ "version": "1.17.0",
4
4
  "description": "Find and remove unused Next.js API routes & Nest.js Controllers",
5
5
  "type": "module",
6
6
  "files": [