create-spillway 0.0.0-stage → 0.1.10
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/LICENSE +21 -0
- package/README.md +40 -2
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +133 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +291 -0
- package/dist/index.js.map +1 -0
- package/package.json +69 -3
- package/templates/astro/.env.example +27 -0
- package/templates/astro/README.md +57 -0
- package/templates/astro/_gitignore +11 -0
- package/templates/astro/astro.config.mjs +21 -0
- package/templates/astro/package.json +34 -0
- package/templates/astro/scripts/brand.mjs +40 -0
- package/templates/astro/src/env.d.ts +2 -0
- package/templates/astro/src/layouts/Layout.astro +57 -0
- package/templates/astro/src/lib/cache.ts +52 -0
- package/templates/astro/src/lib/spillway.ts +106 -0
- package/templates/astro/src/middleware.ts +18 -0
- package/templates/astro/src/pages/[...path].astro +26 -0
- package/templates/astro/src/pages/api/preview/exit.ts +4 -0
- package/templates/astro/src/pages/api/preview/index.ts +15 -0
- package/templates/astro/src/pages/api/revalidate.ts +34 -0
- package/templates/astro/src/pages/robots.txt.ts +6 -0
- package/templates/astro/src/pages/sitemap.xml.ts +19 -0
- package/templates/astro/src/styles/site.css +83 -0
- package/templates/astro/src/styles/spillway-brand.css +1 -0
- package/templates/astro/src/styles/spillway-brand.json +3 -0
- package/templates/astro/tsconfig.json +6 -0
- package/templates/next/.env.example +24 -0
- package/templates/next/README.md +48 -0
- package/templates/next/_gitignore +12 -0
- package/templates/next/app/[[...slug]]/page.tsx +56 -0
- package/templates/next/app/api/preview/exit/route.ts +6 -0
- package/templates/next/app/api/preview/route.ts +16 -0
- package/templates/next/app/api/revalidate/route.ts +41 -0
- package/templates/next/app/globals.css +83 -0
- package/templates/next/app/layout.tsx +71 -0
- package/templates/next/app/not-found.tsx +10 -0
- package/templates/next/app/robots.ts +10 -0
- package/templates/next/app/sitemap.ts +12 -0
- package/templates/next/app/spillway-brand.css +1 -0
- package/templates/next/app/spillway-brand.json +3 -0
- package/templates/next/components/Nav.tsx +30 -0
- package/templates/next/lib/spillway.ts +71 -0
- package/templates/next/next.config.ts +14 -0
- package/templates/next/package.json +34 -0
- package/templates/next/scripts/brand.mjs +40 -0
- package/templates/next/tsconfig.json +21 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spillway-next-starter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "A Next.js front end on Spillway CMS, made with create-spillway",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "next dev --port 3001",
|
|
9
|
+
"brand": "node scripts/brand.mjs",
|
|
10
|
+
"prebuild": "node scripts/brand.mjs",
|
|
11
|
+
"build": "next build",
|
|
12
|
+
"start": "next start",
|
|
13
|
+
"typecheck": "tsc --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@puckeditor/core": "^0.24.0",
|
|
17
|
+
"@spillway-cms/blocks": "latest",
|
|
18
|
+
"@spillway-cms/brand": "latest",
|
|
19
|
+
"@spillway-cms/client": "latest",
|
|
20
|
+
"@spillway-cms/next": "latest",
|
|
21
|
+
"next": "^16.4.5",
|
|
22
|
+
"react": "^19.0.0",
|
|
23
|
+
"react-dom": "^19.0.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.0.0",
|
|
27
|
+
"@types/react": "^19.0.0",
|
|
28
|
+
"@types/react-dom": "^19.0.0",
|
|
29
|
+
"typescript": "^5.9.0"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20.16"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Writes the Spillway site's published brand (GET /api/public/brand) into the project with @spillway-cms/brand: the
|
|
2
|
+
// stylesheet with the --sw-* variables and fonts, and its version (the layout compares it with the live brand).
|
|
3
|
+
// Runs before every build (prebuild) and by hand with `npm run brand`. When Spillway cannot be reached it keeps the files
|
|
4
|
+
// it has, so a build never fails for it.
|
|
5
|
+
//
|
|
6
|
+
// Using Tailwind v4? Write brandStylesheet(brand, { tailwind: 'v4' }) below and import this file after
|
|
7
|
+
// @import "tailwindcss"; then bg-primary, text-primary-700, font-heading and rounded-brand follow the brand.
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
import { brandStylesheet, fetchBrand } from '@spillway-cms/brand';
|
|
10
|
+
|
|
11
|
+
const CSS = 'app/spillway-brand.css';
|
|
12
|
+
const JSON_FILE = 'app/spillway-brand.json';
|
|
13
|
+
|
|
14
|
+
for (const file of ['.env.local', '.env']) {
|
|
15
|
+
try {
|
|
16
|
+
process.loadEnvFile(file); // never overrides a variable that is already set
|
|
17
|
+
} catch {
|
|
18
|
+
// no such file
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const url = process.env.SPILLWAY_URL;
|
|
23
|
+
if (!url) {
|
|
24
|
+
console.warn(`[brand] SPILLWAY_URL is not set; keeping ${CSS}`);
|
|
25
|
+
} else {
|
|
26
|
+
try {
|
|
27
|
+
const site = process.env.SPILLWAY_SITE ? { site: process.env.SPILLWAY_SITE, token: process.env.SPILLWAY_TOKEN } : {};
|
|
28
|
+
const brand = await fetchBrand(url, { ...site, requestInit: { signal: AbortSignal.timeout(15_000) } });
|
|
29
|
+
const css = brandStylesheet(brand);
|
|
30
|
+
if (fs.existsSync(CSS) && fs.readFileSync(CSS, 'utf8') === css) {
|
|
31
|
+
console.log(`[brand] version ${brand.version} unchanged`);
|
|
32
|
+
} else {
|
|
33
|
+
fs.writeFileSync(CSS, css);
|
|
34
|
+
fs.writeFileSync(JSON_FILE, JSON.stringify({ version: brand.version }, null, 2) + '\n');
|
|
35
|
+
console.log(`[brand] version ${brand.version} written to ${CSS}`);
|
|
36
|
+
}
|
|
37
|
+
} catch (err) {
|
|
38
|
+
console.warn(`[brand] could not fetch the brand from ${url} (${err instanceof Error ? err.message : err}); keeping ${CSS}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "react-jsx",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [{ "name": "next" }],
|
|
17
|
+
"paths": { "@/*": ["./*"] }
|
|
18
|
+
},
|
|
19
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".next/dev/types/**/*.ts"],
|
|
20
|
+
"exclude": ["node_modules"]
|
|
21
|
+
}
|