@zeropress/theme
v0.5.1
Published
ZeroPress theme developer toolkit
Readme
@zeropress/theme
ZeroPress theme development toolkit.
This package provides the public CLI for previewing, validating, and packaging ZeroPress themes.
Install
# Run directly with npx
npx @zeropress/theme --help
# Or install globally
npm install -g @zeropress/theme
zeropress-theme --helpQuick Start
npx @zeropress/theme dev ./my-themeUsage
zeropress-theme dev <themeDir> [--data <path>] [--host <ip>] [--port <n>] [--strict-port] [--open]
zeropress-theme validate <themeDir|theme.zip> [--strict] [--json]
zeropress-theme pack <themeDir> [--out <dir>] [--name <zipFile>] [--dry-run]Arguments
<themeDir>: Theme directory<theme.zip>: Packaged theme zip file
Options
--help, -h: Show help--version, -v: Show version
Examples
zeropress-theme dev ./my-theme --data ./preview-data.json
zeropress-theme validate ./my-theme --strict
zeropress-theme pack ./my-theme --out ./artifactsCommands
dev
Launches a local preview server with WebSocket-based live reload.
Usage
zeropress-theme dev <themeDir> [--data <path>] [--host <ip>] [--port <n>] [--strict-port] [--open]Arguments
<themeDir>: Theme directory to preview
Options
| Option | Description | Default |
| --- | --- | --- |
| --data <path> | Local preview-data v0.5 JSON file | Built-in sample data |
| --host <ip> | Bind address | 127.0.0.1 |
| --port <n> | Preferred server port | 4000 |
| --strict-port | Fail when the preferred port is already in use instead of trying the next port | — |
| --open | Open the browser automatically | — |
Examples
zeropress-theme dev ./my-theme
zeropress-theme dev ./my-theme --data ./preview-data.jsonNotes
- Builds the theme through
@zeropress/build-coreand serves the latest in-memory output snapshot - Falls back to files in the public directory when a route is not generated
- The public directory defaults to
./public/; setZEROPRESS_PUBLIC_DIRto use a different public root - Generated output is served before public files when paths overlap
robots.txtis a fallback special file: if publicrobots.txtexists, the dev server serves that file instead of generated fallback robots output- Public
robots.txtis served as-is. If it needs aSitemapdirective, add it to the file manually. - Root-level public favicon files named
favicon.ico,favicon.svg,favicon.png, andapple-touch-icon.pngare auto-discovered and injected into generated HTML<head>output unless preview-data already definessite.favicon - Hidden entries,
node_modules,Thumbs.db,*.key,*.pem, and symlinks inside the public directory are ignored - The theme directory must not overlap with the resolved public directory
- Starts on the preferred port, or the next available port unless
--strict-portis used - Watches theme directory changes and performs a full rebuild with full reload
- Watches the
--datafile too when one is provided - Watches the public directory too when it exists at startup; creating it after startup requires restarting
dev - Non-matching routes return
404 - If
404.htmlexists at theme root, it is rendered; otherwise a built-in fallback page is used devonly accepts canonical preview-data v0.5--datamust point to a local file path- Built-in sample data includes enabled
primaryandfootermenus for{{menu:*}}previews - Post templates can render a theme-owned comments island by checking
{{#if post.comments_enabled}} - Output behavior follows build-core parity for archive, category, tag,
404, and special files
validate
Validates a theme directory or packaged zip against Theme Runtime v0.5.
Usage
zeropress-theme validate <themeDir|theme.zip> [--strict] [--json]Arguments
<themeDir|theme.zip>: Theme directory or packaged theme zip file
Options
| Option | Description |
| --- | --- |
| --strict | Treat warnings as errors |
| --json | Output results as JSON |
Examples
zeropress-theme validate ./my-theme
zeropress-theme validate ./dist/my-theme-1.0.0.zip --strictErrors
theme.jsonmissing or invalid- Missing or invalid
namespace,slug,license, orruntime - Missing required templates:
layout.html,index.html,post.html,page.html - Invalid semver in
version assets/style.cssmissing- Invalid slot usage in
layout.html <script>insidelayout.html- Nested slots or Mustache block syntax
- Path traversal or symlink escape
Warnings
archive.html,category.html,tag.htmlmissing- macOS metadata files such as
__MACOSX/and._*are ignored
Exit Codes
| Code | Meaning |
| --- | --- |
| 0 | No errors or warnings |
| 1 | Errors found |
| 2 | Warnings only |
With --strict, warnings also return exit code 1.
pack
Creates an upload-ready zip file for a theme directory.
Usage
zeropress-theme pack <themeDir> [--out <dir>] [--name <zipFile>] [--dry-run]Arguments
<themeDir>: Theme directory to package
Options
| Option | Description | Default |
| --- | --- | --- |
| --out <dir> | Output directory | dist |
| --name <zipFile> | Zip filename | {name}-{version}.zip |
| --dry-run | Print the output path and included files without writing a zip | — |
Examples
zeropress-theme pack ./my-theme --dry-run
zeropress-theme pack ./my-theme --out ./artifactsNotes
- Runs
validatebefore packaging - Excludes unnecessary files such as
.git,node_modules,dist,*.log,__MACOSX,.DS_Store, and lockfiles - Generates a root-flattened zip
- Re-validates the generated archive
- With
--dry-run, prints the output path and included files without creating a zip
CI Usage
zeropress-theme validate ./theme --strict
zeropress-theme validate ./artifacts/theme-1.0.0.zip --strict
zeropress-theme pack ./theme --dry-run
zeropress-theme pack ./theme --out ./artifactsRequirements
- Node.js >= 18.18.0
- ESM only
Related
License
MIT
