create-nextblock 0.15.0 → 0.15.2
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/bin/create-nextblock.js +23 -2
- package/docker-template/.dockerignore +2 -1
- package/package.json +1 -1
- package/scripts/sync-template.js +97 -0
- package/templates/nextblock-template/.dockerignore +2 -1
- package/templates/nextblock-template/README.md +57 -34
- package/templates/nextblock-template/app/api/cron/reset-sandbox/sandboxResetSql.ts +525 -1
- package/templates/nextblock-template/app/cms/settings/site-scripts/components/SiteScriptManager.tsx +13 -5
- package/templates/nextblock-template/docs/04-DATABASE-AND-AUTH.md +2 -1
- package/templates/nextblock-template/docs/08-NEXTBLOCK-CORTEX-AI-ARCHITECTURE.md +26 -11
- package/templates/nextblock-template/docs/11-SELF-HOSTED-DOCKER.md +9 -0
- package/templates/nextblock-template/docs/12-VERCEL-DEPLOYMENT.md +8 -0
- package/templates/nextblock-template/docs/13-STAYING-UP-TO-DATE.md +372 -151
- package/templates/nextblock-template/docs/README.md +2 -0
- package/templates/nextblock-template/gitignore +3 -0
- package/templates/nextblock-template/lib/onboarding/status.ts +11 -5
- package/templates/nextblock-template/lib/setup/migrations-bundle.ts +35 -0
- package/templates/nextblock-template/lib/updates/check-upstream.ts +167 -46
- package/templates/nextblock-template/package.json +6 -1
- package/templates/nextblock-template/tools/build-migrate.mjs +102 -209
- package/templates/nextblock-template/tools/lib/migrate-core.mjs +569 -0
- package/templates/nextblock-template/tools/update.mjs +1285 -0
- package/templates/nextblock-template/tsconfig.tsbuildinfo +0 -1
package/templates/nextblock-template/app/cms/settings/site-scripts/components/SiteScriptManager.tsx
CHANGED
|
@@ -184,14 +184,22 @@ function ScriptEditor({
|
|
|
184
184
|
page's CSP nonce.
|
|
185
185
|
</p>
|
|
186
186
|
<p className="text-xs text-muted-foreground">
|
|
187
|
-
Pages are React-hydrated.
|
|
188
|
-
|
|
187
|
+
Pages are React-hydrated. Do <strong>not</strong> change the text, classes, or attributes
|
|
188
|
+
of existing markup — React reconciles afterwards and reverts your change (a counter
|
|
189
|
+
animates, then snaps back). Waiting for the <code>load</code> event is not enough;
|
|
190
|
+
hydration can still be running. Animate with the Web Animations API instead, which writes
|
|
191
|
+
no attributes:
|
|
189
192
|
</p>
|
|
190
193
|
<pre className="overflow-x-auto rounded-md bg-muted p-3 text-xs">
|
|
191
|
-
<code>{`
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
<code>{`el.animate(
|
|
195
|
+
[{ opacity: 0 }, { opacity: 1 }],
|
|
196
|
+
{ duration: 600, fill: 'both' }
|
|
197
|
+
);`}</code>
|
|
194
198
|
</pre>
|
|
199
|
+
<p className="text-xs text-muted-foreground">
|
|
200
|
+
Appending your own new elements is always safe — React does not own those. So is anything
|
|
201
|
+
you can express in CSS.
|
|
202
|
+
</p>
|
|
195
203
|
</div>
|
|
196
204
|
|
|
197
205
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
@@ -104,7 +104,8 @@ Defined primarily in `00000000000002_setup_content_tables.sql`:
|
|
|
104
104
|
|
|
105
105
|
### Commerce tables
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
All defined in the baseline schema `00000000000000` (the numbers `00000000000003`/
|
|
108
|
+
`00000000000004` in earlier revisions of this doc were pre-re-baseline file names):
|
|
108
109
|
|
|
109
110
|
- `products`
|
|
110
111
|
- `product_media`
|
|
@@ -1561,8 +1561,8 @@ When modifying Cortex AI, keep these invariants:
|
|
|
1561
1561
|
15. A substituted actor identity is for attribution only, never authorization.
|
|
1562
1562
|
16. The audit log for site scripts is append-only in the database. Reverting writes a
|
|
1563
1563
|
new revision; it never removes one.
|
|
1564
|
-
17. Inline scripts in block HTML need the CSP nonce, and must
|
|
1565
|
-
|
|
1564
|
+
17. Inline scripts in block HTML need the CSP nonce, and must not mutate
|
|
1565
|
+
server-rendered DOM at all — `load` is not a post-hydration signal.
|
|
1566
1566
|
|
|
1567
1567
|
## MCP Server: Security Model and Operator Guide
|
|
1568
1568
|
|
|
@@ -1638,15 +1638,30 @@ The site CSP carries a nonce, and per CSP Level 2 a browser **ignores
|
|
|
1638
1638
|
authorized regardless of the CSP host allowlist. That is inherent to the feature
|
|
1639
1639
|
and a reason it is ADMIN-only.
|
|
1640
1640
|
|
|
1641
|
-
Author scripts
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1641
|
+
### Author scripts and React hydration
|
|
1642
|
+
|
|
1643
|
+
Public pages are React-hydrated, and this is the single most common way an author
|
|
1644
|
+
script goes wrong. **Do not change the text, classes, or attributes of
|
|
1645
|
+
server-rendered markup.** React reconciles after the script runs and either reverts
|
|
1646
|
+
the change or logs a hydration mismatch — a counter visibly animates and then snaps
|
|
1647
|
+
back to its server value.
|
|
1648
|
+
|
|
1649
|
+
Waiting for the `load` event is **not** a fix. With streaming and selective
|
|
1650
|
+
hydration, hydration can still be in flight when `load` fires; this was tried and
|
|
1651
|
+
still produced mismatches on `<section className=…>`.
|
|
1652
|
+
|
|
1653
|
+
Patterns that are actually safe:
|
|
1654
|
+
|
|
1655
|
+
- **Web Animations API.** `el.animate([...], {fill: 'both'})` creates an Animation
|
|
1656
|
+
object and writes neither `class` nor `style`, so React has nothing to diff. A
|
|
1657
|
+
paused animation held at `currentTime = 0` hides an element without a class.
|
|
1658
|
+
- **Append your own elements.** React does not own what the script creates, so a
|
|
1659
|
+
progress bar or overlay appended to `<body>` is unconditionally safe.
|
|
1660
|
+
- **CSS.** Anything expressible in CSS carries no hydration risk at all.
|
|
1661
|
+
- **If text must change**, render the FINAL value server-side and animate toward it
|
|
1662
|
+
once the element scrolls into view, so any reconciliation lands on the correct
|
|
1663
|
+
value rather than resetting the animation. Format numbers with a fixed formatter,
|
|
1664
|
+
not `toLocaleString()`, so the client string matches the server byte for byte.
|
|
1650
1665
|
|
|
1651
1666
|
### SSRF
|
|
1652
1667
|
|
|
@@ -95,6 +95,15 @@ Both named volumes persist your database and uploaded media across restarts.
|
|
|
95
95
|
| `npm run docker:up` | Rebuild and (re)start the stack. |
|
|
96
96
|
| `npm run docker:down` | Stop the stack. Add `-v` to also delete the volumes (wipes local data). |
|
|
97
97
|
| `npm run docker:logs` | Follow the app logs (`docker compose logs -f nextblock-cms`). |
|
|
98
|
+
| `npm run update` | Update the app, its dependencies and the staged migration SQL. Follow it with `docker:up`, which is what applies the migrations — see below. |
|
|
99
|
+
|
|
100
|
+
> **Updating a Docker install: `npm run update` then `npm run docker:up`.** The updater
|
|
101
|
+
> deliberately does *not* apply migrations here. This stack ships its own migration runner
|
|
102
|
+
> (the `migrate` service, which mounts `supabase/migrations` and records applied versions in
|
|
103
|
+
> `public._nextblock_docker_migrations` — a different tracker from the one every other
|
|
104
|
+
> install uses), so applying the same SQL from the updater as well would run it through two
|
|
105
|
+
> trackers. The updater refreshes the SQL on disk and hands the schema step to the stack.
|
|
106
|
+
> Full details in [docs/13](./13-STAYING-UP-TO-DATE.md).
|
|
98
107
|
|
|
99
108
|
### Ports (override with env vars)
|
|
100
109
|
|
|
@@ -168,3 +168,11 @@ zero-config); a **private** repo additionally needs a `NEXTBLOCK_GITHUB_TOKEN` e
|
|
|
168
168
|
the in-CMS conflict banner. (Only a *manually-created GitHub fork* has Actions disabled
|
|
169
169
|
until you enable them on the Actions tab.) Full details — both tracks, conflict handling,
|
|
170
170
|
and build-time migrations — are in [docs/13](./13-STAYING-UP-TO-DATE.md).
|
|
171
|
+
|
|
172
|
+
> **This applies to the 1-click deploy specifically, not to "anything on Vercel".** The
|
|
173
|
+
> sync workflow merges the NextBlock **monorepo** into your repository, so it only works
|
|
174
|
+
> where your repository *is* that monorepo — a 1-click deploy, a GitHub fork, or a clone. A
|
|
175
|
+
> project created with `npm create nextblock` is the flattened standalone app; deploying it
|
|
176
|
+
> to Vercel does not change its shape, and NextBlock deliberately does not offer it the
|
|
177
|
+
> workflow (merging `apps/`, `libs/` and `nx.json` into it would wreck it). That kind of
|
|
178
|
+
> install updates with `npm run update` — see [docs/13](./13-STAYING-UP-TO-DATE.md).
|