CLI ¶
Run CarvePress with carve-press <command> [options]. If the first argument is an option, build is assumed.
Commands ¶
| Command | Description |
|---|---|
build | Build the site, reusing the renders of unchanged pages. |
check | Run every build check without writing a build. |
fmt [paths...] | Format .crv sources in place, srcDir by default. |
import <source> | Convert Markdown or HTML pages into .crv pages. |
routes | Print discovered routes and source files. |
dev | Build, serve, watch, and live reload. |
serve | Serve the existing outDir. |
init | Scaffold a new site. |
new <path> | Create a new page under srcDir. |
help | Print help. |
Flags ¶
| Flag | Applies To | Default | Description |
|---|---|---|---|
--root <dir> | all commands | current working directory | Project root. |
--port <n> | dev, serve | 5173 for dev, 4173 for serve | Server port from 0 through 65535; invalid values fall back. |
--host <host> | dev, serve | 127.0.0.1 | Server host. |
--open | dev | off | Open the dev server URL in a browser. |
--force | init, import | off | Allow existing files to be overwritten. |
--title <title> | new | title-cased file name | Page title for a new page. |
--no-cache | build | off | Render every page; neither read nor write the build cache. |
--check | fmt | off | List files that would change and exit 1 instead of writing them. |
--align-tables | fmt | off | Pad table columns to a shared display width. |
--out <dir> | import | srcDir, or docs without a config | Directory the pages are written to. |
--from <format> | import | by file extension | Convert only markdown or html. Required for a single file whose extension is neither. |
--report <file> | import | off | Write the full report, every finding included, as JSON. |
--help | all commands | off | Print help. |
--version | all commands | off | Print the package version. |
Build Cache ¶
build stores each page’s render in node_modules/.cache/carve-press/render-cache.json and reuses it while the page, its includes, the images it sizes and the site configuration are unchanged. The build prints how many pages it rendered and how many came from the cache. See Configuration for what invalidates it. --no-cache renders everything.
Checking a Site ¶
check renders every page, lints it and its includes, and validates links, nav, sidebars, prev/next overrides and the route manifest, exactly as build does. The output goes to a temporary directory that is removed afterwards, so outDir and routes.json are left untouched. Any failure exits with a non-zero status, which makes it a pull-request gate:
npx carve-press checkFormatting Sources ¶
fmt rewrites .crv files with the Carve engine’s canonical writer. With no paths it formats every .crv under srcDir, including snippets that srcExclude keeps out of routing; hidden directories and node_modules are skipped. Pass files or directories to format only those.
--check writes nothing: it prints each file that is not canonical and exits 1 if there is any. --align-tables pads every table column to a common width, measured by display width. It is opt-in, so use the same flag in --check and in the formatting run, or the two disagree.
A file the writer cannot format is reported with the reason and the command exits 2.
Importing a Site ¶
import moves an existing Markdown or HTML site to Carve. Point it at a file or a directory:
carve-press import old-docs --report import-report.jsonEach .md, .markdown, .html or .htm file becomes a .crv page at the same relative path under --out, which defaults to the configured srcDir. Other files, such as images next to the pages, are copied into the configured publicDir (public without a config) at the same relative path, because the build publishes that directory. Importing a folder in place works too: carve-press import docs writes docs/guide.crv next to docs/guide.md, and .crv files already in the source are left alone. Hidden directories (.vitepress, .git), node_modules and the configured outDir are skipped, and an existing file in the target is never overwritten unless --force is given.
Markdown goes through the engine’s Markdown importer, which keeps YAML frontmatter. For HTML, the first <main>, else <article>, else <body> is taken as the page content, so site navigation and footers stay behind; a page without an H1 gets its <title> as the frontmatter title.
The terminal report lists every finding that lost or degraded content, with its file and line: elements the HTML importer dropped, Markdown constructs it could only approximate, links that still name a source file such as ../index.md, and relative images. CarvePress routes have no extension, so those links need pointing at the route, and each relative-image finding names the root-relative path to write instead. The --report file carries every finding, informational ones too. After an import, run carve-press check to see what the build would still reject.
Examples ¶
carve-press build
carve-press build --no-cache
carve-press check
carve-press fmt --check --align-tables
carve-press fmt docs/guide --align-tables
carve-press import old-docs --out docs --report import-report.json
carve-press routes --root .
carve-press dev --host 0.0.0.0 --port 5173
carve-press serve --port 4173
carve-press init --force
carve-press new guide/install --title "Install"Unknown commands print usage and exit with a non-zero status. User-facing build errors are formatted without raw stack traces.
Last updated