@upfluxhq/cli 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -100,6 +100,8 @@ upflux release [options]
100
100
  | `-m, --mandatory` | | Mark update as mandatory |
101
101
  | `-r, --rollout <number>` | | Rollout percentage (0-100, default: 100) |
102
102
  | `-v, --version-range <range>` | | Binary version range (e.g., >=1.0.0) |
103
+ | `--min-binary-version <version>` | | Minimum native binary version required. Devices below this are directed to update from the App Store / Play Store before receiving this OTA. |
104
+ | `--skip-native-check` | | Skip automatic native change detection (useful in CI/CD) |
103
105
  | `--dev` | | Create development bundle |
104
106
  | `--skip-bundle` | | Skip bundling, use existing files in output dir |
105
107
  | `--schedule` | | Create as draft, set schedule time in dashboard |
@@ -168,6 +170,63 @@ upflux release --label v1.0.0 --capacitor --web-dir dist
168
170
 
169
171
  ---
170
172
 
173
+ ## Native Change Detection
174
+
175
+ The CLI automatically detects native code changes since your last release and warns you when a store update may be required. This helps prevent devices from receiving OTA updates that depend on native features not yet available in their installed binary.
176
+
177
+ ### How It Works
178
+
179
+ 1. After each successful release, the CLI saves the current **git commit hash** to `.upflux`.
180
+ 2. On the next release, it runs `git diff <lastHash>..HEAD` against native files.
181
+ 3. If changes are found, it warns you and offers to auto-set `--min-binary-version`.
182
+
183
+ > **Note:** Detection requires git. If the project is not a git repo, detection is silently skipped.
184
+
185
+ ### Files Watched
186
+
187
+ | File | What is detected |
188
+ |---|---|
189
+ | `android/app/build.gradle` | `versionName` bump, `minSdkVersion` change |
190
+ | `android/app/src/main/AndroidManifest.xml` | New permissions |
191
+ | `ios/Podfile` | New native pods |
192
+ | `ios/Podfile.lock` | Any pod version change |
193
+ | `package.json` | New native dependency packages |
194
+
195
+ ### Example Interaction
196
+
197
+ ```
198
+ ⚠️ Native changes detected since last release:
199
+
200
+ Android:
201
+ • build.gradle: versionName → 2.0.0
202
+ • AndroidManifest.xml: New permission: android.permission.CAMERA
203
+
204
+ 💡 Suggested flags:
205
+ --min-binary-version 2.0.0
206
+ --version-range ">=2.0.0"
207
+
208
+ ? How would you like to handle these native changes?
209
+ ❯ Auto-apply suggested flags (--min-binary-version 2.0.0 --version-range ">=2.0.0")
210
+ Enter min-binary-version manually
211
+ Continue without (not recommended for native changes)
212
+ ```
213
+
214
+ ### Setting `--min-binary-version` Manually
215
+
216
+ ```bash
217
+ # Require devices to have at least v2.0.0 binary before receiving this OTA
218
+ upflux release --label v2.0.0-ota --min-binary-version 2.0.0 --version-range ">=2.0.0"
219
+ ```
220
+
221
+ ### Skipping in CI/CD
222
+
223
+ ```bash
224
+ # In CI, skip interactive detection and pass flag explicitly
225
+ upflux release --label v2.0.0 --min-binary-version 2.0.0 --skip-native-check
226
+ ```
227
+
228
+ ---
229
+
171
230
  ### `status`
172
231
 
173
232
  Check deployment status and recent releases.
@@ -290,7 +349,9 @@ The CLI stores credentials in `.upflux` in the current directory:
290
349
  "deploymentName": "staging"
291
350
  }
292
351
  ],
293
- "activeIndex": 0
352
+ "activeIndex": 0,
353
+ "lastReleaseHash": "a3f8c12d...",
354
+ "lastReleaseLabel": "v1.5.0"
294
355
  }
295
356
  ```
296
357
 
@@ -271,9 +271,46 @@ function writeUpfluxConfig(outputDir, releaseLabel, appId) {
271
271
  appId,
272
272
  createdAt: new Date().toISOString(),
273
273
  };
274
+ const configContent = JSON.stringify(config, null, 2);
274
275
  const configPath = path.join(outputDir, "upflux.json");
275
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
276
+ fs.writeFileSync(configPath, configContent);
276
277
  console.log(chalk_1.default.gray(` Created upflux.json with version: ${releaseLabel}`));
278
+ // Also copy to native asset directories so the SDK can read the
279
+ // embedded version at runtime and skip unnecessary OTA downloads
280
+ copyUpfluxConfigToNativeAssets(configContent);
281
+ }
282
+ /**
283
+ * Copy upflux.json to native platform asset directories
284
+ *
285
+ * The React Native SDK reads upflux.json from native assets at runtime to detect
286
+ * which OTA version is embedded in the binary. Without this file in the right place,
287
+ * the SDK cannot compare embedded vs server versions, causing unnecessary downloads
288
+ * even when the Play Store / App Store binary already has the latest code.
289
+ *
290
+ * Android: android/app/src/main/assets/upflux.json
291
+ * iOS: ios/ (added to Xcode project bundle resources manually by developer)
292
+ *
293
+ * @param configContent - The JSON string content of upflux.json
294
+ */
295
+ function copyUpfluxConfigToNativeAssets(configContent) {
296
+ // Android: copy to assets directory where UpfluxModule.readAsset() can find it
297
+ const androidAssetsDir = path.resolve("android", "app", "src", "main", "assets");
298
+ if (fs.existsSync(path.resolve("android"))) {
299
+ // Ensure assets directory exists
300
+ if (!fs.existsSync(androidAssetsDir)) {
301
+ fs.mkdirSync(androidAssetsDir, { recursive: true });
302
+ }
303
+ const androidConfigPath = path.join(androidAssetsDir, "upflux.json");
304
+ fs.writeFileSync(androidConfigPath, configContent);
305
+ console.log(chalk_1.default.gray(` Copied upflux.json → android/app/src/main/assets/`));
306
+ }
307
+ // iOS: copy to ios/ project root (developer adds to Xcode bundle resources)
308
+ const iosDir = path.resolve("ios");
309
+ if (fs.existsSync(iosDir)) {
310
+ const iosConfigPath = path.join(iosDir, "upflux.json");
311
+ fs.writeFileSync(iosConfigPath, configContent);
312
+ console.log(chalk_1.default.gray(` Copied upflux.json → ios/`));
313
+ }
277
314
  }
278
315
  const release = new commander_1.Command("release")
279
316
  .description("Bundle and upload a new release to Upflux")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upfluxhq/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Upflux CLI for managing OTA updates",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",