@forumone/create-throughline 0.3.1 → 0.5.0

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.
Files changed (39) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/dist/generator.d.ts.map +1 -1
  3. package/dist/generator.js +5 -0
  4. package/dist/generator.js.map +1 -1
  5. package/dist/post-install.d.ts.map +1 -1
  6. package/dist/post-install.js +10 -3
  7. package/dist/post-install.js.map +1 -1
  8. package/dist/templates/base/.env.example +32 -18
  9. package/dist/templates/base/CLAUDE.md +112 -0
  10. package/dist/templates/base/README.md +92 -7
  11. package/dist/templates/base/apps/web/e2e/site.ts +36 -0
  12. package/dist/templates/base/apps/web/e2e/smoke.spec.ts +52 -0
  13. package/dist/templates/base/apps/web/package.json.template +23 -7
  14. package/dist/templates/base/apps/web/playwright.config.ts +63 -0
  15. package/dist/templates/base/apps/web/scripts/check-migrations.ts +147 -0
  16. package/dist/templates/base/apps/web/scripts/lib/target.ts +95 -0
  17. package/dist/templates/base/apps/web/scripts/write-migration-snapshot.ts +119 -0
  18. package/dist/templates/base/apps/web/src/access/anonymousAccess.test.ts +36 -0
  19. package/dist/templates/base/apps/web/src/app/api/inngest/route.ts.template +41 -4
  20. package/dist/templates/base/apps/web/src/instrumentation.ts +35 -0
  21. package/dist/templates/base/apps/web/src/lib/cache-tags.ts +23 -0
  22. package/dist/templates/base/apps/web/src/lib/database.ts +158 -0
  23. package/dist/templates/base/apps/web/src/payload.config.ts.template +136 -19
  24. package/dist/templates/base/apps/web/vitest.config.ts +57 -0
  25. package/dist/templates/base/claude/hooks/gate.sh +45 -0
  26. package/dist/templates/base/claude/settings.json +16 -0
  27. package/dist/templates/base/github/scripts/check-generated.sh +44 -0
  28. package/dist/templates/base/github/workflows/ci.yml +143 -0
  29. package/dist/templates/base/gitignore +9 -0
  30. package/dist/templates/base/package.json.template +7 -1
  31. package/dist/templates/base/scripts/check-audit.ts +117 -0
  32. package/dist/templates/base/scripts/check-single-instance.ts +113 -0
  33. package/dist/templates/base/scripts/check-tested-packages.ts +163 -0
  34. package/dist/templates/base/turbo.json +16 -1
  35. package/dist/templates/with-reference-ds/design-system/scripts/build-manifest.ts +59 -29
  36. package/dist/templates/with-reference-ds/design-system/scripts/validate.ts +26 -1
  37. package/dist/templates/with-reference-ds/design-system/src/components/Divider/Divider.contract.ts +1 -0
  38. package/dist/versions.json +11 -11
  39. package/package.json +5 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,130 @@
