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/bin/create-nextblock.js
CHANGED
|
@@ -1097,6 +1097,9 @@ async function ensureGitignore(projectDir) {
|
|
|
1097
1097
|
'# Backups',
|
|
1098
1098
|
'backup/',
|
|
1099
1099
|
'backups/',
|
|
1100
|
+
// Written by `npm run update` when it replaces a framework file. Local safety copies
|
|
1101
|
+
// of the previous version — useful to diff against, never to commit.
|
|
1102
|
+
'.nextblock-backup/',
|
|
1100
1103
|
'',
|
|
1101
1104
|
'# Misc',
|
|
1102
1105
|
'.DS_Store',
|
|
@@ -1814,6 +1817,13 @@ async function transformPackageJson(projectDir) {
|
|
|
1814
1817
|
const packageJson = await fs.readJSON(packageJsonPath);
|
|
1815
1818
|
const projectName = basename(projectDir);
|
|
1816
1819
|
|
|
1820
|
+
// Capture the template's version BEFORE the manifest becomes the user's to manage.
|
|
1821
|
+
// From here on `packageJson.version` belongs to their site; this stamp is what
|
|
1822
|
+
// `npm run update` and the dashboard's update check compare against, so that a user
|
|
1823
|
+
// versioning their own project can never break update detection.
|
|
1824
|
+
const scaffoldedFrom =
|
|
1825
|
+
typeof packageJson.version === 'string' ? packageJson.version : null;
|
|
1826
|
+
|
|
1817
1827
|
if (projectName) {
|
|
1818
1828
|
packageJson.name = projectName;
|
|
1819
1829
|
}
|
|
@@ -1821,6 +1831,17 @@ async function transformPackageJson(projectDir) {
|
|
|
1821
1831
|
packageJson.version = packageJson.version ?? '0.1.0';
|
|
1822
1832
|
packageJson.private = packageJson.private ?? true;
|
|
1823
1833
|
|
|
1834
|
+
// `install` is the authoritative answer to "can the upstream-sync GitHub Action work
|
|
1835
|
+
// here?". The Action merges the NextBlock MONOREPO into the repository, so it only makes
|
|
1836
|
+
// sense for a repo that IS the monorepo (a 1-click deploy, fork or clone). This project
|
|
1837
|
+
// is the flattened standalone app, so the answer is no — and the marker must overwrite
|
|
1838
|
+
// the "monorepo" value the template inherits from apps/nextblock/package.json.
|
|
1839
|
+
packageJson.nextblock = {
|
|
1840
|
+
...(packageJson.nextblock ?? {}),
|
|
1841
|
+
install: 'standalone',
|
|
1842
|
+
...(scaffoldedFrom ? { version: scaffoldedFrom, installedAt: new Date().toISOString() } : {}),
|
|
1843
|
+
};
|
|
1844
|
+
|
|
1824
1845
|
packageJson.dependencies = packageJson.dependencies ?? {};
|
|
1825
1846
|
|
|
1826
1847
|
for (const [pkgName, manifestPath] of Object.entries(
|
|
@@ -1850,10 +1871,10 @@ async function transformPackageJson(projectDir) {
|
|
|
1850
1871
|
// `npm run test-create`); fall back to this baked-in set in the published CLI where the
|
|
1851
1872
|
// monorepo root is not on disk. Keep the fallback in sync with the root package.json.
|
|
1852
1873
|
const FALLBACK_OVERRIDES = {
|
|
1853
|
-
postcss: '^8.5.
|
|
1874
|
+
postcss: '^8.5.26',
|
|
1854
1875
|
qs: '^6.15.2',
|
|
1855
1876
|
uuid: '^11.1.1',
|
|
1856
|
-
glob: '^
|
|
1877
|
+
glob: '^13.0.6',
|
|
1857
1878
|
'whatwg-encoding': 'npm:@exodus/bytes@latest',
|
|
1858
1879
|
'node-domexception': 'npm:domexception@latest',
|
|
1859
1880
|
keygrip: 'npm:keygrip@latest',
|
package/package.json
CHANGED
package/scripts/sync-template.js
CHANGED
|
@@ -53,6 +53,7 @@ const IGNORED_SEGMENTS = new Set([
|
|
|
53
53
|
'coverage',
|
|
54
54
|
'backup',
|
|
55
55
|
'backups',
|
|
56
|
+
'.nextblock-backup',
|
|
56
57
|
]);
|
|
57
58
|
|
|
58
59
|
async function ensureTemplateSync() {
|
|
@@ -101,6 +102,9 @@ async function ensureTemplateSync() {
|
|
|
101
102
|
await syncPackageVersions();
|
|
102
103
|
await ensureDockerAssets();
|
|
103
104
|
await removeTemplateProjectJson();
|
|
105
|
+
await removeBuildArtifacts();
|
|
106
|
+
await markTemplateAsStandalone();
|
|
107
|
+
await ensureTemplateReadme();
|
|
104
108
|
|
|
105
109
|
console.log(chalk.green('Template sync complete.'));
|
|
106
110
|
}
|
|
@@ -178,6 +182,9 @@ pnpm-debug.log*
|
|
|
178
182
|
|
|
179
183
|
supabase/.temp
|
|
180
184
|
supabase/.branches
|
|
185
|
+
|
|
186
|
+
# Local safety copies written by \`npm run update\` when it replaces a framework file.
|
|
187
|
+
.nextblock-backup/
|
|
181
188
|
`;
|
|
182
189
|
await fs.outputFile(destination, content);
|
|
183
190
|
}
|
|
@@ -339,6 +346,96 @@ async function removeTemplateProjectJson() {
|
|
|
339
346
|
await fs.remove(projectJsonPath).catch(() => undefined);
|
|
340
347
|
}
|
|
341
348
|
|
|
349
|
+
// The wholesale copy of apps/nextblock brings its README, which is written for the MONOREPO:
|
|
350
|
+
// it tells the reader to run `npx nx serve nextblock` (a script a scaffolded project does not
|
|
351
|
+
// have) and links to `../../docs/*` (paths that do not exist outside the repo). Replace it
|
|
352
|
+
// with one written for the project the CLI actually produces.
|
|
353
|
+
async function ensureTemplateReadme() {
|
|
354
|
+
const content = `# NextBlock
|
|
355
|
+
|
|
356
|
+
Your NextBlock site — a standalone Next.js app with the CMS, block editor and storefront
|
|
357
|
+
built in. Everything here is yours to edit.
|
|
358
|
+
|
|
359
|
+
## Everyday commands
|
|
360
|
+
|
|
361
|
+
\`\`\`bash
|
|
362
|
+
npm run dev # start the dev server on http://localhost:3000
|
|
363
|
+
npm run build # production build (applies pending migrations first)
|
|
364
|
+
npm start # serve the production build
|
|
365
|
+
npm run lint # lint
|
|
366
|
+
\`\`\`
|
|
367
|
+
|
|
368
|
+
## Keeping NextBlock up to date
|
|
369
|
+
|
|
370
|
+
\`\`\`bash
|
|
371
|
+
npm run update # code + dependencies + database schema, in one step
|
|
372
|
+
npm run update -- --check # show what would change; write nothing
|
|
373
|
+
\`\`\`
|
|
374
|
+
|
|
375
|
+
New framework code comes from the published \`create-nextblock\` package and is applied as a
|
|
376
|
+
**git 3-way merge**, so edits you made to NextBlock's own files are preserved — only a change
|
|
377
|
+
that genuinely overlaps yours conflicts, with the usual \`<<<<<<<\` markers. Your own pages,
|
|
378
|
+
components, content and \`.env\` are never touched.
|
|
379
|
+
|
|
380
|
+
If a merge does conflict, the update finishes the code and dependency work and **stops before
|
|
381
|
+
touching the database**. Fix the conflicts, then run \`npm run update\` again to apply the
|
|
382
|
+
migrations — or \`git reset --hard HEAD\` to back the whole update out. Either way the database
|
|
383
|
+
is untouched until you say so.
|
|
384
|
+
|
|
385
|
+
Commit your work before updating: a clean git tree is what lets you review the result with
|
|
386
|
+
\`git diff\` and undo it with \`git reset\`.
|
|
387
|
+
|
|
388
|
+
Full details: [docs/13-STAYING-UP-TO-DATE.md](./docs/13-STAYING-UP-TO-DATE.md).
|
|
389
|
+
|
|
390
|
+
## Running the whole stack locally with Docker
|
|
391
|
+
|
|
392
|
+
\`\`\`bash
|
|
393
|
+
npm run docker:setup # first run: generate .env, build, and start everything
|
|
394
|
+
npm run docker:up # rebuild and restart (also applies pending migrations)
|
|
395
|
+
npm run docker:down # stop (your data persists in Docker volumes)
|
|
396
|
+
npm run docker:logs # follow the app logs
|
|
397
|
+
\`\`\`
|
|
398
|
+
|
|
399
|
+
On a Docker install, run \`npm run update\` and then \`npm run docker:up\` — the stack applies
|
|
400
|
+
the migrations itself.
|
|
401
|
+
|
|
402
|
+
## Documentation
|
|
403
|
+
|
|
404
|
+
The \`docs/\` folder ships with your project:
|
|
405
|
+
|
|
406
|
+
- [01-PROJECT-OVERVIEW.md](./docs/01-PROJECT-OVERVIEW.md) — how the pieces fit together
|
|
407
|
+
- [03-CMS-AND-EDITOR.md](./docs/03-CMS-AND-EDITOR.md) — the editor and block system
|
|
408
|
+
- [04-DATABASE-AND-AUTH.md](./docs/04-DATABASE-AND-AUTH.md) — schema, auth and migrations
|
|
409
|
+
- [10-CUSTOM-BLOCKS.md](./docs/10-CUSTOM-BLOCKS.md) — building your own blocks
|
|
410
|
+
- [13-STAYING-UP-TO-DATE.md](./docs/13-STAYING-UP-TO-DATE.md) — updating
|
|
411
|
+
`;
|
|
412
|
+
await fs.outputFile(resolve(TARGET_DIR, 'README.md'), content);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// apps/nextblock/package.json declares `nextblock.install = "monorepo"` — the marker that
|
|
416
|
+
// tells the runtime the upstream-sync GitHub Action can work here, because the repository IS
|
|
417
|
+
// the monorepo. The template is the flattened standalone app, where that Action would merge
|
|
418
|
+
// apps/ + libs/ + nx.json into a tree that has none of them, so the marker must be flipped.
|
|
419
|
+
// The CLI also sets this at scaffold time; doing it here as well means the template is
|
|
420
|
+
// correct on its own, and the value is never wrong for even one step of the pipeline.
|
|
421
|
+
async function markTemplateAsStandalone() {
|
|
422
|
+
const pkgPath = resolve(TARGET_DIR, 'package.json');
|
|
423
|
+
if (!(await fs.pathExists(pkgPath))) return;
|
|
424
|
+
const pkg = await fs.readJSON(pkgPath);
|
|
425
|
+
pkg.nextblock = { ...(pkg.nextblock ?? {}), install: 'standalone' };
|
|
426
|
+
await fs.writeJSON(pkgPath, pkg, { spaces: 2 });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Build artifacts that the wholesale copy of apps/nextblock drags along. tsconfig.tsbuildinfo
|
|
430
|
+
// alone is ~3.7 MB of incremental-compile state that is meaningless outside the monorepo, and
|
|
431
|
+
// it shipped in the published CLI tarball and in every scaffolded project.
|
|
432
|
+
async function removeBuildArtifacts() {
|
|
433
|
+
const targets = ['tsconfig.tsbuildinfo', '.DS_Store', 'Thumbs.db'];
|
|
434
|
+
await Promise.all(
|
|
435
|
+
targets.map((name) => fs.remove(resolve(TARGET_DIR, name)).catch(() => undefined)),
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
|
|
342
439
|
// Copy the standalone Docker assets into the template and register the docker:* npm scripts so a
|
|
343
440
|
// generated project can run `npm run docker:setup` for the one-click local self-hosted sandbox.
|
|
344
441
|
async function ensureDockerAssets() {
|
|
@@ -1,34 +1,57 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
# NextBlock
|
|
2
|
+
|
|
3
|
+
Your NextBlock site — a standalone Next.js app with the CMS, block editor and storefront
|
|
4
|
+
built in. Everything here is yours to edit.
|
|
5
|
+
|
|
6
|
+
## Everyday commands
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm run dev # start the dev server on http://localhost:3000
|
|
10
|
+
npm run build # production build (applies pending migrations first)
|
|
11
|
+
npm start # serve the production build
|
|
12
|
+
npm run lint # lint
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Keeping NextBlock up to date
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm run update # code + dependencies + database schema, in one step
|
|
19
|
+
npm run update -- --check # show what would change; write nothing
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
New framework code comes from the published `create-nextblock` package and is applied as a
|
|
23
|
+
**git 3-way merge**, so edits you made to NextBlock's own files are preserved — only a change
|
|
24
|
+
that genuinely overlaps yours conflicts, with the usual `<<<<<<<` markers. Your own pages,
|
|
25
|
+
components, content and `.env` are never touched.
|
|
26
|
+
|
|
27
|
+
If a merge does conflict, the update finishes the code and dependency work and **stops before
|
|
28
|
+
touching the database**. Fix the conflicts, then run `npm run update` again to apply the
|
|
29
|
+
migrations — or `git reset --hard HEAD` to back the whole update out. Either way the database
|
|
30
|
+
is untouched until you say so.
|
|
31
|
+
|
|
32
|
+
Commit your work before updating: a clean git tree is what lets you review the result with
|
|
33
|
+
`git diff` and undo it with `git reset`.
|
|
34
|
+
|
|
35
|
+
Full details: [docs/13-STAYING-UP-TO-DATE.md](./docs/13-STAYING-UP-TO-DATE.md).
|
|
36
|
+
|
|
37
|
+
## Running the whole stack locally with Docker
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm run docker:setup # first run: generate .env, build, and start everything
|
|
41
|
+
npm run docker:up # rebuild and restart (also applies pending migrations)
|
|
42
|
+
npm run docker:down # stop (your data persists in Docker volumes)
|
|
43
|
+
npm run docker:logs # follow the app logs
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
On a Docker install, run `npm run update` and then `npm run docker:up` — the stack applies
|
|
47
|
+
the migrations itself.
|
|
48
|
+
|
|
49
|
+
## Documentation
|
|
50
|
+
|
|
51
|
+
The `docs/` folder ships with your project:
|
|
52
|
+
|
|
53
|
+
- [01-PROJECT-OVERVIEW.md](./docs/01-PROJECT-OVERVIEW.md) — how the pieces fit together
|
|
54
|
+
- [03-CMS-AND-EDITOR.md](./docs/03-CMS-AND-EDITOR.md) — the editor and block system
|
|
55
|
+
- [04-DATABASE-AND-AUTH.md](./docs/04-DATABASE-AND-AUTH.md) — schema, auth and migrations
|
|
56
|
+
- [10-CUSTOM-BLOCKS.md](./docs/10-CUSTOM-BLOCKS.md) — building your own blocks
|
|
57
|
+
- [13-STAYING-UP-TO-DATE.md](./docs/13-STAYING-UP-TO-DATE.md) — updating
|