@runwell/shopify-toolkit 0.12.0 → 0.13.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.
Files changed (2) hide show
  1. package/lib/baseline.js +13 -5
  2. package/package.json +2 -2
package/lib/baseline.js CHANGED
@@ -129,7 +129,7 @@ export async function syncBaseline({ baselineRoot, targetDir, config, dryRun, wr
129
129
  }
130
130
  }
131
131
 
132
- function applySettingsPatches(tenantSchema, patchDoc) {
132
+ export function applySettingsPatches(tenantSchema, patchDoc) {
133
133
  // tenantSchema is an array of setting groups. patchDoc.patches is an array.
134
134
  const patches = patchDoc.patches || [];
135
135
  for (const patchGroup of patches) {
@@ -137,12 +137,20 @@ function applySettingsPatches(tenantSchema, patchDoc) {
137
137
  if (!existing) {
138
138
  tenantSchema.push(patchGroup);
139
139
  } else {
140
- // Merge settings, skipping duplicates by id (or by content for header/paragraph)
141
- const existingIds = new Set((existing.settings || []).map(s => s.id).filter(Boolean));
140
+ // Dedup by composite key: id when present, else (type, content) for
141
+ // header/paragraph entries, else full JSON. Without this, header and
142
+ // paragraph entries (no id) get re-appended every sync.
143
+ const keyOf = (s) =>
144
+ s.id ? `id:${s.id}` :
145
+ s.content !== undefined ? `${s.type}:content:${s.content}` :
146
+ `raw:${JSON.stringify(s)}`;
147
+ existing.settings = existing.settings || [];
148
+ const existingKeys = new Set(existing.settings.map(keyOf));
142
149
  for (const s of patchGroup.settings || []) {
143
- if (s.id && existingIds.has(s.id)) continue;
144
- existing.settings = existing.settings || [];
150
+ const key = keyOf(s);
151
+ if (existingKeys.has(key)) continue;
145
152
  existing.settings.push(s);
153
+ existingKeys.add(key);
146
154
  }
147
155
  }
148
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runwell/shopify-toolkit",
3
- "version": "0.12.0",
3
+ "version": "0.13.1",
4
4
  "description": "Reusable Shopify theme modules from Runwell. Replaces typically app-driven features (reviews, wishlist, urgency, FAQ, post-purchase upsell, exit popups, free-ship progress, sticky ATC, testimonials, badges, bundles) with native Liquid + JS + CSS that ship across multiple client themes via a config-driven sync CLI.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -17,7 +17,7 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "scripts": {
20
- "test": "node --test test/",
20
+ "test": "node --test 'test/**/*.test.js'",
21
21
  "lint": "echo 'todo: eslint config'",
22
22
  "release": "npm publish --access restricted"
23
23
  },