packagepurge 1.0.0 → 2.0.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.
- package/.agent/workflows/build.md +58 -0
- package/.github/workflows/release.yml +176 -0
- package/README.md +215 -49
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +122 -132
- package/dist/cli/index.js.map +1 -1
- package/dist/core/bindings.d.ts +11 -0
- package/dist/core/bindings.d.ts.map +1 -1
- package/dist/core/bindings.js +40 -94
- package/dist/core/bindings.js.map +1 -1
- package/dist/utils/core-utils.d.ts +31 -0
- package/dist/utils/core-utils.d.ts.map +1 -0
- package/dist/utils/core-utils.js +121 -0
- package/dist/utils/core-utils.js.map +1 -0
- package/dist/utils/formatter.d.ts +63 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +295 -0
- package/dist/utils/formatter.js.map +1 -0
- package/package.json +3 -3
- package/core/src/arc_lfu.rs +0 -91
- package/core/src/cache.rs +0 -205
- package/core/src/lockfiles.rs +0 -112
- package/core/src/main.rs +0 -125
- package/core/src/ml.rs +0 -188
- package/core/src/optimization.rs +0 -314
- package/core/src/safety.rs +0 -103
- package/core/src/scanner.rs +0 -136
- package/core/src/symlink.rs +0 -223
- package/core/src/types.rs +0 -87
- package/core/src/usage_tracker.rs +0 -107
- package/src/cli/index.ts +0 -212
- package/src/core/bindings.ts +0 -157
- package/src/managers/base-manager.ts +0 -117
- package/src/managers/index.ts +0 -32
- package/src/managers/npm-manager.ts +0 -96
- package/src/managers/pnpm-manager.ts +0 -107
- package/src/managers/yarn-manager.ts +0 -112
- package/src/types/index.ts +0 -97
- package/src/utils/logger.ts +0 -50
- package/tsconfig.json +0 -22
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Build PackagePurge (Rust core + TypeScript CLI)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Build PackagePurge
|
|
6
|
+
|
|
7
|
+
This workflow builds both the Rust core binary and the TypeScript CLI.
|
|
8
|
+
|
|
9
|
+
## Prerequisites
|
|
10
|
+
|
|
11
|
+
- Node.js >= 16.0.0
|
|
12
|
+
- Rust toolchain (cargo)
|
|
13
|
+
- npm
|
|
14
|
+
|
|
15
|
+
## Steps
|
|
16
|
+
|
|
17
|
+
// turbo-all
|
|
18
|
+
|
|
19
|
+
1. Install npm dependencies:
|
|
20
|
+
```bash
|
|
21
|
+
cd c:\Users\barne\OneDrive\Desktop\PackagePurge
|
|
22
|
+
npm install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
2. Build Rust core (release mode):
|
|
26
|
+
```bash
|
|
27
|
+
cd c:\Users\barne\OneDrive\Desktop\PackagePurge\core
|
|
28
|
+
cargo build --release
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
3. Build TypeScript:
|
|
32
|
+
```bash
|
|
33
|
+
cd c:\Users\barne\OneDrive\Desktop\PackagePurge
|
|
34
|
+
npx tsc
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
4. Verify CLI works:
|
|
38
|
+
```bash
|
|
39
|
+
cd c:\Users\barne\OneDrive\Desktop\PackagePurge
|
|
40
|
+
node dist/cli/index.js --help
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Output
|
|
44
|
+
|
|
45
|
+
After successful build:
|
|
46
|
+
- Rust binary: `core/target/release/packagepurge_core.exe` (Windows) or `core/target/release/packagepurge-core` (Unix)
|
|
47
|
+
- TypeScript output: `dist/` directory
|
|
48
|
+
- CLI entry point: `dist/cli/index.js`
|
|
49
|
+
|
|
50
|
+
## Quick Build Command
|
|
51
|
+
|
|
52
|
+
For a full rebuild:
|
|
53
|
+
```bash
|
|
54
|
+
cd c:\Users\barne\OneDrive\Desktop\PackagePurge
|
|
55
|
+
npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This runs both `build:core` (cargo) and `tsc` sequentially.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
name: Build and Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
inputs:
|
|
9
|
+
version:
|
|
10
|
+
description: "Version to release (e.g., 1.0.2)"
|
|
11
|
+
required: true
|
|
12
|
+
type: string
|
|
13
|
+
|
|
14
|
+
env:
|
|
15
|
+
CARGO_TERM_COLOR: always
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
build:
|
|
19
|
+
name: Build ${{ matrix.target }}
|
|
20
|
+
runs-on: ${{ matrix.os }}
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
include:
|
|
25
|
+
- target: x86_64-pc-windows-msvc
|
|
26
|
+
os: windows-latest
|
|
27
|
+
ext: .exe
|
|
28
|
+
name: windows-x64
|
|
29
|
+
- target: x86_64-unknown-linux-gnu
|
|
30
|
+
os: ubuntu-latest
|
|
31
|
+
ext: ""
|
|
32
|
+
name: linux-x64
|
|
33
|
+
- target: x86_64-apple-darwin
|
|
34
|
+
os: macos-latest
|
|
35
|
+
ext: ""
|
|
36
|
+
name: macos-x64
|
|
37
|
+
- target: aarch64-apple-darwin
|
|
38
|
+
os: macos-latest
|
|
39
|
+
ext: ""
|
|
40
|
+
name: macos-arm64
|
|
41
|
+
|
|
42
|
+
steps:
|
|
43
|
+
- name: Checkout
|
|
44
|
+
uses: actions/checkout@v4
|
|
45
|
+
|
|
46
|
+
- name: Setup Rust
|
|
47
|
+
uses: dtolnay/rust-toolchain@stable
|
|
48
|
+
with:
|
|
49
|
+
targets: ${{ matrix.target }}
|
|
50
|
+
|
|
51
|
+
- name: Build Rust binary
|
|
52
|
+
working-directory: ./core
|
|
53
|
+
run: cargo build --release --target ${{ matrix.target }}
|
|
54
|
+
|
|
55
|
+
- name: Prepare binary (Unix)
|
|
56
|
+
if: runner.os != 'Windows'
|
|
57
|
+
run: |
|
|
58
|
+
mkdir -p artifacts
|
|
59
|
+
cp core/target/${{ matrix.target }}/release/packagepurge_core${{ matrix.ext }} artifacts/purge-${{ matrix.name }}${{ matrix.ext }}
|
|
60
|
+
chmod +x artifacts/purge-${{ matrix.name }}${{ matrix.ext }}
|
|
61
|
+
|
|
62
|
+
- name: Prepare binary (Windows)
|
|
63
|
+
if: runner.os == 'Windows'
|
|
64
|
+
run: |
|
|
65
|
+
mkdir artifacts
|
|
66
|
+
copy core\target\${{ matrix.target }}\release\packagepurge_core${{ matrix.ext }} artifacts\purge-${{ matrix.name }}${{ matrix.ext }}
|
|
67
|
+
|
|
68
|
+
- name: Upload artifact
|
|
69
|
+
uses: actions/upload-artifact@v4
|
|
70
|
+
with:
|
|
71
|
+
name: purge-${{ matrix.name }}
|
|
72
|
+
path: artifacts/purge-${{ matrix.name }}${{ matrix.ext }}
|
|
73
|
+
|
|
74
|
+
release:
|
|
75
|
+
name: Create Release
|
|
76
|
+
needs: build
|
|
77
|
+
runs-on: ubuntu-latest
|
|
78
|
+
permissions:
|
|
79
|
+
contents: write
|
|
80
|
+
|
|
81
|
+
steps:
|
|
82
|
+
- name: Checkout
|
|
83
|
+
uses: actions/checkout@v4
|
|
84
|
+
|
|
85
|
+
- name: Download all artifacts
|
|
86
|
+
uses: actions/download-artifact@v4
|
|
87
|
+
with:
|
|
88
|
+
path: artifacts
|
|
89
|
+
merge-multiple: true
|
|
90
|
+
|
|
91
|
+
- name: List artifacts
|
|
92
|
+
run: ls -la artifacts/
|
|
93
|
+
|
|
94
|
+
- name: Create checksums
|
|
95
|
+
working-directory: artifacts
|
|
96
|
+
run: |
|
|
97
|
+
sha256sum purge-* > checksums.txt
|
|
98
|
+
cat checksums.txt
|
|
99
|
+
|
|
100
|
+
- name: Get version
|
|
101
|
+
id: version
|
|
102
|
+
run: |
|
|
103
|
+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
|
|
104
|
+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
|
|
105
|
+
else
|
|
106
|
+
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
107
|
+
fi
|
|
108
|
+
|
|
109
|
+
- name: Create Release
|
|
110
|
+
uses: softprops/action-gh-release@v1
|
|
111
|
+
with:
|
|
112
|
+
tag_name: v${{ steps.version.outputs.version }}
|
|
113
|
+
name: PackagePurge v${{ steps.version.outputs.version }}
|
|
114
|
+
draft: false
|
|
115
|
+
prerelease: false
|
|
116
|
+
generate_release_notes: true
|
|
117
|
+
files: |
|
|
118
|
+
artifacts/purge-*
|
|
119
|
+
artifacts/checksums.txt
|
|
120
|
+
body: |
|
|
121
|
+
## Installation
|
|
122
|
+
|
|
123
|
+
### Via npm (recommended)
|
|
124
|
+
```bash
|
|
125
|
+
npm install -g packagepurge
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Download Binary
|
|
129
|
+
Download the appropriate binary for your platform:
|
|
130
|
+
| Platform | Binary |
|
|
131
|
+
|----------|--------|
|
|
132
|
+
| Windows x64 | `purge-windows-x64.exe` |
|
|
133
|
+
| Linux x64 | `purge-linux-x64` |
|
|
134
|
+
| macOS x64 | `purge-macos-x64` |
|
|
135
|
+
| macOS ARM64 | `purge-macos-arm64` |
|
|
136
|
+
|
|
137
|
+
After downloading, make it executable (Unix):
|
|
138
|
+
```bash
|
|
139
|
+
chmod +x purge-linux-x64
|
|
140
|
+
./purge-linux-x64 --help
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Verify Download
|
|
144
|
+
Verify your download with the checksums in `checksums.txt`.
|
|
145
|
+
|
|
146
|
+
npm-publish:
|
|
147
|
+
name: Publish to npm
|
|
148
|
+
needs: release
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
steps:
|
|
151
|
+
- name: Checkout
|
|
152
|
+
uses: actions/checkout@v4
|
|
153
|
+
|
|
154
|
+
- name: Setup Node.js
|
|
155
|
+
uses: actions/setup-node@v4
|
|
156
|
+
with:
|
|
157
|
+
node-version: "20"
|
|
158
|
+
registry-url: "https://registry.npmjs.org"
|
|
159
|
+
|
|
160
|
+
- name: Setup Rust
|
|
161
|
+
uses: dtolnay/rust-toolchain@stable
|
|
162
|
+
|
|
163
|
+
- name: Install dependencies
|
|
164
|
+
run: npm ci
|
|
165
|
+
|
|
166
|
+
- name: Build Rust core
|
|
167
|
+
working-directory: ./core
|
|
168
|
+
run: cargo build --release
|
|
169
|
+
|
|
170
|
+
- name: Build TypeScript
|
|
171
|
+
run: npx tsc
|
|
172
|
+
|
|
173
|
+
- name: Publish to npm
|
|
174
|
+
run: npm publish
|
|
175
|
+
env:
|
|
176
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/README.md
CHANGED
|
@@ -2,92 +2,209 @@
|
|
|
2
2
|
|
|
3
3
|
**Intelligent package manager cache cleanup service with project-aware optimization**
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/packagepurge)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
5
8
|
PackagePurge is a comprehensive service that solves the persistent "npm hell" storage problem by intelligently managing disk space across npm, yarn, and pnpm caches while maintaining safety and project awareness.
|
|
6
9
|
|
|
7
|
-
## 🎯
|
|
10
|
+
## 🎯 Features
|
|
8
11
|
|
|
9
|
-
- **
|
|
12
|
+
- **Human-Readable Output**: Beautiful table format with color-coded status (JSON/YAML also available)
|
|
13
|
+
- **Intelligent LRU Caching**: Size-aware preservation of frequently used packages
|
|
10
14
|
- **Project-Aware Optimization**: Analyzes actual project dependencies before cleanup
|
|
11
15
|
- **Multi-Manager Support**: Works with npm, yarn, and pnpm
|
|
12
16
|
- **Safety-First Design**: Built-in backup and rollback mechanisms
|
|
13
|
-
- **Cross-Project Deduplication**: Reduces storage by
|
|
17
|
+
- **Cross-Project Deduplication**: Reduces storage by symlinking common dependencies
|
|
18
|
+
- **ML-Powered Predictions**: Rule-based classifier for smart eviction decisions
|
|
14
19
|
|
|
15
|
-
##
|
|
20
|
+
## 📦 Installation
|
|
16
21
|
|
|
17
|
-
###
|
|
22
|
+
### Option 1: npm (Recommended)
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
4. **Reporting Dashboard**: Analytics with savings-to-risk ratio metrics
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g packagepurge
|
|
26
|
+
```
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
After installation, you can use either `purge` (recommended) or `packagepurge`:
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
- **Dependency Analysis**: Custom parsers for package.json, lock files
|
|
30
|
-
- **ML Component**: Rule-based classifier (extensible to actual ML models)
|
|
31
|
-
- **Symlinking**: Cross-platform hard linking and symbolic links
|
|
32
|
-
- **Caching**: LRU cache with ML-driven predictions
|
|
30
|
+
```bash
|
|
31
|
+
purge --help
|
|
32
|
+
```
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
### Option 2: Download Binary
|
|
35
|
+
|
|
36
|
+
Download pre-built binaries from [GitHub Releases](https://github.com/Benaah/PackagePurge/releases):
|
|
37
|
+
|
|
38
|
+
| Platform | Binary |
|
|
39
|
+
|----------|--------|
|
|
40
|
+
| Windows x64 | `purge-windows-x64.exe` |
|
|
41
|
+
| Linux x64 | `purge-linux-x64` |
|
|
42
|
+
| macOS x64 | `purge-macos-x64` |
|
|
43
|
+
| macOS ARM64 (M1/M2) | `purge-macos-arm64` |
|
|
35
44
|
|
|
45
|
+
**Linux/macOS:**
|
|
36
46
|
```bash
|
|
37
|
-
|
|
47
|
+
# Download and make executable
|
|
48
|
+
chmod +x purge-linux-x64
|
|
49
|
+
sudo mv purge-linux-x64 /usr/local/bin/purge
|
|
50
|
+
purge --help
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Windows:**
|
|
54
|
+
```powershell
|
|
55
|
+
# Add to PATH or run directly
|
|
56
|
+
.\purge-windows-x64.exe --help
|
|
38
57
|
```
|
|
39
58
|
|
|
40
|
-
|
|
59
|
+
|
|
60
|
+
## 🚀 Quick Start
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Scan your projects for packages
|
|
64
|
+
purge scan --paths ./my-project
|
|
65
|
+
|
|
66
|
+
# Analyze cleanup opportunities (dry run)
|
|
67
|
+
purge analyze --preserve-days 30
|
|
68
|
+
|
|
69
|
+
# See what can be optimized with ML
|
|
70
|
+
purge optimize --enable-ml
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 📖 Usage
|
|
41
74
|
|
|
42
75
|
### Scan Filesystem
|
|
76
|
+
|
|
77
|
+
Scan directories to find packages and projects:
|
|
78
|
+
|
|
43
79
|
```bash
|
|
44
|
-
|
|
45
|
-
|
|
80
|
+
# Scan current directory
|
|
81
|
+
purge scan
|
|
82
|
+
|
|
83
|
+
# Scan specific paths
|
|
84
|
+
purge scan --paths ./project1 ./project2
|
|
85
|
+
|
|
86
|
+
# Output as JSON for scripting
|
|
87
|
+
purge scan --format json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Sample Output:**
|
|
91
|
+
```
|
|
92
|
+
📦 Packages Found
|
|
93
|
+
|
|
94
|
+
Package Version Size Path
|
|
95
|
+
────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
96
|
+
react 18.2.0 125 KB .../node_modules/react
|
|
97
|
+
lodash 4.17.21 528 KB .../node_modules/lodash
|
|
98
|
+
typescript 5.3.3 65.2 MB .../node_modules/typescript
|
|
99
|
+
|
|
100
|
+
📊 Total: 245 packages, 156.7 MB
|
|
101
|
+
|
|
102
|
+
📁 Projects Found: 3
|
|
103
|
+
• C:\projects\my-app
|
|
104
|
+
• C:\projects\api-server
|
|
46
105
|
```
|
|
47
106
|
|
|
48
107
|
### Analyze (Dry Run)
|
|
108
|
+
|
|
109
|
+
Preview what would be cleaned without making changes:
|
|
110
|
+
|
|
49
111
|
```bash
|
|
50
|
-
|
|
51
|
-
|
|
112
|
+
# Analyze with default 90-day preservation
|
|
113
|
+
purge analyze
|
|
114
|
+
|
|
115
|
+
# Custom preservation period
|
|
116
|
+
purge analyze --preserve-days 30 --paths ./my-project
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Sample Output:**
|
|
120
|
+
```
|
|
121
|
+
🧹 Cleanup Plan
|
|
122
|
+
|
|
123
|
+
Orphaned (12 packages, 45.2 MB)
|
|
124
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
125
|
+
• old-package 12.5 MB .../node_modules/old-package
|
|
126
|
+
• unused-lib 8.3 MB .../node_modules/unused-lib
|
|
127
|
+
|
|
128
|
+
Outdated (8 packages, 23.1 MB)
|
|
129
|
+
────────────────────────────────────────────────────────────────────────────────
|
|
130
|
+
• stale-dependency 5.2 MB .../cache/stale-dep
|
|
131
|
+
|
|
132
|
+
📊 Summary
|
|
133
|
+
Total packages: 20
|
|
134
|
+
Estimated savings: 68.3 MB
|
|
52
135
|
```
|
|
53
136
|
|
|
54
|
-
### Optimize with ML/LRU
|
|
137
|
+
### Optimize with ML/LRU
|
|
138
|
+
|
|
139
|
+
Get intelligent cleanup recommendations:
|
|
140
|
+
|
|
55
141
|
```bash
|
|
56
142
|
# Basic optimization
|
|
57
|
-
|
|
143
|
+
purge optimize
|
|
58
144
|
|
|
59
|
-
# With ML predictions
|
|
60
|
-
|
|
145
|
+
# With ML predictions
|
|
146
|
+
purge optimize --enable-ml --preserve-days 90
|
|
61
147
|
|
|
62
|
-
# With symlinking
|
|
63
|
-
|
|
148
|
+
# With symlinking for duplicates
|
|
149
|
+
purge optimize --enable-symlinking
|
|
64
150
|
|
|
65
|
-
# Full optimization
|
|
66
|
-
|
|
151
|
+
# Full optimization
|
|
152
|
+
purge optimize --enable-ml --enable-symlinking --lru-max-packages 2000
|
|
67
153
|
```
|
|
68
154
|
|
|
69
155
|
### Execute Symlinking
|
|
156
|
+
|
|
157
|
+
Deduplicate packages across projects by creating symlinks:
|
|
158
|
+
|
|
70
159
|
```bash
|
|
71
|
-
|
|
72
|
-
packagepurge symlink --paths ./project1 ./project2
|
|
160
|
+
purge symlink --paths ./project1 ./project2
|
|
73
161
|
```
|
|
74
162
|
|
|
163
|
+
> **Note (Windows)**: Symlinking requires Administrator privileges or Developer Mode enabled.
|
|
164
|
+
|
|
75
165
|
### Clean (Quarantine)
|
|
166
|
+
|
|
167
|
+
Move packages to quarantine (recoverable):
|
|
168
|
+
|
|
76
169
|
```bash
|
|
77
170
|
# First analyze to get targets
|
|
78
|
-
|
|
171
|
+
purge analyze --format json > plan.json
|
|
79
172
|
|
|
80
173
|
# Then quarantine targets
|
|
81
|
-
|
|
174
|
+
purge clean --targets /path/to/package1 /path/to/package2
|
|
82
175
|
```
|
|
83
176
|
|
|
84
177
|
### Rollback
|
|
178
|
+
|
|
179
|
+
Restore quarantined packages:
|
|
180
|
+
|
|
85
181
|
```bash
|
|
86
182
|
# Rollback latest quarantine
|
|
87
|
-
|
|
183
|
+
purge rollback --latest
|
|
88
184
|
|
|
89
185
|
# Rollback by ID
|
|
90
|
-
|
|
186
|
+
purge rollback --id <quarantine-id>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## 🎨 Output Formats
|
|
190
|
+
|
|
191
|
+
PackagePurge supports three output formats:
|
|
192
|
+
|
|
193
|
+
| Format | Flag | Description |
|
|
194
|
+
|--------|------|-------------|
|
|
195
|
+
| Table | `--format table` | Human-readable with colors (default) |
|
|
196
|
+
| JSON | `--format json` | Machine-readable for scripting |
|
|
197
|
+
| YAML | `--format yaml` | Alternative structured format |
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Default table output
|
|
201
|
+
purge scan
|
|
202
|
+
|
|
203
|
+
# JSON for piping to jq
|
|
204
|
+
purge scan --format json | jq '.packages | length'
|
|
205
|
+
|
|
206
|
+
# YAML output
|
|
207
|
+
purge analyze --format yaml
|
|
91
208
|
```
|
|
92
209
|
|
|
93
210
|
## 🔧 Configuration
|
|
@@ -104,22 +221,71 @@ Create a `.packagepurge.json` file in your project root:
|
|
|
104
221
|
}
|
|
105
222
|
```
|
|
106
223
|
|
|
107
|
-
##
|
|
224
|
+
## 🏗️ Architecture
|
|
108
225
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
- **
|
|
112
|
-
- **
|
|
113
|
-
- **
|
|
226
|
+
### Technical Stack
|
|
227
|
+
|
|
228
|
+
- **Core Engine**: Rust (high-performance scanning and optimization)
|
|
229
|
+
- **CLI**: TypeScript (Node.js) with Commander.js
|
|
230
|
+
- **LRU Cache**: Size-aware with ML-driven predictions
|
|
231
|
+
- **Symlinking**: Cross-platform hard linking and symbolic links
|
|
232
|
+
|
|
233
|
+
### How It Works
|
|
234
|
+
|
|
235
|
+
1. **Scan**: Discovers all `node_modules` and cache directories
|
|
236
|
+
2. **Analyze**: Builds dependency graph and identifies orphaned/stale packages
|
|
237
|
+
3. **Optimize**: Uses LRU cache + optional ML to predict which packages to keep
|
|
238
|
+
4. **Clean**: Moves targets to quarantine (reversible) or creates symlinks
|
|
239
|
+
|
|
240
|
+
## 📊 Cleanup Reasons
|
|
241
|
+
|
|
242
|
+
| Reason | Color | Description |
|
|
243
|
+
|--------|-------|-------------|
|
|
244
|
+
| Orphaned | Yellow | Not used by any project |
|
|
245
|
+
| Outdated | Gray | Not accessed within preserve period |
|
|
246
|
+
| ML: Unused | Magenta | ML predicts won't be needed |
|
|
247
|
+
| Size Pressure | Red | Cache at capacity, evicting largest |
|
|
248
|
+
| Symlink Candidate | Blue | Duplicate that can be deduplicated |
|
|
114
249
|
|
|
115
250
|
## 🛡️ Safety Features
|
|
116
251
|
|
|
117
|
-
- Automatic backup
|
|
118
|
-
- Rollback capability for immediate restoration
|
|
119
|
-
- Dry-run mode for previewing changes
|
|
120
|
-
- Project
|
|
252
|
+
- **Automatic backup** before cleanup
|
|
253
|
+
- **Rollback capability** for immediate restoration
|
|
254
|
+
- **Dry-run mode** for previewing changes
|
|
255
|
+
- **Project validation** before deletion
|
|
256
|
+
- **Quarantine system** - nothing is permanently deleted immediately
|
|
257
|
+
|
|
258
|
+
## 🔧 Troubleshooting
|
|
259
|
+
|
|
260
|
+
### Windows Symlink Issues
|
|
261
|
+
|
|
262
|
+
If symlinking fails on Windows:
|
|
263
|
+
|
|
264
|
+
1. **Enable Developer Mode**: Settings → For Developers → Developer Mode: On
|
|
265
|
+
2. **Or run as Administrator**
|
|
266
|
+
|
|
267
|
+
### Large Scan Times
|
|
268
|
+
|
|
269
|
+
For very large directories:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Limit scan depth by specifying paths
|
|
273
|
+
purge scan --paths ./specific-project
|
|
274
|
+
|
|
275
|
+
# Use quiet mode to reduce output
|
|
276
|
+
purge scan -q --format json
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## 🤝 Contributing
|
|
280
|
+
|
|
281
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
121
282
|
|
|
122
283
|
## 📝 License
|
|
123
284
|
|
|
124
|
-
MIT
|
|
285
|
+
MIT © [Eng. Onyango Benard](https://github.com/Benaah)
|
|
286
|
+
|
|
287
|
+
## 🔗 Links
|
|
125
288
|
|
|
289
|
+
- [GitHub Repository](https://github.com/Benaah/PackagePurge)
|
|
290
|
+
- [npm Package](https://www.npmjs.com/package/packagepurge)
|
|
291
|
+
- [Report Issues](https://github.com/Benaah/PackagePurge/issues)
|
package/dist/cli/index.d.ts
CHANGED