@wix/himalaya-cli 0.1709.0 → 0.1711.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/dist/cli.mjs CHANGED
@@ -27244,13 +27244,64 @@ function resolveServeBuildSha({ env = {}, git: git2 }) {
27244
27244
  }
27245
27245
  return "";
27246
27246
  }
27247
- var DEFAULT_BRANCH_REFS, FULL_SHA;
27247
+ function mergedDefaultBranchSha({ git: git2, head: head3, base: base2 }) {
27248
+ const tryGit2 = (args) => {
27249
+ try {
27250
+ const out2 = git2(args);
27251
+ return typeof out2 === "string" ? out2.trim() : "";
27252
+ } catch {
27253
+ return "";
27254
+ }
27255
+ };
27256
+ if (!FULL_SHA.test(head3 ?? "") || !FULL_SHA.test(base2 ?? "") || head3 === base2) return "";
27257
+ const ref = DEFAULT_BRANCH_REFS.find((r3) => {
27258
+ if (!tryGit2(["rev-parse", "--verify", "--quiet", r3])) return false;
27259
+ try {
27260
+ git2(["merge-base", "--is-ancestor", base2, r3]);
27261
+ return true;
27262
+ } catch {
27263
+ return false;
27264
+ }
27265
+ });
27266
+ if (!ref) return "";
27267
+ let rawPaths = "";
27268
+ try {
27269
+ rawPaths = String(git2(["diff", "--no-renames", "--name-only", "-z", base2, head3]));
27270
+ } catch {
27271
+ return "";
27272
+ }
27273
+ const paths2 = rawPaths.split("\0").filter(Boolean);
27274
+ if (paths2.length === 0 || paths2.length > MAX_MERGED_PATHS) return "";
27275
+ const candidates = tryGit2(["--literal-pathspecs", "rev-list", "--reverse", "--ancestry-path", `${base2}..${ref}`, "--", ...paths2]).split("\n").filter((c2) => FULL_SHA.test(c2)).slice(0, MAX_MERGED_CANDIDATES);
27276
+ let canMergeTree = true;
27277
+ for (const c2 of candidates) {
27278
+ if (canMergeTree) {
27279
+ try {
27280
+ const merged = String(git2(["merge-tree", "--write-tree", c2, head3])).split("\n")[0].trim();
27281
+ if (FULL_SHA.test(merged) && merged === tryGit2(["rev-parse", `${c2}^{tree}`])) return c2;
27282
+ continue;
27283
+ } catch (err) {
27284
+ if (err?.status === 1) continue;
27285
+ canMergeTree = false;
27286
+ }
27287
+ }
27288
+ try {
27289
+ git2(["--literal-pathspecs", "diff", "--quiet", c2, head3, "--", ...paths2]);
27290
+ return c2;
27291
+ } catch {
27292
+ }
27293
+ }
27294
+ return "";
27295
+ }
27296
+ var DEFAULT_BRANCH_REFS, FULL_SHA, MAX_MERGED_PATHS, MAX_MERGED_CANDIDATES;
27248
27297
  var init_build_sha = __esm({
27249
27298
  "../../packages/serve/scripts/build-sha.mjs"() {
27250
27299
  "use strict";
27251
27300
  init_define_HHP_CATALOG();
27252
27301
  DEFAULT_BRANCH_REFS = ["origin/master", "origin/main", "refs/remotes/origin/HEAD"];
27253
27302
  FULL_SHA = /^[0-9a-f]{40}$/i;
27303
+ MAX_MERGED_PATHS = 500;
27304
+ MAX_MERGED_CANDIDATES = 200;
27254
27305
  }
27255
27306
  });
27256
27307
 
