@wix/himalaya-cli 0.1709.0 → 0.1710.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"] },
@@ -150763,15 +150815,24 @@ function rebindReleaseId(manifest2) {
150763
150815
  }
150764
150816
  function shellSha(root = REPO_ROOT5) {
150765
150817
  if (!isMonorepoCheckout(root)) return "";
150766
- return resolveServeBuildSha({
150818
+ const git2 = (args) => execFileSync2("git", args, { cwd: root, stdio: ["ignore", "pipe", "ignore"] }).toString();
150819
+ const base2 = resolveServeBuildSha({
150767
150820
  // NO env. The resolver accepts a CI-supplied candidate (BUILD_VCS_NUMBER) because the serve
150768
150821
  // artifact wants "the commit CI built me from" — but here the answer must be an ancestor of
150769
150822
  // the commit we are PUBLISHING, i.e. of whatever `gitSha()` just reported. In CI those two
150770
150823
  // need not be equal, and anchoring to the wrong one would record a shellSha unrelated to this
150771
150824
  // release's own history. Empty env forces `rev-parse HEAD`, the same source gitSha() uses.
150772
150825
  env: {},
150773
- git: (args) => execFileSync2("git", args, { cwd: root, stdio: ["ignore", "pipe", "ignore"] }).toString()
150826
+ git: git2
150774
150827
  });
150828
+ if (!base2) return "";
150829
+ let head3 = "";
150830
+ try {
150831
+ head3 = git2(["rev-parse", "HEAD"]).trim();
150832
+ } catch {
150833
+ return base2;
150834
+ }
150835
+ return mergedDefaultBranchSha({ git: git2, head: head3, base: base2 }) || base2;
150775
150836
  }
150776
150837
  function isMonorepoCheckout(dir) {
150777
150838
  try {
@@ -267566,6 +267627,10 @@ async function pushCommand(ctx) {
267566
267627
  app: app2,
267567
267628
  releaseId: release3,
267568
267629
  draft,
267630
+ // A push with neither --draft nor --live is a draft BY POLICY, for every app: going live is a
267631
+ // deliberate second step. Without this line the RFC 0080 P1 verification read `draft: true` on
267632
+ // a push it ran without --draft as a bug, so the envelope says it rather than leaving it to the help text.
267633
+ ...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
267634
  ...publishWarnings.length ? { warnings: publishWarnings } : {},
267570
267635
  ...ringPinReport ? { ringPins: ringPinReport.ringPins } : {},
267571
267636
  ...needsBinary ? { needsBinary } : {},
@@ -269773,13 +269838,20 @@ function shellShaDivergenceWarnings(jobs) {
269773
269838
  const seen = /* @__PURE__ */ new Map();
269774
269839
  for (const j2 of jobs) {
269775
269840
  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);
269841
+ const built = typeof j2.gitCommitSha === "string" ? j2.gitCommitSha.trim().toLowerCase() : void 0;
269842
+ if (j2.shellShaSource !== "release" || !release3 || !built) continue;
269843
+ const commit = releaseCommit(release3) ?? release3.trim().toLowerCase();
269844
+ if (built.startsWith(commit)) continue;
269845
+ seen.set(release3, { commit, built });
269778
269846
  }
269779
269847
  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.`
269848
+ ([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
269849
  );
269782
269850
  }
269851
+ function releaseCommit(release3) {
269852
+ const head3 = release3.trim().toLowerCase().split("-")[0] ?? "";
269853
+ return /^[0-9a-f]{7,40}$/.test(head3) ? head3 : void 0;
269854
+ }
269783
269855
  function customerUploadWaiting(record3) {
269784
269856
  const pending2 = record3?.customerAppStore;
269785
269857
  return pending2?.status === "READY_FOR_UPLOAD" || pending2?.status === "UPLOADING";
@@ -336,6 +336,16 @@ So the serve plane checks first and refuses with **`409 release_sha_not_on_remot
336
336
  sha. **The fix is to re-publish from a checkout whose HEAD is on the default branch**
337
337
  (`git checkout origin/master`, then `himi push`) and dist the new release id.
338
338
 
339
+ **Which commit a branch push builds.** A release pushed from a Himalaya checkout also records a
340
+ `shellSha`, the default-branch commit the pool builds instead of a branch head. When the branch is
341
+ **already merged** it is the master commit that merged it: the oldest one that already contains the
342
+ branch's changes, so merging the branch into it would change nothing. Otherwise it is the commit the
343
+ branch was cut from (its merge-base), which holds none of the branch's native changes. The search is
344
+ bounded (500 changed files, 200 candidate commits) and uses `merge-tree --write-tree` (git 2.38+; an older git matches exact bytes only);
345
+ past those it keeps the merge-base. `himi dist` warns when the built commit is not the release's
346
+ own. The merge-base rule alone gave a push from a squash-merged branch a shell from before its own
347
+ change, and that shell rejected the release's newer brand contract.
348
+
339
349
  The check is deliberately narrow, because a false refusal blocks a QA build that would have
340
350
  worked. It refuses only what it can positively establish:
341
351
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1709.0",
3
+ "version": "0.1710.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": "c7fb4af8a8070c3153a9da52446ee94e1e57f2ad99514c5ccd90cb71"
85
85
  }