1
1
  # @forumone/create-throughline
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 006ae30: A missing environment variable is reported together with every other one, in a
8
+ single error, instead of one plugin at a time.
9
+
10
+ The plugins that read the environment at init now declare what they cannot
11
+ start without, as data: `approvalsEnv` (`APPROVAL_TOKEN_SECRET`, 32+
12
+ characters), `emailEnv` (`RESEND_API_KEY`, `EMAIL_FROM_ADDRESS`) and `formsEnv`
13
+ (`FORMS_IP_HASH_SECRET`, 32+ characters). Each is a list of `EnvRequirement`
14
+ (`{ name, minLength?, why }`), a new type in `plugin-contract`, and each
15
+ plugin's own init check now reads the same entries, so the two cannot drift.
16
+ An empty or whitespace-only value now counts as missing in those checks.
17
+
18
+ Core exports `assertEnvironment(...checks)`. Call it first in
19
+ `payload.config.ts` with the plugins' lists and your own variables; it throws
20
+ one `EnvironmentError` whose first line reads "Configuration problem: N
21
+ environment variables are missing or invalid", followed by every missing or
22
+ too-short variable and why it is needed. Values are never printed. An argument
23
+ can also be a function, for a rule that is not "this name, this long", such as
24
+ a database URL accepted under several names. `checkEnvValue` is the one-value
25
+ check behind it, for a plugin's own backstop.
26
+
27
+ New projects call `assertEnvironment` at the top of `payload.config.ts` with
28
+ `approvalsEnv`, `emailEnv`, `formsEnv`, `PAYLOAD_SECRET` (32+ characters),
29
+ `NEXT_PUBLIC_SERVER_URL` and the database resolver, and `.env.example` marks
30
+ which variables are checked. An existing site can do the same and delete any
31
+ hand-kept copy of the plugins' requirements.
32
+
33
+ - 833c1bd: A scaffolded project ships the rules an agent, or a new developer, needs:
34
+
35
+ - **`CLAUDE.md`** covers the layout, the gate in CI's own order, which files are generated and committed, how migrations and snapshots work, and the contract rule for the design system.
36
+ - **A Stop hook** (`.claude/hooks/gate.sh`) runs typecheck and lint when a session ends with pending changes. It reports, never blocks, and is silenced by `THROUGHLINE_SKIP_GATE=1`.
37
+
38
+ The README's project layout now matches what the scaffold generates.
39
+
40
+ - 549d292: A scaffolded project runs every Payload CLI script — `payload`, `generate:types`, `generate:importmap`, `migrate`, `migrate:create`, `migrate:status` — through core's `throughline-payload`, so a hung run is killed rather than left spinning after its shell dies. It adds `payload:reap` to `apps/web` and the root, and ignores `.payload-cli-pids`.
41
+ - 70385c4: A scaffolded project reports its failures. `apps/web/src/instrumentation.ts` sends unhandled request errors to `ERROR_WEBHOOK_URL` through core's reporter, and warns at boot when that variable is unset. The Inngest route passes `createTerminalFailureHandler` to every framework workflow and `createHealthcheckFailureHandler` to the healthcheck. `payload.config.ts` registers `jobFailuresPlugin`. `.env.example` lists `ERROR_WEBHOOK_URL` as optional.
42
+
43
+ A new project's first migration includes the `job-failures` table. An existing project that copies these changes needs `payload migrate:create`.
44
+
45
+ - c8a86bf: A scaffolded project now starts with tests in `apps/web`:
46
+
47
+ - **Vitest.** `vitest.config.ts` loads `payload.config.ts` with placeholder variables and no database. `src/access/anonymousAccess.test.ts` uses `describeAnonymousAccess` to put every collection the project has into an access bucket. `pnpm test` runs it in CI's `fast` job. `check:tested` drops its exception for `apps/web`.
48
+ - **Playwright smoke pack.** `e2e/` runs against `next start`, or against `E2E_BASE_URL`. It checks the front door, a 404, the admin sign-in screen, and anonymous REST reads. The paths are in `e2e/site.ts`, along with the checks a new project cannot pass yet because it does not serve the routes they test. It runs in CI's `verify` job after the build. The new scripts are `test`, `test:smoke` and `test:smoke:install`.
49
+ - **`pages` read rule.** The example `pages` collection gains a published-or-signed-in `read` rule. Before, Payload's default refused every anonymous read, so the public site could never read a page.
50
+
51
+ ### Patch Changes
52
+
53
+ - c8a86bf: The `Divider` contract now declares `decorative` with `defaultValue: true`, matching the component. Before, the default was written only in prose, so a divider added in the CMS started unticked and screen readers announced it.
54
+ - ab623e1: The scaffolded `payload.config.ts` uses core's `mcpApiKeyAccess(isAdmin)` to make the MCP key collection admin-only, replacing the inline override. It now also covers `unlock` and refuses a key principal outright. The scaffold depends on `payload` and `@payloadcms/*` `^3.89.0`.
55
+ - 653817e: Revalidation no longer guesses paths, and covers the changes a publish event never announces.
56
+
57
+ - **workflows (breaking)**: `createRevalidateOnPublishFunction` has no built-in URL
58
+ builders. They mapped `pages` to `/<slug>`, `posts` to `/blog/<slug>` and any other
59
+ collection to `/<slug>`, so a site whose routes differed revalidated the wrong path
60
+ without a word. `urlBuilders` is now required; a collection with no entry has its
61
+ tags dropped and no path revalidated, and the run logs a warning. To keep the old
62
+ behaviour, pass the old builders:
63
+
64
+ ```ts
65
+ urlBuilders: {
66
+ pages: (slug) => (slug === 'home' || slug === '' ? '/' : `/${slug}`),
67
+ posts: (slug) => `/blog/${slug}`,
68
+ }
69
+ ```
70
+
71
+ and then check them against your routes.
72
+
73
+ - **workflows**: `createTagRevalidationHooks` — collection `afterChange` and
74
+ `afterDelete`, and global `afterChange`, hooks that call
75
+ `revalidateTag(tag, { expire: 0 })`. Draft saves and autosave drop nothing (via
76
+ publishing's `isDraftWrite`); an unpublish still does. A hook never throws: outside a
77
+ Next request (seeds, migrations, the CLI) it logs at `debug`, and any other failure
78
+ at `error` with the tag and the cause.
79
+ - **workflows**: `createCacheTags` builds every tag string, so the hooks, the publish
80
+ workflow (new `cacheTags` option) and cached reads cannot name different tags.
81
+ Defaults: the bare slug for a collection, `global_<slug>` for a global. Also on the
82
+ dependency-free `@forumone/throughline-workflows/cache-tags` subpath for frontend code.
83
+ `@forumone/throughline-publishing` is now a dependency of this package.
84
+ - **create-throughline**: the scaffold adds `apps/web/src/lib/cache-tags.ts`, attaches
85
+ the tag hooks to `Pages`, and passes explicit `urlBuilders` and the shared
86
+ `cacheTags` to the publish workflow.
87
+
88
+ ## 0.4.0
89
+
90
+ ### Minor Changes
91
+
92
+ - 8b7d698: A scaffolded project ships a two-tier CI workflow:
93
+
94
+ - `fast` runs on every pull request with no database. It installs from the lockfile, then runs typecheck, lint, the workspace and migration gates, manifest validation, a generated-files check and tests, with a non-blocking audit.
95
+ - `verify` runs on pushes to main. It migrates a fresh Postgres and runs a production build.
96
+
97
+ `check-generated.sh` regenerates `payload-types.ts` and the admin import map and fails on any difference, including an uncommitted file. `apps/web` gains `generate:types` and `generate:importmap`.
98
+
99
+ - 8b7d698: A scaffolded project manages its schema through migrations from the first table on:
100
+
101
+ - **Config.** `payload.config.ts` sets `push: false` and an explicit `migrationDir`. It connects through a resolver that knows the Vercel–Neon integration's variables, keeps a migration off Neon's pooled endpoint, and accepts an optional migration-only credential.
102
+ - **Scripts.** `apps/web` gains `migrate`, `migrate:create`, `migrate:status`, `migrate:snapshot` and `check:migrations`. The check asserts that every migration has its schema snapshot, that no snapshot is orphaned, and that no drop follows a `CASCADE` that has already carried it out.
103
+ - **Write guard.** `scripts/lib/target.ts` gives scripts that write to a database a `requireTarget` guard.
104
+
105
+ - 8b7d698: A scaffolded project ships three workspace gates as root scripts:
106
+
107
+ - `check:instances`: `payload`, `@payloadcms/ui`, `react` and `react-dom` each resolve to exactly one copy
108
+ - `check:tested`: every package that ships code has at least one test
109
+ - `check:audit`: production advisories are checked against an allowlist that carries a reason for each entry and fails when an entry goes stale
110
+
111
+ ### Patch Changes
112
+
113
+ - e9077b3: The reference design system's manifest build and validation, which every scaffolded project vendors, now:
114
+
115
+ - refuse a component directory with no contract, instead of silently leaving it out of the manifest
116
+ - read the directories that hold components from a `CONTRACT_LAYERS` list
117
+ - name the manifest from the project's own `package.json`, instead of claiming to be `@forumone/throughline-reference-ds`
118
+ - treat `antiExamples.empty` and `intent.brevity` as errors
119
+
120
+ - 6800052: The scaffold compiles against the current Throughline releases, and serves its tools over MCP:
121
+
122
+ - `payload.config.ts` no longer imports `createApiKeysCollection`, which core removed.
123
+ - One `createMcpToolCollector()` is passed to every tool-bearing plugin, and `@payloadcms/plugin-mcp` is registered after them, with its key collection narrowed to admins.
124
+ - The Inngest route types the integration registry, so `serve()` can type its function list.
125
+ - `@payloadcms/plugin-form-builder` is a caret range like the rest of `@payloadcms/*`, so it no longer installs a second `@payloadcms/ui`.
126
+ - `.env.example` and the printed next steps drop the per-server MCP keys that no longer exist.
127
+
3
128
  ## 0.3.1
4
129
 
5
130
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAa,MAAM,kBAAkB,CAAA;AAK5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAK3C,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qEAAqE;IACrE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC7F;AAED,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,iBAAe,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAmClF;AAiBD,iBAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI3C;AAUD,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AA6BD,eAAO,MAAM,SAAS;;;;;;;CAAsE,CAAA"}
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAa,MAAM,kBAAkB,CAAA;AAK5F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAK3C,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,qEAAqE;IACrE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CACpC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsC7F;AAED,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;;;;;GASG;AACH,iBAAe,eAAe,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAmClF;AAiBD,iBAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAI3C;AAeD,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AA6BD,eAAO,MAAM,SAAS;;;;;;;CAAsE,CAAA"}
package/dist/generator.js CHANGED
@@ -117,9 +117,14 @@ function isBinary(filename) {
117
117
  /**
118
118
  * npm strips files literally named `.gitignore` from a published tarball, so
119
119
  * we author them as `gitignore` in templates and restore the dot on output.
120
+ * `.github` and `.claude` go the same way: a dot-directory in a tarball is at
121
+ * the mercy of whichever ignore rules the publishing npm applies, and neither
122
+ * the scaffold's CI nor its agent setup is something to lose silently.
120
123
  */
121
124
  const DOTFILE_RENAMES = {
122
125
  gitignore: '.gitignore',
126
+ github: '.github',
127
+ claude: '.claude',
123
128
  };
124
129
  function applyDotfileRename(name) {
125
130
  return DOTFILE_RENAMES[name] ?? name;
@@ -1 +1 @@
1
- {"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAGzD,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AACzD,MAAM,qBAAqB,GAAG,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAW7D;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAgB,EAAE,UAA2B,EAAE;IAC5E,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,qBAAqB,CAAA;IAClE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAEnD,6EAA6E;IAC7E,yEAAyE;IACzE,kEA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;gBAAE,cAAc,EAAE,CAAA;;gBAC3B,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC,CAAA;QAC7E,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,8EAA8E;AAC9E,wEAAwE;AACxE,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"post-install.d.ts","sourceRoot":"","sources":["../src/post-install.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkFrD"}
1
+ {"version":3,"file":"post-install.d.ts","sourceRoot":"","sources":["../src/post-install.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAE3C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwFrD"}
@@ -28,11 +28,18 @@ export function printNextSteps(answers) {
28
28
  lines.push(` ${pc.dim('openssl rand -base64 48 # PAYLOAD_SECRET')}`);
29
29
  lines.push(` ${pc.dim('openssl rand -base64 48 # APPROVAL_TOKEN_SECRET')}`);
30
30
  lines.push(` ${pc.dim('openssl rand -base64 48 # FORMS_IP_HASH_SECRET')}`);
31
+ // `push: false`: the schema exists only once a migration has created it.
32
+ lines.push(formatStep(step++, 'Create and apply the first migration:'));
33
+ lines.push(` ${pc.dim('pnpm --dir apps/web migrate:create initial')}`);
34
+ lines.push(` ${pc.dim('pnpm --dir apps/web migrate')}`);
35
+ // Committed and checked by CI, so the first push is green only with them.
36
+ lines.push(formatStep(step++, 'Generate the Payload types and import map, and commit them:'));
37
+ lines.push(` ${pc.dim('pnpm --dir apps/web generate:types')}`);
38
+ lines.push(` ${pc.dim('pnpm --dir apps/web generate:importmap')}`);
31
39
  lines.push(formatStep(step++, `${pc.bold('pnpm dev')} to run locally`));
32
40
  lines.push(formatStep(step++, 'Open http://localhost:3000/admin and create your first admin user'));
33
- lines.push(formatStep(step++, 'In the admin, go to API Keys and create one key per MCP server'));
34
- lines.push(formatStep(step++, 'Paste those keys into .env.local'));
35
- lines.push(formatStep(step, 'Wire Claude (or your MCP client) to your MCP endpoints — see the generated README.md'));
41
+ lines.push(formatStep(step++, 'In the admin, create one key under MCP → Payload MCP API Keys'));
42
+ lines.push(formatStep(step, 'Give that key to Claude (or your MCP client) for /api/mcp — see the generated README.md'));
36
43
  // eslint-disable-next-line no-console
37
44
  console.log();
38
45
  // eslint-disable-next-line no-console
@@ -1 +1 @@
1
- {"version":3,"file":"post-install.js","sourceRoot":"","sources":["../src/post-install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,IAAI,GAAG,CAAC,CAAA;IAEZ,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC3C,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAA;IAE7D,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,EAAE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+ # Every variable marked "checked at startup" is listed in the assertEnvironment
2
+ # call at the top of apps/web/src/payload.config.ts, which reports all the
3
+ # missing or too-short ones in a single error before anything else runs. Add a
4
+ # variable there when you add one here that the site cannot start without.
5
+
6
+ # --- Required (checked at startup) ---
7
+ # The database may come from DATABASE_URI or, on Vercel + Neon, the
8
+ # integration's DATABASE_URL and friends — see apps/web/src/lib/database.ts.
2
9
  DATABASE_URI=postgres://user:pass@host/dbname
10
+ # Optional: a schema-owner credential used only by `pnpm migrate`, so the app
11
+ # itself can run as a role that reads and writes rows and no more. See
12
+ # apps/web/src/lib/database.ts.
13
+ # MIGRATION_DATABASE_URL=
14
+ # 32+ characters. Generate: openssl rand -base64 48
3
15
  PAYLOAD_SECRET=generate-with-openssl-rand-base64-48
4
16
  NEXT_PUBLIC_SERVER_URL=http://localhost:3000
5
17
 
@@ -10,32 +22,34 @@ INNGEST_EVENT_KEY=
10
22
  INNGEST_SIGNING_KEY=
11
23
 
12
24
  # --- Resend (for approval + form notification emails) ---
25
+ # RESEND_API_KEY and EMAIL_FROM_ADDRESS are checked at startup (emailEnv).
13
26
  RESEND_API_KEY=
14
27
  EMAIL_FROM_ADDRESS=notifications@example.com
28
+ # Optional.
15
29
  EMAIL_FROM_NAME={{projectName}}
16
30
  EMAIL_REPLY_TO=
17
31
 
18
- # --- Approval tokens ---
19
- # Generate: openssl rand -base64 48
32
+ # --- Approval tokens (checked at startup: approvalsEnv) ---
33
+ # 32+ characters. Generate: openssl rand -base64 48
20
34
  APPROVAL_TOKEN_SECRET=
21
35
 
22
- # --- Forms ---
23
- # Generate: openssl rand -base64 48
36
+ # --- Forms (checked at startup: formsEnv) ---
37
+ # 32+ characters. Generate: openssl rand -base64 48
24
38
  FORMS_IP_HASH_SECRET=
25
39
 
26
- # --- MCP server keys ---
27
- # Each key is generated in the Payload admin (API Keys collection) after
28
- # first deploy and pasted back here for local dev.
29
- COMPONENT_SERVER_API_KEY=
30
- PUBLISHING_SERVER_API_KEY=
31
- APPROVALS_SERVER_API_KEY=
32
- AUDIT_SERVER_API_KEY=
33
- FORMS_SERVER_API_KEY=
34
- INTEGRATIONS_SERVER_API_KEY=
35
-
36
- # System API key used by scheduled workflows that talk back to the
37
- # Publishing MCP server (executes scheduled publishes).
38
- PUBLISHING_SYSTEM_API_KEY=
40
+ # --- MCP ---
41
+ # No keys here. Every Throughline tool is served on one /api/mcp by
42
+ # @payloadcms/plugin-mcp; create a key in the admin under MCP -> Payload MCP
43
+ # API Keys and give it to your MCP client, not to this file. Scheduled
44
+ # publishes run in process and need no key either.
45
+
46
+ # --- Optional: error reporting ---
47
+ # Where unhandled request errors, workflows that ran out of retries and failing
48
+ # healthchecks are POSTed as JSON (with a one-line `text`, so a Slack incoming
49
+ # webhook works as-is). A log drain, an alerting endpoint or a proxy in front of
50
+ # your error tracker. Unset: errors reach the log only, and the server says so
51
+ # at boot. Job failures are also recorded in the admin under Job Failures.
52
+ ERROR_WEBHOOK_URL=
39
53
 
40
54
  # --- Optional: storage ---
41
55
  # Vercel Blob token if deploying to Vercel; remove this and the storage
@@ -0,0 +1,112 @@
1
+ # {{projectName}}
2
+
3
+ A **Throughline** project: a Payload CMS application (`apps/web`) wired to the
4
+ Throughline plugin suite, plus the design system that supplies its component
5
+ vocabulary. Throughline docs: https://github.com/forumone/throughline
6
+
7
+ ```
8
+ apps/web/ Next.js + Payload host
9
+ design-system/ The design system and its Storybook
10
+ scripts/ Workspace gates, each explained at the top of its file
11
+ .github/ CI: `fast` on every pull request, `verify` on main
12
+ ```
13
+
14
+ ## The gate
15
+
16
+ This is what CI's `fast` job runs, in its order. Run it before calling work
17
+ done:
18
+
19
+ ```bash
20
+ pnpm install --frozen-lockfile \
21
+ && pnpm typecheck && pnpm lint \
22
+ && pnpm check:instances && pnpm check:tested && pnpm check:migrations \
23
+ && pnpm validate \
24
+ && bash .github/scripts/check-generated.sh \
25
+ && pnpm test
26
+ ```
27
+
28
+ `--frozen-lockfile` leads because a lockfile missing an entry passes every
29
+ other gate locally and fails in CI. `check-generated.sh` needs the environment
30
+ `payload.config.ts` validates; the placeholders at the top of
31
+ `.github/workflows/ci.yml` are enough — it parses the connection string and
32
+ never connects.
33
+
34
+ `verify` adds a migrated Postgres and `pnpm build`; it runs on main.
35
+
36
+ A Stop hook (`.claude/hooks/gate.sh`) runs typecheck and lint when a session
37
+ ends with pending changes. It reports and never blocks. Set
38
+ `THROUGHLINE_SKIP_GATE=1` to silence it.
39
+
40
+ ## Generated files are committed — never hand-edit them
41
+
42
+ After any change to `payload.config.ts`, a collection or a plugin version:
43
+
44
+ ```bash
45
+ pnpm --dir apps/web generate:types # -> src/payload-types.ts
46
+ pnpm --dir apps/web generate:importmap # -> src/app/(payload)/admin/importMap.js
47
+ ```
48
+
49
+ Commit both. CI regenerates them and fails on a difference. A stale import map
50
+ is a 500 on any admin screen that renders a component it has never heard of;
51
+ stale types make everything downstream compile against a schema that no longer
52
+ exists.
53
+
54
+ ## Schema changes go through migrations
55
+
56
+ `push` is off, in development too: `apps/web/src/migrations` is the only way the
57
+ schema changes.
58
+
59
+ ```bash
60
+ pnpm --dir apps/web migrate:create <name> # diffs the config against the newest snapshot
61
+ pnpm --dir apps/web migrate # apply
62
+ pnpm --dir apps/web migrate:snapshot # only after hand-writing a migration
63
+ ```
64
+
65
+ `migrate:create` diffs against the `.json` snapshot beside the newest migration,
66
+ **not the database**. A hand-written migration without its snapshot leaves the
67
+ generator a step behind, re-proposing changes that already shipped.
68
+ `check:migrations` fails on a missing or orphaned snapshot, and on a drop that a
69
+ `CASCADE` has already carried out.
70
+
71
+ The `payload` CLI loads `.env.local`; `tsx` scripts load nothing. For anything
72
+ that writes to a database, pass the variables on the command line and use
73
+ `requireTarget` from `apps/web/scripts/lib/target.ts`, which prints the target
74
+ and demands `--confirm` before overwriting.
75
+
76
+ ## The design system reaches the CMS through its manifest
77
+
78
+ `payload.config.ts` hands the design system's manifest to `componentsPlugin`,
79
+ and that manifest is how the CMS knows which components exist and how they may
80
+ be composed. It is built from a `<Name>.contract.ts` beside every component.
81
+ {{#if useReferenceDs}}
82
+ - **A new component needs a contract.** `build:manifest` refuses a component
83
+ directory without one; prefix a directory with `_` if it is not a component.
84
+ - **`pnpm validate` must pass.** It catches an unknown token, a composition rule
85
+ naming a component that does not exist, and an example pointing at a story
86
+ that is not there.
87
+ {{else}}
88
+ The design system here is a placeholder. When you build it, give every
89
+ component a contract, publish a manifest, and point `componentsPlugin` at it —
90
+ see the design-contract package in the Throughline repository.
91
+ {{/if}}
92
+ ## Tests
93
+
94
+ `check:tested` requires at least one test in every package that ships code.
95
+
96
+ `apps/web` starts with one: `src/access/anonymousAccess.test.ts`, which
97
+ `pnpm test` runs through a vitest config that loads `payload.config.ts` without
98
+ a database. It puts every collection in one of two buckets: read by the
99
+ rendered site, so anonymous reads must be allowed, or private, so they must be
100
+ refused. A new collection fails it until you add it to a bucket. Decide which,
101
+ and don't open a collection to anonymous reads to make the test pass. More good
102
+ first tests need no database: field validations, and hooks as functions.
103
+
104
+ `pnpm test:smoke` runs the Playwright smoke pack in `e2e/` against
105
+ `next start`, so build first, or against a deployed site when `E2E_BASE_URL`
106
+ is set. Every check is a GET. CI runs it in `verify`, after the production
107
+ build. Add routes to `e2e/site.ts` as the site gains them.
108
+
109
+ ## Conventions
110
+
111
+ - pnpm only. The lockfile is at the root.
112
+ - Open a pull request for review; do not merge your own.
@@ -30,12 +30,28 @@ openssl rand -base64 48
30
30
  # - APPROVAL_TOKEN_SECRET — generated above
31
31
  # - FORMS_IP_HASH_SECRET — generated above
32
32
  # - RESEND_API_KEY — from Resend dashboard
33
+ # - EMAIL_FROM_ADDRESS — a verified sender on your Resend domain
33
34
  # - INNGEST_EVENT_KEY/SIGNING — from Inngest (optional in local dev)
34
-
35
- # 5. Start the dev server
35
+ #
36
+ # Anything missing or too short is reported all at once, in one error that
37
+ # starts "Configuration problem", by the assertEnvironment call at the top
38
+ # of apps/web/src/payload.config.ts — the first command that loads the
39
+ # config (step 5) tells you everything left to fill in.
40
+
41
+ # 5. Create and apply the first migration. The config sets `push: false`, so
42
+ # migrations are the only way the schema changes, from the first table on.
43
+ pnpm --dir apps/web migrate:create initial
44
+ pnpm --dir apps/web migrate
45
+
46
+ # 6. Generate the Payload types and admin import map, and commit both along
47
+ # with the migration. CI fails until they match the config.
48
+ pnpm --dir apps/web generate:types
49
+ pnpm --dir apps/web generate:importmap
50
+
51
+ # 7. Start the dev server
36
52
  pnpm dev
37
53
 
38
- # 6. Visit http://localhost:3000/admin and create your first user.
54
+ # 8. Visit http://localhost:3000/admin and create your first user.
39
55
  ```
40
56
 
41
57
  ## After admin signup
@@ -65,6 +81,71 @@ pnpm dev
65
81
  - `pnpm typecheck` — TypeScript check across the monorepo
66
82
  - `pnpm lint` — ESLint
67
83
  - `pnpm test` — run all package tests
84
+ - `pnpm payload:reap` — kill any Payload CLI run a killed shell left behind (the next Payload command does this too)
85
+
86
+ Every script that runs the Payload CLI — `payload`, `generate:*`, `migrate*` —
87
+ goes through `throughline-payload` from `@forumone/throughline-core`. pnpm does
88
+ not forward signals to the node process it starts, so a bare `payload` whose
89
+ shell is killed keeps running, and a hung one spins on a core indefinitely. The
90
+ runner gives Payload its own process group, forwards Ctrl-C and friends to it,
91
+ and kills it after five minutes (`PAYLOAD_CLI_TIMEOUT_MS`, `0` to disable;
92
+ `migrate*` has no limit unless you set one). Run the Payload CLI through these
93
+ scripts rather than `npx payload`.
94
+
95
+ - `pnpm --dir apps/web test:smoke` — the Playwright smoke pack, against a local `next start` (run `pnpm build` first) or `E2E_BASE_URL`
96
+
97
+ ## Tests
98
+
99
+ `apps/web` has two kinds of test.
100
+
101
+ - **`pnpm test`** runs vitest in Node with no database and no browser, so it runs in CI's `fast` job on every pull request. `vitest.config.ts` gives `payload.config.ts` placeholder environment variables, so the config loads without connecting to anything. The first test, `src/access/anonymousAccess.test.ts`, puts every collection into one of two buckets: collections the public site reads with nobody signed in (`renderPath`), and collections it must not read (`private`). It then checks each collection's `read` rule against its bucket. **Adding a collection, or a plugin that brings collections, fails this test until you put each new collection in a bucket.** See the Throughline guide _Adding a collection_.
102
+ - **`pnpm --dir apps/web test:smoke`** is a Playwright smoke pack (`e2e/`) that sends real requests to `next start` on an empty, migrated database. It checks that the front door answers, that an unknown path returns 404, that the admin shows its sign-in screen, and that the REST API refuses anonymous reads of private collections while allowing reads of public ones. It runs in CI's `verify` job, which has a database. Set `E2E_BASE_URL` to run it against a deployed site. Every check is a GET request. The paths it checks are configured in `e2e/site.ts`. That file also lists checks a new project cannot pass yet because it does not serve the route: security headers, `robots.txt`, the sitemap, `llms.txt` and a draft-mode route. Add each check when you add its route.
103
+
104
+ Run `pnpm --dir apps/web test:smoke:install` once to download Chromium.
105
+
106
+ ## Migrations
107
+
108
+ The schema changes only through `apps/web/src/migrations` — `push` is off, in
109
+ development too. From `apps/web`:
110
+
111
+ - `pnpm migrate:create <name>` — generate a migration from the config. It diffs against the `.json` snapshot beside the newest migration, not against the database, and needs no database.
112
+ - `pnpm migrate` — apply pending migrations. Connects through `MIGRATION_DATABASE_URL` when it is set.
113
+ - `pnpm migrate:status` — what has been applied.
114
+ - `pnpm migrate:snapshot` — after **hand-writing** a migration, write its snapshot, or the generator falls a step behind and re-proposes changes that already shipped.
115
+ - `pnpm check:migrations` — every migration has a snapshot, no snapshot is orphaned, and no drop follows a `CASCADE` that already carried it out. Also runs from the root.
116
+
117
+ Scripts that write to a database can call `requireTarget` from `apps/web/scripts/lib/target.ts`, which prints the database, host and variable it is about to write through, and demands `--confirm` before overwriting anything.
118
+
119
+ ## Generated files
120
+
121
+ `apps/web/src/payload-types.ts` and `apps/web/src/app/(payload)/admin/importMap.js`
122
+ are generated from `payload.config.ts` and **committed**. Regenerate both after
123
+ any change to the config, a collection or a plugin version, and commit the
124
+ result — CI regenerates them and fails on a difference:
125
+
126
+ ```bash
127
+ pnpm --dir apps/web generate:types
128
+ pnpm --dir apps/web generate:importmap
129
+ ```
130
+
131
+ A stale import map is a 500 on any admin screen that renders a component the
132
+ map has never heard of.
133
+
134
+ ## CI
135
+
136
+ `.github/workflows/ci.yml` runs two tiers. `fast` runs on every pull request
137
+ and needs no database: install from the lockfile, typecheck, lint, the gates
138
+ below, manifest validation, the generated-files check and tests. `verify` runs
139
+ on pushes to main: it migrates a fresh Postgres, runs a production build, and
140
+ runs the smoke pack against it.
141
+
142
+ ## Workspace gates
143
+
144
+ Each is explained at the top of its script in `scripts/`:
145
+
146
+ - `pnpm check:instances` — `payload`, `@payloadcms/ui`, `react` and `react-dom` each resolve to exactly one copy. Two byte-identical copies are two React contexts, and a runtime failure nothing else can see.
147
+ - `pnpm check:tested` — every workspace package that ships code has at least one test. Not a coverage number. A package with no tests can go on the exception list in the script, with a reason. An entry fails once that package has tests.
148
+ - `pnpm check:audit` — high and critical production advisories against an allowlist that carries a reason for each entry, and that fails when an entry stops applying.
68
149
 
69
150
  ## Project layout
70
151
 
@@ -72,10 +153,14 @@ pnpm dev
72
153
  {{projectName}}/
73
154
  ├── apps/
74
155
  │ └── web/ # Next.js + Payload host
75
- ├── packages/
76
- │ ├── design-system/ # UI components consumed by Components MCP
77
- │ ├── content/ # Reusable collections + blocks (optional)
78
- │ └── brand/ # Brand tokens / email theme (optional)
156
+ │ ├── scripts/ # migration tooling, requireTarget
157
+ │ └── src/migrations/ # the only way the schema changes
158
+ ├── design-system/ # components + contracts -> the manifest the CMS reads
159
+ ├── packages/ # your own shared packages (optional)
160
+ ├── scripts/ # workspace gates
161
+ ├── .claude/ # agent settings and the Stop-hook gate
162
+ ├── .github/ # CI: fast + verify
163
+ ├── CLAUDE.md # the rules an agent (or a new developer) needs
79
164
  ├── .env.example
80
165
  ├── pnpm-workspace.yaml
81
166
  ├── turbo.json
@@ -0,0 +1,36 @@
1
+ /*
2
+ What the smoke pack checks, and where. Site data: change the paths here, not in
3
+ the specs.
4
+
5
+ **What the pack does not check yet, because a fresh project does not serve it.**
6
+ Each is a check worth adding with the route that makes it true:
7
+
8
+ - security headers — `next.config.mjs` sets none. Add `headers()` there, then
9
+ assert them per route: HSTS, `nosniff`, a referrer policy, and framing
10
+ (`DENY` on `/admin`, `SAMEORIGIN` where live preview frames the site).
11
+ - `robots.txt` and `sitemap.xml` — add `app/robots.ts` and `app/sitemap.ts`;
12
+ assert a 200, the content type, and that the sitemap lists each URL once.
13
+ - `llms.txt` — a route serving `text/markdown`, with a heading and links.
14
+ - draft mode — a preview route must refuse a request without its secret
15
+ (401) and one naming no document (400).
16
+ */
17
+ export const site = {
18
+ /**
19
+ * A deployed site to point at, from `E2E_BASE_URL`. Unset, the pack starts
20
+ * `next start` locally on `port`.
21
+ */
22
+ baseURL: process.env.E2E_BASE_URL?.trim() || undefined,
23
+ port: 3100,
24
+
25
+ /** The front door. */
26
+ home: '/',
27
+ /** The Payload admin. On an empty database it asks for the first user. */
28
+ admin: '/admin',
29
+ /** A path nothing serves, which must be a 404 and never a 500. */
30
+ missing: '/a-page-that-was-never-written',
31
+
32
+ /** REST collections an anonymous request must be refused. */
33
+ privateCollections: ['users', 'payload-mcp-api-keys'],
34
+ /** REST collections an anonymous request may read — published documents only. */
35
+ publicCollections: ['pages'],
36
+ }
@@ -0,0 +1,52 @@
1
+ import { expect, test } from '@playwright/test'
2
+ import { site } from './site'
3
+
4
+ test.describe('the front door', () => {
5
+ test('answers with a document and a main landmark', async ({ page }) => {
6
+ const response = await page.goto(site.home)
7
+ expect(response?.status()).toBe(200)
8
+ await expect(page.locator('main')).toBeAttached()
9
+ })
10
+
11
+ test('404s a path that does not exist, rather than erroring', async ({ request }) => {
12
+ const response = await request.get(site.missing, { maxRedirects: 0 })
13
+ expect(response.status()).toBe(404)
14
+ })
15
+ })
16
+
17
+ test.describe('the admin', () => {
18
+ /*
19
+ The whole admin is one client bundle and the import map it reads. A stale
20
+ map, a missing environment variable or a plugin that throws at init all
21
+ surface here as a 500 or a blank screen — and as nothing at all in a test
22
+ that does not load the page.
23
+ */
24
+ test('serves a sign-in screen', async ({ page }) => {
25
+ const response = await page.goto(site.admin)
26
+ expect(response?.status()).toBeLessThan(500)
27
+ await expect(page.getByRole('textbox', { name: /email/i })).toBeVisible({ timeout: 30_000 })
28
+ })
29
+ })
30
+
31
+ test.describe('the REST API, to a request with nobody signed in', () => {
32
+ /*
33
+ The same rules `src/access/anonymousAccess.test.ts` checks as values, here as
34
+ responses: proof that nothing between the rule and the wire — a plugin, an
35
+ endpoint, a framework upgrade — reopened a collection.
36
+ */
37
+ for (const slug of site.privateCollections) {
38
+ test(`refuses to list ${slug}`, async ({ request }) => {
39
+ const response = await request.get(`/api/${slug}`)
40
+ expect(response.status()).toBe(403)
41
+ })
42
+ }
43
+
44
+ for (const slug of site.publicCollections) {
45
+ test(`lists ${slug}`, async ({ request }) => {
46
+ const response = await request.get(`/api/${slug}`)
47
+ expect(response.status()).toBe(200)
48
+ const body = (await response.json()) as { docs?: unknown }
49
+ expect(Array.isArray(body.docs)).toBe(true)
50
+ })
51
+ }
52
+ })