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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +125 -0
  3. package/core/Cargo.lock +1093 -0
  4. package/core/Cargo.toml +22 -0
  5. package/core/src/arc_lfu.rs +91 -0
  6. package/core/src/cache.rs +205 -0
  7. package/core/src/lockfiles.rs +112 -0
  8. package/core/src/main.rs +125 -0
  9. package/core/src/ml.rs +188 -0
  10. package/core/src/optimization.rs +314 -0
  11. package/core/src/safety.rs +103 -0
  12. package/core/src/scanner.rs +136 -0
  13. package/core/src/symlink.rs +223 -0
  14. package/core/src/types.rs +87 -0
  15. package/core/src/usage_tracker.rs +107 -0
  16. package/dist/cli/index.d.ts +2 -0
  17. package/dist/cli/index.d.ts.map +1 -0
  18. package/dist/cli/index.js +249 -0
  19. package/dist/cli/index.js.map +1 -0
  20. package/dist/core/bindings.d.ts +33 -0
  21. package/dist/core/bindings.d.ts.map +1 -0
  22. package/dist/core/bindings.js +172 -0
  23. package/dist/core/bindings.js.map +1 -0
  24. package/dist/managers/base-manager.d.ts +33 -0
  25. package/dist/managers/base-manager.d.ts.map +1 -0
  26. package/dist/managers/base-manager.js +122 -0
  27. package/dist/managers/base-manager.js.map +1 -0
  28. package/dist/managers/index.d.ts +12 -0
  29. package/dist/managers/index.d.ts.map +1 -0
  30. package/dist/managers/index.js +37 -0
  31. package/dist/managers/index.js.map +1 -0
  32. package/dist/managers/npm-manager.d.ts +14 -0
  33. package/dist/managers/npm-manager.d.ts.map +1 -0
  34. package/dist/managers/npm-manager.js +128 -0
  35. package/dist/managers/npm-manager.js.map +1 -0
  36. package/dist/managers/pnpm-manager.d.ts +14 -0
  37. package/dist/managers/pnpm-manager.d.ts.map +1 -0
  38. package/dist/managers/pnpm-manager.js +137 -0
  39. package/dist/managers/pnpm-manager.js.map +1 -0
  40. package/dist/managers/yarn-manager.d.ts +14 -0
  41. package/dist/managers/yarn-manager.d.ts.map +1 -0
  42. package/dist/managers/yarn-manager.js +141 -0
  43. package/dist/managers/yarn-manager.js.map +1 -0
  44. package/dist/types/index.d.ts +85 -0
  45. package/dist/types/index.d.ts.map +1 -0
  46. package/dist/types/index.js +13 -0
  47. package/dist/types/index.js.map +1 -0
  48. package/dist/utils/logger.d.ts +18 -0
  49. package/dist/utils/logger.d.ts.map +1 -0
  50. package/dist/utils/logger.js +50 -0
  51. package/dist/utils/logger.js.map +1 -0
  52. package/package.json +64 -0
  53. package/src/cli/index.ts +212 -0
  54. package/src/core/bindings.ts +157 -0
  55. package/src/managers/base-manager.ts +117 -0
  56. package/src/managers/index.ts +32 -0
  57. package/src/managers/npm-manager.ts +96 -0
  58. package/src/managers/pnpm-manager.ts +107 -0
  59. package/src/managers/yarn-manager.ts +112 -0
  60. package/src/types/index.ts +97 -0
  61. package/src/utils/logger.ts +50 -0
  62. 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
+