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.
- package/CHANGELOG.md +23 -2
- package/CLAUDE.md +239 -0
- package/CODE_QUALITY.md +398 -0
- package/ENHANCEMENTS.md +310 -0
- package/FEATURE_ENHANCEMENTS.md +435 -0
- package/README.md +46 -13
- package/SAFETY_FEATURES.md +396 -0
- package/USAGE.md +225 -41
- package/VERSION_MANAGEMENT.md +438 -0
- package/dist/cli.js +116 -7
- package/dist/commands/build/releases.js +57 -0
- package/dist/commands/buildReleases.js +48 -74
- package/dist/commands/clean/flutter.js +51 -0
- package/dist/commands/clean/ios.js +109 -0
- package/dist/commands/cleanProject.js +34 -4
- package/dist/commands/cleanProjectIos.js +17 -7
- package/dist/commands/config/init.js +54 -0
- package/dist/commands/config/rollback.js +161 -0
- package/dist/commands/generateModule.js +39 -11
- package/dist/commands/init.js +54 -0
- package/dist/commands/openProject.js +17 -0
- package/dist/commands/project/devices.js +188 -0
- package/dist/commands/project/generate.js +143 -0
- package/dist/commands/project/open.js +63 -0
- package/dist/commands/project/setup.js +46 -0
- package/dist/commands/rollback.js +161 -0
- package/dist/commands/setupVSCode.js +27 -21
- package/dist/commands/updateVersions.js +13 -1
- package/dist/commands/version/bump.js +161 -0
- package/dist/commands/version/update.js +91 -0
- package/dist/commands/version.js +161 -0
- package/dist/constants.js +131 -0
- package/dist/utils/backupHelpers.js +88 -0
- package/dist/utils/buildHelpers.js +55 -0
- package/dist/utils/commandHelpers.js +51 -0
- package/dist/utils/configHelpers.js +80 -0
- package/dist/utils/dryRunHelpers.js +103 -0
- package/dist/utils/fileHelpers.js +2 -1
- package/dist/utils/helpers/build.js +55 -0
- package/dist/utils/helpers/dryRun.js +103 -0
- package/dist/utils/helpers/file.js +24 -0
- package/dist/utils/helpers/string.js +3 -0
- package/dist/utils/helpers/version.js +80 -0
- package/dist/utils/services/backup.js +88 -0
- package/dist/utils/services/command.js +51 -0
- package/dist/utils/services/config.js +80 -0
- package/dist/utils/services/exec.js +132 -0
- package/dist/utils/services/logger.js +15 -0
- package/dist/utils/validationHelpers.js +101 -0
- package/dist/utils/validators/validation.js +101 -0
- package/dist/utils/versionHelpers.js +80 -0
- package/package.json +1 -1
- package/src/cli.ts +165 -7
- package/src/commands/build/releases.ts +79 -0
- package/src/commands/clean/flutter.ts +58 -0
- package/src/commands/{cleanProjectIos.ts → clean/ios.ts} +19 -10
- package/src/commands/config/init.ts +63 -0
- package/src/commands/config/rollback.ts +200 -0
- package/src/commands/project/devices.ts +246 -0
- package/src/commands/{generateModule.ts → project/generate.ts} +47 -17
- package/src/commands/{openProject.ts → project/open.ts} +26 -5
- package/src/commands/project/setup.ts +50 -0
- package/src/commands/version/bump.ts +202 -0
- package/src/commands/{updateVersions.ts → version/update.ts} +22 -6
- package/src/constants.ts +144 -0
- package/src/utils/helpers/build.ts +80 -0
- package/src/utils/helpers/dryRun.ts +124 -0
- package/src/utils/{fileHelpers.ts → helpers/file.ts} +3 -2
- package/src/utils/helpers/version.ts +109 -0
- package/src/utils/services/backup.ts +109 -0
- package/src/utils/services/command.ts +76 -0
- package/src/utils/services/config.ts +106 -0
- package/src/utils/{execHelpers.ts → services/exec.ts} +1 -1
- package/src/utils/validators/validation.ts +122 -0
- package/src/commands/buildReleases.ts +0 -102
- package/src/commands/cleanProject.ts +0 -25
- package/src/commands/setupVSCode.ts +0 -44
- /package/src/utils/{stringHelpers.ts → helpers/string.ts} +0 -0
- /package/src/utils/{loggerHelpers.ts → services/logger.ts} +0 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# OptiKit CLI - Smart Version Management
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
OptiKit provides intelligent version management that handles the complexities of Flutter's dual build number system (iOS and Android) automatically.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🎯 The Problem
|
|
10
|
+
|
|
11
|
+
Flutter apps have **two separate build numbers**:
|
|
12
|
+
- **Android**: Single build number in `pubspec.yaml` (e.g., `1.0.0+5`)
|
|
13
|
+
- **iOS**: Separate build number in Xcode project
|
|
14
|
+
|
|
15
|
+
**Common scenarios:**
|
|
16
|
+
1. **New version release** → Increment version, reset iOS build to 1, increment Android build
|
|
17
|
+
2. **TestFlight upload** → Keep version same, only increment iOS build
|
|
18
|
+
3. **Google Play upload** → Keep version same, only increment Android build
|
|
19
|
+
|
|
20
|
+
OptiKit handles all these scenarios automatically!
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 📱 Commands
|
|
25
|
+
|
|
26
|
+
### 1. Show Current Version
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
optikit version
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Output:**
|
|
33
|
+
```
|
|
34
|
+
📱 Current Version Information
|
|
35
|
+
|
|
36
|
+
Version: 1.2.3+45
|
|
37
|
+
Major: 1
|
|
38
|
+
Minor: 2
|
|
39
|
+
Patch: 3
|
|
40
|
+
Build: 45
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
### 2. Bump Version (Semantic Versioning)
|
|
46
|
+
|
|
47
|
+
#### Bump Patch (1.2.3 → 1.2.4)
|
|
48
|
+
```bash
|
|
49
|
+
optikit version bump patch
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**What it does:**
|
|
53
|
+
- Increments patch number: `1.2.3` → `1.2.4`
|
|
54
|
+
- Increments Android build: `45` → `46`
|
|
55
|
+
- **Resets iOS build to 1** (new version = fresh start)
|
|
56
|
+
|
|
57
|
+
**Use when:**
|
|
58
|
+
- Bug fixes
|
|
59
|
+
- Minor updates
|
|
60
|
+
- No new features
|
|
61
|
+
|
|
62
|
+
#### Bump Minor (1.2.4 → 1.3.0)
|
|
63
|
+
```bash
|
|
64
|
+
optikit version bump minor
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**What it does:**
|
|
68
|
+
- Increments minor number: `1.2` → `1.3`
|
|
69
|
+
- Resets patch to 0: `1.2.4` → `1.3.0`
|
|
70
|
+
- Increments Android build: `46` → `47`
|
|
71
|
+
- **Resets iOS build to 1**
|
|
72
|
+
|
|
73
|
+
**Use when:**
|
|
74
|
+
- New features added
|
|
75
|
+
- Backward-compatible changes
|
|
76
|
+
|
|
77
|
+
#### Bump Major (1.3.0 → 2.0.0)
|
|
78
|
+
```bash
|
|
79
|
+
optikit version bump major
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**What it does:**
|
|
83
|
+
- Increments major number: `1` → `2`
|
|
84
|
+
- Resets minor and patch to 0: `1.3.0` → `2.0.0`
|
|
85
|
+
- Increments Android build: `47` → `48`
|
|
86
|
+
- **Resets iOS build to 1**
|
|
87
|
+
|
|
88
|
+
**Use when:**
|
|
89
|
+
- Breaking changes
|
|
90
|
+
- Major redesign
|
|
91
|
+
- Complete rewrite
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### 3. Bump iOS Build Only (TestFlight)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
optikit version bump-ios
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**What it does:**
|
|
102
|
+
- **Only** increments iOS build number
|
|
103
|
+
- Keeps version unchanged
|
|
104
|
+
- Keeps Android build unchanged
|
|
105
|
+
|
|
106
|
+
**Example:**
|
|
107
|
+
```
|
|
108
|
+
Before:
|
|
109
|
+
Version: 1.2.3
|
|
110
|
+
Android: 45
|
|
111
|
+
iOS: 1
|
|
112
|
+
|
|
113
|
+
After:
|
|
114
|
+
Version: 1.2.3 (unchanged)
|
|
115
|
+
Android: 45 (unchanged)
|
|
116
|
+
iOS: 2 ✅
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Use when:**
|
|
120
|
+
- Uploading to TestFlight
|
|
121
|
+
- iOS-only fixes
|
|
122
|
+
- Testing iOS-specific features
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### 4. Bump Android Build Only
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
optikit version bump-android
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**What it does:**
|
|
133
|
+
- **Only** increments Android build number
|
|
134
|
+
- Keeps version unchanged
|
|
135
|
+
- Keeps iOS build unchanged
|
|
136
|
+
|
|
137
|
+
**Example:**
|
|
138
|
+
```
|
|
139
|
+
Before:
|
|
140
|
+
Version: 1.2.3+45
|
|
141
|
+
iOS: 1
|
|
142
|
+
|
|
143
|
+
After:
|
|
144
|
+
Version: 1.2.3+46 ✅
|
|
145
|
+
iOS: 1 (unchanged)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Use when:**
|
|
149
|
+
- Uploading to Google Play
|
|
150
|
+
- Android-only fixes
|
|
151
|
+
- Testing Android-specific features
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 📊 Version Strategy
|
|
156
|
+
|
|
157
|
+
### Scenario 1: New App Version Release
|
|
158
|
+
|
|
159
|
+
**Goal:** Release version 1.0.3 (from 1.0.2)
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Current: 1.0.2+5
|
|
163
|
+
optikit version bump patch
|
|
164
|
+
|
|
165
|
+
# Result:
|
|
166
|
+
# Version: 1.0.3+6
|
|
167
|
+
# iOS build: 1 (reset)
|
|
168
|
+
# Android build: 6 (incremented)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Why iOS resets to 1?**
|
|
172
|
+
- New version = new submission to App Store
|
|
173
|
+
- Build numbers restart for each version in App Store Connect
|
|
174
|
+
- This matches Apple's expectation
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### Scenario 2: Multiple TestFlight Builds
|
|
179
|
+
|
|
180
|
+
**Goal:** Upload multiple iOS test builds without changing version
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
# Current: 1.0.3+6 (iOS build: 1)
|
|
184
|
+
|
|
185
|
+
# First TestFlight upload
|
|
186
|
+
optikit version bump-ios
|
|
187
|
+
# Version: 1.0.3+6, iOS: 2
|
|
188
|
+
|
|
189
|
+
# Found a bug, fix it, upload again
|
|
190
|
+
optikit version bump-ios
|
|
191
|
+
# Version: 1.0.3+6, iOS: 3
|
|
192
|
+
|
|
193
|
+
# Another fix
|
|
194
|
+
optikit version bump-ios
|
|
195
|
+
# Version: 1.0.3+6, iOS: 4
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Perfect for:**
|
|
199
|
+
- Internal testing
|
|
200
|
+
- Beta testing
|
|
201
|
+
- Multiple TestFlight iterations
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
### Scenario 3: Android Hotfix
|
|
206
|
+
|
|
207
|
+
**Goal:** Fix Android-only bug and upload to Google Play
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# Current: 1.0.3+6 (iOS: 4)
|
|
211
|
+
|
|
212
|
+
# Increment Android build only
|
|
213
|
+
optikit version bump-android
|
|
214
|
+
# Version: 1.0.3+7, iOS: 4 (unchanged)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
### Scenario 4: Complete Release Cycle
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# 1. Start: 1.0.2+10 (iOS: 5)
|
|
223
|
+
|
|
224
|
+
# 2. New feature development
|
|
225
|
+
optikit version bump minor
|
|
226
|
+
# → 1.1.0+11 (iOS: 1, Android: 11)
|
|
227
|
+
|
|
228
|
+
# 3. TestFlight testing (3 iterations)
|
|
229
|
+
optikit version bump-ios # iOS: 2
|
|
230
|
+
optikit version bump-ios # iOS: 3
|
|
231
|
+
optikit version bump-ios # iOS: 4
|
|
232
|
+
|
|
233
|
+
# 4. Android beta testing
|
|
234
|
+
optikit version bump-android # Android: 12
|
|
235
|
+
|
|
236
|
+
# 5. Fix found during testing
|
|
237
|
+
optikit version bump patch
|
|
238
|
+
# → 1.1.1+13 (iOS: 1, Android: 13)
|
|
239
|
+
|
|
240
|
+
# 6. Final TestFlight
|
|
241
|
+
optikit version bump-ios # iOS: 2
|
|
242
|
+
|
|
243
|
+
# 7. Release to stores!
|
|
244
|
+
# iOS: 1.1.1 (build 2)
|
|
245
|
+
# Android: 1.1.1 (build 13)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 🎨 Visual Examples
|
|
251
|
+
|
|
252
|
+
### Example 1: Patch Bump
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
BEFORE: AFTER:
|
|
256
|
+
┌─────────────┐ ┌─────────────┐
|
|
257
|
+
│ Version │ │ Version │
|
|
258
|
+
│ 1.2.3 │ ───> │ 1.2.4 │ ✅ Patch +1
|
|
259
|
+
│ │ │ │
|
|
260
|
+
│ Android: 45 │ ───> │ Android: 46 │ ✅ Build +1
|
|
261
|
+
│ iOS: 3 │ ───> │ iOS: 1 │ ✅ Reset to 1
|
|
262
|
+
└─────────────┘ └─────────────┘
|
|
263
|
+
|
|
264
|
+
Command: optikit version bump patch
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Example 2: iOS-Only Bump
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
BEFORE: AFTER:
|
|
271
|
+
┌─────────────┐ ┌─────────────┐
|
|
272
|
+
│ Version │ │ Version │
|
|
273
|
+
│ 1.2.4 │ ───> │ 1.2.4 │ ⏸️ Unchanged
|
|
274
|
+
│ │ │ │
|
|
275
|
+
│ Android: 46 │ ───> │ Android: 46 │ ⏸️ Unchanged
|
|
276
|
+
│ iOS: 1 │ ───> │ iOS: 2 │ ✅ Build +1
|
|
277
|
+
└─────────────┘ └─────────────┘
|
|
278
|
+
|
|
279
|
+
Command: optikit version bump-ios
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## 🔍 Technical Details
|
|
285
|
+
|
|
286
|
+
### File Updates
|
|
287
|
+
|
|
288
|
+
#### Version Bump Commands Update:
|
|
289
|
+
1. **pubspec.yaml**: `version: X.Y.Z+B`
|
|
290
|
+
2. **iOS project.pbxproj**: `MARKETING_VERSION` and `CURRENT_PROJECT_VERSION`
|
|
291
|
+
3. **iOS Info.plist**: `CFBundleShortVersionString` and `CFBundleVersion`
|
|
292
|
+
|
|
293
|
+
#### Automatic Backups:
|
|
294
|
+
All files are backed up before modification (see [SAFETY_FEATURES.md](SAFETY_FEATURES.md))
|
|
295
|
+
|
|
296
|
+
### Version Format
|
|
297
|
+
|
|
298
|
+
**pubspec.yaml:**
|
|
299
|
+
```yaml
|
|
300
|
+
version: 1.2.3+45
|
|
301
|
+
│ │ │ │
|
|
302
|
+
│ │ │ └─ Build number (Android)
|
|
303
|
+
│ │ └──── Patch
|
|
304
|
+
│ └────── Minor
|
|
305
|
+
└──────── Major
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**iOS (separate):**
|
|
309
|
+
- **CFBundleShortVersionString**: `1.2.3` (display version)
|
|
310
|
+
- **CFBundleVersion**: `1`, `2`, `3`... (build number)
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 📋 Command Reference
|
|
315
|
+
|
|
316
|
+
| Command | Version | Android Build | iOS Build | Use Case |
|
|
317
|
+
|---------|---------|---------------|-----------|----------|
|
|
318
|
+
| `version bump patch` | +0.0.1 | +1 | Reset to 1 | Bug fixes |
|
|
319
|
+
| `version bump minor` | +0.1.0 | +1 | Reset to 1 | New features |
|
|
320
|
+
| `version bump major` | +1.0.0 | +1 | Reset to 1 | Breaking changes |
|
|
321
|
+
| `version bump-ios` | No change | No change | +1 | TestFlight builds |
|
|
322
|
+
| `version bump-android` | No change | +1 | No change | Google Play builds |
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## 🎯 Best Practices
|
|
327
|
+
|
|
328
|
+
### 1. Always Use Semantic Versioning
|
|
329
|
+
```bash
|
|
330
|
+
# Bug fix
|
|
331
|
+
optikit version bump patch
|
|
332
|
+
|
|
333
|
+
# New feature
|
|
334
|
+
optikit version bump minor
|
|
335
|
+
|
|
336
|
+
# Breaking change
|
|
337
|
+
optikit version bump major
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### 2. TestFlight Workflow
|
|
341
|
+
```bash
|
|
342
|
+
# Create new version
|
|
343
|
+
optikit version bump minor
|
|
344
|
+
|
|
345
|
+
# Multiple TestFlight uploads
|
|
346
|
+
optikit version bump-ios # Upload 1
|
|
347
|
+
optikit version bump-ios # Upload 2
|
|
348
|
+
optikit version bump-ios # Upload 3
|
|
349
|
+
|
|
350
|
+
# When satisfied, release to App Store
|
|
351
|
+
# (No additional command needed)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### 3. Hotfix Workflow
|
|
355
|
+
```bash
|
|
356
|
+
# iOS hotfix
|
|
357
|
+
optikit version bump patch
|
|
358
|
+
optikit flutter-build-ipa
|
|
359
|
+
|
|
360
|
+
# Android hotfix
|
|
361
|
+
optikit version bump patch
|
|
362
|
+
optikit flutter-build-bundle
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### 4. Check Before Bumping
|
|
366
|
+
```bash
|
|
367
|
+
# Always check current version first
|
|
368
|
+
optikit version
|
|
369
|
+
|
|
370
|
+
# Then bump
|
|
371
|
+
optikit version bump patch
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## ⚠️ Important Notes
|
|
377
|
+
|
|
378
|
+
### iOS Build Number Strategy
|
|
379
|
+
|
|
380
|
+
**Why reset to 1?**
|
|
381
|
+
- App Store Connect requires unique build numbers **per version**
|
|
382
|
+
- Build 1 of version 1.0.0 ≠ Build 1 of version 1.0.1
|
|
383
|
+
- This matches Apple's system and prevents confusion
|
|
384
|
+
|
|
385
|
+
**Example:**
|
|
386
|
+
```
|
|
387
|
+
App Store Connect:
|
|
388
|
+
├── Version 1.0.0
|
|
389
|
+
│ ├── Build 1
|
|
390
|
+
│ ├── Build 2
|
|
391
|
+
│ └── Build 3 ✅ Released
|
|
392
|
+
└── Version 1.0.1
|
|
393
|
+
├── Build 1 ← Starts fresh
|
|
394
|
+
├── Build 2
|
|
395
|
+
└── Build 3 ✅ Released
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Android Build Number Strategy
|
|
399
|
+
|
|
400
|
+
**Why always increment?**
|
|
401
|
+
- Google Play requires strictly increasing build numbers
|
|
402
|
+
- Build 45 < Build 46 < Build 47
|
|
403
|
+
- Never reset, always increment
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## 🚀 Quick Reference
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# Show current version
|
|
411
|
+
optikit version
|
|
412
|
+
|
|
413
|
+
# Release new version
|
|
414
|
+
optikit version bump patch # 1.0.0 → 1.0.1
|
|
415
|
+
optikit version bump minor # 1.0.1 → 1.1.0
|
|
416
|
+
optikit version bump major # 1.1.0 → 2.0.0
|
|
417
|
+
|
|
418
|
+
# TestFlight only
|
|
419
|
+
optikit version bump-ios
|
|
420
|
+
|
|
421
|
+
# Google Play only
|
|
422
|
+
optikit version bump-android
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## 📖 Related Documentation
|
|
428
|
+
|
|
429
|
+
- [ENHANCEMENTS.md](ENHANCEMENTS.md) - Bug fixes
|
|
430
|
+
- [SAFETY_FEATURES.md](SAFETY_FEATURES.md) - Backups & validation
|
|
431
|
+
- [CODE_QUALITY.md](CODE_QUALITY.md) - Architecture
|
|
432
|
+
- [FEATURE_ENHANCEMENTS.md](FEATURE_ENHANCEMENTS.md) - New features
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
**Version:** 1.1.1+smart-versioning
|
|
437
|
+
**Last Updated:** December 23, 2025
|
|
438
|
+
**Status:** ✅ Production Ready
|
package/dist/cli.js
CHANGED
|
@@ -3,15 +3,19 @@ import chalk from "chalk";
|
|
|
3
3
|
import boxen from "boxen";
|
|
4
4
|
import yargs from "yargs/yargs";
|
|
5
5
|
import { hideBin } from "yargs/helpers";
|
|
6
|
-
import { generateModule } from "./commands/
|
|
7
|
-
import { cleanProject } from "./commands/
|
|
8
|
-
import { cleanIosProject } from "./commands/
|
|
9
|
-
import { updateFlutterVersion } from "./commands/
|
|
10
|
-
import { buildFlutterApk, buildFlutterBundle, buildFlutterIos, buildFlutterIpa, } from "./commands/
|
|
6
|
+
import { generateModule } from "./commands/project/generate.js";
|
|
7
|
+
import { cleanProject } from "./commands/clean/flutter.js";
|
|
8
|
+
import { cleanIosProject } from "./commands/clean/ios.js";
|
|
9
|
+
import { updateFlutterVersion } from "./commands/version/update.js";
|
|
10
|
+
import { buildFlutterApk, buildFlutterBundle, buildFlutterIos, buildFlutterIpa, } from "./commands/build/releases.js";
|
|
11
11
|
import { boxenOptions } from "./styles.js";
|
|
12
|
-
import { openIos, openAndroid } from "./commands/
|
|
12
|
+
import { openIos, openAndroid } from "./commands/project/open.js";
|
|
13
13
|
import { createRequire } from "module";
|
|
14
|
-
import { createVscodeSettings } from "./commands/
|
|
14
|
+
import { createVscodeSettings } from "./commands/project/setup.js";
|
|
15
|
+
import { initializeProject } from "./commands/config/init.js";
|
|
16
|
+
import { rollbackFiles, rollbackRestore } from "./commands/config/rollback.js";
|
|
17
|
+
import { bumpVersion, bumpIosBuildOnly, bumpAndroidBuildOnly, showCurrentVersion } from "./commands/version/bump.js";
|
|
18
|
+
import { listDevices, runApp, runAppInteractive } from "./commands/project/devices.js";
|
|
15
19
|
const require = createRequire(import.meta.url);
|
|
16
20
|
const packageInfo = require("../package.json");
|
|
17
21
|
const version = packageInfo.version;
|
|
@@ -127,6 +131,111 @@ const options = yargs(hideBin(process.argv))
|
|
|
127
131
|
await openAndroid();
|
|
128
132
|
}).command("setup-vscode", "Create a .vscode folder with recommended Flutter settings", () => { }, async () => {
|
|
129
133
|
await createVscodeSettings();
|
|
134
|
+
})
|
|
135
|
+
.command("init", "Initialize OptiKit configuration in the current project", () => { }, async () => {
|
|
136
|
+
await initializeProject();
|
|
137
|
+
})
|
|
138
|
+
.command("rollback", "List and restore files from OptiKit backups", (yargs) => {
|
|
139
|
+
return yargs.option("restore", {
|
|
140
|
+
type: "number",
|
|
141
|
+
description: "Restore backup by index number",
|
|
142
|
+
demandOption: false,
|
|
143
|
+
});
|
|
144
|
+
}, async (argv) => {
|
|
145
|
+
const restoreIndex = argv.restore;
|
|
146
|
+
if (restoreIndex !== undefined) {
|
|
147
|
+
await rollbackRestore(restoreIndex);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
await rollbackFiles();
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
.command("version", "Show current version information", () => { }, async () => {
|
|
154
|
+
await showCurrentVersion();
|
|
155
|
+
})
|
|
156
|
+
.command("version bump <type>", "Bump version (major, minor, or patch)", (yargs) => {
|
|
157
|
+
return yargs.positional("type", {
|
|
158
|
+
describe: "Version bump type (major, minor, patch)",
|
|
159
|
+
type: "string",
|
|
160
|
+
choices: ["major", "minor", "patch"],
|
|
161
|
+
});
|
|
162
|
+
}, async (argv) => {
|
|
163
|
+
const type = argv.type;
|
|
164
|
+
await bumpVersion(type);
|
|
165
|
+
})
|
|
166
|
+
.command("version bump-ios", "Increment iOS build number only (for TestFlight)", () => { }, async () => {
|
|
167
|
+
await bumpIosBuildOnly();
|
|
168
|
+
})
|
|
169
|
+
.command("version bump-android", "Increment Android build number only", () => { }, async () => {
|
|
170
|
+
await bumpAndroidBuildOnly();
|
|
171
|
+
})
|
|
172
|
+
.command("devices", "List all connected devices", (yargs) => {
|
|
173
|
+
return yargs.option("disable-fvm", {
|
|
174
|
+
type: "boolean",
|
|
175
|
+
default: false,
|
|
176
|
+
description: "Run without FVM (use --disable-fvm to enable)",
|
|
177
|
+
});
|
|
178
|
+
}, async (argv) => {
|
|
179
|
+
const useFvm = !argv.disableFvm;
|
|
180
|
+
await listDevices(useFvm);
|
|
181
|
+
})
|
|
182
|
+
.command("run", "Run Flutter app on connected device", (yargs) => {
|
|
183
|
+
return yargs
|
|
184
|
+
.option("device", {
|
|
185
|
+
alias: "d",
|
|
186
|
+
type: "string",
|
|
187
|
+
description: "Specific device ID to run on",
|
|
188
|
+
})
|
|
189
|
+
.option("release", {
|
|
190
|
+
alias: "r",
|
|
191
|
+
type: "boolean",
|
|
192
|
+
default: false,
|
|
193
|
+
description: "Run in release mode",
|
|
194
|
+
})
|
|
195
|
+
.option("flavor", {
|
|
196
|
+
alias: "f",
|
|
197
|
+
type: "string",
|
|
198
|
+
description: "Build flavor to use",
|
|
199
|
+
})
|
|
200
|
+
.option("disable-fvm", {
|
|
201
|
+
type: "boolean",
|
|
202
|
+
default: false,
|
|
203
|
+
description: "Run without FVM (use --disable-fvm to enable)",
|
|
204
|
+
});
|
|
205
|
+
}, async (argv) => {
|
|
206
|
+
const useFvm = !argv.disableFvm;
|
|
207
|
+
await runApp({
|
|
208
|
+
device: argv.device,
|
|
209
|
+
release: argv.release,
|
|
210
|
+
flavor: argv.flavor,
|
|
211
|
+
useFvm,
|
|
212
|
+
});
|
|
213
|
+
})
|
|
214
|
+
.command("run-select", "Interactive device selection and run", (yargs) => {
|
|
215
|
+
return yargs
|
|
216
|
+
.option("release", {
|
|
217
|
+
alias: "r",
|
|
218
|
+
type: "boolean",
|
|
219
|
+
default: false,
|
|
220
|
+
description: "Run in release mode",
|
|
221
|
+
})
|
|
222
|
+
.option("flavor", {
|
|
223
|
+
alias: "f",
|
|
224
|
+
type: "string",
|
|
225
|
+
description: "Build flavor to use",
|
|
226
|
+
})
|
|
227
|
+
.option("disable-fvm", {
|
|
228
|
+
type: "boolean",
|
|
229
|
+
default: false,
|
|
230
|
+
description: "Run without FVM (use --disable-fvm to enable)",
|
|
231
|
+
});
|
|
232
|
+
}, async (argv) => {
|
|
233
|
+
const useFvm = !argv.disableFvm;
|
|
234
|
+
await runAppInteractive({
|
|
235
|
+
release: argv.release,
|
|
236
|
+
flavor: argv.flavor,
|
|
237
|
+
useFvm,
|
|
238
|
+
});
|
|
130
239
|
})
|
|
131
240
|
.version(version)
|
|
132
241
|
.help(true).argv;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { executeBuild } from "../../utils/helpers/build.js";
|
|
2
|
+
import { BUILD_CONFIGS } from "../../constants.js";
|
|
3
|
+
export { buildFlutterApk, buildFlutterBundle, buildFlutterIos, buildFlutterIpa, };
|
|
4
|
+
/**
|
|
5
|
+
* Builds Flutter APK with release configuration, obfuscation, and split debug info
|
|
6
|
+
* @param noFvm - Whether to disable FVM usage
|
|
7
|
+
*/
|
|
8
|
+
async function buildFlutterApk(noFvm) {
|
|
9
|
+
await executeBuild({
|
|
10
|
+
type: "APK",
|
|
11
|
+
command: "flutter build apk",
|
|
12
|
+
flags: [
|
|
13
|
+
...BUILD_CONFIGS.APK.flags,
|
|
14
|
+
`--split-debug-info=${BUILD_CONFIGS.APK.outputPath}`,
|
|
15
|
+
],
|
|
16
|
+
requireAndroid: true,
|
|
17
|
+
}, noFvm);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Builds Flutter App Bundle with release configuration, obfuscation, and split debug info
|
|
21
|
+
* @param noFvm - Whether to disable FVM usage
|
|
22
|
+
*/
|
|
23
|
+
async function buildFlutterBundle(noFvm) {
|
|
24
|
+
await executeBuild({
|
|
25
|
+
type: "Bundle",
|
|
26
|
+
command: "flutter build appbundle",
|
|
27
|
+
flags: [
|
|
28
|
+
...BUILD_CONFIGS.BUNDLE.flags,
|
|
29
|
+
`--split-debug-info=${BUILD_CONFIGS.BUNDLE.outputPath}`,
|
|
30
|
+
],
|
|
31
|
+
requireAndroid: true,
|
|
32
|
+
}, noFvm);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Builds Flutter iOS app with release configuration
|
|
36
|
+
* @param noFvm - Whether to disable FVM usage
|
|
37
|
+
*/
|
|
38
|
+
async function buildFlutterIos(noFvm) {
|
|
39
|
+
await executeBuild({
|
|
40
|
+
type: "iOS app",
|
|
41
|
+
command: "flutter build ios",
|
|
42
|
+
flags: [...BUILD_CONFIGS.IOS.flags],
|
|
43
|
+
requireIos: true,
|
|
44
|
+
}, noFvm);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates release IPA with updated build version number
|
|
48
|
+
* @param noFvm - Whether to disable FVM usage
|
|
49
|
+
*/
|
|
50
|
+
async function buildFlutterIpa(noFvm) {
|
|
51
|
+
await executeBuild({
|
|
52
|
+
type: "IPA",
|
|
53
|
+
command: "flutter build ipa",
|
|
54
|
+
flags: [...BUILD_CONFIGS.IPA.flags],
|
|
55
|
+
requireIos: true,
|
|
56
|
+
}, noFvm);
|
|
57
|
+
}
|