@appdirect/sfb-toolkit 5.0.9 → 6.0.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/.eslintrc +35 -35
- package/CHANGELOG.md +45 -0
- package/Dockerfile +2 -1
- package/agent/.cursor/rules/sfb-storefront.mdc +18 -0
- package/agent/.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md +130 -0
- package/agent/.cursor/skills/sfb-custom-components/SKILL.md +44 -0
- package/agent/.cursor/skills/sfb-localization-settings/SKILL.md +99 -0
- package/agent/.cursor/skills/sfb-theme-customize/SKILL.md +25 -0
- package/agent/.cursor/skills/sfb-toolkit-commands/SKILL.md +35 -0
- package/agent/AGENTS.md +222 -0
- package/agent/CLAUDE.md +20 -0
- package/bin/index.js +82 -100
- package/coverage/clover.xml +1937 -333
- package/coverage/coverage-final.json +41 -20
- package/coverage/lcov-report/{controllers/controllers-utils → config}/index.html +19 -19
- package/coverage/lcov-report/config/index.js.html +124 -0
- package/coverage/lcov-report/index.html +108 -78
- package/coverage/lcov-report/{constants → src/constants}/customUserAttributesMock.js.html +12 -12
- package/coverage/lcov-report/{constants → src/constants}/index.html +10 -10
- package/coverage/lcov-report/{constants → src/constants}/pageUrls.js.html +14 -14
- package/coverage/lcov-report/{constants → src/constants}/userMock.js.html +13 -13
- package/coverage/lcov-report/{controllers → src/controllers}/controllers-utils/assetsUtils.js.html +20 -20
- package/coverage/lcov-report/src/controllers/controllers-utils/index.html +131 -0
- package/coverage/lcov-report/src/controllers/controllers-utils/locale.js.html +115 -0
- package/coverage/lcov-report/{controllers → src/controllers}/data-filters/bootstrap-data-filter.js.html +15 -15
- package/coverage/lcov-report/{controllers → src/controllers}/data-filters/call-to-actions-filter.js.html +22 -22
- package/coverage/lcov-report/{controllers → src/controllers}/data-filters/index.html +37 -22
- package/coverage/lcov-report/src/controllers/data-filters/media-url-filter.js.html +394 -0
- package/coverage/lcov-report/{controllers → src/controllers}/index.html +27 -27
- package/coverage/lcov-report/{controllers → src/controllers}/index.js.html +159 -126
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/ResultItem.js.html +43 -43
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/SearchBar.js.html +22 -22
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/index.html +28 -28
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/base/item.js.html +28 -28
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/container.js.html +31 -31
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/data-view.js.html +29 -29
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/header-view.js.html +35 -38
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/index.html +45 -45
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/components/search.js.html +54 -54
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/index.html +22 -22
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/pageUrl.js.html +17 -17
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/roleType.js.html +14 -14
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/constants/searchType.js.html +17 -17
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/utils/debounce.js.html +15 -15
- package/coverage/lcov-report/{front-end-utils → src/front-end-utils}/src/utils/index.html +20 -20
- package/coverage/lcov-report/{middlewares → src/middlewares}/config.js.html +11 -11
- package/coverage/lcov-report/{middlewares → src/middlewares}/index.html +10 -10
- package/coverage/lcov-report/{tools → src/routes}/index.html +30 -30
- package/coverage/lcov-report/src/routes/media-proxy.js.html +613 -0
- package/coverage/lcov-report/src/tools/compile-styles.js.html +1018 -0
- package/coverage/lcov-report/src/tools/custom-components-export-compat-loader.js.html +745 -0
- package/coverage/lcov-report/src/tools/index.html +371 -0
- package/coverage/lcov-report/src/tools/prompt-questions.js.html +1117 -0
- package/coverage/lcov-report/{tools → src/tools}/proxy-fetch.js.html +15 -15
- package/coverage/lcov-report/src/tools/resolve-components-react.js.html +457 -0
- package/coverage/lcov-report/src/tools/sass-legacy-compat.js.html +1192 -0
- package/coverage/lcov-report/src/tools/toolkit-cli-argv.js.html +226 -0
- package/coverage/lcov-report/src/tools/toolkit-common-fun.js.html +1402 -0
- package/coverage/lcov-report/src/tools/toolkit-common-vars-namespace.js.html +403 -0
- package/coverage/lcov-report/src/tools/toolkit-common-vars.js.html +283 -0
- package/coverage/lcov-report/src/tools/toolkit-components-fun.js.html +1237 -0
- package/coverage/lcov-report/src/tools/toolkit-components-vars.js.html +232 -0
- package/coverage/lcov-report/src/tools/toolkit-install-agent-guidance.js.html +439 -0
- package/coverage/lcov-report/src/tools/toolkit-live-reload.js.html +688 -0
- package/coverage/lcov-report/src/tools/toolkit-path.js.html +184 -0
- package/coverage/lcov-report/src/tools/toolkit-spawn.js.html +199 -0
- package/coverage/lcov-report/src/tools/toolkit-v6-theme-risk.js.html +1039 -0
- package/coverage/lcov-report/src/tools/toolkit-zip-utils.js.html +190 -0
- package/coverage/lcov.info +3387 -727
- package/index.js +40 -20
- package/npm-shrinkwrap.json +5026 -15490
- package/package.json +49 -40
- package/readme.md +20 -1
- package/rspack-components.config.cjs +81 -0
- package/rspack-components.config.prod.cjs +71 -0
- package/rspack.config.cjs +25 -0
- package/rspack.shared.cjs +164 -0
- package/src/controllers/controllers-utils/locale.js +10 -0
- package/src/controllers/data-filters/media-url-filter.js +103 -0
- package/src/controllers/index.js +15 -4
- package/src/front-end-utils/dist/toolbar.bundle.js +1 -2
- package/src/front-end-utils/src/components/header-view.js +0 -1
- package/src/routes/index.js +2 -0
- package/src/routes/media-proxy.js +176 -0
- package/src/tools/compile-styles.js +311 -0
- package/src/tools/compiler-components-prod.js +32 -21
- package/src/tools/compiler-css.js +7 -7
- package/src/tools/custom-components-export-compat-loader.js +220 -0
- package/src/tools/resolve-components-react.js +124 -0
- package/src/tools/sass-legacy-compat.js +369 -0
- package/src/tools/toolkit-checkout.js +3 -6
- package/src/tools/toolkit-cli-argv.js +47 -0
- package/src/tools/toolkit-common-fun.js +149 -31
- package/src/tools/toolkit-common-utils.js +5 -3
- package/src/tools/toolkit-common-vars.js +4 -3
- package/src/tools/toolkit-components-copy.js +6 -4
- package/src/tools/toolkit-components-fun.js +6 -4
- package/src/tools/toolkit-config-setup.js +2 -1
- package/src/tools/toolkit-create.js +5 -7
- package/src/tools/toolkit-import.js +5 -6
- package/src/tools/toolkit-install-agent-guidance-cli.js +24 -0
- package/src/tools/toolkit-install-agent-guidance.js +118 -0
- package/src/tools/toolkit-install.js +8 -8
- package/src/tools/toolkit-live-reload.js +201 -0
- package/src/tools/toolkit-package.js +25 -7
- package/src/tools/toolkit-path.js +33 -0
- package/src/tools/toolkit-setup-e2e.js +2 -1
- package/src/tools/toolkit-setup.js +5 -1
- package/src/tools/toolkit-spawn.js +38 -0
- package/src/tools/toolkit-start.js +98 -54
- package/src/tools/toolkit-storybook.js +38 -19
- package/src/tools/toolkit-update.js +5 -3
- package/src/tools/toolkit-v6-theme-risk.js +318 -0
- package/themes-param.json +1 -0
- package/src/front-end-utils/dist/toolbar.bundle.js.LICENSE.txt +0 -52
- package/src/tools/gulp-tasks.js +0 -80
- package/webpack-components.config.cjs +0 -123
- package/webpack-components.config.prod.cjs +0 -113
- package/webpack.config.cjs +0 -25
package/agent/AGENTS.md
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Storefront Toolkit — AI agent guidance
|
|
2
|
+
|
|
3
|
+
This workspace is an **AppDirect Storefront Builder (SFB) toolkit project**. Themes under `themes/` are previewed with `sfb-toolkit` and published as a zip to Theme Manager.
|
|
4
|
+
|
|
5
|
+
**Toolkit 6.x** (Node ≥22.12, Rspack + sass-embedded). Follow this file and the installed skills — do not rely on external documentation.
|
|
6
|
+
|
|
7
|
+
## Hard rules
|
|
8
|
+
|
|
9
|
+
1. **Do not invent DOM or class names.** Plaza UI markup is mostly React from `@appdirect/sfb-theme-components` / `customComponents`, not static HTML in page files. Inspect the live DOM in the browser after `sfb-toolkit start`. If you cannot open a browser, ask the human for a DOM snapshot / classname before writing CSS.
|
|
10
|
+
2. **Before editing `settings.json`, call `window.__ADComponents.<Name>.schema()` in the browser.** That is the live contract for field names, types, defaults, and `marketplaceData`. Do not guess keys from memory or invent `{ value, type }` shapes. If you cannot open a browser, ask the human to paste the `schema()` output.
|
|
11
|
+
3. **Edit `.scss` / theme Sass, never generated `.css`.** The toolkit overwrites compiled CSS on start/package.
|
|
12
|
+
4. **Use toolkit CLI to scaffold custom components.** Do not hand-roll `customComponents` setup.
|
|
13
|
+
5. **Preserve HTML structure and ABEM classnames** when restyling — public API. Prefer additive CSS.
|
|
14
|
+
6. **If there is no `customComponents/` folder**, run `sfb-toolkit components` before `components-add` / `components-copy`.
|
|
15
|
+
7. **Pick `components-copy` targets from the catalog, not from guesses.** Read `.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md` (export name, editor title, what it does, page). Confirm the export is on the theme (`<component name>`, `settings.json`, or `Object.keys(window.__ADComponents)`). Prefer CSS / `settings.json` / `components-add` when a fork is not required. Pass explicit names + `-r`/`-c`/`-s` — no interactive no-args copy. If nothing in the catalog matches, **ask the human**.
|
|
16
|
+
8. **All user-facing text must be localized.** Never hardcode display copy in React/JSX, Nunjucks, or as a bare string-only `settings.json` value. Put strings in theme localization YAML for the **current preview locale** (URL `/en-US/…` → usually `themes/<name>/translations/en-us.yml`). Schema / `settings.json` text inputs use `isLocalized: true` + a YAML key. See Localization below.
|
|
17
|
+
|
|
18
|
+
## Toolkit commands
|
|
19
|
+
|
|
20
|
+
Run from the **workspace root** (folder with `.sfbconfig`, `config/`, `themes/`).
|
|
21
|
+
|
|
22
|
+
| Command | When to use |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `sfb-toolkit setup [name]` | Create a new workspace + first theme (also installs this guidance) |
|
|
25
|
+
| `sfb-toolkit create [name]` | Add another theme to an existing workspace |
|
|
26
|
+
| `sfb-toolkit import [zip] [marketplaceUrl] [themeName]` | Import a theme zip into `themes/` |
|
|
27
|
+
| `sfb-toolkit checkout [name]` | Switch active theme context |
|
|
28
|
+
| `sfb-toolkit about` | List themes in the workspace |
|
|
29
|
+
| `sfb-toolkit status` | Show current config |
|
|
30
|
+
| `sfb-toolkit update` | Update marketplace URL for the current theme |
|
|
31
|
+
| `sfb-toolkit start` | Local preview (default `http://localhost:3555/en-US/home`, port from `config.port`). Flag: `-v` verbose |
|
|
32
|
+
| `sfb-toolkit package` | Build theme zip for upload. Use **`-a` / `--all`** when translations or `settings.json` changed so prompts cannot omit them |
|
|
33
|
+
| `sfb-toolkit install [module]` | `npm install` into the **active theme** (special path for `@appdirect/sfb-theme-components`) |
|
|
34
|
+
| `sfb-toolkit install-agent-guidance` | Install/refresh this guidance in an existing workspace |
|
|
35
|
+
| `sfb-toolkit components` | **Enable** custom components (required once if none exist). May prompt y/n |
|
|
36
|
+
| `sfb-toolkit components-info` | Report overrides / user-defined custom components |
|
|
37
|
+
| `sfb-toolkit components-copy [components…]` | Fork UI-library components. Interactive if no args; with names you must pass an export flag (`-r` replace / `-c` comment / `-s` skip) |
|
|
38
|
+
| `sfb-toolkit components-add [name]` | Scaffold a **new** custom component. Without args it prompts; flags: `-p <page>`, `-o` orderable |
|
|
39
|
+
| `sfb-toolkit components-delete` | Remove copied UI-library components |
|
|
40
|
+
| `sfb-toolkit version` / `v` | Print toolkit version |
|
|
41
|
+
| `sfb-toolkit storybook` | **Deprecated** — only for themes already configured with Storybook |
|
|
42
|
+
| `sfb-toolkit config-setup [proj] [theme]` | Bootstrap config/folders only (no theme tree copy) |
|
|
43
|
+
|
|
44
|
+
**Non-interactive tip:** prefer passing CLI args/flags. For packaging after i18n or settings edits, use `sfb-toolkit package -a`.
|
|
45
|
+
|
|
46
|
+
Typical loop: `start` → browser verify → edit → `package -a` when ready.
|
|
47
|
+
|
|
48
|
+
Toolkit 6 may print theme-risk banners for older / non-current Plaza stacks; recent Plaza stays quiet.
|
|
49
|
+
|
|
50
|
+
## How themes actually render
|
|
51
|
+
|
|
52
|
+
- Plaza **pages** (`content/pages/**`) mostly place `<component name="…" id="…">` or `<PageOrderableContainer …>`. They are not full product HTML documents.
|
|
53
|
+
- Visible UI comes from React on **`window.__ADComponents`** (CDN by default, or local/custom bundle after `sfb-toolkit components`).
|
|
54
|
+
- Lookup uses the component **name** (id before `:orderable:…`): `window.__ADComponents[name]`.
|
|
55
|
+
- Classnames use ABEM via `createNamespace` (e.g. `faq_title`). **Inspect DevTools** — do not guess.
|
|
56
|
+
- Header/footer platform chrome and cart preview: structure is largely fixed — CSS only after DOM inspection.
|
|
57
|
+
- Classic themes use more Nunjucks HTML; Plaza is component-first.
|
|
58
|
+
|
|
59
|
+
**CSS coat of paint:** theme Sass under `themes/<name>/` targeting classes you observed. Prefer CSS variables / theme color tokens.
|
|
60
|
+
|
|
61
|
+
**Test:** `sfb-toolkit start` → open `http://localhost:<port>/en-US/<page>` → DevTools → adjust SCSS/`settings.json` → confirm → `sfb-toolkit package -a`.
|
|
62
|
+
|
|
63
|
+
## Custom components
|
|
64
|
+
|
|
65
|
+
### If custom components are NOT set up yet
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
sfb-toolkit components
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This installs pinned `@appdirect/sfb-theme-components`, creates `themes/<active>/customComponents/`, writes `settings-schema.json` `{ "useComponents": true }`, and switches `base.html` from CDN bundles to the custom/local bundle.
|
|
72
|
+
|
|
73
|
+
**Not set up** if: no `customComponents/`, or layout still on CDN `sfb-components-bundles`, or missing `useComponents: true`.
|
|
74
|
+
|
|
75
|
+
`components` ≠ `components-add`. Enable first; then add or copy.
|
|
76
|
+
|
|
77
|
+
### After setup
|
|
78
|
+
|
|
79
|
+
1. Prefer **not** forking: theme SCSS, `settings.json` (via `schema()`), or `components-add` for net-new UI.
|
|
80
|
+
2. `sfb-toolkit components-add` — new component (orderable → Theme Editor + `settings.json`; non-orderable → page HTML)
|
|
81
|
+
3. `sfb-toolkit components-copy <ExactExportName…> -r|-c|-s` — choose **Export** from [COMPONENT-CATALOG.md](.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md) (hard rule 7).
|
|
82
|
+
4. Edit under `themes/<name>/customComponents/`
|
|
83
|
+
5. `sfb-toolkit start` to verify
|
|
84
|
+
6. `sfb-toolkit components-info` before publishing
|
|
85
|
+
|
|
86
|
+
Keep aligned: `Component.schema().name` === `customComponents/index.js` export === `<component name="…">` === `window.__ADComponents` key.
|
|
87
|
+
|
|
88
|
+
Overriding library components/atoms is risky. Library upgrades are manual (`sfb-toolkit install @appdirect/sfb-theme-components@…`).
|
|
89
|
+
|
|
90
|
+
### `window.__ADComponents` ↔ `settings.json` (required)
|
|
91
|
+
|
|
92
|
+
Components register on `window.__ADComponents`. The Theme Editor / toolkit expect `settings.json` to match each component’s **schema**, not invent fields.
|
|
93
|
+
|
|
94
|
+
**Mandatory before any `settings.json` edit for a component:**
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
// DevTools console after sfb-toolkit start (page that loads that component)
|
|
98
|
+
Object.keys(window.__ADComponents) // list available names
|
|
99
|
+
window.__ADComponents.ProductBanner.schema() // example — use the real Name
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Use the returned object:
|
|
103
|
+
|
|
104
|
+
| Schema field | How it drives settings.json |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `name` | Must match `<component name>`, export, and `__ADComponents` key |
|
|
107
|
+
| `form.<fieldName>.type` | Becomes settings `type` (`TOGGLE`, `COLORPICKER`, `DROPDOWN`, …) |
|
|
108
|
+
| `form.<fieldName>.defaultValue` | Starting `value` (or a localization key) |
|
|
109
|
+
| `form.<fieldName>` + localized flags | Often `{ value: "<i18n key>", isLocalized: true, type }` |
|
|
110
|
+
| `marketplaceData` | Prop → page-api path (additive-only; do not rename/remove) |
|
|
111
|
+
| `orderableSection` | Where orderables may appear in Theme Editor |
|
|
112
|
+
|
|
113
|
+
**settings.json keys:**
|
|
114
|
+
|
|
115
|
+
- Under `pages.<page>.components`, the map key must equal the HTML `id` attribute, e.g. `"ProductBanner"` or `"ProductDescription:orderable:<uuid>"`.
|
|
116
|
+
- Field entries: `{ "value": …, "type": "<schema form type>" }`.
|
|
117
|
+
- Header/Footer under `pages.global` often nest their own `components` + `orderableComponents`.
|
|
118
|
+
|
|
119
|
+
If `window.__ADComponents.<Name>` is missing, the page bundle did not load that component — fix placement/`customComponents` exports before editing settings.
|
|
120
|
+
|
|
121
|
+
## Localization (three layers — do not mix)
|
|
122
|
+
|
|
123
|
+
### Always localize (required)
|
|
124
|
+
|
|
125
|
+
**Every** user-visible string is localization content — component labels, headings, buttons, helper text, menu titles, empty states, errors, Nunjucks copy, custom-component UI. Do not ship hardcoded English (or any language) in source or settings alone.
|
|
126
|
+
|
|
127
|
+
Before editing any storefront copy:
|
|
128
|
+
|
|
129
|
+
1. Read the **current preview locale** from the browser URL (`http://localhost:3555/en-US/home` → `en-US`).
|
|
130
|
+
2. Map it to the theme file: lowercase with a hyphen → `themes/<active>/translations/en-us.yml` (same for `fr-CA` → `fr-ca.yml`).
|
|
131
|
+
3. **Default assumption:** locale is **`en-US`** / file **`en-us.yml`** unless the preview URL or human says otherwise.
|
|
132
|
+
4. Put new/changed strings in **that** YAML file (and wire the key from settings/template/component). Do not only edit `settings.json` or JSX.
|
|
133
|
+
|
|
134
|
+
### Schema / `settings.json` text inputs → YAML
|
|
135
|
+
|
|
136
|
+
Editor text fields on components (titles, taglines, button labels, helper text, etc. from `Component.schema().form` and live values in `settings.json`) follow the same rule:
|
|
137
|
+
|
|
138
|
+
- Use `{ "value": "<theme.i18n.key>", "isLocalized": true, "type": "…" }` in `settings.json`.
|
|
139
|
+
- Add/update the matching key in the **current locale** YAML, e.g.
|
|
140
|
+
`uieditor.home.HeroBanner:orderable:<uuid>.title: Find the tools your team already loves`
|
|
141
|
+
- Never leave the display string only in `settings.json` — preview for that locale will miss or show the wrong text.
|
|
142
|
+
- Follow existing key patterns next to neighboring entries in the same YAML file.
|
|
143
|
+
|
|
144
|
+
### Outside `settings.json` — Nunjucks theme strings (`i18n.custom`)
|
|
145
|
+
|
|
146
|
+
Theme template / layout copy (pages, macros, includes) is **also** localized via the same YAML files. Theme-authored strings use the `i18n.custom.*` path (nested YAML under the page/section):
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
# themes/<name>/translations/en-us.yml
|
|
150
|
+
home:
|
|
151
|
+
welcome: Welcome my friend
|
|
152
|
+
startingat: The product {productName} costs {startingPrice}.
|
|
153
|
+
comments: Posted {num, plural, one{# comment} other{# comments}}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
{{ t(i18n.custom.home.welcome) }}
|
|
158
|
+
{{ formatMessage(t(i18n.custom.home.startingat), { productName: name, startingPrice: price }) }}
|
|
159
|
+
{{ formatMessage(t(i18n.custom.home.comments), { num: 2 }) }}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
- File naming: `themes/<themeName>/translations/<lang>-<country>.yml` (ISO 639-1 + ISO 3166-1, e.g. `fr-ca.yml`).
|
|
163
|
+
- `formatMessage` + ICU syntax for variables and plurals (FormatJS).
|
|
164
|
+
- One locale file per language; translations are **per theme** (not shared across themes).
|
|
165
|
+
- Adding YAML does **not** enable marketplace languages by itself — marketplace language support is a separate config.
|
|
166
|
+
|
|
167
|
+
### Outside `settings.json` — label / CTA overrides (`i18n.overrides`)
|
|
168
|
+
|
|
169
|
+
To relabel page-api / Data Viewer strings (Plaza) or CTA button text (Plaza + Classic), add an `i18n.overrides` section in the locale YAML. Find paths with the developer toolbar Data Viewer.
|
|
170
|
+
|
|
171
|
+
Examples:
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
i18n.overrides:
|
|
175
|
+
application.overview.i18n.featuresAndBenefits: Top features
|
|
176
|
+
application.overview.callToActions.fix.label: See More
|
|
177
|
+
application.callToActions.items.BUY: Purchase
|
|
178
|
+
application.editions.items.callToAction.BUY: Buy this edition
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
For CTA items keyed by `actionType`, drop the numeric index and use the uppercase type (`BUY`, `CONFIGURE`, …) instead of `.label`.
|
|
182
|
+
|
|
183
|
+
### Three layers
|
|
184
|
+
|
|
185
|
+
1. **Theme instance content** — `themes/<name>/translations/<lang>-<COUNTRY>.yml` (e.g. `en-us.yml`, `fr-ca.yml`):
|
|
186
|
+
- Flat / dotted keys for Theme Editor + `settings.json` (`uieditor.…`, menus)
|
|
187
|
+
- Nested keys for Nunjucks via `{{ t(i18n.custom…) }}` / `formatMessage`
|
|
188
|
+
- `i18n.overrides` for page-api i18n objects and CTA labels
|
|
189
|
+
- Settings with `isLocalized: true` store the **key**, not the string
|
|
190
|
+
2. **Schema / defaultValue keys** — `uieditor.sfbComponent.*` / `uieditor.editorProperties.*`. Appear as schema titles **and** sometimes as default `settings.json` values. Those strings usually live in the localization service / UI-editor bundles, not theme YAML. To customize tenant-visible copy, prefer a **theme translation key** + `isLocalized: true` pointing at your `translations/*.yml` entry.
|
|
191
|
+
3. **Nunjucks / page-api wiring** — templates call `t` / `formatMessage`; page-api supplies `i18n.*` that overrides can replace.
|
|
192
|
+
|
|
193
|
+
When changing copy: update the right layer **and** the settings/template reference (YAML + `isLocalized` key, or YAML + `t(i18n.custom…)`, or `i18n.overrides`).
|
|
194
|
+
|
|
195
|
+
## settings.json and style contracts
|
|
196
|
+
|
|
197
|
+
| File | Role |
|
|
198
|
+
|---|---|
|
|
199
|
+
| `settings.json` | Live WYSIWYG **values**: `pages.*.components` (`{ value, type }`), `orderableComponents` (`Name:orderable:uuid`), Header/Footer under `pages.global` (often nested `components` + `orderableComponents`), `globalStyles`, `menus` |
|
|
200
|
+
| `editor-properties.json` | Global style **schema** (not live values) |
|
|
201
|
+
| `design-properties.json` | Header/footer chrome **defaults** |
|
|
202
|
+
|
|
203
|
+
- **Always** discover fields with `window.__ADComponents.<Name>.schema()` first (hard rule 2).
|
|
204
|
+
- Settings for components that are not placed/exported will not appear.
|
|
205
|
+
- After changing settings or translations, package with `sfb-toolkit package -a`.
|
|
206
|
+
|
|
207
|
+
## Useful paths
|
|
208
|
+
|
|
209
|
+
- Active theme: `config/index.js` → `theme`, or `.sfbconfig` → `current`
|
|
210
|
+
- Pages: `themes/<name>/content/pages/`
|
|
211
|
+
- Layout: `themes/<name>/content/layout/base.html`
|
|
212
|
+
- Translations: `themes/<name>/translations/`
|
|
213
|
+
- Custom components: `themes/<name>/customComponents/`
|
|
214
|
+
|
|
215
|
+
## Skills
|
|
216
|
+
|
|
217
|
+
Playbooks are installed for Cursor (`.cursor/skills/`) and Claude Code (`.claude/skills/`):
|
|
218
|
+
|
|
219
|
+
- `sfb-toolkit-commands`
|
|
220
|
+
- `sfb-theme-customize`
|
|
221
|
+
- `sfb-custom-components` (+ `COMPONENT-CATALOG.md` — full library export list)
|
|
222
|
+
- `sfb-localization-settings`
|
package/agent/CLAUDE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Claude Code — Storefront Toolkit workspace
|
|
2
|
+
|
|
3
|
+
@AGENTS.md
|
|
4
|
+
|
|
5
|
+
Follow **AGENTS.md** as the source of truth for this workspace (commands, theme DOM rules, custom components, i18n, settings).
|
|
6
|
+
|
|
7
|
+
## Quick constraints
|
|
8
|
+
|
|
9
|
+
- Inspect the **browser DOM** after `sfb-toolkit start` — do not invent HTML/classnames for Plaza React UI. If you cannot browse, ask the human for a DOM snapshot.
|
|
10
|
+
- Edit **SCSS**, not generated CSS.
|
|
11
|
+
- No `customComponents/` yet → run `sfb-toolkit components` before add/copy.
|
|
12
|
+
- For `components-copy`, use `.cursor/skills/sfb-custom-components/COMPONENT-CATALOG.md`, confirm on theme; ask if no match. Prefer CSS/settings/`components-add`.
|
|
13
|
+
- Before editing `settings.json`, call `window.__ADComponents.<Name>.schema()` in the browser (hard rule). Never invent setting keys.
|
|
14
|
+
- **All user-facing text must be localized** → theme `translations/<locale>.yml` for the **current preview locale** (usually `en-US` → `en-us.yml`): settings `isLocalized: true`, Nunjucks `t(i18n.custom…)` / `formatMessage`, labels/CTAs `i18n.overrides` (never hardcode copy only in JSX/settings/templates).
|
|
15
|
+
- Prefer `sfb-toolkit package -a` after translation/settings changes.
|
|
16
|
+
- Keep `schema().name` / export / `<component name>` / `window.__ADComponents` aligned.
|
|
17
|
+
|
|
18
|
+
## Skills
|
|
19
|
+
|
|
20
|
+
Also under `.claude/skills/` (and `.cursor/skills/`): `sfb-toolkit-commands`, `sfb-theme-customize`, `sfb-custom-components`, `sfb-localization-settings`.
|
package/bin/index.js
CHANGED
|
@@ -10,6 +10,11 @@ const {
|
|
|
10
10
|
const { PAGE_NAME_TO_NAMESPACE } = require("../src/tools/toolkit-common-vars-namespace")
|
|
11
11
|
const { COMPONENTS_DELETE_FLAG_SHORT, COMPONENTS_DELETE_FLAG_FULL, INDEX_EXPORT_COMMENT_OUT,
|
|
12
12
|
INDEX_EXPORT_REPLACE, INDEX_EXPORT_NO_CHANGE } = require('../src/tools/toolkit-components-vars')
|
|
13
|
+
const {
|
|
14
|
+
normalizeRunScriptArg,
|
|
15
|
+
buildComponentsCopyPayload,
|
|
16
|
+
buildComponentsDeleteArg,
|
|
17
|
+
} = require("../src/tools/toolkit-cli-argv")
|
|
13
18
|
|
|
14
19
|
const PROJECT_SETUP_PATH = "src/tools/toolkit-setup.js"
|
|
15
20
|
const PROJECT_SETUP_E2E_PATH = "src/tools/toolkit-setup-e2e.js"
|
|
@@ -32,42 +37,58 @@ const COMPONENTS_ADD = "src/tools/toolkit-components-add.js"
|
|
|
32
37
|
const IMPORT_PATH = "src/tools/toolkit-import.js"
|
|
33
38
|
const COMPONENTS_COPY = "src/tools/toolkit-components-copy.js"
|
|
34
39
|
const COMPONENTS_DELETE = "src/tools/toolkit-components-delete.js"
|
|
40
|
+
const INSTALL_AGENT_GUIDANCE_PATH = "src/tools/toolkit-install-agent-guidance-cli.js"
|
|
35
41
|
|
|
36
42
|
const program = new Command()
|
|
37
43
|
|
|
38
44
|
const DEPRECATED_COMMAND_PREFIX = chalk.bold.bgRed(" DEPRECATED ");
|
|
39
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Run a toolkit script with argv (no shell) to avoid Node 24 DEP0190.
|
|
48
|
+
* null/undefined become "undefined" to match prior `node script ${arg}` templates.
|
|
49
|
+
*/
|
|
50
|
+
const runScript = (scriptRelPath, args = [], { exitOnClose = false } = {}) => {
|
|
51
|
+
const scriptPath = `${__dirname}/../${scriptRelPath}`
|
|
52
|
+
const argv = args.map(normalizeRunScriptArg)
|
|
53
|
+
const child = spawn(process.execPath, [scriptPath, ...argv], {
|
|
54
|
+
stdio: "inherit",
|
|
55
|
+
cwd: process.cwd(),
|
|
56
|
+
})
|
|
57
|
+
child.on("error", (err) => {
|
|
58
|
+
console.error(`Failed to run ${scriptRelPath}: ${err.message}`)
|
|
59
|
+
process.exit(1)
|
|
60
|
+
})
|
|
61
|
+
if (exitOnClose) {
|
|
62
|
+
child.on("exit", (code, signal) => {
|
|
63
|
+
if (signal) {
|
|
64
|
+
process.kill(process.pid, signal)
|
|
65
|
+
return
|
|
66
|
+
}
|
|
67
|
+
process.exit(code ?? 0)
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
return child
|
|
71
|
+
}
|
|
72
|
+
|
|
40
73
|
program
|
|
41
74
|
.command("setup [name]")
|
|
42
75
|
.description("Creates a new project")
|
|
43
76
|
.action((name) => {
|
|
44
|
-
|
|
45
|
-
stdio: "inherit",
|
|
46
|
-
shell: true,
|
|
47
|
-
})
|
|
77
|
+
runScript(PROJECT_SETUP_PATH, [name])
|
|
48
78
|
})
|
|
49
79
|
|
|
50
80
|
program
|
|
51
81
|
.command("setup-e2e-theme", { hidden: true })
|
|
52
82
|
.description("Creates a new project for e2e tests")
|
|
53
83
|
.action((name) => {
|
|
54
|
-
|
|
55
|
-
stdio: "inherit",
|
|
56
|
-
shell: true,
|
|
57
|
-
})
|
|
84
|
+
runScript(PROJECT_SETUP_E2E_PATH, [name])
|
|
58
85
|
})
|
|
59
86
|
|
|
60
87
|
program
|
|
61
88
|
.command("config-setup [projname] [themename]")
|
|
62
89
|
.description("Creates the config files for a new project")
|
|
63
90
|
.action((projname, themename) => {
|
|
64
|
-
|
|
65
|
-
`node "${__dirname}/../${PROJECT_CONFIG_SETUP_PATH}" ${projname} ${themename}`,
|
|
66
|
-
{
|
|
67
|
-
stdio: "inherit",
|
|
68
|
-
shell: true,
|
|
69
|
-
}
|
|
70
|
-
)
|
|
91
|
+
runScript(PROJECT_CONFIG_SETUP_PATH, [projname, themename])
|
|
71
92
|
})
|
|
72
93
|
|
|
73
94
|
program
|
|
@@ -86,61 +107,50 @@ program
|
|
|
86
107
|
.on("option:verbose", () => {
|
|
87
108
|
process.env.verboseToolkitOutput = "true"
|
|
88
109
|
})
|
|
110
|
+
.option(
|
|
111
|
+
"--live-reload",
|
|
112
|
+
"Opt-in: SSE live-reload for preview/iframe (off by default)"
|
|
113
|
+
)
|
|
114
|
+
.on("option:live-reload", () => {
|
|
115
|
+
process.env.SFB_TOOLKIT_LIVE_RELOAD = "1"
|
|
116
|
+
})
|
|
89
117
|
.action(() => {
|
|
90
|
-
|
|
91
|
-
stdio: "inherit",
|
|
92
|
-
shell: true,
|
|
93
|
-
})
|
|
118
|
+
runScript(SERVER_START_PATH, [], { exitOnClose: true })
|
|
94
119
|
})
|
|
95
120
|
|
|
96
121
|
program
|
|
97
122
|
.command("about")
|
|
98
123
|
.description("Lists existing themes")
|
|
99
|
-
.action((
|
|
100
|
-
|
|
101
|
-
stdio: "inherit",
|
|
102
|
-
shell: true,
|
|
103
|
-
})
|
|
124
|
+
.action(() => {
|
|
125
|
+
runScript(ABOUT_PATH)
|
|
104
126
|
})
|
|
105
127
|
|
|
106
128
|
program
|
|
107
129
|
.command("status")
|
|
108
130
|
.description("Gives information about the current config")
|
|
109
131
|
.action(() => {
|
|
110
|
-
|
|
111
|
-
stdio: "inherit",
|
|
112
|
-
shell: true,
|
|
113
|
-
})
|
|
132
|
+
runScript(STATUS_PATH)
|
|
114
133
|
})
|
|
115
134
|
|
|
116
135
|
program
|
|
117
136
|
.command("create [name]")
|
|
118
137
|
.description("Creates a new theme")
|
|
119
138
|
.action((name) => {
|
|
120
|
-
|
|
121
|
-
stdio: "inherit",
|
|
122
|
-
shell: true,
|
|
123
|
-
})
|
|
139
|
+
runScript(NEW_THEME_PATH, [name])
|
|
124
140
|
})
|
|
125
141
|
|
|
126
142
|
program
|
|
127
143
|
.command("checkout [name]")
|
|
128
144
|
.description("Changes context to theme")
|
|
129
145
|
.action((name) => {
|
|
130
|
-
|
|
131
|
-
stdio: "inherit",
|
|
132
|
-
shell: true,
|
|
133
|
-
})
|
|
146
|
+
runScript(CHECKOUT_PATH, [name])
|
|
134
147
|
})
|
|
135
148
|
|
|
136
149
|
program
|
|
137
150
|
.command("update")
|
|
138
151
|
.description("Updates current theme configuration")
|
|
139
152
|
.action((name) => {
|
|
140
|
-
|
|
141
|
-
stdio: "inherit",
|
|
142
|
-
shell: true,
|
|
143
|
-
})
|
|
153
|
+
runScript(UPDATE_PATH, [name])
|
|
144
154
|
})
|
|
145
155
|
|
|
146
156
|
program
|
|
@@ -151,10 +161,7 @@ program
|
|
|
151
161
|
process.env.PACK_ALL = "true"
|
|
152
162
|
})
|
|
153
163
|
.action(() => {
|
|
154
|
-
|
|
155
|
-
stdio: "inherit",
|
|
156
|
-
shell: true,
|
|
157
|
-
})
|
|
164
|
+
runScript(PACKAGE_PATH)
|
|
158
165
|
})
|
|
159
166
|
|
|
160
167
|
program
|
|
@@ -175,19 +182,21 @@ program
|
|
|
175
182
|
)
|
|
176
183
|
}
|
|
177
184
|
|
|
178
|
-
const isNode18AndUp = majorVersion >= 18
|
|
179
|
-
|
|
180
185
|
const nodeArgs = []
|
|
181
186
|
|
|
182
|
-
if (
|
|
187
|
+
if (majorVersion >= 18) {
|
|
183
188
|
nodeArgs.push("--openssl-legacy-provider")
|
|
184
189
|
}
|
|
185
190
|
|
|
186
191
|
nodeArgs.push(`${__dirname}/../${STORYBOOK}`)
|
|
187
192
|
|
|
188
|
-
spawn(
|
|
193
|
+
const child = spawn(process.execPath, nodeArgs, {
|
|
189
194
|
stdio: "inherit",
|
|
190
|
-
|
|
195
|
+
cwd: process.cwd(),
|
|
196
|
+
})
|
|
197
|
+
child.on("error", (err) => {
|
|
198
|
+
console.error(`Failed to run storybook: ${err.message}`)
|
|
199
|
+
process.exit(1)
|
|
191
200
|
})
|
|
192
201
|
})
|
|
193
202
|
|
|
@@ -195,30 +204,30 @@ program
|
|
|
195
204
|
.command("install [module]")
|
|
196
205
|
.description("Installs npm module in the currently selected theme.")
|
|
197
206
|
.action((module) => {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
207
|
+
runScript(INSTALL, [module])
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
program
|
|
211
|
+
.command("install-agent-guidance")
|
|
212
|
+
.description(
|
|
213
|
+
"Install or refresh AI agent guidance (AGENTS.md, CLAUDE.md, Cursor skills) in this workspace"
|
|
214
|
+
)
|
|
215
|
+
.action(() => {
|
|
216
|
+
runScript(INSTALL_AGENT_GUIDANCE_PATH)
|
|
202
217
|
})
|
|
203
218
|
|
|
204
219
|
program
|
|
205
220
|
.command("components")
|
|
206
221
|
.description("Setup custom components")
|
|
207
222
|
.action(() => {
|
|
208
|
-
|
|
209
|
-
stdio: "inherit",
|
|
210
|
-
shell: true,
|
|
211
|
-
})
|
|
223
|
+
runScript(COMPONENTS)
|
|
212
224
|
})
|
|
213
225
|
|
|
214
226
|
program
|
|
215
227
|
.command("components-info")
|
|
216
228
|
.description("Custom components information")
|
|
217
229
|
.action(() => {
|
|
218
|
-
|
|
219
|
-
stdio: "inherit",
|
|
220
|
-
shell: true,
|
|
221
|
-
})
|
|
230
|
+
runScript(COMPONENTS_INFO)
|
|
222
231
|
})
|
|
223
232
|
|
|
224
233
|
program
|
|
@@ -235,14 +244,10 @@ program
|
|
|
235
244
|
const hasComponentArguments = components.length !== 0;
|
|
236
245
|
|
|
237
246
|
if(hasFlagArgument === hasComponentArguments) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
})}"`, {
|
|
243
|
-
stdio: "inherit",
|
|
244
|
-
shell: true,
|
|
245
|
-
})
|
|
247
|
+
const payload = hasFlagArgument
|
|
248
|
+
? buildComponentsCopyPayload(components, options)
|
|
249
|
+
: false
|
|
250
|
+
runScript(COMPONENTS_COPY, [payload])
|
|
246
251
|
} else if(hasFlagArgument) {
|
|
247
252
|
console.log('error: missing [components] argument');
|
|
248
253
|
} else {
|
|
@@ -256,10 +261,9 @@ program
|
|
|
256
261
|
.option(`${COMPONENTS_DELETE_FLAG_SHORT}, ${COMPONENTS_DELETE_FLAG_FULL} <sfbVersion> <components...>`,
|
|
257
262
|
'Delete all specified [components] found in sfb_theme_components[sfbVersion]')
|
|
258
263
|
.action(() => {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
})
|
|
264
|
+
runScript(COMPONENTS_DELETE, [
|
|
265
|
+
buildComponentsDeleteArg(process.argv.slice(3)),
|
|
266
|
+
])
|
|
263
267
|
})
|
|
264
268
|
|
|
265
269
|
program
|
|
@@ -273,23 +277,14 @@ program
|
|
|
273
277
|
.option("-o, --orderable", "Whether the component is orderable", false)
|
|
274
278
|
.description('Add a new custom component')
|
|
275
279
|
.action((name, options) => {
|
|
276
|
-
|
|
277
|
-
`node "${__dirname}/../${COMPONENTS_ADD}" ${name} ${options.page} ${options.orderable}`,
|
|
278
|
-
{
|
|
279
|
-
stdio: "inherit",
|
|
280
|
-
shell: true,
|
|
281
|
-
}
|
|
282
|
-
)
|
|
280
|
+
runScript(COMPONENTS_ADD, [name, options.page, options.orderable])
|
|
283
281
|
})
|
|
284
282
|
|
|
285
283
|
program
|
|
286
284
|
.command("use-local-sfb-components", { hidden: true })
|
|
287
285
|
.description("Setup theme to use local sfb-components bundles for e2e")
|
|
288
286
|
.action(() => {
|
|
289
|
-
|
|
290
|
-
stdio: "inherit",
|
|
291
|
-
shell: true,
|
|
292
|
-
})
|
|
287
|
+
runScript(DEV_E2E)
|
|
293
288
|
})
|
|
294
289
|
|
|
295
290
|
program
|
|
@@ -297,10 +292,7 @@ program
|
|
|
297
292
|
.alias("v")
|
|
298
293
|
.description("Shows version of sfb-toolkit\n")
|
|
299
294
|
.action(() => {
|
|
300
|
-
|
|
301
|
-
stdio: "inherit",
|
|
302
|
-
shell: true,
|
|
303
|
-
})
|
|
295
|
+
runScript(VERSION_PATH)
|
|
304
296
|
})
|
|
305
297
|
|
|
306
298
|
program
|
|
@@ -309,24 +301,14 @@ program
|
|
|
309
301
|
})
|
|
310
302
|
.description("Creates a new application")
|
|
311
303
|
.action((ExtensionName, MarketplacePath, AppPath) => {
|
|
312
|
-
|
|
313
|
-
spawn(`node "${__dirname}/../${CREATE_EXTENSION_PATH}" ${args}`, {
|
|
314
|
-
stdio: "inherit",
|
|
315
|
-
shell: true,
|
|
316
|
-
})
|
|
304
|
+
runScript(CREATE_EXTENSION_PATH, [ExtensionName, MarketplacePath, AppPath])
|
|
317
305
|
})
|
|
318
306
|
|
|
319
307
|
program
|
|
320
308
|
.command("import [themePath] [marketplacePath] [themeName]")
|
|
321
309
|
.description('Imports a theme')
|
|
322
310
|
.action((themePath, marketplacePath, themeName) => {
|
|
323
|
-
|
|
324
|
-
`node "${__dirname}/../${IMPORT_PATH}" ${themePath} ${marketplacePath} ${themeName}`,
|
|
325
|
-
{
|
|
326
|
-
stdio: "inherit",
|
|
327
|
-
shell: true,
|
|
328
|
-
}
|
|
329
|
-
)
|
|
311
|
+
runScript(IMPORT_PATH, [themePath, marketplacePath, themeName])
|
|
330
312
|
})
|
|
331
313
|
|
|
332
314
|
shouldNotBeInExtensionsFolder()
|