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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user