jatin-lean 0.1.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jatin
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,215 @@
1
+ # ⚡ jatin-lean
2
+
3
+ **A high-performance Rust CLI utility to prune non-essential files from `node_modules`, reducing disk footprint by up to 50% without breaking runtime dependencies.**
4
+
5
+ Created by **Jatin Jalandhra**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/jatin-lean.svg)](https://www.npmjs.com/package/jatin-lean)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
9
+
10
+ ---
11
+
12
+ ## 🚀 Quick Start
13
+
14
+ ```bash
15
+ # Run directly with npx (no installation needed)
16
+ npx jatin-lean
17
+
18
+ # Execute deletion
19
+ npx jatin-lean --force
20
+
21
+ # Verbose mode
22
+ npx jatin-lean --verbose
23
+ ```
24
+
25
+ ---
26
+
27
+ ## 🎯 What It Does
28
+
29
+ Intelligently removes non-runtime files from your `node_modules`:
30
+
31
+ | Category | Examples | Risk |
32
+ |---|---|---|
33
+ | **Documentation** | README.md, CHANGELOG.md | ▪ Low |
34
+ | **Test Assets** | test/, *.test.js, *.spec.js | ▪ Low |
35
+ | **CI/CD Config** | .travis.yml, .github/ | ▪ Low |
36
+ | **Examples** | example/, demos/ | ▪ Low |
37
+ | **Source Maps** | *.js.map, *.css.map | ▪▪ Medium |
38
+ | **Build Artifacts** | *.c, *.o, Makefile | ▪▪ Medium |
39
+ | **TS Sources** | *.ts, *.tsx (keeps .d.ts) | ▪▪▪ High |
40
+
41
+ ---
42
+
43
+ ## 🛡️ Safety First
44
+
45
+ Before deleting anything:
46
+ 1. ✅ Parses `package.json` entry points (main, module, exports, bin, types)
47
+ 2. ✅ Auto-whitelists runtime-critical files
48
+ 3. ✅ Never touches `.bin/` directories
49
+ 4. ✅ Dry-run mode by default (safe preview)
50
+
51
+ ---
52
+
53
+ ## 📖 Usage
54
+
55
+ ### Basic Commands
56
+
57
+ ```bash
58
+ # Dry run (default - safe preview)
59
+ npx jatin-lean
60
+
61
+ # Execute deletion
62
+ npx jatin-lean --force
63
+
64
+ # Verbose - show every file
65
+ npx jatin-lean --verbose
66
+
67
+ # Scan specific project
68
+ npx jatin-lean /path/to/project
69
+
70
+ # Global mode - scan all projects
71
+ npx jatin-lean ~/projects --global
72
+ ```
73
+
74
+ ### CLI Options
75
+
76
+ | Flag | Description |
77
+ |---|---|
78
+ | `--force` / `-f` | Execute deletion (default is dry-run) |
79
+ | `--verbose` / `-v` | Show individual files targeted |
80
+ | `--global` / `-g` | Scan all projects in a directory |
81
+ | `--max-depth N` | Max directory depth for global scan |
82
+ | `--help` / `-h` | Print help information |
83
+ | `--version` / `-V` | Print version |
84
+
85
+ ---
86
+
87
+ ## 📊 Example Output
88
+
89
+ ```
90
+ ╔═══════════════════════════════════════════════╗
91
+ ║ ⚡ jatin-lean — Node Modules Pruner ⚡ ║
92
+ ║ Slim your node_modules by up to 50% ║
93
+ ║ Created by Jatin Jalandhra ║
94
+ ╚═══════════════════════════════════════════════╝
95
+
96
+ Phase 1: Discovery ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
97
+ ◉ Scanning node_modules... Found 5,057 files across 71 packages.
98
+ ◉ Total size indexed: 68.7MB
99
+
100
+ Phase 2: Simulation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
101
+ ◉ Analyzing dependency tree... 2,400 files (35MB) identified.
102
+
103
+ ╭────────────────┬───────┬─────────┬────────────╮
104
+ │ Category ┆ Files ┆ Size ┆ Risk │
105
+ ╞════════════════╪═══════╪═════════╪════════════╡
106
+ │ Documentation ┆ 1,200 ┆ 15MB ┆ ▪ Low │
107
+ │ Test-Asset ┆ 800 ┆ 12MB ┆ ▪ Low │
108
+ │ Source-Map ┆ 400 ┆ 8MB ┆ ▪▪ Medium │
109
+ ╰────────────────┴───────┴─────────┴────────────╯
110
+
111
+ Phase 3: Confirmation ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
112
+ [SAFE] No critical runtime files targeted.
113
+
114
+ 💾 Total Savings: 35MB (51% of node_modules)
115
+ ℹ This will NOT affect npm start or npm build.
116
+
117
+ → Run with --force to execute deletion.
118
+ ✨ Made with ❤️ by Jatin Jalandhra
119
+ ```
120
+
121
+ ---
122
+
123
+ ## 🔧 Use Cases
124
+
125
+ ### In package.json Scripts
126
+
127
+ ```json
128
+ {
129
+ "scripts": {
130
+ "postinstall": "jatin-lean --force",
131
+ "clean:modules": "jatin-lean --force"
132
+ }
133
+ }
134
+ ```
135
+
136
+ ### In Dockerfile
137
+
138
+ ```dockerfile
139
+ FROM node:18-alpine
140
+ WORKDIR /app
141
+ COPY package*.json ./
142
+ RUN npm ci --production
143
+ RUN npx jatin-lean --force
144
+ COPY . .
145
+ CMD ["npm", "start"]
146
+ ```
147
+
148
+ ### CI/CD Pipeline
149
+
150
+ ```yaml
151
+ - name: Install dependencies
152
+ run: npm ci
153
+ - name: Optimize node_modules
154
+ run: npx jatin-lean --force
155
+ ```
156
+
157
+ ---
158
+
159
+ ## 🌍 Platform Support
160
+
161
+ Pre-built binaries for:
162
+ - **Linux**: x64, ARM64
163
+ - **macOS**: Intel, Apple Silicon
164
+ - **Windows**: x64
165
+
166
+ The correct binary is automatically downloaded during installation.
167
+
168
+ ---
169
+
170
+ ## ⚡ Performance
171
+
172
+ - **Fast**: Parallel scanning with Rust + rayon
173
+ - **Efficient**: Completes in seconds, not minutes
174
+ - **Safe**: Entry points protected automatically
175
+
176
+ Expected performance:
177
+ - Small projects (< 100 packages): < 1 second
178
+ - Medium projects (100-500 packages): 1-3 seconds
179
+ - Large projects (500+ packages): 3-10 seconds
180
+
181
+ ---
182
+
183
+ ## 📄 License
184
+
185
+ MIT License - see [LICENSE](LICENSE) for details.
186
+
187
+ ---
188
+
189
+ ## 🤝 Contributing
190
+
191
+ Contributions are welcome! Please feel free to submit a Pull Request.
192
+
193
+ ---
194
+
195
+ ## ⚠️ Disclaimer
196
+
197
+ While `jatin-lean` is designed to be safe:
198
+ 1. Run in dry-run mode first (default behavior)
199
+ 2. Review the list of files to be deleted
200
+ 3. Test your application after pruning
201
+ 4. Keep backups of critical projects
202
+
203
+ **Use at your own risk.**
204
+
205
+ ---
206
+
207
+ ## 🔗 Links
208
+
209
+ - [GitHub Repository](https://github.com/your-username/jatin-lean)
210
+ - [Issue Tracker](https://github.com/your-username/jatin-lean/issues)
211
+ - [npm Package](https://www.npmjs.com/package/jatin-lean)
212
+
213
+ ---
214
+
215
+ **Made with ❤️ by Jatin Jalandhra**
package/bin/jatin-lean ADDED
Binary file
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Wrapper script to execute the jatin-lean binary.
5
+ * This is the entry point when running `npx jatin-lean` or `jatin-lean`.
6
+ */
7
+
8
+ const { spawn } = require('child_process');
9
+ const path = require('path');
10
+ const fs = require('fs');
11
+
12
+ const BINARY_NAME = 'jatin-lean' + (process.platform === 'win32' ? '.exe' : '');
13
+ const BINARY_PATH = path.join(__dirname, '..', 'bin', BINARY_NAME);
14
+
15
+ function runBinary() {
16
+ // Check if binary exists
17
+ if (!fs.existsSync(BINARY_PATH)) {
18
+ console.error('Error: jatin-lean binary not found.');
19
+ console.error('Please run: npm install jatin-lean');
20
+ console.error(`Expected location: ${BINARY_PATH}`);
21
+ process.exit(1);
22
+ }
23
+
24
+ // Check if binary is executable
25
+ try {
26
+ fs.accessSync(BINARY_PATH, fs.constants.X_OK);
27
+ } catch (error) {
28
+ console.error('Error: Binary is not executable.');
29
+ console.error('Attempting to fix permissions...');
30
+ try {
31
+ fs.chmodSync(BINARY_PATH, 0o755);
32
+ console.log('✓ Permissions fixed.');
33
+ } catch (chmodError) {
34
+ console.error('Failed to fix permissions:', chmodError.message);
35
+ process.exit(1);
36
+ }
37
+ }
38
+
39
+ // Pass all arguments to the binary
40
+ const args = process.argv.slice(2);
41
+
42
+ const child = spawn(BINARY_PATH, args, {
43
+ stdio: 'inherit',
44
+ env: process.env,
45
+ });
46
+
47
+ child.on('error', (error) => {
48
+ console.error('Failed to start jatin-lean:', error.message);
49
+ process.exit(1);
50
+ });
51
+
52
+ child.on('exit', (code, signal) => {
53
+ if (signal) {
54
+ process.kill(process.pid, signal);
55
+ } else {
56
+ process.exit(code || 0);
57
+ }
58
+ });
59
+ }
60
+
61
+ runBinary();
package/index.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Main entry point for programmatic usage (if needed in the future).
3
+ * For now, this package is primarily a CLI tool.
4
+ */
5
+
6
+ const { execSync } = require('child_process');
7
+ const path = require('path');
8
+
9
+ const BINARY_PATH = path.join(__dirname, 'bin', 'jatin-lean' + (process.platform === 'win32' ? '.exe' : ''));
10
+
11
+ /**
12
+ * Execute jatin-lean with the given arguments.
13
+ * @param {string[]} args - Command line arguments
14
+ * @param {object} options - Execution options
15
+ * @returns {Buffer} - Command output
16
+ */
17
+ function run(args = [], options = {}) {
18
+ const command = `"${BINARY_PATH}" ${args.join(' ')}`;
19
+ return execSync(command, {
20
+ stdio: 'inherit',
21
+ ...options,
22
+ });
23
+ }
24
+
25
+ module.exports = {
26
+ run,
27
+ binaryPath: BINARY_PATH,
28
+ };
package/install.js ADDED
@@ -0,0 +1,124 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install script to download the appropriate binary for the platform.
5
+ * This runs automatically after `npm install jatin-lean`.
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const https = require('https');
11
+ const { execSync } = require('child_process');
12
+
13
+ const PACKAGE_VERSION = require('./package.json').version;
14
+ const BINARY_NAME = 'jatin-lean';
15
+
16
+ // Platform-specific binary names
17
+ const PLATFORM_MAP = {
18
+ 'linux-x64': 'jatin-lean-linux-x64',
19
+ 'linux-arm64': 'jatin-lean-linux-arm64',
20
+ 'darwin-x64': 'jatin-lean-macos-x64',
21
+ 'darwin-arm64': 'jatin-lean-macos-arm64',
22
+ 'win32-x64': 'jatin-lean-windows-x64.exe',
23
+ };
24
+
25
+ function getPlatformKey() {
26
+ const platform = process.platform;
27
+ const arch = process.arch;
28
+ return `${platform}-${arch}`;
29
+ }
30
+
31
+ function getBinaryName() {
32
+ const platformKey = getPlatformKey();
33
+ const binaryName = PLATFORM_MAP[platformKey];
34
+
35
+ if (!binaryName) {
36
+ console.error(`Unsupported platform: ${platformKey}`);
37
+ console.error('Supported platforms:', Object.keys(PLATFORM_MAP).join(', '));
38
+ process.exit(1);
39
+ }
40
+
41
+ return binaryName;
42
+ }
43
+
44
+ function getBinaryPath() {
45
+ return path.join(__dirname, 'bin', BINARY_NAME + (process.platform === 'win32' ? '.exe' : ''));
46
+ }
47
+
48
+ function downloadBinary(url, dest) {
49
+ return new Promise((resolve, reject) => {
50
+ console.log(`Downloading ${url}...`);
51
+
52
+ const file = fs.createWriteStream(dest);
53
+
54
+ https.get(url, (response) => {
55
+ if (response.statusCode === 302 || response.statusCode === 301) {
56
+ // Follow redirect
57
+ https.get(response.headers.location, (redirectResponse) => {
58
+ redirectResponse.pipe(file);
59
+ file.on('finish', () => {
60
+ file.close();
61
+ resolve();
62
+ });
63
+ }).on('error', reject);
64
+ } else if (response.statusCode === 200) {
65
+ response.pipe(file);
66
+ file.on('finish', () => {
67
+ file.close();
68
+ resolve();
69
+ });
70
+ } else {
71
+ reject(new Error(`Failed to download: HTTP ${response.statusCode}`));
72
+ }
73
+ }).on('error', reject);
74
+ });
75
+ }
76
+
77
+ async function install() {
78
+ const binaryName = getBinaryName();
79
+ const binaryPath = getBinaryPath();
80
+ const binDir = path.dirname(binaryPath);
81
+
82
+ // Create bin directory if it doesn't exist
83
+ if (!fs.existsSync(binDir)) {
84
+ fs.mkdirSync(binDir, { recursive: true });
85
+ }
86
+
87
+ // Check if binary already exists (for local development)
88
+ if (fs.existsSync(binaryPath)) {
89
+ console.log('Binary already exists, skipping download.');
90
+ fs.chmodSync(binaryPath, 0o755);
91
+ return;
92
+ }
93
+
94
+ // For now, try to copy from local build if available (development mode)
95
+ const localBinaryPath = path.join(__dirname, '..', 'target', 'release', BINARY_NAME);
96
+ if (fs.existsSync(localBinaryPath)) {
97
+ console.log('Using local development binary...');
98
+ fs.copyFileSync(localBinaryPath, binaryPath);
99
+ fs.chmodSync(binaryPath, 0o755);
100
+ console.log('✓ Installation complete!');
101
+ return;
102
+ }
103
+
104
+ // In production, download from GitHub releases
105
+ const downloadUrl = `https://github.com/your-username/jatin-lean/releases/download/v${PACKAGE_VERSION}/${binaryName}`;
106
+
107
+ try {
108
+ await downloadBinary(downloadUrl, binaryPath);
109
+ fs.chmodSync(binaryPath, 0o755);
110
+ console.log('✓ Installation complete!');
111
+ } catch (error) {
112
+ console.error('Failed to download binary:', error.message);
113
+ console.error('\nYou can manually download the binary from:');
114
+ console.error(downloadUrl);
115
+ console.error(`\nAnd place it at: ${binaryPath}`);
116
+ process.exit(1);
117
+ }
118
+ }
119
+
120
+ // Run installation
121
+ install().catch((error) => {
122
+ console.error('Installation failed:', error);
123
+ process.exit(1);
124
+ });
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "jatin-lean",
3
+ "version": "0.1.0",
4
+ "description": "A high-performance CLI utility to prune non-essential files from node_modules, reducing disk footprint by up to 50% without breaking runtime dependencies.",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "jatin-lean": "bin/jatin-lean.js"
8
+ },
9
+ "scripts": {
10
+ "postinstall": "node install.js",
11
+ "test": "node bin/jatin-lean.js --help"
12
+ },
13
+ "keywords": [
14
+ "node_modules",
15
+ "cleanup",
16
+ "prune",
17
+ "disk-space",
18
+ "optimization",
19
+ "npm",
20
+ "dependencies",
21
+ "cli"
22
+ ],
23
+ "author": "Jatin Jalandhra",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/your-username/jatin-lean.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/your-username/jatin-lean/issues"
31
+ },
32
+ "homepage": "https://github.com/your-username/jatin-lean#readme",
33
+ "engines": {
34
+ "node": ">=14.0.0"
35
+ },
36
+ "os": [
37
+ "linux",
38
+ "darwin",
39
+ "win32"
40
+ ],
41
+ "cpu": [
42
+ "x64",
43
+ "arm64"
44
+ ],
45
+ "files": [
46
+ "bin/",
47
+ "install.js",
48
+ "index.js",
49
+ "README.md",
50
+ "LICENSE"
51
+ ]
52
+ }