@@ -33033,6 +33084,7 @@ function resolveIdiom(tokens2, ctx = {}) {
33033
33084
  var IDIOM_CONTEXTS, UNSAFE_KEYS;
33034
33085
  var init_idiom = __esm({
33035
33086
  "../../core/ts/src/idiom.ts"() {
33087
+ "use strict";
33036
33088
  init_define_HHP_CATALOG();
33037
33089
  IDIOM_CONTEXTS = {
33038
33090
  ios: { native: ["ios"] },
@@ -34855,6 +34907,7 @@ function shouldRevealError(args) {
34855
34907
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE, AUTHORED_PATTERN_LIMIT, authoredPatterns;
34856
34908
  var init_validation = __esm({
34857
34909
  "../../core/ts/src/validation.ts"() {
34910
+ "use strict";
34858
34911
  init_define_HHP_CATALOG();
34859
34912
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
34860
34913
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
@@ -150763,15 +150816,24 @@ function rebindReleaseId(manifest2) {
150763
150816
  }
150764
150817
  function shellSha(root = REPO_ROOT5) {
150765
150818
  if (!isMonorepoCheckout(root)) return "";
150766
- return resolveServeBuildSha({
150819
+ const git2 = (args) => execFileSync2("git", args, { cwd: root, stdio: ["ignore", "pipe", "ignore"] }).toString();
150820
+ const base2 = resolveServeBuildSha({
150767
150821
  // NO env. The resolver accepts a CI-supplied candidate (BUILD_VCS_NUMBER) because the serve
150768
150822
  // artifact wants "the commit CI built me from" — but here the answer must be an ancestor of
150769
150823
  // the commit we are PUBLISHING, i.e. of whatever `gitSha()` just reported. In CI those two
150770
150824
  // need not be equal, and anchoring to the wrong one would record a shellSha unrelated to this
150771
150825
  // release's own history. Empty env forces `rev-parse HEAD`, the same source gitSha() uses.
150772
150826
  env: {},
150773
- git: (args) => execFileSync2("git", args, { cwd: root, stdio: ["ignore", "pipe", "ignore"] }).toString()
150827
+ git: git2
150774
150828
  });
150829
+ if (!base2) return "";
150830
+ let head3 = "";
150831
+ try {
150832
+ head3 = git2(["rev-parse", "HEAD"]).trim();
150833
+ } catch {
150834
+ return base2;
150835
+ }
150836
+ return mergedDefaultBranchSha({ git: git2, head: head3, base: base2 }) || base2;
150775
150837
  }
150776
150838
  function isMonorepoCheckout(dir) {
150777
150839
  try {
@@ -267566,6 +267628,10 @@ async function pushCommand(ctx) {
267566
267628
  app: app2,
267567
267629
  releaseId: release3,
267568
267630
  draft,
267631
+ // A push with neither --draft nor --live is a draft BY POLICY, for every app: going live is a
267632
+ // deliberate second step. Without this line the RFC 0080 P1 verification read `draft: true` on
267633
+ // a push it ran without --draft as a bug, so the envelope says it rather than leaving it to the help text.
267634
+ ...draft && flags.draft !== true ? { draftNote: `a draft by default: every \`himi push\` is owner-private and NOT live unless it is given --live. Make this release live with \`himi promote --app ${app2} --release ${release3}${targetName2() !== "local" ? ` --target ${targetName2()}` : ""}\`.` } : {},
267569
267635
  ...publishWarnings.length ? { warnings: publishWarnings } : {},
267570
267636
  ...ringPinReport ? { ringPins: ringPinReport.ringPins } : {},
267571
267637
  ...needsBinary ? { needsBinary } : {},
@@ -269773,13 +269839,20 @@ function shellShaDivergenceWarnings(jobs) {
269773
269839
  const seen = /* @__PURE__ */ new Map();
269774
269840
  for (const j2 of jobs) {
269775
269841
  const release3 = typeof j2.release === "string" ? j2.release : void 0;
269776
- const built = typeof j2.gitCommitSha === "string" ? j2.gitCommitSha : void 0;
269777
- if (j2.shellShaSource === "release" && release3 && built && release3 !== built) seen.set(release3, built);
269842
+ const built = typeof j2.gitCommitSha === "string" ? j2.gitCommitSha.trim().toLowerCase() : void 0;
269843
+ if (j2.shellShaSource !== "release" || !release3 || !built) continue;
269844
+ const commit = releaseCommit(release3) ?? release3.trim().toLowerCase();
269845
+ if (built.startsWith(commit)) continue;
269846
+ seen.set(release3, { commit, built });
269778
269847
  }
269779
269848
  return [...seen].map(
269780
- ([release3, built]) => `\u26A0 this build compiles the native shell at ${built.slice(0, 12)}, not release ${release3.slice(0, 12)} \u2014 the release was pushed from a branch whose HEAD is not on the default branch, so the Mac pool checks out the nearest default-branch ancestor. A native-shell or tools/mobile-dist/** change on that branch is NOT in this binary even if the job reports SUCCESS; re-push from a checkout whose HEAD is on origin/master to validate it.`
269849
+ ([release3, { commit, built }]) => `\u26A0 this build compiles the native shell at ${built.slice(0, 12)}, not release ${release3.slice(0, 12)}'s own commit ${commit.slice(0, 12)}, which is not on the default branch \u2014 so the Mac pool builds a default-branch commit instead: the one that merged that branch when it is already merged, otherwise the commit it was cut from. In the second case a native-shell or tools/mobile-dist/** change on that branch is NOT in this binary even if the job reports SUCCESS; re-push from a checkout whose HEAD is on origin/master to validate it.`
269781
269850
  );
269782
269851
  }
269852
+ function releaseCommit(release3) {
269853
+ const head3 = release3.trim().toLowerCase().split("-")[0] ?? "";
269854
+ return /^[0-9a-f]{7,40}$/.test(head3) ? head3 : void 0;
269855
+ }
269783
269856
  function customerUploadWaiting(record3) {
269784
269857
  const pending2 = record3?.customerAppStore;
269785
269858
  return pending2?.status === "READY_FOR_UPLOAD" || pending2?.status === "UPLOADING";
@@ -272,6 +272,18 @@ answer that — the live
272
272
  pointer moves, so the record has to say whether a build was pinned deliberately or just caught that
273
273
  release.
274
274
 
275
+ **A draft needs `--allow-draft`**, which refuses a named draft without it (`409 release_draft`). A
276
+ pinned binary refreshes its app-config from its own release (`?release=<id>`), and keeps the pin on
277
+ whatever config it installs. A draft or superseded release answers that read with `401
278
+ preview_token_required`, so the binary keeps the app-config it was built with. Before this, the
279
+ refresh read the app's live config. For an app with nothing live that is an empty baseline, which
280
+ replaced the baked config and took its `homeScreenId` with it: every launch after the first opened
281
+ the shell's own home and showed "Unable to load this content". Installing a build over an earlier
282
+ one keeps the app's data, so a pinned build replaces a cached config that is not pinned to its own
283
+ release, and an install the old behaviour broke recovers on the next build. Screen, token and catalog reads are
284
+ still unpinned. On an app with nothing live they 404 and the baked copies stay. On an app that has
285
+ a live release, they revalidate onto the live content.
286
+
275
287
  **Serverless brokers, it does not build.** Compiling Swift needs Xcode on macOS and
276
288
  Gradle is a stateful multi-GB build, so the serve plane only mints a scoped Job Service
277
289
  token, creates the Mac-pool job, and polls it. The compute never moves.
@@ -336,6 +348,16 @@ So the serve plane checks first and refuses with **`409 release_sha_not_on_remot
336
348
  sha. **The fix is to re-publish from a checkout whose HEAD is on the default branch**
337
349
  (`git checkout origin/master`, then `himi push`) and dist the new release id.
338
350
 
351
+ **Which commit a branch push builds.** A release pushed from a Himalaya checkout also records a
352
+ `shellSha`, the default-branch commit the pool builds instead of a branch head. When the branch is
353
+ **already merged** it is the master commit that merged it: the oldest one that already contains the
354
+ branch's changes, so merging the branch into it would change nothing. Otherwise it is the commit the
355
+ branch was cut from (its merge-base), which holds none of the branch's native changes. The search is
356
+ bounded (500 changed files, 200 candidate commits) and uses `merge-tree --write-tree` (git 2.38+; an older git matches exact bytes only);
357
+ past those it keeps the merge-base. `himi dist` warns when the built commit is not the release's
358
+ own. The merge-base rule alone gave a push from a squash-merged branch a shell from before its own
359
+ change, and that shell rejected the release's newer brand contract.
360
+
339
361
  The check is deliberately narrow, because a false refusal blocks a QA build that would have
340
362
  worked. It refuses only what it can positively establish:
341
363
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1709.0",
3
+ "version": "0.1711.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": [
@@ -81,5 +81,5 @@
81
81
  "artifactId": "himalaya-cli"
82
82
  }
83
83
  },
84
- "falconPackageHash": "415fbe34a0c070c0ffc015cf469ee704916ab52fe8d654bcf54a340b"
84
+ "falconPackageHash": "75ffdc562de143cb5782bbc1791093965c374bde446ab0640072c0d6"
85
85
  }