packagepurge 1.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/LICENSE +21 -0
- package/README.md +125 -0
- package/core/Cargo.lock +1093 -0
- package/core/Cargo.toml +22 -0
- package/core/src/arc_lfu.rs +91 -0
- package/core/src/cache.rs +205 -0
- package/core/src/lockfiles.rs +112 -0
- package/core/src/main.rs +125 -0
- package/core/src/ml.rs +188 -0
- package/core/src/optimization.rs +314 -0
- package/core/src/safety.rs +103 -0
- package/core/src/scanner.rs +136 -0
- package/core/src/symlink.rs +223 -0
- package/core/src/types.rs +87 -0
- package/core/src/usage_tracker.rs +107 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +249 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/core/bindings.d.ts +33 -0
- package/dist/core/bindings.d.ts.map +1 -0
- package/dist/core/bindings.js +172 -0
- package/dist/core/bindings.js.map +1 -0
- package/dist/managers/base-manager.d.ts +33 -0
- package/dist/managers/base-manager.d.ts.map +1 -0
- package/dist/managers/base-manager.js +122 -0
- package/dist/managers/base-manager.js.map +1 -0
- package/dist/managers/index.d.ts +12 -0
- package/dist/managers/index.d.ts.map +1 -0
- package/dist/managers/index.js +37 -0
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/npm-manager.d.ts +14 -0
- package/dist/managers/npm-manager.d.ts.map +1 -0
- package/dist/managers/npm-manager.js +128 -0
- package/dist/managers/npm-manager.js.map +1 -0
- package/dist/managers/pnpm-manager.d.ts +14 -0
- package/dist/managers/pnpm-manager.d.ts.map +1 -0
- package/dist/managers/pnpm-manager.js +137 -0
- package/dist/managers/pnpm-manager.js.map +1 -0
- package/dist/managers/yarn-manager.d.ts +14 -0
- package/dist/managers/yarn-manager.d.ts.map +1 -0
- package/dist/managers/yarn-manager.js +141 -0
- package/dist/managers/yarn-manager.js.map +1 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +13 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/logger.d.ts +18 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +64 -0
- package/src/cli/index.ts +212 -0
- package/src/core/bindings.ts +157 -0
- package/src/managers/base-manager.ts +117 -0
- package/src/managers/index.ts +32 -0
- package/src/managers/npm-manager.ts +96 -0
- package/src/managers/pnpm-manager.ts +107 -0
- package/src/managers/yarn-manager.ts +112 -0
- package/src/types/index.ts +97 -0
- package/src/utils/logger.ts +50 -0
- package/tsconfig.json +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 PackagePurge
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# PackagePurge ๐งน
|
|
2
|
+
|
|
3
|
+
**Intelligent package manager cache cleanup service with project-aware optimization**
|
|
4
|
+
|
|
5
|
+
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
|
+
|
|
7
|
+
## ๐ฏ Core Value Proposition
|
|
8
|
+
|
|
9
|
+
- **Intelligent Caching**: LRU-based preservation of frequently used packages
|
|
10
|
+
- **Project-Aware Optimization**: Analyzes actual project dependencies before cleanup
|
|
11
|
+
- **Multi-Manager Support**: Works with npm, yarn, and pnpm
|
|
12
|
+
- **Safety-First Design**: Built-in backup and rollback mechanisms
|
|
13
|
+
- **Cross-Project Deduplication**: Reduces storage by sharing common dependencies
|
|
14
|
+
|
|
15
|
+
## ๐๏ธ Architecture
|
|
16
|
+
|
|
17
|
+
### Core Components
|
|
18
|
+
|
|
19
|
+
1. **Storage Scanner**: Filesystem analysis with AST/dependency graph parsing
|
|
20
|
+
2. **Optimization Engine**: Rule-based and ML-driven cleanup strategies
|
|
21
|
+
3. **Safety Layer**: Backup and rollback functionality
|
|
22
|
+
4. **Reporting Dashboard**: Analytics with savings-to-risk ratio metrics
|
|
23
|
+
|
|
24
|
+
### Technical Stack
|
|
25
|
+
|
|
26
|
+
- **Core**: Rust (high-performance scanning and optimization)
|
|
27
|
+
- **CLI**: TypeScript (Node.js) with Commander.js
|
|
28
|
+
- **File Operations**: Rust stdlib + fs-extra for robust filesystem operations
|
|
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
|
|
33
|
+
|
|
34
|
+
## ๐ฆ Installation
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install -g packagepurge
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## ๐ Usage
|
|
41
|
+
|
|
42
|
+
### Scan Filesystem
|
|
43
|
+
```bash
|
|
44
|
+
packagepurge scan
|
|
45
|
+
packagepurge scan --paths ./project1 ./project2
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Analyze (Dry Run)
|
|
49
|
+
```bash
|
|
50
|
+
packagepurge analyze
|
|
51
|
+
packagepurge analyze --paths ./my-project --preserve-days 90
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Optimize with ML/LRU and Symlinking
|
|
55
|
+
```bash
|
|
56
|
+
# Basic optimization
|
|
57
|
+
packagepurge optimize
|
|
58
|
+
|
|
59
|
+
# With ML predictions enabled
|
|
60
|
+
packagepurge optimize --enable-ml --preserve-days 90
|
|
61
|
+
|
|
62
|
+
# With symlinking enabled
|
|
63
|
+
packagepurge optimize --enable-symlinking
|
|
64
|
+
|
|
65
|
+
# Full optimization with all features
|
|
66
|
+
packagepurge optimize --enable-ml --enable-symlinking --lru-max-packages 2000
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Execute Symlinking
|
|
70
|
+
```bash
|
|
71
|
+
# Symlink duplicate packages across projects
|
|
72
|
+
packagepurge symlink --paths ./project1 ./project2
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Clean (Quarantine)
|
|
76
|
+
```bash
|
|
77
|
+
# First analyze to get targets
|
|
78
|
+
packagepurge analyze > plan.json
|
|
79
|
+
|
|
80
|
+
# Then quarantine targets
|
|
81
|
+
packagepurge clean --targets $(jq -r '.items[].target_path' plan.json)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Rollback
|
|
85
|
+
```bash
|
|
86
|
+
# Rollback latest quarantine
|
|
87
|
+
packagepurge rollback --latest
|
|
88
|
+
|
|
89
|
+
# Rollback by ID
|
|
90
|
+
packagepurge rollback --id <quarantine-id>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## ๐ง Configuration
|
|
94
|
+
|
|
95
|
+
Create a `.packagepurge.json` file in your project root:
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"preserveDays": 90,
|
|
100
|
+
"keepVersions": 2,
|
|
101
|
+
"enableML": false,
|
|
102
|
+
"backupEnabled": true,
|
|
103
|
+
"managers": ["npm", "yarn", "pnpm"]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## ๐ Metrics
|
|
108
|
+
|
|
109
|
+
PackagePurge tracks:
|
|
110
|
+
- **Disk Space Saved**: Total GB recovered
|
|
111
|
+
- **Savings-to-Risk Ratio**: `Disk Space Saved / (Rollbacks + Re-installs)`
|
|
112
|
+
- **Cache Hit Rate**: Percentage of packages preserved by LRU
|
|
113
|
+
- **Project Coverage**: Percentage of projects analyzed
|
|
114
|
+
|
|
115
|
+
## ๐ก๏ธ Safety Features
|
|
116
|
+
|
|
117
|
+
- Automatic backup creation before cleanup
|
|
118
|
+
- Rollback capability for immediate restoration
|
|
119
|
+
- Dry-run mode for previewing changes
|
|
120
|
+
- Project dependency validation before deletion
|
|
121
|
+
|
|
122
|
+
## ๐ License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
125
|
+
|