npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dynamic-mock-server/cli

v0.1.0-beta

Published

Interactive CLI for Dynamic Mock Server

Downloads

80

Readme

@dynamic-mock-server/cli

Interactive and command-line interface for the Dynamic Mock Server

Intuitive CLI for managing your mock server in real-time. Features both an interactive mode powered by @clack/prompts and a command mode powered by Commander.js for scriptable automation.

Features

  • 🎨 Interactive Mode: Beautiful UI with @clack/prompts for navigation
  • ⚙️ Command Mode: Scriptable CLI powered by Commander.js
  • 🔄 Hot Management: Change suites and responses without restart
  • 📊 Real-time Status: View server stats, routes, and configuration
  • 🎯 Suite Control: Switch between route suites on the fly
  • 🔧 Route Overrides: Override individual route responses
  • 💻 Programmatic API: Use CLI classes in your own code
  • 🌈 Colored Output: Clear, colorful terminal UI with picocolors

Installation

pnpm add @dynamic-mock-server/cli

For global installation:

pnpm add -g @dynamic-mock-server/cli

Quick Start

Interactive Mode

Launch the beautiful interactive interface:

dynamic-mock-server interactive
# or shorthand
dynamic-mock-server i

Features:

  • Arrow key navigation
  • Real-time status display
  • View configuration
  • Change active suite
  • List and manage routes
  • Override route responses
  • Restart server
  • View alerts
  • Graceful exit

Command Mode

Use commands for scriptable automation:

# Start server
dynamic-mock-server start

# View status
dynamic-mock-server status

# Suite management
dynamic-mock-server suites list
dynamic-mock-server suites set happy-path
dynamic-mock-server suites clear

# Route management
dynamic-mock-server routes list
dynamic-mock-server routes set get-users error
dynamic-mock-server routes clear get-users

# Server control
dynamic-mock-server restart
dynamic-mock-server stop

CLI Commands

Server Management

start

Start the mock server.

dynamic-mock-server start

Options:

  • -p, --port <number> - Server port (overrides config)
  • -h, --host <string> - Server host (overrides config)
  • --no-interactive - Disable interactive mode (show logs)

Examples:

dynamic-mock-server start
dynamic-mock-server start -p 8080
dynamic-mock-server start -h 0.0.0.0
dynamic-mock-server start --no-interactive

Note: Interactive mode disables server logs for clean UI. Use --no-interactive to see full logs.

status

Display current server information.

dynamic-mock-server status

Displays:

  • Running status
  • Server URL
  • Active suite
  • Total routes, responses, and suites
  • Active alerts

restart

Restart the server.

dynamic-mock-server restart

stop

Stop the server gracefully.

dynamic-mock-server stop

Interactive Mode

interactive or i

Enter interactive mode for real-time management.

dynamic-mock-server interactive
# or
dynamic-mock-server i

Routes Suites

suites list

List all available routes suites.

dynamic-mock-server suites list

suites set <suiteId>

Set the active routes suite.

dynamic-mock-server suites set happy-path
dynamic-mock-server suites set error-scenarios

suites clear

Clear the active suite (no default responses).

dynamic-mock-server suites clear

Routes

routes list

List all available routes with their responses.

dynamic-mock-server routes list

routes set <routeId> <responseId>

Override a specific route's response.

dynamic-mock-server routes set get-users error
dynamic-mock-server routes set get-products empty

routes clear <routeId>

Clear a route override (revert to suite default).

dynamic-mock-server routes clear get-users

Programmatic Usage

Use CLI classes in your own application:

import { CLI, InteractiveCLI } from "@dynamic-mock-server/cli";
import { Core } from "@dynamic-mock-server/core";

// Create core instance
const core = new Core();

// Option 1: Use CLI class programmatically
const cli = new CLI({ core });

// Start server
await cli.start();

// Change active suite
await cli.changeSuite("happy-path");

// Override route response
await cli.setRouteResponse("get-users", "error");

// Restart server
await cli.restartServer();

// Option 2: Use Interactive CLI
const interactiveCLI = new InteractiveCLI(core);
await interactiveCLI.start();

Interactive Mode Features

When using dynamic-mock-server interactive, you get:

Main Menu Options

  • 📊 Show server status - Display server URL, active suite, route counts
  • 🔧 View configuration - See current config settings
  • 🗂️ Change routes suite - Select from available suites
  • 📝 View routes - List all routes with methods and URLs
  • 🎯 Override route response - Set specific route responses
  • 🔄 Restart server - Restart without losing context
  • ⚠️ View alerts - Check for warnings or errors
  • 🚪 Exit - Gracefully exit the CLI

Interactive Navigation

  • Arrow keys to navigate options
  • Enter/Return to select
  • Ctrl+C or ESC to go back or cancel
  • Clean, colorful output with visual feedback

API Reference

CLI Class

Base CLI class for programmatic server management.

Constructor

constructor(options: CLIOptions)

CLIOptions:

  • core: Core - Core instance to manage

Methods

async start(): Promise<void>

Start the server.

await cli.start();
async changeSuite(suiteId: string | null): Promise<void>

Change the active routes suite.

await cli.changeSuite("happy-path");
await cli.changeSuite(null); // Clear suite
async setRouteResponse(routeId: string, responseId: string | null): Promise<void>

Override a specific route's response.

await cli.setRouteResponse("get-users", "error");
await cli.setRouteResponse("get-users", null); // Clear override
async restartServer(): Promise<void>

Restart the mock server.

await cli.restartServer();

InteractiveCLI Class

Interactive CLI with @clack/prompts UI. Extends CLI class.

Constructor

constructor(core: Core)

Parameters:

  • core: Core - Core instance to manage

Methods

async start(): Promise<void>

Start interactive mode with menu navigation.

const interactiveCLI = new InteractiveCLI(core);
await interactiveCLI.start();
async stop(): Promise<void>

Stop interactive mode.

await interactiveCLI.stop();

Examples

Basic CLI Usage

import { Core } from "@dynamic-mock-server/core";
import { CLI } from "@dynamic-mock-server/cli";

const core = new Core();
const cli = new CLI({ core });

// Start server
await cli.start();

// Show status
console.log("Server running!");

// Change suite after 5 seconds
setTimeout(async () => {
  await cli.changeSuite("error-scenarios");
  console.log("Switched to error scenarios");
}, 5000);

Interactive CLI

import { Core } from "@dynamic-mock-server/core";
import { InteractiveCLI } from "@dynamic-mock-server/cli";

const core = new Core();
const interactiveCLI = new InteractiveCLI(core);

// Start interactive mode
await interactiveCLI.start();
// User can now navigate with arrow keys and manage server

Custom CLI Tool

#!/usr/bin/env node
import { Core } from "@dynamic-mock-server/core";
import { CLI } from "@dynamic-mock-server/cli";

const core = new Core();
const cli = new CLI({ core });

// Your custom logic
const args = process.argv.slice(2);

if (args[0] === "demo") {
  // Add demo routes
  core.mocksManager.addRoute({
    id: "demo",
    url: "/demo",
    method: "GET",
    responses: [{ id: "ok", status: 200, body: { demo: true } }],
  });
}

await cli.start();
console.log("Demo server started!");

Dependencies

  • @dynamic-mock-server/core - Core server functionality
  • @clack/prompts - Interactive prompts for beautiful CLI
  • commander - Command-line argument parsing
  • picocolors - Terminal coloring

Configuration

The CLI respects the server configuration file (dynamicMockServer.config.{js,json,yaml}). See @dynamic-mock-server/config for details.

Related Packages

License

Apache-2.0 © Miguel Martínez