optikit 1.1.1 → 1.2.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 (79) hide show
  1. package/CHANGELOG.md +23 -2
  2. package/CLAUDE.md +239 -0
  3. package/CODE_QUALITY.md +398 -0
  4. package/ENHANCEMENTS.md +310 -0
  5. package/FEATURE_ENHANCEMENTS.md +435 -0
  6. package/README.md +46 -13
  7. package/SAFETY_FEATURES.md +396 -0
  8. package/USAGE.md +225 -41
  9. package/VERSION_MANAGEMENT.md +438 -0
  10. package/dist/cli.js +116 -7
  11. package/dist/commands/build/releases.js +57 -0
  12. package/dist/commands/buildReleases.js +48 -74
  13. package/dist/commands/clean/flutter.js +51 -0
  14. package/dist/commands/clean/ios.js +109 -0
  15. package/dist/commands/cleanProject.js +34 -4
  16. package/dist/commands/cleanProjectIos.js +17 -7
  17. package/dist/commands/config/init.js +54 -0
  18. package/dist/commands/config/rollback.js +161 -0
  19. package/dist/commands/generateModule.js +39 -11
  20. package/dist/commands/init.js +54 -0
  21. package/dist/commands/openProject.js +17 -0
  22. package/dist/commands/project/devices.js +188 -0
  23. package/dist/commands/project/generate.js +143 -0
  24. package/dist/commands/project/open.js +63 -0
  25. package/dist/commands/project/setup.js +46 -0
  26. package/dist/commands/rollback.js +161 -0
  27. package/dist/commands/setupVSCode.js +27 -21
  28. package/dist/commands/updateVersions.js +13 -1
  29. package/dist/commands/version/bump.js +161 -0
  30. package/dist/commands/version/update.js +91 -0
  31. package/dist/commands/version.js +161 -0
  32. package/dist/constants.js +131 -0
  33. package/dist/utils/backupHelpers.js +88 -0
  34. package/dist/utils/buildHelpers.js +55 -0
  35. package/dist/utils/commandHelpers.js +51 -0
  36. package/dist/utils/configHelpers.js +80 -0
  37. package/dist/utils/dryRunHelpers.js +103 -0
  38. package/dist/utils/fileHelpers.js +2 -1
  39. package/dist/utils/helpers/build.js +55 -0
  40. package/dist/utils/helpers/dryRun.js +103 -0
  41. package/dist/utils/helpers/file.js +24 -0
  42. package/dist/utils/helpers/string.js +3 -0
  43. package/dist/utils/helpers/version.js +80 -0
  44. package/dist/utils/services/backup.js +88 -0
  45. package/dist/utils/services/command.js +51 -0
  46. package/dist/utils/services/config.js +80 -0
  47. package/dist/utils/services/exec.js +132 -0
  48. package/dist/utils/services/logger.js +15 -0
  49. package/dist/utils/validationHelpers.js +101 -0
  50. package/dist/utils/validators/validation.js +101 -0
  51. package/dist/utils/versionHelpers.js +80 -0
  52. package/package.json +1 -1
  53. package/src/cli.ts +165 -7
  54. package/src/commands/build/releases.ts +79 -0
  55. package/src/commands/clean/flutter.ts +58 -0
  56. package/src/commands/{cleanProjectIos.ts → clean/ios.ts} +19 -10
  57. package/src/commands/config/init.ts +63 -0
  58. package/src/commands/config/rollback.ts +200 -0
  59. package/src/commands/project/devices.ts +246 -0
  60. package/src/commands/{generateModule.ts → project/generate.ts} +47 -17
  61. package/src/commands/{openProject.ts → project/open.ts} +26 -5
  62. package/src/commands/project/setup.ts +50 -0
  63. package/src/commands/version/bump.ts +202 -0
  64. package/src/commands/{updateVersions.ts → version/update.ts} +22 -6
  65. package/src/constants.ts +144 -0
  66. package/src/utils/helpers/build.ts +80 -0
  67. package/src/utils/helpers/dryRun.ts +124 -0
  68. package/src/utils/{fileHelpers.ts → helpers/file.ts} +3 -2
  69. package/src/utils/helpers/version.ts +109 -0
  70. package/src/utils/services/backup.ts +109 -0
  71. package/src/utils/services/command.ts +76 -0
  72. package/src/utils/services/config.ts +106 -0
  73. package/src/utils/{execHelpers.ts → services/exec.ts} +1 -1
  74. package/src/utils/validators/validation.ts +122 -0
  75. package/src/commands/buildReleases.ts +0 -102
  76. package/src/commands/cleanProject.ts +0 -25
  77. package/src/commands/setupVSCode.ts +0 -44
  78. /package/src/utils/{stringHelpers.ts → helpers/string.ts} +0 -0
  79. /package/src/utils/{loggerHelpers.ts → services/logger.ts} +0 -0
