CLI Command Reference
This page describes each command of the mockkit CLI. For installation and other setup, see Getting Started.
mockkit init [projectDir]
Creates (or overwrites) mockkit.json and initializes an existing project for MockKit.
mockkit init [projectDir]- If
projectDiris omitted, the current directory is used. - If
mockkit.jsonalready exists, a confirmation prompt to overwrite it is shown.
Interactive Setup Fields
When init runs, the following items are asked in order.
- Project name
- Static site generator in use (
manualornuxt) - Output directory (
build.distDir) - Public directory (
build.publicDir) - Development server port (
build.devPort) - Development command (
build.devCommand) - Static generation command (
build.generateCommand)
When nuxt Is Selected
If you select nuxt, init attempts to detect default values from one of the following configuration files.
nuxt.config.tsnuxt.config.jsnuxt.config.mjsnuxt.config.cjs
If none are found, init is aborted.
mockkit configure [--clear]
Saves or removes the API key used to publish to MockKit.
mockkit configure [--clear]- The API key is saved to
~/.mockkit/credentials.json. - With
--clear, the saved API key is removed.
mockkit publish [projectDir] [--site-id <id>] [--dist-path <path>]
Uploads the build output from a static site generator to MockKit.
mockkit publish [projectDir] [--site-id <id>] [--dist-path <path>]- If
projectDiris omitted, the current directory is used. - With
--site-id <id>, publishes as a new version of the site with that ID. - With
--dist-path <path>, you can explicitly specify the directory to upload.
Execution Requirements
mockkit.jsonmust exist inprojectDirdist-pathmust exist and be a directorydist-pathmust contain at least one file
How the Site ID Is Determined
If --site-id is not specified, the site ID is determined in the following order.
siteIdinmockkit.json- Interactive selection from the site list returned by the API
- Interactive creation of a new site
The determined site ID is recorded in mockkit.json.
mockkit dev [projectDir] [--host <host>]
Starts the development server and keeps mockkit-manifest.json in sync.
mockkit dev [projectDir] [--host <host>]- If
projectDiris omitted, the current directory is used. - With
--host <host>, you can pass the host bind address to MockKit Viewer (for example,0.0.0.0). - Runs
build.devCommandfrommockkit.json. - Starts the MockKit Viewer development server.
- Watches
mockkit.jsonfor changes and regeneratesmockkit-manifest.jsonunderbuild.publicDirwhen it is updated.
mockkit generate [projectDir]
Runs the static generation command defined in mockkit.json.
mockkit generate [projectDir]- If
projectDiris omitted, the current directory is used. - Regenerates
mockkit-manifest.jsonunderbuild.publicDirbefore runningbuild.generateCommand.
mockkit manifest [projectDir]
Synchronously generates mockkit-manifest.json from mockkit.json.
mockkit manifest [projectDir]- If
projectDiris omitted, the current directory is used.