@mockkit/cli
v0.0.6
Published
`@mockkit/cli` helps you initialize mockups, wireframes, or frontend apps built with static site generators (SSG) as MockKit projects, preview them in a development environment, and publish them to [MockKit](https://mockkit.app).
Readme
@mockkit/cli
@mockkit/cli helps you initialize mockups, wireframes, or frontend apps built with static site generators (SSG) as MockKit projects, preview them in a development environment, and publish them to MockKit.
Geting Started
cd /path/to/your/existing/mockup/site
npx @mockkit/cli --help
npx @mockkit/cli init
npx @mockkit/cli generate
npx @mockkit/cli publishCommands
mockkit init [projectDir]: Create or overwritemockkit.jsonwith interactive prompts.mockkit configure [--clear]: Save or clear your MockKit API Key.mockkit publish [projectDir] [--site-id <id>] [--dist-path <path>]: Upload static build artifacts.mockkit dev [projectDir]: Run the dev command defined inmockkit.json.mockkit generate [projectDir]: Run the static generation command defined inmockkit.json.mockkit manifest [projectDir]: Syncmockkit-manifest.jsonfrommockkit.json.
Prerequisites
- Node.js (current LTS is recommended).
- A static site project directory where you run the command.
- For
publish: a valid MockKit API Key.
Installation and execution
This package exposes the mockkit binary.
You can run it with the following command even without installing it first.
npx @mockkit/cliIf it is already installed in your project's package.json:
npm exec mockkitOr, if mockkit is installed globally:
mockkitQuick start
- Initialize MockKit in your existing project (such as one built with Nuxt, 11ty, or another static site generator):
cd /path/to/project
mockkit init- Configure your API Key:
mockkit configure- Build your static site so files exist under your output directory (for example
./dist).
mockkit generate- Publish artifacts:
mockkit publishinit
init creates mockkit.json in the target directory.
If not specified, projectDir defaults to the current directory.
mockkit init [projectDir]Prompt flow
init asks for:
- Project name
- Static site generator (currently you can choose either
manualornuxt) - Destination directory (
build.distDir) - Public directory (
build.publicDir) - Development server port (
build.devPort) - Development command (
build.devCommand) - Static generation command (
build.generateCommand)
If mockkit.json already exists, the CLI asks for overwrite confirmation first.
Nuxt detection behavior
When nuxt is selected, the CLI detects defaults from one of:
nuxt.config.tsnuxt.config.jsnuxt.config.mjsnuxt.config.cjs
If none is found, init aborts.
configure
configure stores your API Key in:
~/.mockkit/credentials.json
Run:
mockkit configureTo remove the saved key:
mockkit configure --clearpublish
publish uploads files from your built output directory to MockKit.
mockkit publish [projectDir] [options]Options
--site-id <id>: Use this site ID directly.--dist-path <path>: Build artifact directory.
Requirements
mockkit.jsonmust exist inprojectDir.dist-pathmust exist and be a directory.- At least one file must exist under
dist-path.
Site ID resolution order
When --site-id is not provided, the CLI resolves site ID in this order:
siteIdinmockkit.json- Interactive selection from API site list
- Interactive creation of a new site
After resolution, the selected site ID is written back to mockkit.json.
dev
dev starts the development workflow and keeps mockkit-manifest.json in sync.
mockkit dev [projectDir]Behavior:
- Runs
build.devCommandfrommockkit.json. - Starts the MockKit Viewer development server.
- Watches
mockkit.json, and when it changes, rewritesmockkit-manifest.jsonin the configuredbuild.publicDir.
generate
generate runs build.generateCommand from mockkit.json in projectDir.
mockkit generate [projectDir]If not specified, projectDir defaults to the current directory.
Before running the generation command, generate rewrites mockkit-manifest.json in the configured build.publicDir.
manifest
manifest syncs mockkit-manifest.json from mockkit.json.
mockkit manifest [projectDir]If not specified, projectDir defaults to the current directory.
Troubleshooting
mockkit.json does not exist...- Run
mockkit initin the correct project directory.
- Run
Dist path does not exist...oris not a directory...- Make sure to build your project as a static site first (for example, by running
nuxt generate).
- Make sure to build your project as a static site first (for example, by running
No files found under dist path...- Confirm your static build output is generated and not empty.
API Key is required to run publish...- Run
mockkit configureand set a key starting withmk_apikey_.
- Run
- API request failure messages (4xx/5xx)
- Verify API Key validity and site access permissions.
