@wix/himalaya-cli 0.1068.0 → 0.1069.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 (2) hide show
  1. package/dist/cli.mjs +50 -23
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -484,6 +484,36 @@ var init_ownership = __esm({
484
484
  }
485
485
  });
486
486
 
487
+ // ../../core/serve-storage/src/wip-pointer.ts
488
+ function wipSupported(store) {
489
+ if (!store.getWipRecord || !store.updateWipRecord) return false;
490
+ return store.supportsWip ? store.supportsWip() : true;
491
+ }
492
+ function normalizeWipRecord(value) {
493
+ if (!value || typeof value !== "object") return { wip: null, promoted: [], evictedBefore: null };
494
+ const v = value;
495
+ const wip = v.wip && typeof v.wip.releaseId === "string" ? v.wip : null;
496
+ const promoted = (Array.isArray(v.promoted) ? v.promoted : []).flatMap((entry) => {
497
+ if (typeof entry === "string") return [{ id: entry, at: null }];
498
+ const e = entry;
499
+ return e && typeof e.id === "string" ? [{ id: e.id, at: storedTime(e.at) }] : [];
500
+ });
501
+ return { wip, promoted, evictedBefore: storedTime(v.evictedBefore) };
502
+ }
503
+ async function readWip(store, app) {
504
+ if (!wipSupported(store)) return "unsupported";
505
+ const { wip, promoted } = normalizeWipRecord(await store.getWipRecord(app));
506
+ if (!wip || promoted.some((p) => p.id === wip.releaseId)) return null;
507
+ const live2 = await store.getManifest(app);
508
+ return live2?.releaseId === wip.releaseId ? null : wip;
509
+ }
510
+ var storedTime;
511
+ var init_wip_pointer = __esm({
512
+ "../../core/serve-storage/src/wip-pointer.ts"() {
513
+ storedTime = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) ? value : null;
514
+ }
515
+ });
516
+
487
517
  // ../../core/serve-storage/src/store.ts
488
518
  function validateFunctionManifest(manifest) {
489
519
  const dataErrors = validateDataResources(manifest.functionDataResources, manifest.app).filter((issue2) => issue2.severity === "error");
@@ -526,6 +556,14 @@ async function retainedReleaseRefs(store, app, keepRecent = 20, keepReleaseIds =
526
556
  }
527
557
  }
528
558
  }
559
+ const offered = await readWip(store, app);
560
+ if (offered && offered !== "unsupported" && !loaded.has(offered.releaseId) && store.getManifestById) {
561
+ const m = await store.getManifestById(app, offered.releaseId);
562
+ if (m) {
563
+ manifests.push(m);
564
+ loaded.add(m.releaseId);
565
+ }
566
+ }
529
567
  for (const releaseId of new Set(keepReleaseIds)) {
530
568
  if (loaded.has(releaseId)) continue;
531
569
  if (!store.getManifestById) throw new Error(`cannot retain function job release ${releaseId}: versioned manifest lookup is unsupported`);
@@ -554,6 +592,7 @@ var TEMPLATE_APP_PREFIX;
554
592
  var init_store = __esm({
555
593
  "../../core/serve-storage/src/store.ts"() {
556
594
  init_ownership();
595
+ init_wip_pointer();
557
596
  TEMPLATE_APP_PREFIX = "himi-template-";
558
597
  }
559
598
  });
@@ -764,34 +803,28 @@ var init_file_store = __esm({
764
803
  else ledger.push(entry);
765
804
  writeFileSync2(this.ledgerPath(app), JSON.stringify(ledger, null, 2));
766
805
  }
767
- // ---- RFC 0061 §3.1 owner-follow `wip` pointer ----
768
- // Inside the app directory, so `remove` and `reset` take it with the app. `clearWipIf` is a CAS
769
- // for the way this backend is deployed — ONE writer process (serve-control; serve only reads):
770
- // the read, compare and delete below are synchronous with no await between them, so no other
806
+ // ---- RFC 0061 §3.1 owner-follow `wip` record ----
807
+ // Inside the app directory, so `remove` and `reset` take it with the app. `updateWipRecord` is a
808
+ // CAS for the way this backend is deployed — ONE writer process (serve-control; serve only
809
+ // reads): the read, `fn` and write below are synchronous with no await between them, so no other
771
810
  // request in that process can land in the middle. It is not a cross-process lock.
772
- wipPath(app) {
773
- return join2(this.appDir(app), "_wip.json");
774
- }
775
811
  readWipSync(app) {
776
812
  const b = this.read(app, "_wip.json");
777
813
  if (!b) return null;
778
814
  try {
779
- const wip = JSON.parse(b.toString("utf8"));
780
- return wip && typeof wip.releaseId === "string" ? wip : null;
815
+ return JSON.parse(b.toString("utf8"));
781
816
  } catch {
782
817
  return null;
783
818
  }
784
819
  }
785
- async putWip(app, wip) {
786
- mkdirSync2(this.appDir(app), { recursive: true });
787
- writeFileSync2(this.wipPath(app), JSON.stringify(wip, null, 2));
788
- }
789
- async getWip(app) {
820
+ async getWipRecord(app) {
790
821
  return this.readWipSync(app);
791
822
  }
792
- async clearWipIf(app, releaseId) {
793
- if (this.readWipSync(app)?.releaseId !== releaseId) return false;
794
- rmSync(this.wipPath(app), { force: true });
823
+ async updateWipRecord(app, fn) {
824
+ const next = fn(this.readWipSync(app));
825
+ if (next === void 0) return false;
826
+ mkdirSync2(this.appDir(app), { recursive: true });
827
+ writeFileSync2(join2(this.appDir(app), "_wip.json"), JSON.stringify(next, null, 2));
795
828
  return true;
796
829
  }
797
830
  bundleUrl(_app, sha2565) {
@@ -38224,12 +38257,6 @@ var init_src6 = __esm({
38224
38257
  }
38225
38258
  });
38226
38259
 
38227
- // ../../core/serve-storage/src/wip-pointer.ts
38228
- var init_wip_pointer = __esm({
38229
- "../../core/serve-storage/src/wip-pointer.ts"() {
38230
- }
38231
- });
38232
-
38233
38260
  // ../../core/serve-storage/src/release-patch.ts
38234
38261
  import { createHash as createHash17 } from "node:crypto";
38235
38262
  function sha256hex(b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1068.0",
3
+ "version": "0.1069.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -65,5 +65,5 @@
65
65
  "artifactId": "himalaya-cli"
66
66
  }
67
67
  },
68
- "falconPackageHash": "d27d980f58b63c6236045887c8cfe93d017ac0d63ffdb1bcba762d90"
68
+ "falconPackageHash": "d66a8a95769c3eb84b52d4da2233db6689f1f833a2b254304aff2bc0"
69
69
  }