Skip to content

cli(feat): add opt-in demo seed + leak-proof admin field hints#147

Open
Ducksss wants to merge 1 commit into
devfrom
claude/fervent-shaw-45f7c9
Open

cli(feat): add opt-in demo seed + leak-proof admin field hints#147
Ducksss wants to merge 1 commit into
devfrom
claude/fervent-shaw-45f7c9

Conversation

@Ducksss

@Ducksss Ducksss commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add an opt-in demo seed: payload-components seed <name> and payload-components add <name> --demo write a runnable seed script (payload-components/seed-<name>.ts) that creates one labeled, deletable example Page (/payload-components-demo-<name>) pre-filled from manifest.sampleContent.
  • The CLI never opens the database — the generated script runs in the user's own toolchain via payload run, so the published bundle keeps its ajv+semver-only runtime-dependency contract. Seed-script generation is extracted into a Playwright-free shared module (tools/payload-components/seed/seed-script.ts) reused verbatim by the fresh-project smoke harness.
  • Add leak-proof admin guidance: admin.placeholder / admin.description across the 7 shared field modules + the HeroBasic/EmbedBasic configs. These render in the admin but are never written to the document — deliberately not defaultValue, which would persist and could ship to production.

Why: installed blocks arrive with empty fields and no signal of intended content, which doesn't match the filled-in catalog preview. This gives developers a one-time, catalog-matching example page (opt-in, deletable) and gives editors persistent in-field guidance — without any path for sample copy to reach production.

Verification

  • pnpm test:release

Ran locally and green: pnpm lint, pnpm source:build, tsc --noEmit, pnpm test:registry, pnpm test:int (68 passed, 1 skipped — incl. new --demo orchestration cases and the repointed smoke-seed unit test), pnpm test:pack (dependency contract holds — 0 Playwright refs in dist/cli.js). Not yet run: pnpm test:e2e, the final pnpm build, and the heavy pnpm test:fresh (full create-payload-app E2E) — left for CI.

Registry Checklist

  • Registry changes keep generated public/r output out of git. (public/r is gitignored; rebuilt locally to confirm the field hints embed correctly, not committed.)
  • Component changes update source, manifest, docs, and installer tests together. (Source field configs + add-command installer tests updated; no manifest/component-shape change was needed. Docs for the new seed/--demo commands are not added yet — see Notes.)
  • Payload target code keeps Local API and hook examples transaction-safe. (Generated seed script mirrors the established smoke-seed Local API pattern: overrideAccess + context.disableRevalidate, idempotent delete-then-create of a single labeled slug.)

Notes

  • Two-step by design: seed/--demo write the script; the user then runs it (pnpm exec payload run payload-components/seed-<name>.ts) to create the page. The CLI cannot open the DB without breaking its ajv+semver dependency contract. An auto-run mode (spawn the project's own payload run as a subprocess, like the smoke harness) is a straightforward follow-up if a one-command flow is preferred.
  • Deferred (optional follow-ups): unifying manifest.sampleContent with the site's src/lib/demo-content.ts (they currently drift), and docs for the new commands.

🤖 Generated with Claude Code

Help users reach good block content after install, two ways, without
baking sample copy into saved documents:

- `payload-components seed <name>` and `add <name> --demo` write a runnable
  seed script (payload-components/seed-<name>.ts) that creates one labeled,
  deletable example Page (slug payload-components-demo-<name>) pre-filled
  from manifest.sampleContent. The CLI never opens the database — the user
  runs the script via `payload run` in their own toolchain, so the published
  bundle keeps its ajv+semver-only runtime-dependency contract. Seed-script
  generation is extracted into a Playwright-free shared module
  (tools/payload-components/seed/seed-script.ts) reused by the smoke harness.

- admin.placeholder / admin.description hints on the shared field modules
  and the HeroBasic/EmbedBasic configs. They render in the admin but are
  never written to the document, so guidance can't leak to production.
  Deliberately NOT defaultValue.

Tests: new add --demo orchestration cases; smoke-seed unit test repointed to
the shared module. Verified locally: tsc, lint, registry:check, test:int
(68 passed), test:pack (dep contract holds).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
payload-components Ready Ready Preview, Comment Jun 19, 2026 10:18am
payload-components-97bf Ready Ready Preview, Comment Jun 19, 2026 10:18am

@Ducksss

Ducksss commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Retargeted to dev, which is the integration branch. This still needs rebase/conflict resolution before review because GitHub reports merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant