@upfluxhq/cli 0.1.0-beta.3 → 0.1.0-beta.5

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.
@@ -203,6 +203,33 @@ assetsBaseDir, iosAssetsBaseDir, androidAssetsBaseDir) {
203
203
  contentType: guessContentType(assetPath),
204
204
  });
205
205
  }
206
+ // Add upflux.json config files for both platforms
207
+ if (iosAssetsBaseDir) {
208
+ const iosConfigPath = path.join(iosAssetsBaseDir, "upflux.json");
209
+ if (fs.existsSync(iosConfigPath)) {
210
+ files.push({
211
+ type: "asset",
212
+ platform: "ios",
213
+ filename: "upflux.json",
214
+ relativePath: "upflux.json",
215
+ localPath: iosConfigPath,
216
+ contentType: "application/json",
217
+ });
218
+ }
219
+ }
220
+ if (androidAssetsBaseDir) {
221
+ const androidConfigPath = path.join(androidAssetsBaseDir, "upflux.json");
222
+ if (fs.existsSync(androidConfigPath)) {
223
+ files.push({
224
+ type: "asset",
225
+ platform: "android",
226
+ filename: "upflux.json",
227
+ relativePath: "upflux.json",
228
+ localPath: androidConfigPath,
229
+ contentType: "application/json",
230
+ });
231
+ }
232
+ }
206
233
  }
207
234
  else {
208
235
  // Single-bundle mode
@@ -229,6 +256,19 @@ assetsBaseDir, iosAssetsBaseDir, androidAssetsBaseDir) {
229
256
  contentType: guessContentType(assetPath),
230
257
  });
231
258
  }
259
+ // Add upflux.json config file
260
+ if (assetsBaseDir) {
261
+ const configPath = path.join(assetsBaseDir, "upflux.json");
262
+ if (fs.existsSync(configPath)) {
263
+ files.push({
264
+ type: "asset",
265
+ filename: "upflux.json",
266
+ relativePath: "upflux.json",
267
+ localPath: configPath,
268
+ contentType: "application/json",
269
+ });
270
+ }
271
+ }
232
272
  }
233
273
  return files;
234
274
  }
@@ -254,6 +254,27 @@ function collectAssets(dir) {
254
254
  }
255
255
  return assets;
256
256
  }
257
+ /**
258
+ * Write upflux.json config file to the bundle output directory
259
+ *
260
+ * This file embeds the OTA version into the app bundle at build time.
261
+ * The SDK reads this on fresh install to know which version the app ships with,
262
+ * preventing unnecessary OTA downloads when the embedded bundle is already latest.
263
+ *
264
+ * @param outputDir - Directory to write upflux.json to
265
+ * @param releaseLabel - The OTA version (e.g., "v1.0.0")
266
+ * @param appId - The app ID
267
+ */
268
+ function writeUpfluxConfig(outputDir, releaseLabel, appId) {
269
+ const config = {
270
+ releaseLabel,
271
+ appId,
272
+ createdAt: new Date().toISOString(),
273
+ };
274
+ const configPath = path.join(outputDir, "upflux.json");
275
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
276
+ console.log(chalk_1.default.gray(` Created upflux.json with version: ${releaseLabel}`));
277
+ }
257
278
  const release = new commander_1.Command("release")
258
279
  .description("Bundle and upload a new release to Upflux")
259
280
  .option("-a, --app <appId>", "Application ID (uses stored value if not provided)")
@@ -404,6 +425,9 @@ const release = new commander_1.Command("release")
404
425
  if (!fs.existsSync(outputDir)) {
405
426
  fs.mkdirSync(outputDir, { recursive: true });
406
427
  }
428
+ // Write upflux.json to web directory BEFORE zipping
429
+ // This embeds the OTA version into the Capacitor app bundle
430
+ writeUpfluxConfig(webDirPath, opts.label, appId);
407
431
  // Zip the web directory
408
432
  console.log(chalk_1.default.blue(`📦 Zipping ${webDir}/ directory...`));
409
433
  const zipPath = path.join(outputDir, `bundle-${opts.label}.zip`);
@@ -506,6 +530,10 @@ const release = new commander_1.Command("release")
506
530
  androidAssetFiles = opts.assets
507
531
  ? opts.assets.map((p) => path.resolve(p))
508
532
  : collectAssets(androidAssetsPath);
533
+ // Write upflux.json to BOTH platform output directories
534
+ // React Native reads this from bundled assets to know embedded OTA version
535
+ writeUpfluxConfig(iosOutputDir, opts.label, appId);
536
+ writeUpfluxConfig(androidOutputDir, opts.label, appId);
509
537
  // Set bundlePath and assetFiles for display (use iOS as primary for logging)
510
538
  bundlePath = iosBundlePath;
511
539
  assetFiles = [...iosAssetFiles, ...androidAssetFiles];
@@ -548,6 +576,9 @@ const release = new commander_1.Command("release")
548
576
  console.warn(chalk_1.default.yellow(`⚠ ${invalidAssets.length} asset(s) not found, will be skipped`));
549
577
  assetFiles = assetFiles.filter(p => fs.existsSync(p));
550
578
  }
579
+ // Write upflux.json to output directory
580
+ // React Native reads this from bundled assets to know embedded OTA version
581
+ writeUpfluxConfig(outputDir, opts.label, appId);
551
582
  }
552
583
  }
553
584
  // ========================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upfluxhq/cli",
3
- "version": "0.1.0-beta.3",
3
+ "version": "0.1.0-beta.5",
4
4
  "description": "Upflux CLI for managing OTA updates",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",