@koda-sl/baker-cli 0.325.0 → 0.325.1

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/README.md CHANGED
@@ -1429,6 +1429,8 @@ baker experiment fold # make the page
1429
1429
 
1430
1430
  **Finishing with the variant takes two beats, and `fold` is the second.** `finish --keep variant` records which version is live and the edge serves it to everyone at once. `baker experiment fold` moves that version into the page's own folder, archives the one that lost as a self-contained snapshot under `src/_variants/<page id>/<n>/`, and deletes the variant folder. Until it runs, the page is served by a rewrite and cannot be tested again. Run `fold` with no arguments after any test ends, then publish; Baker drops the rewrite by itself once the new pages are live.
1431
1431
 
1432
+ **The archive is a record, not code that ships.** It is never built, never served, nothing in the workspace may edit it, and no quality check can fail on it or rewrite it — those go together: a record you are forbidden to change must not be something a check can turn red, or the only way past the check is to destroy the record. Its references to shared parts of the site are re-aimed as it is written, so a snapshot opened a year later still names the layout and sections that rendered it; links in the markup are left exactly as the page wrote them.
1433
+
1432
1434
  **`plan` before building anything.** At a 3% conversion rate a +20% lift needs roughly 14,000 visitors *per variant*; `plan` says how long that is at this page's traffic, lists what this page's visitors actually went on to do, and what a 14, 28, 56 or 90-day window could settle. The duration is a guide and never a finish line — the test ends when the numbers are clear, and a page with no traffic yet still runs, sized on a stand-in that `warning` names (`--baseline 0.05` states the rate to expect). What `plan` refuses is what cannot be measured: no conversion defined, or a goal the page has demonstrably never produced. `--lift` sets the smallest lift worth detecting (default `0.2`) — halving it roughly quadruples the traffic needed.
1433
1435
 
1434
1436
  ### Google Analytics 4 (`baker ga4`)
package/dist/cli.js CHANGED
@@ -44668,6 +44668,7 @@ async function readForms(root, slug) {
44668
44668
  }
44669
44669
 
44670
44670
  // src/commands/experiment/fold.ts
44671
+ import { statSync } from "fs";
44671
44672
  import { cp as cp3, mkdir as mkdir9, readdir as readdir12, readFile as readFile25, rm as rm8, stat as stat6, writeFile as writeFile12 } from "fs/promises";
44672
44673
  import path32 from "path";
44673
44674
 
@@ -44795,20 +44796,42 @@ async function archiveContents(opts) {
44795
44796
  return targets;
44796
44797
  }
44797
44798
  function repointIntoArchive(text2, sourceAbs, destAbs, archivedBySource) {
44798
- return text2.replace(QUOTED_RELATIVE2, (match, quote, spec) => {
44799
- const resolved = resolveWithExtensions(path32.resolve(path32.dirname(sourceAbs), spec), archivedBySource);
44799
+ const fromDir = path32.dirname(sourceAbs);
44800
+ const toDir = path32.dirname(destAbs);
44801
+ return text2.replace(QUOTED_RELATIVE2, (match, quote, spec, offset) => {
44802
+ const [specPath, suffix] = splitSuffix(spec);
44803
+ const target = path32.resolve(fromDir, specPath);
44804
+ const resolved = resolveInArchive(target, archivedBySource) ?? resolveOnDisk(target, isImportPosition(text2, offset));
44800
44805
  if (resolved === null) return match;
44801
- const rel = posix2(path32.relative(path32.dirname(destAbs), resolved));
44802
- return `${quote}${rel.startsWith(".") ? rel : `./${rel}`}${quote}`;
44806
+ const rel = posix2(path32.relative(toDir, resolved));
44807
+ return `${quote}${rel.startsWith(".") ? rel : `./${rel}`}${suffix}${quote}`;
44803
44808
  });
44804
44809
  }
44805
- function resolveWithExtensions(base, archivedBySource) {
44806
- for (const suffix of ["", ".astro", ".ts", ".tsx", ".js", ".jsx", ".mjs", "/index.astro", "/index.ts"]) {
44810
+ function splitSuffix(spec) {
44811
+ const cut = spec.search(/[?#]/);
44812
+ return cut === -1 ? [spec, ""] : [spec.slice(0, cut), spec.slice(cut)];
44813
+ }
44814
+ var EXTENSIONS = ["", ".astro", ".ts", ".tsx", ".js", ".jsx", ".mjs"];
44815
+ function resolveInArchive(base, archivedBySource) {
44816
+ for (const suffix of [...EXTENSIONS, "/index.astro", "/index.ts"]) {
44807
44817
  const hit = archivedBySource.get(base + suffix);
44808
44818
  if (hit !== void 0) return hit;
44809
44819
  }
44810
44820
  return null;
44811
44821
  }
44822
+ function isImportPosition(text2, offset) {
44823
+ return /\b(?:from|import|require)\s*\(?\s*$/.test(text2.slice(Math.max(0, offset - 64), offset));
44824
+ }
44825
+ function resolveOnDisk(base, allowDirectoryIndex) {
44826
+ const candidates = allowDirectoryIndex ? [...EXTENSIONS, "/index.astro", "/index.ts", "/index.js"] : EXTENSIONS;
44827
+ for (const suffix of candidates) {
44828
+ try {
44829
+ if (statSync(base + suffix).isFile()) return base + suffix;
44830
+ } catch {
44831
+ }
44832
+ }
44833
+ return null;
44834
+ }
44812
44835
  async function promoteVariantFiles(opts) {
44813
44836
  const { root, pageDir, variantDir } = opts;
44814
44837
  const written = [];