@commercelayer/agent-cli 0.2.0 → 0.2.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/dist/store.js +9 -1
  2. package/package.json +1 -1
package/dist/store.js CHANGED
@@ -231,7 +231,15 @@ export function diff(state, desired) {
231
231
  changes.push({ action: 'update', type: 'store', id: 'name' });
232
232
  if (state.policies !== undefined && canonical(state.policies) !== canonical(desired.policies))
233
233
  changes.push({ action: 'update', type: 'store', id: 'policies' });
234
- if (state.theme !== undefined && canonical(state.theme) !== canonical(desired.theme))
234
+ }
235
+ // The theme is listed like a resource: a create when the store has none yet (first apply
236
+ // included), an update when it changes. An API that does not know themes (undefined) is skipped.
237
+ const hasTheme = (t) => Boolean(t && Object.keys(t).length);
238
+ if (!applied || state.theme !== undefined) {
239
+ const before = applied ? state.theme : null;
240
+ if (!hasTheme(before) && hasTheme(desired.theme))
241
+ changes.push({ action: 'create', type: 'store', id: 'theme' });
242
+ else if (hasTheme(before) && canonical(before) !== canonical(desired.theme))
235
243
  changes.push({ action: 'update', type: 'store', id: 'theme' });
236
244
  }
237
245
  const after = toApplied(desired);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/agent-cli",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "c11r: the Commerce Layer CLI for coding agents. Builds a sandbox store that people and shopping agents can buy from.",
5
5
  "homepage": "https://commercelayer.ai",
6
6
  "keywords": [