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
@@ -78,6 +78,11 @@ the ready-to-send list is in **ipal-setup** stage 0 (ipal-site phase 0 uses the
|
||||
| Admin | 2FA, white-label (client brand in the panel), agency credit |
|
||||
| Hosting | Coolify, the production domain(s), who adds the DNS records (deployment.md §6) |
|
||||
|
||||
- **A new site starts with `ipal-kit create`** (docs/project-starter.md): `pnpm --config.auto-install-peers=false dlx
|
||||
@intecion/ipal-kit@<version> create <domain>` asks exactly these questions (or reads them from `--answers file.json`),
|
||||
generates the site from the reference site, writes the answers into `AGENTS.md` and makes the first commit. Ask the owner
|
||||
first, then pass the answers — the command never fills a gap. The manual path (`ipal-setup` stages 1–11) is for an
|
||||
existing project or what the command does not cover yet (another default language, no URL prefix, Postgres).
|
||||
- Write every answer into the project's `AGENTS.md` → **"Project decisions"** (one line per topic).
|
||||
- **Do not guess a missing answer.** No answer to an architecture question → do not build that part; ask again.
|
||||
(Only *content* gaps — company data, texts, IDs — may wait: use `[TO FILL: …]` in the panel, §0a.)
|
||||
@@ -1314,6 +1319,7 @@ Anything that needs a developer → move it to the panel.
|
||||
| R2, `buildImagesConfig`, YouTube | [storage.md](../storage.md) |
|
||||
| Front end: `createContentHelpers` (`@/lib/content`), `createPageRoute`, `SiteProviders` | [frontend.md](../frontend.md) |
|
||||
| Integrations (the `site-integrations` global, statuses, email test) | [integrations.md](../integrations.md) |
|
||||
| New site from the reference site: `ipal-kit create`, `@intecion/ipal-kit/starter` | [project-starter.md](../project-starter.md) |
|
||||
| Deployment, production env, health check | [deployment.md](../deployment.md) |
|
||||
| Seeds on production: create-only, dry run, backup, update guard | [seeding.md](../seeding.md) |
|
||||
| Meta Pixel / GA4 via GTM | [gtm-meta-pixel.md](../gtm-meta-pixel.md) |
|
||||
|
||||
@@ -25,7 +25,7 @@ Rules: AGENT.md §13, §0a.
|
||||
| `README.md` | how to run the reference site and what is where |
|
||||
| `docs/DEPLOY.md` | the Coolify runbook: local check, app settings, MongoDB resource, env, targeted seeds, DNS, rollback |
|
||||
| `ipal-doctor.json` | the production domain and launch state for ipal-doctor (below) |
|
||||
| `next.config.ts` | security headers, enforced CSP, admin CSP, upload headers, images, no X-Powered-By (below) |
|
||||
| `next.config.ts` | security headers, enforced CSP, admin CSP, upload headers, images, no X-Powered-By |
|
||||
| `package.json` | scripts (build, start, seed, tokens, generate), pinned Payload versions and overrides |
|
||||
| `playwright.config.ts` | smoke tests against the built, seeded site (below) |
|
||||
| `postcss.config.mjs` | Tailwind 4 through PostCSS (below) |
|
||||
@@ -67,48 +67,6 @@ legacy-peer-deps=true
|
||||
}
|
||||
```
|
||||
|
||||
### `next.config.ts`
|
||||
|
||||
```ts
|
||||
import type { NextConfig } from 'next'
|
||||
|
||||
import {
|
||||
buildAdminCspHeaders,
|
||||
buildImagesConfig,
|
||||
buildSecurityHeaders,
|
||||
buildUploadSecurityHeaders,
|
||||
withSecurityConfig,
|
||||
} from '@intecion/ipal-kit'
|
||||
import { withPayload } from '@payloadcms/next/withPayload'
|
||||
|
||||
// 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
|
||||
|
||||
const securityHeaders = buildSecurityHeaders({
|
||||
csp: { ...csp, analytics: true, turnstile: true },
|
||||
hsts: process.env.NODE_ENV === 'production',
|
||||
})
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
// ALLOW_LOCAL_MEDIA=1 (local / CI production checks only): let next/image optimize files the app serves on localhost
|
||||
images: buildImagesConfig(process.env.ALLOW_LOCAL_MEDIA === '1' ? { production: false } : {}),
|
||||
// Metadata in <head> for crawlers (deployment.md §3a)
|
||||
htmlLimitedBots:
|
||||
/Googlebot|Google-InspectionTool|Storebot-Google|Bingbot|Yandex|DuckDuckBot|Baiduspider|Screaming Frog|AhrefsBot|SemrushBot/i,
|
||||
async headers() {
|
||||
return [
|
||||
{ source: '/:path*', headers: securityHeaders },
|
||||
{ source: '/admin/:path*', headers: buildAdminCspHeaders(csp) }, // after the site-wide rule
|
||||
...buildUploadSecurityHeaders(),
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
// withSecurityConfig: no X-Powered-By (Next's and Payload's)
|
||||
export default withPayload(withSecurityConfig(nextConfig))
|
||||
```
|
||||
|
||||
### `playwright.config.ts`
|
||||
|
||||
```ts
|
||||
@@ -200,8 +158,12 @@ 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
|
||||
],
|
||||
}
|
||||
```
|
||||
@@ -245,9 +207,21 @@ 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)),
|
||||
)
|
||||
}
|
||||
```
|
||||
@@ -566,12 +540,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,
|
||||
|
||||
@@ -195,6 +195,7 @@ Mandatory set: AGENT.md §0b, skill **ipal-setup**; checks: **ipal-audit**, **ip
|
||||
| a11y widget CSS | `styles.css` | `@import "@intecion/ipal-kit/a11y.css";` (only with `<AccessibilityWidget>`) | widget options change the page | accessibility.md |
|
||||
| `/its` panel | `app/(payload)/its/…` | `adminRoute: '/its'` + `its` in the proxy matcher | `/its` login, `/admin` 404 | security.md |
|
||||
| skills | `package.json` | `"ipal:skills": "ipal-skills"` | `.agents/skills/` up to date | PROGRAMISTA §2.1a |
|
||||
| a new site | CLI (from the parent folder) | `pnpm --config.auto-install-peers=false dlx @intecion/ipal-kit@<version> create <domain> [--answers answers.json] [--dir] [--external] [--no-install] [--no-git] [--dry-run]`; in a project: `pnpm exec ipal-kit create <domain> --dir ../<name>-web`. Building blocks: `@intecion/ipal-kit/starter` (resources/api.md) | one commit, `AGENTS.md` decisions filled, `pnpm typecheck` passes | project-starter.md |
|
||||
| eject a library block | CLI | `pnpm exec ipal-blocks list` / `pnpm exec ipal-blocks eject faq [--dest src/blocks] [--dry-run]` → `src/blocks/Faq/`; then the ejected builder in `blockOptions`' place and `components: { faq: FaqBlock }` | the block renders from the project file | block-library.md "Own blocks and eject" |
|
||||
|
||||
**`createContentHelpers` keys (exports of `@/lib/content`)** — all lazy and cached per request:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# ipal-kit — export index
|
||||
|
||||
Every public export of `@intecion/ipal-kit` (all entries: root, `/client`, `/rsc`,
|
||||
`/server`, `/seed`, `/next/middleware`, `/admin`, `/env`, `/blocks`, `/blocks/rsc`, `/templates`, `/tokens`), grouped by module. Search with grep
|
||||
`/server`, `/seed`, `/starter`, `/next/middleware`, `/admin`, `/env`, `/blocks`, `/blocks/rsc`, `/templates`, `/tokens`), grouped by module. Search with grep
|
||||
(`grep -n "name" .agents/skills/ipal-reference/resources/api.md`) before you write anything yourself.
|
||||
"Import from" column — the first entry is preferred. Plugin options, env, routes and what the
|
||||
project wires: `../SKILL.md`. Module details: `node_modules/@intecion/ipal-kit/docs/<page>.md`.
|
||||
@@ -739,6 +739,31 @@ Most routes and metadata are already ready in `createContentHelpers` (`generateP
|
||||
|
||||
**Types:** `ThemeOptions` (root, `ipalKit({ theme })`), `Theme`, `ThemeSetting`, `ThemeConfig` (root, `/client`) — theme, setting from the panel and theme options; `ThemeScriptProps` (`/rsc`), `ThemeSwitcherProps`, `ThemeSwitcherClassNames` (`/client`) — component props.
|
||||
|
||||
## Project starter (`starter`) — details: `node_modules/@intecion/ipal-kit/docs/project-starter.md`
|
||||
|
||||
Bin: `ipal-kit create <domain>` (`pnpm --config.auto-install-peers=false dlx @intecion/ipal-kit@<version> create …`).
|
||||
`@intecion/ipal-kit/starter` uses Node built-ins only (no Payload) — the building blocks of the command.
|
||||
|
||||
| Export | Import from | What it does / when |
|
||||
|---|---|---|
|
||||
| `runCreateCli(args, log?)`, `CREATE_USAGE` | `@intecion/ipal-kit/starter` | The command (`ipal-kit create`) — returns the exit code. |
|
||||
| `parseCreateArgs(args)`, `normalizeDomain(input)`, `localEnv(example)` | `@intecion/ipal-kit/starter` | Its pieces: options, `https://www.X.pl/` → `x.pl` (punycode), `.env` with a fresh `PAYLOAD_SECRET`. |
|
||||
| `validateAnswers(input)`, `STARTER_TOPICS` | `@intecion/ipal-kit/starter` | The architecture answers (`StarterAnswers`): every missing / invalid one as a line; `[]` = valid. |
|
||||
| `flagsFromAnswers(answers)` | `@intecion/ipal-kit/starter` | The `@starter:if` flags the answers turn on (`twoFactor`, `posts`, `crawl`, `r2`, `enforceCsp: false`, `demo: false`…). |
|
||||
| `askAnswers(ask)` | `@intecion/ipal-kit/starter` | The questions with any `ask(question) → Promise<string>` (terminal, chat bridge). |
|
||||
| `collectBundle(dir)`, `packBundle(bundle)`, `unpackBundle(buffer)`, `bundleFlags(bundle)` | `@intecion/ipal-kit/starter` | `reference/` → the bundle (fails on a fake value in a kept file) → gzip and back; the flags the markers use. |
|
||||
| `renderSite(bundle, answers, ctx)`, `placeholderValues(answers, ctx)` | `@intecion/ipal-kit/starter` | The new site's files (path → content), in memory; the value of every `{{token}}`. |
|
||||
| `applyVariants(text, flags, file?)`, `variantFlags(text)` | `@intecion/ipal-kit/starter` | `@starter:if` / `else` / `endif` blocks (nesting; `//: ` / `#: ` lines uncommented inside kept blocks). |
|
||||
| `applyPlaceholders(text, fakes, values)`, `leftoverFakes(text, fakes)` | `@intecion/ipal-kit/starter` | Fake values → the site's values (longest first); what is left. |
|
||||
| `assertManifest(value)`, `fileRole(path, manifest)`, `matchGlob(path, glob)`, `ALWAYS_SKIPPED` | `@intecion/ipal-kit/starter` | `starter.manifest.json`: drop / generate / template / keep. |
|
||||
| `renderI18nConfig`, `renderTokens`, `renderDesignMd`, `renderAgentsMd`, `renderDecisions`, `renderDoctorConfig` | `@intecion/ipal-kit/starter` | Files and sections written from the answers (languages, brand, DESIGN.md, AGENTS.md decisions, ipal-doctor.json). |
|
||||
| `rewriteFonts(layout, answers)`, `fontExport(name)`, `rewritePackageJson(text, rules, ctx, answers)` | `@intecion/ipal-kit/starter` | next/font calls → the answered fonts; the manifest's package.json rewrite. |
|
||||
| `lockfileWithoutPlugin(lock)` | `@intecion/ipal-kit/starter` | The reference lockfile without the plugin (shipped with the bundle). |
|
||||
| `secretFindings(files)` | `@intecion/ipal-kit/starter` | The pre-commit check: `.env*`, assigned secrets, private keys. |
|
||||
|
||||
**Types:** `StarterAnswers`, `AnalyticsTool`, `ContentCollection` — the answers; `StarterBundle`, `StarterManifest`, `FileRole`,
|
||||
`StarterFlags`, `SiteContext` — the bundle, the manifest, the flags and the site context (all `/starter`).
|
||||
|
||||
## Design tokens (`tokens`) — details: `node_modules/@intecion/ipal-kit/docs/design-tokens.md`
|
||||
|
||||
CSS: `@intecion/ipal-kit/tokens.css` (neutral `--ipal-*` defaults, light/dark, `[data-surface="inverse"]`), `@intecion/ipal-kit/tailwind.css`
|
||||
|
||||
@@ -66,7 +66,21 @@ propose a concrete choice and get a yes before you build it.
|
||||
|
||||
## 1. Installation
|
||||
|
||||
**Steps.** Scaffold: `npx create-payload-app@latest <project>` (Blank, Postgres/Mongo), delete the starter
|
||||
**New site: `ipal-kit create` does stages 1–10 in one command** (`node_modules/@intecion/ipal-kit/docs/project-starter.md`).
|
||||
After stage 0, write the answers as JSON (shape `StarterAnswers` from `@intecion/ipal-kit/starter`) and run, from the
|
||||
folder that will hold the project (needs the `@intecion` registry line in `~/.npmrc`):
|
||||
```bash
|
||||
pnpm --config.auto-install-peers=false dlx @intecion/ipal-kit@<version> create <domain> --answers answers.json
|
||||
```
|
||||
It generates the site from the reference site, writes `.env` (fresh `PAYLOAD_SECRET`), installs from the shipped
|
||||
lockfile, runs `ipal-skills`, `ipal-tokens`, `generate:types`, `generate:importmap`, `typecheck` (and `ipal-doctor
|
||||
--strict` when shipped), checks for secrets and makes the first commit. **Check:** `git log --oneline` = 1 commit,
|
||||
`git status` clean, `AGENTS.md` → "Project decisions" holds every answer, `pnpm typecheck` passes. Then go to stage 11.
|
||||
**Turn off / override:** it refuses another default language than `pl`, sites without `en`, URLs without a prefix and
|
||||
Postgres — use the stages below; every generated file is the project's own afterwards. The stages below are also the
|
||||
path for an existing project.
|
||||
|
||||
**Steps (manual path).** Scaffold: `npx create-payload-app@latest <project>` (Blank, Postgres/Mongo), delete the starter
|
||||
`src/app/(frontend)/layout.tsx` and `page.tsx` (the frontend root becomes `[locale]/layout.tsx`). Do not create
|
||||
`middleware.ts` (Next 16 = `proxy.ts`; delete an existing one). Never install from git (`git+https://…`).
|
||||
```ini
|
||||
|
||||
@@ -45,7 +45,12 @@ decision on that part; no hand-built replacement, no silent workaround. **Code r
|
||||
decision (AGENT §0a) and on a plugin gap (ipal-plugin-gap — report, wait for the owner).
|
||||
|
||||
## Phase 1 — Foundation
|
||||
- New project → **ipal-setup** (all of it, with `ipal-skills`, `AGENTS.md`). Every file you wire has its canonical
|
||||
- **New site → `ipal-kit create`** with the phase-0 answers as JSON (`docs/project-starter.md`):
|
||||
`pnpm --config.auto-install-peers=false dlx @intecion/ipal-kit@<version> create <domain> --answers answers.json`.
|
||||
It generates the site from the reference site (every §0b item wired), installs the skills, writes the answers into
|
||||
`AGENTS.md`, and makes the first commit. Check: `git log --oneline` = 1 commit, `pnpm typecheck` passes. Then continue
|
||||
with phase 2. What it refuses (another default language, no URL prefix, Postgres) → the manual path below.
|
||||
- New project without the command → **ipal-setup** (all of it, with `ipal-skills`, `AGENTS.md`). Every file you wire has its canonical
|
||||
version in the reference site: `node_modules/@intecion/ipal-kit/docs/agent/reference-site/INDEX.md` (AGENT.md
|
||||
"Reference site") — copy the pattern, change only the content.
|
||||
- Existing project on an older ipal-kit → **ipal-upgrade** before anything else.
|
||||
|
||||
Reference in New Issue
Block a user