@@ -0,0 +1,435 @@
1
+ # OptiKit CLI - Feature Enhancements
2
+
3
+ ## Overview
4
+
5
+ This document details the new features added to OptiKit CLI to improve user experience, provide better control, and make the tool more powerful and flexible.
6
+
7
+ ---
8
+
9
+ ## 🆕 New Commands
10
+
11
+ ### 1. Init Command (`optikit init`)
12
+
13
+ **Purpose:** Initialize OptiKit configuration in your project
14
+
15
+ **Usage:**
16
+ ```bash
17
+ optikit init
18
+ ```
19
+
20
+ **What it does:**
21
+ - Creates `.optikitrc.json` with default configuration
22
+ - Adds `.optikit-backup/` to `.gitignore` (if .gitignore exists)
23
+ - Displays the created configuration
24
+
25
+ **Example Output:**
26
+ ```bash
27
+ $ optikit init
28
+ ℹ️ Initializing OptiKit in this project...
29
+ ✅ Configuration saved to /path/to/project/.optikitrc.json
30
+ ✅ OptiKit initialized successfully!
31
+
32
+ Default configuration:
33
+ {
34
+ "backupRetentionCount": 5,
35
+ "useFvmByDefault": false,
36
+ "autoBackup": true,
37
+ "verbose": false
38
+ }
39
+
40
+ You can modify .optikitrc.json to customize these settings.
41
+
42
+ ✅ Added .optikit-backup/ to .gitignore
43
+ ```
44
+
45
+ **Configuration Options:**
46
+ - `backupRetentionCount` - Number of backups to keep (default: 5)
47
+ - `useFvmByDefault` - Use FVM for all commands by default (default: false)
48
+ - `autoBackup` - Automatically backup files before modification (default: true)
49
+ - `verbose` - Enable verbose logging (default: false)
50
+
51
+ ---
52
+
53
+ ### 2. Rollback Command (`optikit rollback`)
54
+
55
+ **Purpose:** List and restore files from OptiKit backups
56
+
57
+ **Usage:**
58
+ ```bash
59
+ # List all available backups
60
+ optikit rollback
61
+
62
+ # Restore a specific backup
63
+ optikit rollback --restore 1
64
+ ```
65
+
66
+ **List Mode Example:**
67
+ ```bash
68
+ $ optikit rollback
69
+ ℹ️ Searching for OptiKit backups...
70
+
71
+ Found 6 backup(s):
72
+
73
+ pubspec.yaml
74
+ [1] 12/23/2025, 3:45:30 PM (5m ago, 2.34 KB)
75
+ [2] 12/23/2025, 2:30:15 PM (1h ago, 2.31 KB)
76
+
77
+ ios/Runner.xcodeproj/project.pbxproj
78
+ [3] 12/23/2025, 3:40:20 PM (10m ago, 45.67 KB)
79
+ [4] 12/23/2025, 1:15:00 PM (3h ago, 45.12 KB)
80
+
81
+ ios/Runner/Info.plist
82
+ [5] 12/23/2025, 3:40:25 PM (10m ago, 1.23 KB)
83
+ [6] 12/23/2025, 1:15:05 PM (3h ago, 1.20 KB)
84
+
85
+ ============================================================
86
+ To restore a backup, run:
87
+ optikit rollback --restore <number>
88
+
89
+ Example:
90
+ optikit rollback --restore 1
91
+ ============================================================
92
+ ```
93
+
94
+ **Restore Mode Example:**
95
+ ```bash
96
+ $ optikit rollback --restore 1
97
+ ℹ️ Restoring: pubspec.yaml
98
+ ℹ️ From backup: 12/23/2025, 3:45:30 PM
99
+ ✅ Restored from backup: pubspec.yaml
100
+ ✅ Backup restored successfully!
101
+ ```
102
+
103
+ **Features:**
104
+ - Recursively searches entire project for backups
105
+ - Groups backups by original file
106
+ - Sorts by timestamp (newest first)
107
+ - Shows human-readable time ago (5m ago, 1h ago, etc.)
108
+ - Displays file sizes
109
+ - Simple numeric index for restoration
110
+
111
+ ---
112
+
113
+ ## 🔧 Configuration System
114
+
115
+ ### Configuration File (`.optikitrc.json`)
116
+
117
+ OptiKit now supports project-level and user-level configuration files.
118
+
119
+ **File Locations** (priority order):
120
+ 1. `.optikitrc` in current directory
121
+ 2. `.optikitrc.json` in current directory
122
+ 3. `.optikitrc` in home directory
123
+ 4. `.optikitrc.json` in home directory
124
+
125
+ **Configuration Schema:**
126
+ ```typescript
127
+ interface OptiKitConfig {
128
+ backupRetentionCount?: number; // Number of backups to keep
129
+ useFvmByDefault?: boolean; // Use FVM by default
130
+ autoBackup?: boolean; // Auto-backup before changes
131
+ verbose?: boolean; // Verbose logging
132
+ }
133
+ ```
134
+
135
+ **Example `.optikitrc.json`:**
136
+ ```json
137
+ {
138
+ "backupRetentionCount": 10,
139
+ "useFvmByDefault": true,
140
+ "autoBackup": true,
141
+ "verbose": false
142
+ }
143
+ ```
144
+
145
+ **Defaults:**
146
+ ```json
147
+ {
148
+ "backupRetentionCount": 5,
149
+ "useFvmByDefault": false,
150
+ "autoBackup": true,
151
+ "verbose": false
152
+ }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 🎨 Dry-Run Mode (Coming Soon)
158
+
159
+ **Purpose:** Preview commands without executing them
160
+
161
+ **Usage:**
162
+ ```bash
163
+ optikit flutter-build-apk --dry-run
164
+ optikit clean-flutter --dry-run
165
+ ```
166
+
167
+ **Features:**
168
+ - Shows all validation checks
169
+ - Displays commands that would be executed
170
+ - Lists files that would be modified
171
+ - No actual changes to system
172
+ - Perfect for learning and testing
173
+
174
+ **Example Output:**
175
+ ```bash
176
+ $ optikit flutter-build-apk --dry-run
177
+ 🔍 DRY-RUN MODE ENABLED - No commands will be executed
178
+ Commands will be displayed but not run
179
+
180
+ ✓ Validating Flutter project PASS
181
+ ✓ Validating Flutter SDK PASS
182
+ ✓ Validating Android project PASS
183
+
184
+ → Build Flutter APK
185
+ Command: fvm flutter build apk --release --obfuscate --split-debug-info=build/app/outputs/symbols
186
+
187
+ ============================================================
188
+ DRY-RUN SUMMARY
189
+ ============================================================
190
+
191
+ Total operations: 1
192
+ Commands: 1
193
+ File operations: 0
194
+
195
+ ============================================================
196
+ No actual changes were made to your system.
197
+ Run without --dry-run to execute these operations.
198
+ ```
199
+
200
+ ---
201
+
202
+ ## 🎯 Use Cases
203
+
204
+ ### Use Case 1: New Project Setup
205
+
206
+ ```bash
207
+ # Initialize OptiKit in your Flutter project
208
+ cd my-flutter-app
209
+ optikit init
210
+
211
+ # Customize configuration
212
+ vim .optikitrc.json
213
+
214
+ # Use OptiKit commands
215
+ optikit clean-flutter
216
+ optikit flutter-build-apk
217
+ ```
218
+
219
+ ### Use Case 2: Version Recovery
220
+
221
+ ```bash
222
+ # Made a mistake updating version?
223
+ optikit flutter-update-version --app-version 2.0.0 --android-build 10
224
+
225
+ # Oops! Wrong version. Let's check backups
226
+ optikit rollback
227
+
228
+ # Restore the old pubspec.yaml
229
+ optikit rollback --restore 1
230
+ ```
231
+
232
+ ### Use Case 3: Team Configuration
233
+
234
+ ```bash
235
+ # Create team-wide configuration
236
+ cat > .optikitrc.json << EOF
237
+ {
238
+ "backupRetentionCount": 10,
239
+ "useFvmByDefault": true,
240
+ "autoBackup": true
241
+ }
242
+ EOF
243
+
244
+ # Commit to repository
245
+ git add .optikitrc.json
246
+ git commit -m "Add OptiKit configuration"
247
+
248
+ # Team members automatically use same settings
249
+ ```
250
+
251
+ ### Use Case 4: Backup Management
252
+
253
+ ```bash
254
+ # Check all backups periodically
255
+ optikit rollback
256
+
257
+ # Restore specific file versions as needed
258
+ optikit rollback --restore 3
259
+
260
+ # Backups are automatically cleaned up (keeps last 5)
261
+ ```
262
+
263
+ ---
264
+
265
+ ## 📊 Benefits
266
+
267
+ ### For Individual Developers
268
+
269
+ 1. **Easy Setup:** `optikit init` gets you started instantly
270
+ 2. **Safety Net:** Automatic backups with easy restoration
271
+ 3. **Customization:** Configure behavior per-project
272
+ 4. **Recovery:** Rollback mistakes quickly
273
+
274
+ ### For Teams
275
+
276
+ 1. **Consistency:** Share configuration across team
277
+ 2. **Standardization:** Everyone uses same settings
278
+ 3. **Documentation:** Configuration file self-documents preferences
279
+ 4. **Version Control:** Config can be committed to Git
280
+
281
+ ### For DevOps/CI
282
+
283
+ 1. **Scriptable:** Configuration via files, not command-line flags
284
+ 2. **Predictable:** Same behavior across environments
285
+ 3. **Auditable:** Configuration changes tracked in Git
286
+ 4. **Flexible:** Different configs for dev/staging/prod
287
+
288
+ ---
289
+
290
+ ## 🔄 Migration Guide
291
+
292
+ ### From Manual Configuration to OptiKit Config
293
+
294
+ **Before:**
295
+ ```bash
296
+ # Remember to use --disable-fvm on this project
297
+ optikit flutter-build-apk --disable-fvm
298
+
299
+ # Remember to keep more backups
300
+ # (no way to configure this)
301
+ ```
302
+
303
+ **After:**
304
+ ```bash
305
+ # One-time setup
306
+ optikit init
307
+ echo '{"useFvmByDefault": false, "backupRetentionCount": 10}' > .optikitrc.json
308
+
309
+ # Now just use commands normally
310
+ optikit flutter-build-apk # Uses config automatically
311
+ ```
312
+
313
+ ---
314
+
315
+ ## 🎓 Best Practices
316
+
317
+ ### 1. Initialize Early
318
+ ```bash
319
+ # First thing when starting a project
320
+ optikit init
321
+ ```
322
+
323
+ ### 2. Commit Configuration
324
+ ```bash
325
+ # Share team settings
326
+ git add .optikitrc.json
327
+ git commit -m "Add OptiKit configuration"
328
+ ```
329
+
330
+ ### 3. Regular Backup Checks
331
+ ```bash
332
+ # Weekly or monthly
333
+ optikit rollback # Review available backups
334
+ ```
335
+
336
+ ### 4. Document Custom Settings
337
+ ```json
338
+ {
339
+ "backupRetentionCount": 10, // Keep more for this critical project
340
+ "useFvmByDefault": true, // Team uses FVM
341
+ "autoBackup": true, // Always backup
342
+ "verbose": false // Quiet output for CI
343
+ }
344
+ ```
345
+
346
+ ---
347
+
348
+ ## 📋 Command Reference
349
+
350
+ ### All New Commands
351
+
352
+ | Command | Description | Options |
353
+ |---------|-------------|---------|
354
+ | `optikit init` | Initialize configuration | None |
355
+ | `optikit rollback` | List backups | None |
356
+ | `optikit rollback --restore N` | Restore backup #N | `--restore <number>` |
357
+
358
+ ### Configuration Options
359
+
360
+ | Option | Type | Default | Description |
361
+ |--------|------|---------|-------------|
362
+ | `backupRetentionCount` | number | 5 | Backups to keep |
363
+ | `useFvmByDefault` | boolean | false | Use FVM by default |
364
+ | `autoBackup` | boolean | true | Auto-backup files |
365
+ | `verbose` | boolean | false | Verbose logging |
366
+
367
+ ---
368
+
369
+ ## 🚀 Future Enhancements
370
+
371
+ ### Planned Features
372
+
373
+ 1. **Dry-Run Mode**
374
+ - Preview all operations
375
+ - See validation results
376
+ - Perfect for learning
377
+
378
+ 2. **Verbose Mode**
379
+ - Detailed operation logs
380
+ - Debug information
381
+ - Command execution details
382
+
383
+ 3. **Progress Indicators**
384
+ - Spinners for long operations
385
+ - Progress bars for builds
386
+ - Time estimates
387
+
388
+ 4. **Config Command**
389
+ ```bash
390
+ optikit config set backupRetentionCount 10
391
+ optikit config get
392
+ optikit config list
393
+ ```
394
+
395
+ 5. **Backup Export**
396
+ ```bash
397
+ optikit backup export ./backup-archive
398
+ ```
399
+
400
+ ---
401
+
402
+ ## 📖 Related Documentation
403
+
404
+ - [CODE_QUALITY.md](CODE_QUALITY.md) - Architecture improvements
405
+ - [SAFETY_FEATURES.md](SAFETY_FEATURES.md) - Validation and backups
406
+ - [ENHANCEMENTS.md](ENHANCEMENTS.md) - Critical bug fixes
407
+ - [CLAUDE.md](CLAUDE.md) - Development guide
408
+
409
+ ---
410
+
411
+ ## 🎉 Summary
412
+
413
+ ### New Capabilities
414
+
415
+ - ✅ **2 new commands** (init, rollback)
416
+ - ✅ **Configuration system** (.optikitrc.json)
417
+ - ✅ **Backup management** (list and restore)
418
+ - ✅ **Project initialization** (quick setup)
419
+ - ✅ **Team settings** (shareable config)
420
+
421
+ ### Developer Experience
422
+
423
+ | Aspect | Before | After |
424
+ |--------|--------|-------|
425
+ | Setup | Manual | `optikit init` |
426
+ | Configuration | Command-line flags | Config file |
427
+ | Backup Management | Manual file browsing | `optikit rollback` |
428
+ | Recovery | Manual copy | `optikit rollback --restore N` |
429
+ | Team Sharing | Documentation | Committed config |
430
+
431
+ ---
432
+
433
+ **Version:** 1.1.1+features
434
+ **Last Updated:** December 23, 2025
435
+ **Status:** ✅ Production Ready
package/README.md CHANGED
@@ -20,30 +20,63 @@
20
20
 
21
21
  Explore the **OptiCore** framework on [pub.dev](https://pub.dev/packages/opticore) and see how **OptiKit** can enhance your development experience.
22
22
 
23
- ## Features
23
+ ## Key Features
24
24
 
25
- - **Customizable**: The CLI commands and options to fit your specific needs.
26
- - **User-Friendly**: Intuitive command-line experience with helpful output.
27
- - **Built-In Error Handling**: Informative error messages for easy troubleshooting.
28
- - **Cross-Platform Compatibility**: Consistent performance across macOS, Windows, and Linux.
29
- - **Flexible Configuration**: Customize options for different environments and setups.
30
- - **Detailed Command Documentation**: Built-in help for all commands to guide usage.
25
+ - **Smart Version Management** - Intelligent semantic versioning with platform-specific build number handling
26
+ - **Automatic Backups & Rollback** - Safe file modifications with easy restoration
27
+ - **Build Automation** - Streamlined APK, Bundle, IPA, and iOS builds with validation
28
+ - **Module Generation** - Scaffold complete BLoC pattern modules for Opticore framework
29
+ - **Project Configuration** - Flexible .optikitrc.json configuration system
30
+ - **Cross-Platform** - Consistent performance across macOS, Windows, and Linux
31
+ - **FVM Support** - Built-in Flutter Version Manager support
32
+
33
+ See [FEATURE_ENHANCEMENTS.md](FEATURE_ENHANCEMENTS.md) for complete feature details.
31
34
 
32
35
  ## Installation
33
36
 
34
37
  For detailed instructions on how to install **OptiKit CLI** on your system, refer to the [Installation Guide](https://github.com/dev-mahmoud-elshenawy/optikit/blob/main/INSTALLATION.md).
35
38
 
36
- ## Troubleshooting
39
+ ## Quick Start
40
+
41
+ ```bash
42
+ # Initialize OptiKit in your Flutter project
43
+ optikit init
44
+
45
+ # Show current version
46
+ optikit version
47
+
48
+ # Bump patch version (1.0.0 → 1.0.1)
49
+ optikit version bump patch
50
+
51
+ # Build APK for release
52
+ optikit flutter-build-apk
53
+
54
+ # View available backups
55
+ optikit rollback
56
+
57
+ # Get help
58
+ optikit --help
59
+ ```
60
+
61
+ ## Documentation
62
+
63
+ ### User Guides
37
64
 
38
- If you encounter any issues while using **OptiKit CLI**, check the [Troubleshooting Guide](https://github.com/dev-mahmoud-elshenawy/optikit/blob/main/TROUBLESHOOT.md) for solutions to common problems.
65
+ - **[Usage Guide](USAGE.md)** - Complete guide to all commands and features
66
+ - **[Installation Guide](INSTALLATION.md)** - How to install OptiKit CLI
67
+ - **[Troubleshooting Guide](TROUBLESHOOT.md)** - Solutions to common problems
39
68
 
40
- ## Usage
69
+ ### Feature Documentation
41
70
 
42
- To learn how to use **OptiKit CLI** and its various commands, refer to the [Usage Guide](https://github.com/dev-mahmoud-elshenawy/optikit/blob/main/USAGE.md).
71
+ - **[Version Management](VERSION_MANAGEMENT.md)** - Smart version bumping and build number strategies
72
+ - **[Safety Features](SAFETY_FEATURES.md)** - Validation and automatic backup system
73
+ - **[Feature Enhancements](FEATURE_ENHANCEMENTS.md)** - New commands (init, rollback, configuration)
74
+ - **[Code Quality](CODE_QUALITY.md)** - Architecture improvements and best practices
43
75
 
44
- ## Changelog
76
+ ### Developer Resources
45
77
 
46
- To learn more about the updates and changes in **OptiKit CLI**, refer to the [Changelog Guide](https://github.com/dev-mahmoud-elshenawy/optikit/blob/main/CHANGELOG.md).
78
+ - **[Changelog](CHANGELOG.md)** - Version history and updates
79
+ - **[Contributing Guide](CLAUDE.md)** - Development guide for contributors
47
80
 
48
81
  ## Contact
49
82