@everystack/cli 0.2.24 → 0.2.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everystack/cli",
3
- "version": "0.2.24",
3
+ "version": "0.2.26",
4
4
  "description": "CLI and OTA updates for Expo apps on everystack",
5
5
  "license": "AGPL-3.0-only",
6
6
  "publishConfig": {
@@ -226,7 +226,9 @@ export async function discoverBuckets(
226
226
 
227
227
  const updatesNeedle = `${prefix}updatesbucket-`.toLowerCase();
228
228
  const clientNeedle = `${prefix}clientbundlesbucket-`.toLowerCase();
229
- const mediaNeedle = `${prefix}mediabucket-`.toLowerCase();
229
+ // Media bucket resource is named 'Media' (not 'MediaBucket'), so match both patterns
230
+ const mediaNeedle = `${prefix}media-`.toLowerCase();
231
+ const mediaBucketNeedle = `${prefix}mediabucket-`.toLowerCase();
230
232
 
231
233
  let updatesBucket: string | undefined;
232
234
  let clientBundlesBucket: string | undefined;
@@ -237,7 +239,7 @@ export async function discoverBuckets(
237
239
  const lower = b.Name.toLowerCase();
238
240
  if (lower.startsWith(updatesNeedle)) updatesBucket = b.Name;
239
241
  if (lower.startsWith(clientNeedle)) clientBundlesBucket = b.Name;
240
- if (lower.startsWith(mediaNeedle)) mediaBucket = b.Name;
242
+ if (!mediaBucket && (lower.startsWith(mediaNeedle) || lower.startsWith(mediaBucketNeedle))) mediaBucket = b.Name;
241
243
  if (updatesBucket && clientBundlesBucket && mediaBucket) break;
242
244
  }
243
245
 
@@ -311,15 +313,18 @@ export async function discoverConfig(
311
313
  // ---------------------------------------------------------------------------
312
314
 
313
315
  const CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
316
+ const CACHE_VERSION = 2; // Bump when CachedOutputs schema changes to invalidate stale caches
314
317
 
315
318
  interface CachedOutputs {
316
319
  _cachedAt: number;
320
+ _version?: number;
317
321
  routerUrl?: string;
318
322
  apiFunctionName?: string;
319
323
  imageFunctionName?: string;
320
324
  workerFunctionName?: string;
321
325
  updatesBucket?: string;
322
326
  clientBundlesBucket?: string;
327
+ mediaBucket?: string;
323
328
  kvsArn?: string;
324
329
  distributionId?: string;
325
330
  }
@@ -332,6 +337,7 @@ export async function getCachedConfig(stage: string): Promise<DiscoveredConfig |
332
337
  try {
333
338
  const raw = await fs.readFile(cachePath(stage), 'utf8');
334
339
  const cached: CachedOutputs = JSON.parse(raw);
340
+ if ((cached._version || 0) < CACHE_VERSION) return null;
335
341
  if (Date.now() - cached._cachedAt > CACHE_TTL_MS) return null;
336
342
  if (!cached.apiFunctionName || !cached.updatesBucket || !cached.clientBundlesBucket) {
337
343
  return null;
@@ -344,6 +350,7 @@ export async function getCachedConfig(stage: string): Promise<DiscoveredConfig |
344
350
  workerFunctionName: cached.workerFunctionName,
345
351
  updatesBucket: cached.updatesBucket,
346
352
  clientBundlesBucket: cached.clientBundlesBucket,
353
+ mediaBucket: cached.mediaBucket,
347
354
  kvsArn: cached.kvsArn,
348
355
  distributionId: cached.distributionId,
349
356
  };
@@ -355,12 +362,14 @@ export async function getCachedConfig(stage: string): Promise<DiscoveredConfig |
355
362
  export async function setCachedConfig(stage: string, config: DiscoveredConfig): Promise<void> {
356
363
  const data: CachedOutputs = {
357
364
  _cachedAt: Date.now(),
365
+ _version: CACHE_VERSION,
358
366
  routerUrl: config.baseUrl,
359
367
  apiFunctionName: config.apiFunctionName,
360
368
  imageFunctionName: config.imageFunctionName,
361
369
  workerFunctionName: config.workerFunctionName,
362
370
  updatesBucket: config.updatesBucket,
363
371
  clientBundlesBucket: config.clientBundlesBucket,
372
+ mediaBucket: config.mediaBucket,
364
373
  kvsArn: config.kvsArn,
365
374
  distributionId: config.distributionId,
366
375
  };