pruny 1.0.5 → 1.0.6

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 (3) hide show
  1. package/docs/index.md +37 -10
  2. package/llms.txt +37 -10
  3. package/package.json +1 -1
package/docs/index.md CHANGED
@@ -49,16 +49,43 @@ Pruny looks for `pruny.config.json` in the project root.
49
49
  }
50
50
  ```
51
51
 
52
- ## How Detection Works
53
- 1. **Discovery**: Finds all `app/api/**/route.{ts,js}` files.
54
- 2. **Scanning**: Greps all source files for usage patterns like:
55
- - `fetch('/api/my-route')`
56
- - `axios.get('/api/my-route')`
57
- - `useSWR('/api/my-route')`
58
- - Template literals: `` `/api/${variable}` `` (matches exact prefix)
59
- 3. **Exclusions**:
60
- - Routes defined in `vercel.json` crons are automatically marked as used.
61
- - Routes matching `ignore.routes` glob patterns are skipped.
52
+ ## Advanced Usage & Limitations
53
+
54
+ ### Dynamic Routes & Custom Clients
55
+ Pruny detects API usage by static analysis of string literals.
56
+ - **Supported**:
57
+ - `fetch('/api/users')`
58
+ - `` fetch(`/api/users/${id}`) `` (Template literals with constant prefix)
59
+ - `axios.get('/api/items')`
60
+ - `useSWR('/api/data')`
61
+ - **Limitations**:
62
+ - **Runtime Construction**: Routes constructed purely at runtime without a static `/api/` prefix literal cannot be detected.
63
+ - ❌ `fetch(myUrlVariable)` -> **False Positive** (Pruny thinks route is unused)
64
+ - ✅ `fetch('/api/' + myUrlVariable)` -> **Detected**
65
+ - **Custom Wrappers**: If you wrap `fetch` in a custom `apiClient` without standard method names, use `// pruny-ignore` (future feature) or manually ignore the route in config.
66
+
67
+ ### Monorepo / Multi-App Setup
68
+ For monorepos with multiple Next.js apps (e.g., `apps/web`, `apps/admin`):
69
+
70
+ 1. **Run per package**:
71
+ ```bash
72
+ cd apps/web && npx pruny
73
+ ```
74
+ 2. **Run from root with --dir**:
75
+ ```bash
76
+ # Scan specific app
77
+ npx pruny --dir ./apps/web
78
+
79
+ # Scan another app
80
+ npx pruny --dir ./apps/admin
81
+ ```
82
+ *Note: Pruny's config resolution looks for `pruny.config.json` in the specific `dir` being scanned.*
83
+
84
+ ### Vercel Cron Detection
85
+ Pruny automatically parses `vercel.json` to process cron jobs.
86
+ - It looks for `crons: [{ path: "/api/cron/job" }]` array.
87
+ - Any route path found in `vercel.json` is automatically marked as **USED**.
88
+ - This prevents accidental deletion of server-side cron handlers that are never "fetched" by client code.
62
89
 
63
90
  ## Source Code
64
91
  - Repository: https://github.com/WebNaresh/pruny
package/llms.txt CHANGED
@@ -49,16 +49,43 @@ Pruny looks for `pruny.config.json` in the project root.
49
49
  }
50
50
  ```
51
51
 
52
- ## How Detection Works
53
- 1. **Discovery**: Finds all `app/api/**/route.{ts,js}` files.
54
- 2. **Scanning**: Greps all source files for usage patterns like:
55
- - `fetch('/api/my-route')`
56
- - `axios.get('/api/my-route')`
57
- - `useSWR('/api/my-route')`
58
- - Template literals: `` `/api/${variable}` `` (matches exact prefix)
59
- 3. **Exclusions**:
60
- - Routes defined in `vercel.json` crons are automatically marked as used.
61
- - Routes matching `ignore.routes` glob patterns are skipped.
52
+ ## Advanced Usage & Limitations
53
+
54
+ ### Dynamic Routes & Custom Clients
55
+ Pruny detects API usage by static analysis of string literals.
56
+ - **Supported**:
57
+ - `fetch('/api/users')`
58
+ - `` fetch(`/api/users/${id}`) `` (Template literals with constant prefix)
59
+ - `axios.get('/api/items')`
60
+ - `useSWR('/api/data')`
61
+ - **Limitations**:
62
+ - **Runtime Construction**: Routes constructed purely at runtime without a static `/api/` prefix literal cannot be detected.
63
+ - ❌ `fetch(myUrlVariable)` -> **False Positive** (Pruny thinks route is unused)
64
+ - ✅ `fetch('/api/' + myUrlVariable)` -> **Detected**
65
+ - **Custom Wrappers**: If you wrap `fetch` in a custom `apiClient` without standard method names, use `// pruny-ignore` (future feature) or manually ignore the route in config.
66
+
67
+ ### Monorepo / Multi-App Setup
68
+ For monorepos with multiple Next.js apps (e.g., `apps/web`, `apps/admin`):
69
+
70
+ 1. **Run per package**:
71
+ ```bash
72
+ cd apps/web && npx pruny
73
+ ```
74
+ 2. **Run from root with --dir**:
75
+ ```bash
76
+ # Scan specific app
77
+ npx pruny --dir ./apps/web
78
+
79
+ # Scan another app
80
+ npx pruny --dir ./apps/admin
81
+ ```
82
+ *Note: Pruny's config resolution looks for `pruny.config.json` in the specific `dir` being scanned.*
83
+
84
+ ### Vercel Cron Detection
85
+ Pruny automatically parses `vercel.json` to process cron jobs.
86
+ - It looks for `crons: [{ path: "/api/cron/job" }]` array.
87
+ - Any route path found in `vercel.json` is automatically marked as **USED**.
88
+ - This prevents accidental deletion of server-side cron handlers that are never "fetched" by client code.
62
89
 
63
90
  ## Source Code
64
91
  - Repository: https://github.com/WebNaresh/pruny
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pruny",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Find and remove unused Next.js API routes",
5
5
  "type": "module",
6
6
  "bin": {