Project starter: ipal-kit create <domain> generates a new site from the reference site
- bin `ipal-kit` (subcommand `create`): the architecture questions (or --answers JSON), rendering from reference/ through starter.manifest.json (placeholders, @starter:if variants, //: alternatives, demo dropped), answers into AGENTS.md "Project decisions" and ipal-doctor.json, local .env with a fresh PAYLOAD_SECRET, install from the shipped lockfile, ipal-skills, ipal-tokens, generate:types/importmap, typecheck, ipal-doctor when shipped, secret check, first commit - @intecion/ipal-kit/starter: the building blocks (renderSite, validateAnswers, applyVariants, collectBundle, lockfileWithoutPlugin, secretFindings …) - build:starter packs reference/ into dist/starter/template.json.gz (90 KB); starter:gate in prepublishOnly: site from the packed tarball, frozen install, seed, build, targeted SEED_ONLY seed in production mode, full seed refused, pnpm start checks - D15: plugin dependencies pinned exactly (nodemailer 10.3.1) - reference/: @starter:if markers (runs as before), manifest generate/variants/rewrite - docs: project-starter.md, AGENT.md, ipal-setup, ipal-site, ipal-reference (+ api.md), README, PROGRAMISTA §2, CHANGELOG, docs/README, reference index Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
154049662e
commit
804a09efed
@@ -1,4 +1,8 @@
|
||||
# @starter:if demo
|
||||
# Example Studio — reference site for @intecion/ipal-kit. Copy to .env for local work.
|
||||
# @starter:else
|
||||
#: # Example Studio — copy to .env for local work (`ipal-kit create` already wrote one with a fresh PAYLOAD_SECRET).
|
||||
# @starter:endif
|
||||
# Production values live in the Coolify app → Environment Variables (docs/DEPLOY.md), never in the repo.
|
||||
|
||||
# MongoDB — database name from databaseNamesFor('example-studio.pl'): example-studiopl_dev / example-studiopl_prod
|
||||
@@ -17,6 +21,14 @@ IPAL_NOINDEX=
|
||||
# NEVER set in Coolify — production requires R2.
|
||||
ALLOW_LOCAL_MEDIA=
|
||||
|
||||
# @starter:if graph
|
||||
#: # Microsoft Graph e-mail (agency-level, all four) — email.md
|
||||
#: GRAPH_TENANT_ID=
|
||||
#: GRAPH_CLIENT_ID=
|
||||
#: GRAPH_CLIENT_SECRET=
|
||||
#: GRAPH_SENDER=
|
||||
# @starter:endif
|
||||
|
||||
# Cloudflare R2 — all or none; empty = media on local disk (dev)
|
||||
R2_BUCKET=
|
||||
R2_ENDPOINT=
|
||||
@@ -28,16 +40,20 @@ R2_PUBLIC_URL=
|
||||
NEXT_PUBLIC_TURNSTILE_SITE_KEY=1x00000000000000000000AA
|
||||
TURNSTILE_SECRET_KEY=1x0000000000000000000000000000000AA
|
||||
|
||||
# @starter:if crawl
|
||||
# Cookie scanner "Crawl site" — the shared services/cookie-crawler deployment
|
||||
IPAL_COOKIE_SCAN_URL=
|
||||
IPAL_COOKIE_SCAN_TOKEN=
|
||||
# @starter:endif
|
||||
|
||||
# IndexNow key (or generate one in Site integrations)
|
||||
INDEXNOW_KEY=
|
||||
|
||||
# @starter:if demo
|
||||
# Smoke tests only (e2e/, pnpm test:e2e) — a test admin on the LOCAL / CI database, created by
|
||||
# e2e/create-test-admin.ts with a known TOTP secret so the test signs in through the real 2FA screen.
|
||||
# Test values, never used anywhere else; the script refuses a production or non-local database.
|
||||
E2E_ADMIN_EMAIL=[email protected]
|
||||
E2E_ADMIN_PASSWORD=e2e-RC2nC29eKC8HJHfg
|
||||
E2E_TOTP_SECRET=JPURUZNWYTZX2L42MT4SS7736WWNQWBL
|
||||
# @starter:endif
|
||||
|
||||
@@ -25,7 +25,7 @@ pnpm test:e2e # smoke tests, after `pnpm pay
|
||||
| Start command | `pnpm start` (`next start` with `--disable-proto=throw`) |
|
||||
| Port | 3000 — no host port mapping (it disables rolling updates) |
|
||||
| Health check | `GET /api/health` → 200 (503 without the database) |
|
||||
| Domains | `https://example-studio.pl,https://www.example-studio.pl`, redirect www → apex (matches `NEXT_PUBLIC_SERVER_URL`) |
|
||||
| Domains | both hosts: `example-studio.pl` and `www.example-studio.pl` (with `https://`), redirect to the host of `NEXT_PUBLIC_SERVER_URL` |
|
||||
|
||||
## 3. The Coolify MongoDB resource
|
||||
- Same server and Docker network as the app; never exposed publicly.
|
||||
@@ -33,6 +33,10 @@ pnpm test:e2e # smoke tests, after `pnpm pay
|
||||
(database name from `databaseNamesFor('example-studio.pl')`; `instrumentation.ts` checks it).
|
||||
- Scheduled backups to S3/R2, and **Backup now** before every seed or bulk change.
|
||||
- MongoDB needs no migrations.
|
||||
<!-- @starter:if !r2 -->
|
||||
#: - **Media on local disk** (no R2): Coolify → the app → **Persistent Storage** → a volume for the `media` folder
|
||||
#: (the upload collection's `staticDir`), or every redeploy deletes the uploads (deployment.md §4.8).
|
||||
<!-- @starter:endif -->
|
||||
|
||||
## 4. Environment variables (Coolify → Environment Variables)
|
||||
| Variable | Build | Runtime | Note |
|
||||
@@ -40,10 +44,17 @@ pnpm test:e2e # smoke tests, after `pnpm pay
|
||||
| `DATABASE_URI` | ✓ | ✓ | build prerenders pages from the database |
|
||||
| `PAYLOAD_SECRET` | ✓ | ✓ | random, ≥ 32 characters |
|
||||
| `NEXT_PUBLIC_SERVER_URL` | ✓ | ✓ | `https://example-studio.pl` |
|
||||
<!-- @starter:if r2 -->
|
||||
| `R2_BUCKET`, `R2_ENDPOINT`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY` | | ✓ | required in production |
|
||||
| `R2_PUBLIC_URL` | ✓ | ✓ | empty = media served by the app |
|
||||
<!-- @starter:endif -->
|
||||
<!-- @starter:if graph -->
|
||||
#: | `GRAPH_TENANT_ID`, `GRAPH_CLIENT_ID`, `GRAPH_CLIENT_SECRET`, `GRAPH_SENDER` | | ✓ | e-mail through Microsoft Graph (all four) |
|
||||
<!-- @starter:endif -->
|
||||
| `IPAL_IP_HEADER` | | ✓ | `x-forwarded-for` behind Coolify's proxy (`cf-connecting-ip` behind Cloudflare) |
|
||||
<!-- @starter:if crawl -->
|
||||
| `IPAL_COOKIE_SCAN_URL`, `IPAL_COOKIE_SCAN_TOKEN` | | ✓ | the shared cookie-crawler service |
|
||||
<!-- @starter:endif -->
|
||||
| `INDEXNOW_KEY` | | ✓ | or generate the key in Site integrations |
|
||||
| `ALLOW_LOCAL_MEDIA` | — | — | **never set here** (local / CI only) |
|
||||
|
||||
|
||||
@@ -9,12 +9,36 @@ import {
|
||||
} from '@intecion/ipal-kit'
|
||||
import { withPayload } from '@payloadcms/next/withPayload'
|
||||
|
||||
// @starter:if enforceCsp
|
||||
// CSP enforced: the reference site is the example after the report-only phase (security.md → "ROLL OUT CSP").
|
||||
// Flags = what the site loads: Turnstile on forms, Google analytics/GTM when IDs are set in Site integrations.
|
||||
const csp = { mode: 'enforce', r2Url: process.env.R2_PUBLIC_URL, reportUri: '/api/csp-report' } as const
|
||||
// @starter:else
|
||||
//: // CSP step 1: report-only. Read the [csp] lines in the logs, add a flag or `extra` per report, then switch to
|
||||
//: // mode: 'enforce' (security.md → "ROLL OUT CSP"; ipal-doctor.json silences the report-only finding until then).
|
||||
//: const csp = { mode: 'report-only', r2Url: process.env.R2_PUBLIC_URL, reportUri: '/api/csp-report' } as const
|
||||
// @starter:endif
|
||||
|
||||
// Flags = what the site loads: Turnstile on forms, the analytics tools whose IDs are set in Site integrations.
|
||||
const securityHeaders = buildSecurityHeaders({
|
||||
csp: { ...csp, analytics: true, turnstile: true },
|
||||
csp: {
|
||||
...csp,
|
||||
// @starter:if analytics
|
||||
analytics: true,
|
||||
// @starter:endif
|
||||
// @starter:if metaPixel
|
||||
//: metaPixel: true,
|
||||
// @starter:endif
|
||||
// @starter:if linkedIn
|
||||
//: linkedIn: true,
|
||||
// @starter:endif
|
||||
// @starter:if tiktok
|
||||
//: tiktok: true,
|
||||
// @starter:endif
|
||||
// @starter:if clarity
|
||||
//: clarity: true,
|
||||
// @starter:endif
|
||||
turnstile: true,
|
||||
},
|
||||
hsts: process.env.NODE_ENV === 'production',
|
||||
})
|
||||
|
||||
|
||||
@@ -42,7 +42,18 @@ export default async function LocaleLayout({ children, params }: Props) {
|
||||
{/* NO <head> — Next manages it */}
|
||||
<body className="flex min-h-screen flex-col bg-bg font-body text-fg antialiased">
|
||||
<SiteProviders
|
||||
// @starter:if consentBasic
|
||||
//: analytics={{ consentMode: 'basic' }} // no request to Google before consent (AGENTS.md → Project decisions)
|
||||
// @starter:endif
|
||||
// @starter:if bannerInline
|
||||
//: banner={<CookieBanner controls="switch" equalChoice settings="inline" />}
|
||||
// @starter:endif
|
||||
// @starter:if bannerModal
|
||||
//: banner={<CookieBanner controls="switch" equalChoice settings="modal" />}
|
||||
// @starter:endif
|
||||
// @starter:if bannerDetailed
|
||||
banner={<CookieBanner controls="switch" equalChoice settings="detailed" />}
|
||||
// @starter:endif
|
||||
lightbox
|
||||
logEndpoint="/api/ipal/consent"
|
||||
shell={shell}
|
||||
|
||||
@@ -7,12 +7,18 @@ import { libraryBlocks, type LibraryBlocksOptions } from '@intecion/ipal-kit/blo
|
||||
export const blockOptions = {
|
||||
contact: true,
|
||||
cta: true,
|
||||
// @starter:if collections
|
||||
entryList: {
|
||||
collections: [
|
||||
// @starter:if posts
|
||||
{ label: { en: 'Blog posts', pl: 'Wpisy' }, value: 'posts' },
|
||||
// @starter:endif
|
||||
// @starter:if caseStudies
|
||||
{ label: { en: 'Case studies', pl: 'Realizacje' }, value: 'caseStudies' },
|
||||
// @starter:endif
|
||||
],
|
||||
},
|
||||
// @starter:endif
|
||||
faq: true,
|
||||
featureGrid: true,
|
||||
gallery: true,
|
||||
|
||||
@@ -6,7 +6,11 @@ import type { ContentOption } from '@intecion/ipal-kit'
|
||||
*/
|
||||
export const contentConfig: ContentOption = {
|
||||
collections: [
|
||||
// @starter:if posts
|
||||
{ slug: 'posts', label: 'Blog', perPage: 9 },
|
||||
// @starter:endif
|
||||
// @starter:if caseStudies
|
||||
{ slug: 'caseStudies', label: 'Case studies', perPage: 9 },
|
||||
// @starter:endif
|
||||
],
|
||||
}
|
||||
|
||||
@@ -7,8 +7,20 @@ export function register() {
|
||||
// databaseName: DATABASE_URI must name example-studiopl_dev / example-studiopl_prod (databaseNamesFor).
|
||||
// R2_PUBLIC_URL optional: media are served through the app by default (storage.md, env.md).
|
||||
assertEnv(
|
||||
ipalEnvRules({ databaseName: { domain: 'example-studio.pl' }, ipHeader: true, storage: process.env.ALLOW_LOCAL_MEDIA !== '1' }).map((rule) =>
|
||||
rule.name === 'R2_PUBLIC_URL' ? { ...rule, required: false } : rule,
|
||||
),
|
||||
ipalEnvRules({
|
||||
// @starter:if crawl
|
||||
//: cookieCrawl: true, // IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN — the shared cookie-crawler service
|
||||
// @starter:endif
|
||||
databaseName: { domain: 'example-studio.pl' },
|
||||
// @starter:if graph
|
||||
//: emailGraph: true, // GRAPH_* — e-mail through Microsoft Graph
|
||||
// @starter:endif
|
||||
ipHeader: true,
|
||||
// @starter:if r2
|
||||
storage: process.env.ALLOW_LOCAL_MEDIA !== '1',
|
||||
// @starter:else
|
||||
//: storage: false, // media on local disk — a Coolify persistent volume (AGENTS.md → Project decisions)
|
||||
// @starter:endif
|
||||
}).map((rule) => (rule.name === 'R2_PUBLIC_URL' ? { ...rule, required: false } : rule)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import { faqItemsFromLayout } from '@intecion/ipal-kit/blocks'
|
||||
// @starter:if localBusiness
|
||||
import { buildLocalBusinessJsonLd, createContentHelpers } from '@intecion/ipal-kit'
|
||||
|
||||
import { getPayload } from 'payload'
|
||||
import { contentConfig } from '@/content.config'
|
||||
import { i18nConfig, type Locale } from '@/i18n.config'
|
||||
// @starter:else
|
||||
//: import { createContentHelpers } from '@intecion/ipal-kit'
|
||||
//:
|
||||
//: import { contentConfig } from '@/content.config'
|
||||
//: import { i18nConfig } from '@/i18n.config'
|
||||
// @starter:endif
|
||||
import config from '@/payload.config'
|
||||
|
||||
/** The ONLY access to Payload, routes, links and navigation (AGENT.md §3, PROGRAMISTA §2.7). */
|
||||
@@ -49,6 +56,13 @@ export const {
|
||||
markdownAlternate: true, // GEO: <link rel="alternate" type="text/markdown"> on every page
|
||||
mcp: { serverName: 'example-studio-site' },
|
||||
pageJsonLd: { faq: (doc) => faqItemsFromLayout(doc) }, // FAQ blocks → FAQPage rich results
|
||||
// @starter:if aiBotsBlockTraining
|
||||
//: robots: { aiBots: 'block-training' }, // client decision — AGENTS.md → Project decisions (ipal-audit-skip: aibots)
|
||||
// @starter:endif
|
||||
// @starter:if aiBotsDisallow
|
||||
//: robots: { aiBots: 'disallow' }, // client decision — AGENTS.md → Project decisions (ipal-audit-skip: aibots)
|
||||
// @starter:endif
|
||||
// @starter:if localBusiness
|
||||
// LocalBusiness from the Company global (replaces the default WebSite + Organization from Site settings)
|
||||
siteJsonLd: async ({ baseUrl, locale }) => {
|
||||
const payload = await getPayload({ config })
|
||||
@@ -65,5 +79,6 @@ export const {
|
||||
}),
|
||||
]
|
||||
},
|
||||
// @starter:endif
|
||||
summaryField: 'aiSummary',
|
||||
})
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// @starter:if twoFactor
|
||||
import { payloadTotp } from '@clocklimited/payload-2fa'
|
||||
// @starter:endif
|
||||
import { buildR2Storage, ipalKit, mailAdapter } from '@intecion/ipal-kit'
|
||||
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
||||
import { s3Storage } from '@payloadcms/storage-s3'
|
||||
@@ -8,10 +10,14 @@ import { buildConfig } from 'payload'
|
||||
import sharp from 'sharp'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// @starter:if caseStudies
|
||||
import { CaseStudies } from './collections/CaseStudies'
|
||||
// @starter:endif
|
||||
import { Media } from './collections/Media'
|
||||
import { Pages } from './collections/Pages'
|
||||
// @starter:if posts
|
||||
import { Posts } from './collections/Posts'
|
||||
// @starter:endif
|
||||
import { contentConfig } from './content.config'
|
||||
import { db } from './db'
|
||||
import { Company } from './globals/Company'
|
||||
@@ -28,7 +34,17 @@ export default buildConfig({
|
||||
},
|
||||
// absolute URLs in form e-mails (logo, links)
|
||||
serverURL: process.env.NEXT_PUBLIC_SERVER_URL,
|
||||
collections: [Pages, Posts, CaseStudies, Media], // ipalKit injects `users` (roles + 2FA)
|
||||
// ipalKit injects `users` (roles + 2FA)
|
||||
collections: [
|
||||
Pages,
|
||||
// @starter:if posts
|
||||
Posts,
|
||||
// @starter:endif
|
||||
// @starter:if caseStudies
|
||||
CaseStudies,
|
||||
// @starter:endif
|
||||
Media,
|
||||
],
|
||||
globals: [Header, Footer, Company],
|
||||
db,
|
||||
editor: lexicalEditor(),
|
||||
@@ -42,14 +58,44 @@ export default buildConfig({
|
||||
access: { authCollection: 'users' },
|
||||
pages: { slug: 'pages' },
|
||||
content: contentConfig,
|
||||
seo: { collections: ['pages', 'posts', 'caseStudies'] },
|
||||
seo: {
|
||||
collections: [
|
||||
'pages',
|
||||
// @starter:if posts
|
||||
'posts',
|
||||
// @starter:endif
|
||||
// @starter:if caseStudies
|
||||
'caseStudies',
|
||||
// @starter:endif
|
||||
],
|
||||
},
|
||||
forms: { redirectRelationships: ['pages'], emailLayout: true },
|
||||
// @starter:if twoFactor
|
||||
twoFactor: { issuer: 'Example Studio', plugin: payloadTotp },
|
||||
// @starter:else
|
||||
//: twoFactor: false, // turned off by the owner — AGENTS.md → Project decisions, ipal-doctor.json
|
||||
// @starter:endif
|
||||
// @starter:if whiteLabel
|
||||
whiteLabel: true,
|
||||
// @starter:endif
|
||||
// @starter:if !adminMeta
|
||||
//: adminMeta: false, // turned off by the owner — AGENTS.md → Project decisions
|
||||
// @starter:endif
|
||||
// @starter:if agencyNone
|
||||
//: agency: false, // no agency credit (owner's choice)
|
||||
// @starter:endif
|
||||
// @starter:if agencyCustom
|
||||
//: agency: { name: 'Example Agency', url: 'https://agency.example' },
|
||||
// @starter:endif
|
||||
indexNow: true,
|
||||
consentLog: true,
|
||||
// Privacy → Cookie review: scan + approval; crawl needs IPAL_COOKIE_SCAN_URL / IPAL_COOKIE_SCAN_TOKEN
|
||||
// @starter:if crawl
|
||||
cookieScanner: { crawl: true },
|
||||
// @starter:endif
|
||||
// @starter:if scannerWithoutCrawl
|
||||
//: cookieScanner: true,
|
||||
// @starter:endif
|
||||
lightbox: true,
|
||||
revalidatePath,
|
||||
}),
|
||||
|
||||
@@ -16,11 +16,24 @@ import { pageLink, tx } from './lib'
|
||||
const blocks = libraryBlockSlugs(blockOptions)
|
||||
|
||||
export async function seedBaseGlobals(seed: Seeder) {
|
||||
await seed.fillGlobal('company', { email: '[TO FILL: e-mail that receives form submissions]', name: '[TO FILL: company name]' })
|
||||
// the inbox and the name come from the starter's answers (AGENTS.md → Project decisions)
|
||||
await seed.fillGlobal('company', { email: '[email protected]', name: 'Example Studio' })
|
||||
await seed.fillGlobal('site-settings', {
|
||||
// @starter:if themeToggle
|
||||
allowThemeToggle: true,
|
||||
// @starter:else
|
||||
//: allowThemeToggle: false,
|
||||
// @starter:endif
|
||||
// @starter:if defaultLight
|
||||
//: defaultTheme: 'light',
|
||||
// @starter:endif
|
||||
// @starter:if defaultDark
|
||||
//: defaultTheme: 'dark',
|
||||
// @starter:endif
|
||||
// @starter:if defaultSystem
|
||||
defaultTheme: 'system',
|
||||
siteName: '[TO FILL: site name]',
|
||||
// @starter:endif
|
||||
siteName: 'Example Studio',
|
||||
themeToggleLabel: tx('Tryb ciemny', 'Dark mode'),
|
||||
})
|
||||
}
|
||||
@@ -32,7 +45,9 @@ export async function seedBasePages(seed: Seeder) {
|
||||
pageTemplates.services({ blocks }),
|
||||
pageTemplates.contact({ blocks, form: { $form: 'Contact form' } }),
|
||||
// The archive page lists its entries with an entry list block (the editor decides where)
|
||||
// @starter:if posts
|
||||
pageTemplates.blogIndex({ blocks, layout: (b) => [b[0], { blockType: 'entryList', entryCollection: 'posts', limit: 9, mode: 'latest', variant: 'cards' }, ...b.slice(1)] }),
|
||||
// @starter:endif
|
||||
pageTemplates.legal('privacyPolicy', { blocks }),
|
||||
pageTemplates.legal('termsOfService', { blocks }),
|
||||
pageTemplates.cookiePolicy({ blocks }),
|
||||
@@ -44,15 +59,35 @@ export async function seedBaseNavigation(seed: Seeder) {
|
||||
const link = (label: { en: string; pl: string }, slug: string) => ({ link: { label, page: { $page: slug }, type: 'internal' } })
|
||||
await seed.fillGlobal('site-settings', {
|
||||
...systemPageRefs({ cookiePolicy: 'polityka-cookies', homepage: 'start', notFound: 'nie-znaleziono', privacyPolicy: 'polityka-prywatnosci', termsOfService: 'regulamin' }),
|
||||
// @starter:if posts
|
||||
postsArchive: { $page: 'blog' },
|
||||
// @starter:endif
|
||||
})
|
||||
await seed.fillGlobal('header', {
|
||||
links: [pageLink(tx('Kontakt', 'Contact'), 'kontakt')],
|
||||
menuLabel: tx('Menu', 'Menu'),
|
||||
navItems: [link(tx('O nas', 'About'), 'o-nas'), link(tx('Usługi', 'Services'), 'uslugi'), link(tx('Blog', 'Blog'), 'blog'), link(tx('Kontakt', 'Contact'), 'kontakt')],
|
||||
navItems: [
|
||||
link(tx('O nas', 'About'), 'o-nas'),
|
||||
link(tx('Usługi', 'Services'), 'uslugi'),
|
||||
// @starter:if posts
|
||||
link(tx('Blog', 'Blog'), 'blog'),
|
||||
// @starter:endif
|
||||
link(tx('Kontakt', 'Contact'), 'kontakt'),
|
||||
],
|
||||
})
|
||||
await seed.fillGlobal('footer', {
|
||||
columns: [{ heading: tx('Strona', 'Site'), items: [link(tx('O nas', 'About'), 'o-nas'), link(tx('Usługi', 'Services'), 'uslugi'), link(tx('Blog', 'Blog'), 'blog')] }],
|
||||
columns: [
|
||||
{
|
||||
heading: tx('Strona', 'Site'),
|
||||
items: [
|
||||
link(tx('O nas', 'About'), 'o-nas'),
|
||||
link(tx('Usługi', 'Services'), 'uslugi'),
|
||||
// @starter:if posts
|
||||
link(tx('Blog', 'Blog'), 'blog'),
|
||||
// @starter:endif
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* Seeds of the reference site — rules: node_modules/@intecion/ipal-kit/docs/seeding.md.
|
||||
*
|
||||
* pnpm seed # everything: demo layer first (filled pages win), then the base layer
|
||||
* pnpm seed:base # only what every new site keeps (the project starter runs this one)
|
||||
* pnpm seed:demo # only the made-up company's content (needs the base forms)
|
||||
* pnpm seed # the reference site: demo layer first (filled pages win), then the base layer;
|
||||
* # a site made by `ipal-kit create`: the base layer only
|
||||
* pnpm seed:base # only what every new site keeps
|
||||
* pnpm seed:demo # reference site only: the made-up company's content (needs the base forms)
|
||||
* SEED_DRY_RUN=1 pnpm seed # print the plan, write nothing
|
||||
*
|
||||
* VERY IMPORTANT — after launch: never the whole seed again. Name the records the run may touch:
|
||||
@@ -16,34 +17,50 @@ import { createSeeder } from '@intecion/ipal-kit/seed'
|
||||
import { getPayload } from 'payload'
|
||||
|
||||
import { seedBaseGlobals, seedBaseNavigation, seedBasePages, seedBaseTexts } from './base'
|
||||
// @starter:if demo
|
||||
import { DEMO_NOTIFY_EMAIL, seedDemoGlobals, seedDemoNavigation, seedDemoPages } from './demo'
|
||||
// @starter:endif
|
||||
import { seedForms } from './forms'
|
||||
// @starter:if demo
|
||||
import { seedMedia } from './media'
|
||||
// @starter:endif
|
||||
|
||||
// @starter:if demo
|
||||
const layer = process.env.SEED_LAYER ?? 'all'
|
||||
const withDemo = layer === 'all' || layer === 'demo'
|
||||
const withBase = layer === 'all' || layer === 'base'
|
||||
// @starter:else
|
||||
//: const withBase = true // a new site has only the base layer (the reference site's demo is not copied)
|
||||
// @starter:endif
|
||||
|
||||
const payload = await getPayload({ config })
|
||||
const seed = createSeeder(payload)
|
||||
|
||||
// @starter:if demo
|
||||
const media = withDemo ? await seedMedia(payload) : {}
|
||||
if (withDemo) {await seedDemoGlobals(seed, media)}
|
||||
// @starter:endif
|
||||
if (withBase) {await seedBaseGlobals(seed)}
|
||||
|
||||
// Forms need the inbox that receives submissions: SEED_NOTIFY_EMAIL, else the Company global — never a guess.
|
||||
const company = (await payload.findGlobal({ slug: 'company' })) as { email?: null | string }
|
||||
// @starter:if demo
|
||||
const notifyTo = process.env.SEED_NOTIFY_EMAIL?.trim() || (withDemo ? DEMO_NOTIFY_EMAIL : company.email?.trim()) || ''
|
||||
// @starter:else
|
||||
//: const notifyTo = process.env.SEED_NOTIFY_EMAIL?.trim() || company.email?.trim() || ''
|
||||
// @starter:endif
|
||||
if (/^[^\s@,;]+@[^\s@,;]+\.[^\s@,;]+$/.test(notifyTo)) {
|
||||
await seedForms(seed, notifyTo)
|
||||
} else {
|
||||
console.error('[seed] Forms skipped: fill Company → E-mail in the panel or run with SEED_NOTIFY_EMAIL=… (ask the client which inbox).')
|
||||
}
|
||||
|
||||
// @starter:if demo
|
||||
if (withDemo) {
|
||||
await seedDemoPages(seed, media)
|
||||
await seedDemoNavigation(seed)
|
||||
}
|
||||
// @starter:endif
|
||||
if (withBase) {
|
||||
await seedBasePages(seed)
|
||||
await seedBaseNavigation(seed)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"$comment": "How `ipal-kit create` turns this reference site into a new project. reference/ is the only hand-edited tree; the starter keeps no template files of its own. Paths are relative to reference/. Rules: keep = copied as is; drop = left out; template = copied with the placeholders below replaced. In-file variants: `// @starter:if <flag>` … `// @starter:endif` ({/* */} in TSX). The fake values are unique strings, so the generator fails if one is left in a file it does not map.",
|
||||
"$comment": "How `ipal-kit create` turns this reference site into a new project (docs/project-starter.md). reference/ is the only hand-edited tree; the starter keeps no template files of its own. Paths are relative to reference/. Roles: drop = left out; generate = written by the starter from the owner's answers; template = copied with the placeholders below replaced; keep = copied as is (and must hold no fake value). variants = whole files that exist only with a flag on. In-file variants: `// @starter:if <flag>` … `// @starter:else` … `// @starter:endif` ({/* */} in TSX, # in env files, <!-- --> in Markdown); inside a kept block a `//: ` / `#: ` line is uncommented — that is how this site carries code it does not run itself. Flags: src/modules/starter/answers.ts (flagsFromAnswers).",
|
||||
"schema": 1,
|
||||
"placeholders": {
|
||||
"{{domain}}": "example-studio.pl",
|
||||
@@ -8,47 +8,68 @@
|
||||
"{{issuer}}": "Example Studio",
|
||||
"{{projectName}}": "example-studiopl-web",
|
||||
"{{mcpName}}": "example-studio-site",
|
||||
"{{serverUrl}}": "https://example-studio.pl"
|
||||
"{{serverUrl}}": "https://example-studio.pl",
|
||||
"{{formRecipient}}": "[email protected]",
|
||||
"{{businessType}}": "ProfessionalService",
|
||||
"{{agencyName}}": "Example Agency",
|
||||
"{{agencyUrl}}": "https://agency.example"
|
||||
},
|
||||
"drop": [
|
||||
"src/seed/demo.ts",
|
||||
"src/seed/showcase.ts",
|
||||
"src/seed/media.ts",
|
||||
"media/**",
|
||||
".agents/**",
|
||||
".env",
|
||||
"node_modules/**",
|
||||
".next/**",
|
||||
"test-results/**",
|
||||
"README.md",
|
||||
"e2e/**",
|
||||
"media/**",
|
||||
"node_modules/**",
|
||||
"playwright-report/**",
|
||||
"playwright.config.ts",
|
||||
"src/payload-types.ts",
|
||||
"next-env.d.ts",
|
||||
"README.md"
|
||||
"src/seed/demo.ts",
|
||||
"src/seed/media.ts",
|
||||
"src/seed/showcase.ts",
|
||||
"test-results/**"
|
||||
],
|
||||
"generate": [
|
||||
"DESIGN.md",
|
||||
"ipal-doctor.json",
|
||||
"src/design/tokens.ts",
|
||||
"src/i18n.config.ts"
|
||||
],
|
||||
"template": [
|
||||
"package.json",
|
||||
"AGENTS.md",
|
||||
"DESIGN.md",
|
||||
"docs/DEPLOY.md",
|
||||
".env.example",
|
||||
"ipal-doctor.json",
|
||||
"src/payload.config.ts",
|
||||
"src/instrumentation.ts",
|
||||
"src/lib/content.ts",
|
||||
"src/db.ts"
|
||||
"src/db.ts",
|
||||
"src/seed/base.ts"
|
||||
],
|
||||
"variants": {
|
||||
"src/collections/Posts.ts": "posts",
|
||||
"src/collections/CaseStudies.ts": "caseStudies",
|
||||
"src/collections/entryFields.ts": "collections"
|
||||
},
|
||||
"keep": [
|
||||
"**"
|
||||
],
|
||||
"keep": ["**"],
|
||||
"rewrite": {
|
||||
"package.json": {
|
||||
"dependencies.@intecion/ipal-kit": "<exact released version>",
|
||||
"dependenciesMeta": null,
|
||||
"scripts.seed": "payload run src/seed/index.ts",
|
||||
"scripts.seed:demo": null
|
||||
},
|
||||
"src/seed/index.ts": "SEED_LAYER defaults to base; the demo imports are removed",
|
||||
"AGENTS.md": "the block between <!-- starter:decisions --> and <!-- /starter:decisions --> is replaced with the answers to the starter's questions"
|
||||
"scripts.seed:demo": null,
|
||||
"scripts.test:e2e": null,
|
||||
"devDependencies.@playwright/test": null
|
||||
}
|
||||
},
|
||||
"pages": {
|
||||
"drop": ["bloki"],
|
||||
"keep": ["design"]
|
||||
"drop": [
|
||||
"bloki"
|
||||
],
|
||||
"keep": [
|
||||
"design"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user