Skip to content

feat: add kiqr scaffold theme command (block + classic) - #18

Closed
kjellbergzoey wants to merge 1 commit into
kiqr:mainfrom
kjellbergzoey:feat/scaffold-theme-command
Closed

feat: add kiqr scaffold theme command (block + classic)#18
kjellbergzoey wants to merge 1 commit into
kiqr:mainfrom
kjellbergzoey:feat/scaffold-theme-command

Conversation

@kjellbergzoey

Copy link
Copy Markdown
Contributor

Summary

Adds kiqr scaffold theme <name> [--type block|classic] — generates a production-ready WordPress theme in a new directory so a developer can scaffold and start developing immediately:

kiqr scaffold theme "My Cool Theme"   # block (FSE) theme — the default
cd my-cool-theme
kiqr init && kiqr up

This closes the FSE-scaffolding gap from the product strategy. No CLI-first WordPress tool scaffolds a modern, correct Full Site Editing theme well in 2026 — this makes kiqr the one that does, while still supporting classic PHP-template themes via --type classic.

What gets generated (block / FSE — the default)

my-cool-theme/
├── .gitignore
├── functions.php          # editor-styles + block supports, enqueues style.css, slug as text domain
├── style.css              # full theme header (Version, Requires at least 6.5, Requires PHP 8.0, Text Domain)
├── theme.json             # schema v3: palette, fluid font scale, spacing scale, layout sizes, appearanceTools
├── readme.txt             # standard WordPress theme readme
├── parts/
│   ├── header.html        # site title + navigation
│   └── footer.html        # site title + copyright
├── patterns/
│   └── hero.php           # registered block pattern (Title/Slug/Categories) — heading + paragraph + button
└── templates/
    ├── index.html         # query loop + pagination, references header/footer parts
    ├── single.html        # post title/date/content + comments
    └── page.html          # page title + content

--type classic generates the standard classic structure: style.css, index.php, functions.php, header.php, footer.php, readme.txt, .gitignore.

Design

  • src/lib/scaffold.ts is pure and fully unit-tested. generateTheme(opts) returns a Record<relativePath, contents> and touches nothing on disk. writeTheme(targetDir, files) writes the map, creating nested dirs, and refuses to clobber a non-empty existing directory.
  • The Pastel command (src/commands/scaffold/theme.tsx) stays thin: validates the name, reuses slugify from lib/theme.ts, computes ./<slug>, calls generateTheme + writeTheme, and renders success/next-steps (or a clean error) via Ink. --type defaults to block (alias -t); optional --author.
  • Mirrors the existing db subcommand group: new src/commands/scaffold/index.tsx for group help. Main help list and README command table updated.

Tests & checks

  • tests/lib/scaffold.test.ts covers the block file set + header/theme.json/template-part/pattern/functions assertions, the classic file set, slug handling, and writeTheme round-trip + clobber refusal in a temp dir.
  • npm run typecheck, npm test (127 passing), npm run build, and biome check . all pass.
  • Smoke-tested end-to-end without Docker: node dist/cli.js scaffold theme "Demo Theme" produced the tree above with valid JSON (theme.json version 3) and a correct style.css header; --type classic and the clobber guard verified too.

🤖 Generated with Claude Code

Add a `kiqr scaffold theme <name> [--type block|classic]` command that
generates a production-ready WordPress theme in a new directory so a
developer can scaffold and `kiqr init && kiqr up` immediately.

Defaults to a modern block (Full Site Editing) theme — theme.json schema
v3 with a color palette, fluid type scale, spacing scale and layout
sizes, plus templates, template parts, and a registered hero block
pattern. Also supports a classic PHP-template theme via `--type classic`.

Generation logic lives in a pure, unit-tested `src/lib/scaffold.ts`
(`generateTheme` returns a file map; `writeTheme` writes it and refuses
to clobber a non-empty directory). The Pastel command stays thin.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kjellberg kjellberg closed this Jun 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants