This document describes how to set up a development environment for the Wokwi CLI and the Wokwi JS client.
Prerequisites:
- Node.js (https://nodejs.org/) (version 20 or higher)
- Git
- PNPM (https://pnpm.io)
We use PNPM workspaces to manage multiple packages in this repository. Install PNPM globally following the official instructions: https://pnpm.io/installation.
Clone the repository and install dependencies:
git clone https://github.com/wokwi/wokwi-cli
cd wokwi-cli
pnpm installWe use Playwright for end-to-end testing. Install the required browsers with:
pnpm exec playwright installThe repository contains two main packages:
@wokwi/cli: The command-line interface for Wokwi.@wokwi/client: The JavaScript client library used to interact with Wokwi from a browser iframe.
When you run pnpm commands from the repository root, the monorepo configuration determines which packages the command runs in. For example, pnpm build runs the build across packages, while pnpm lint runs eslint . for the whole repository.
If you want to build a single package, use the --filter flag. For example, to build only the @wokwi/cli package:
pnpm --filter @wokwi/cli buildOr change into the package directory and run the command there:
cd packages/cli
pnpm buildBuild the packages first:
pnpm buildThen run the CLI from the cli package directory:
cd packages/cli
pnpm cli [arguments]
# Example: show the help screen
pnpm cli -hExample output:
Wokwi CLI v0-development (f33d9d579b0a)
USAGE
$ wokwi-cli [options] [path/to/project]
OPTIONS
--help, -h Shows this help message and exit
...Before running tests, make sure you have built the packages and installed Playwright browsers:
pnpm build
pnpm exec playwright installWe have several types of tests:
- Unit tests (Vitest)
- End-to-end tests (Playwright)
- Integration tests that run the CLI against real Wokwi projects
To run all tests:
pnpm testTo run tests separately, inspect the scripts section in the root package.json.
The repository uses GitHub Actions to run tests on every push and pull request. The workflow files live in .github/workflows/ and contain steps to set up the environment, install dependencies, build packages, and run tests.
If you fork the repository, you must enable GitHub Actions for your fork and add the WOKWI_CLI_TOKEN secret.
Set the WOKWI_CLI_TOKEN secret in your fork under Settings > Secrets and variables > Actions > New repository secret.
Instructions for obtaining the WOKWI_CLI_TOKEN are in the README.md (see the Usage section).
Packages are published manually using pnpm tools. Before publishing, ensure you have:
- Updated the version number in the package's
package.json - Committed all changes
- Built and tested the packages
The @wokwi/cli package includes binary executables for multiple platforms. To publish:
-
Navigate to the package directory:
cd packages/cli -
Clean previous builds:
pnpm clean
-
Build the package:
pnpm build
-
Package binaries for all platforms (optional, for verification): This is used only in CI to produce platform-specific binaries, those are not published to npm.
pnpm package
This creates platform-specific binaries in
dist/bin/usingpkg. -
Create the tarball (optional, for verification):
pnpm pack
-
Publish to npm:
pnpm publish
The @wokwi/client package is a JavaScript library without binaries. To publish:
-
Navigate to the package directory:
cd packages/client -
Clean previous builds:
pnpm clean
-
Build the package:
pnpm build
-
Create the tarball (optional, for verification):
pnpm pack
-
Publish to npm:
pnpm publish
To publish both packages in sequence:
# Publish @wokwi/client first (it's a dependency of @wokwi/cli)
cd packages/client
pnpm clean && pnpm build && pnpm publish
# Then publish @wokwi/cli
cd ../cli
pnpm clean && pnpm build && pnpm publishGitHub Actions are set up to publish CLI tool compiled for multiple platforms. To test the publishing commands locally, you can run:
pnpm run build && pnpm --filter @wokwi/cli run packageIt should produce the platform-specific binaries in packages/cli/dist/bin/.