pruny 1.0.3 → 1.0.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/docs/index.md +65 -0
- package/llms.txt +65 -0
- package/package.json +1 -1
package/docs/index.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Pruny
|
|
2
|
+
|
|
3
|
+
> Find and remove unused Next.js API routes.
|
|
4
|
+
|
|
5
|
+
## Summary
|
|
6
|
+
Pruny is a CLI tool that scans Next.js projects (App Router) to identify API routes that are not referenced in the codebase. It supports auto-detection of usage via `fetch`, `axios`, and `useSWR`, and respects `vercel.json` cron jobs.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g pruny
|
|
12
|
+
# or run directly
|
|
13
|
+
npx pruny
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Scan Mode
|
|
19
|
+
Scans the current directory or specified directory for unused routes.
|
|
20
|
+
```bash
|
|
21
|
+
npx pruny
|
|
22
|
+
npx pruny --dir ./src
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Fix Mode (Deletion)
|
|
26
|
+
Automatically deletes the folders of unused API routes.
|
|
27
|
+
```bash
|
|
28
|
+
npx pruny --fix
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### JSON Output
|
|
32
|
+
Outputs the results in JSON format for program consumption.
|
|
33
|
+
```bash
|
|
34
|
+
npx pruny --json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
Pruny looks for `pruny.config.json` in the project root.
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"dir": "./",
|
|
43
|
+
"ignore": {
|
|
44
|
+
"routes": ["/api/webhooks/**", "/api/cron/**"],
|
|
45
|
+
"folders": ["node_modules", ".next", "dist", ".git"],
|
|
46
|
+
"files": ["*.test.ts", "*.spec.ts"]
|
|
47
|
+
},
|
|
48
|
+
"extensions": [".ts", ".tsx", ".js", ".jsx"]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
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.
|
|
62
|
+
|
|
63
|
+
## Source Code
|
|
64
|
+
- Repository: https://github.com/WebNaresh/pruny
|
|
65
|
+
- Registry: https://www.npmjs.com/package/pruny
|
package/llms.txt
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Pruny
|
|
2
|
+
|
|
3
|
+
> Find and remove unused Next.js API routes.
|
|
4
|
+
|
|
5
|
+
## Summary
|
|
6
|
+
Pruny is a CLI tool that scans Next.js projects (App Router) to identify API routes that are not referenced in the codebase. It supports auto-detection of usage via `fetch`, `axios`, and `useSWR`, and respects `vercel.json` cron jobs.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install -g pruny
|
|
12
|
+
# or run directly
|
|
13
|
+
npx pruny
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
### Scan Mode
|
|
19
|
+
Scans the current directory or specified directory for unused routes.
|
|
20
|
+
```bash
|
|
21
|
+
npx pruny
|
|
22
|
+
npx pruny --dir ./src
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Fix Mode (Deletion)
|
|
26
|
+
Automatically deletes the folders of unused API routes.
|
|
27
|
+
```bash
|
|
28
|
+
npx pruny --fix
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### JSON Output
|
|
32
|
+
Outputs the results in JSON format for program consumption.
|
|
33
|
+
```bash
|
|
34
|
+
npx pruny --json
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
Pruny looks for `pruny.config.json` in the project root.
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"dir": "./",
|
|
43
|
+
"ignore": {
|
|
44
|
+
"routes": ["/api/webhooks/**", "/api/cron/**"],
|
|
45
|
+
"folders": ["node_modules", ".next", "dist", ".git"],
|
|
46
|
+
"files": ["*.test.ts", "*.spec.ts"]
|
|
47
|
+
},
|
|
48
|
+
"extensions": [".ts", ".tsx", ".js", ".jsx"]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
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.
|
|
62
|
+
|
|
63
|
+
## Source Code
|
|
64
|
+
- Repository: https://github.com/WebNaresh/pruny
|
|
65
|
+
- Registry: https://www.npmjs.com/package/pruny
|