@embeddables/cli 0.6.9 → 0.6.11

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.
@@ -510,6 +510,18 @@ Conditions control visibility of components and pages based on User Data. The `C
510
510
 
511
511
  **Storage**: Conditions are stored in the component/page JSON and preserved in config.json (not in React/CSS/JS files).
512
512
 
513
+ ### Experiments and conditions
514
+
515
+ When visibility is gated by an experiment (a key in `connected_experiments`, otherwise the experiment is not connected and will not work, and which controls the variants as well), conditions that use that experiment key must cover both:
516
+
517
+ 1. **Control variant** – Use the control variant value (e.g. `"control"`) in condition values so the control experience is shown when that variant is assigned.
518
+ 2. **No value** – Use the special value `_no_value` in condition values so users who are not yet assigned a variant (user data has no value for that experiment key) see the intended default experience—typically the same as control.
519
+ 3. Other variant keys.
520
+
521
+ #1 and #2 should be on the same conditions as each other, whereas all other variants (#3) can be on other conditions.
522
+
523
+ Example: for experiment key `hero_test` with variants `control` and `variant_b`, the control experience might use a condition like `key: "hero_test", operator: "==", values: ["control", "_no_value"]` so both control users and users with no assignment see the control. The variant experience would use `values: ["variant_b"]`.
524
+
513
525
  ## Config.json Structure
514
526
 
515
527
  The `config.json` file contains the reduced Embeddable JSON with:
@@ -613,7 +625,7 @@ The `config.json` file contains the reduced Embeddable JSON with:
613
625
 
614
626
  5. **Global Components**: Must use the filenames to replace the `_location` property.
615
627
 
616
- 6. **Conditions**: Stored in config.json, applied at runtime. Multiple values in one condition = OR, multiple conditions = AND.
628
+ 6. **Conditions**: Stored in config.json, applied at runtime. Multiple values in one condition = OR, multiple conditions = AND. For experiment-gated conditions, when setting the control variant's conditions always include both the control variant value and `_no_value` so both control and unassigned users see the intended default.
617
629
 
618
630
  7. **CSS Selectors**: Must follow exact structure with proper spacing (trailing space on breakpoints, leading space on sub-elements).
619
631
 
@@ -38,10 +38,10 @@ export async function runBranch(opts) {
38
38
  console.log('');
39
39
  // Pull the selected branch
40
40
  if (selectedBranch === null) {
41
- // User selected "main" - pull without branch
41
+ // User selected "main" - pull main and clear saved branch
42
42
  console.log(pc.cyan('Switching to main (latest published version)...'));
43
43
  console.log('');
44
- await runPull({ id: embeddableId });
44
+ await runPull({ id: embeddableId, useMain: true });
45
45
  }
46
46
  else {
47
47
  console.log(pc.cyan(`Switching to branch: ${selectedBranch.name}...`));
@@ -3,6 +3,8 @@ export type RunPullOptions = {
3
3
  out?: string;
4
4
  branch?: string;
5
5
  branchName?: string;
6
+ /** When true, pull main and clear saved branch (e.g. when user explicitly selects "main" in branch switcher). */
7
+ useMain?: boolean;
6
8
  fix?: boolean;
7
9
  preserve?: boolean;
8
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAgHA,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,cAAc,iBAiQjD"}
1
+ {"version":3,"file":"pull.d.ts","sourceRoot":"","sources":["../../src/commands/pull.ts"],"names":[],"mappings":"AAgHA,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,iHAAiH;IACjH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,cAAc,iBAkQjD"}
@@ -153,10 +153,10 @@ export async function runPull(opts) {
153
153
  embeddableId = selected;
154
154
  console.log('');
155
155
  }
156
- // Stay on current branch when no --branch: use config's _branch_id if set
157
- const currentFromConfig = opts.branch == null ? getCurrentBranchFromConfig(embeddableId) : null;
158
- const effectiveBranch = opts.branch ?? currentFromConfig?.branchId;
159
- const effectiveBranchName = opts.branchName ?? currentFromConfig?.branchName;
156
+ // When useMain, pull main and ignore/clear saved branch. Otherwise stay on current branch when no --branch.
157
+ const currentFromConfig = opts.useMain || opts.branch != null ? null : getCurrentBranchFromConfig(embeddableId);
158
+ const effectiveBranch = opts.useMain ? undefined : (opts.branch ?? currentFromConfig?.branchId);
159
+ const effectiveBranchName = opts.useMain ? undefined : (opts.branchName ?? currentFromConfig?.branchName);
160
160
  let url = `https://engine.embeddables.com/${embeddableId}?version=latest`;
161
161
  if (effectiveBranch) {
162
162
  url += `&embeddable_branch=${effectiveBranch}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embeddables/cli",
3
- "version": "0.6.9",
3
+ "version": "0.6.11",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "embeddables": "./bin/embeddables.mjs"