Skip to content

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.

sh
mockkit init [projectDir]
  • If projectDir is omitted, the current directory is used.
  • If mockkit.json already 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 (manual or nuxt)
  • 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.ts
  • nuxt.config.js
  • nuxt.config.mjs
  • nuxt.config.cjs

If none are found, init is aborted.

mockkit configure [--clear]

Saves or removes the API key used to publish to MockKit.

sh
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.

sh
mockkit publish [projectDir] [--site-id <id>] [--dist-path <path>]
  • If projectDir is 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.json must exist in projectDir
  • dist-path must exist and be a directory
  • dist-path must 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.

  1. siteId in mockkit.json
  2. Interactive selection from the site list returned by the API
  3. 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.

sh
mockkit dev [projectDir] [--host <host>]
  • If projectDir is 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.devCommand from mockkit.json.
  • Starts the MockKit Viewer development server.
  • Watches mockkit.json for changes and regenerates mockkit-manifest.json under build.publicDir when it is updated.

mockkit generate [projectDir]

Runs the static generation command defined in mockkit.json.

sh
mockkit generate [projectDir]
  • If projectDir is omitted, the current directory is used.
  • Regenerates mockkit-manifest.json under build.publicDir before running build.generateCommand.

mockkit manifest [projectDir]

Synchronously generates mockkit-manifest.json from mockkit.json.

sh
mockkit manifest [projectDir]
  • If projectDir is omitted, the current directory is used.