Skip to content

Commit ef83c78

Browse files
committed
feat: add DEVELOPMENT.md for setup instructions and replace CLI integration test script with TypeScript version
1 parent f33d9d5 commit ef83c78

File tree

9 files changed

+427
-331
lines changed

9 files changed

+427
-331
lines changed

DEVELOPMENT.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Development
2+
3+
This document describes how to set up a development environment for the Wokwi CLI and the Wokwi JS client.
4+
5+
## Getting started
6+
7+
Prerequisites:
8+
- Node.js (https://nodejs.org/) (version 20 or higher)
9+
- Git
10+
- PNPM (https://pnpm.io)
11+
12+
We use PNPM workspaces to manage multiple packages in this repository. Install PNPM globally following the official instructions: https://pnpm.io/installation.
13+
14+
## Setting up the repository
15+
16+
Clone the repository and install dependencies:
17+
18+
```bash
19+
git clone https://github.com/wokwi/wokwi-cli
20+
cd wokwi-cli
21+
pnpm install
22+
```
23+
24+
We use Playwright for end-to-end testing. Install the required browsers with:
25+
26+
```bash
27+
pnpm exec playwright install
28+
```
29+
30+
## Packages
31+
32+
The repository contains two main packages:
33+
- `wokwi-cli`: The command-line interface for Wokwi.
34+
- `wokwi-js`: The JavaScript client library used to interact with Wokwi from a browser iframe.
35+
36+
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.
37+
38+
If you want to build a single package, use the `--filter` flag. For example, to build only the `wokwi-cli` package:
39+
40+
```bash
41+
pnpm --filter wokwi-cli build
42+
```
43+
44+
Or change into the package directory and run the command there:
45+
46+
```bash
47+
cd packages/wokwi-cli
48+
pnpm build
49+
```
50+
51+
## Running the CLI in development mode
52+
53+
Build the packages first:
54+
55+
```bash
56+
pnpm build
57+
```
58+
59+
Then run the CLI from the `wokwi-cli` package directory:
60+
61+
```bash
62+
cd packages/wokwi-cli
63+
pnpm cli [arguments]
64+
65+
# Example: show the help screen
66+
pnpm cli -h
67+
```
68+
69+
Example output:
70+
71+
```bash
72+
Wokwi CLI v0-development (f33d9d579b0a)
73+
74+
USAGE
75+
76+
$ wokwi-cli [options] [path/to/project]
77+
78+
OPTIONS
79+
--help, -h Shows this help message and exit
80+
...
81+
```
82+
83+
## Running tests locally
84+
85+
Before running tests, make sure you have built the packages and installed Playwright browsers:
86+
87+
```bash
88+
pnpm build
89+
pnpm exec playwright install
90+
```
91+
92+
We have several types of tests:
93+
- Unit tests (Vitest)
94+
- End-to-end tests (Playwright)
95+
- Integration tests that run the CLI against real Wokwi projects
96+
97+
To run all tests:
98+
99+
```bash
100+
pnpm test
101+
```
102+
103+
To run tests separately, inspect the `scripts` section in the root `package.json`.
104+
105+
## Automatic tests (CI)
106+
107+
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.
108+
109+
If you fork the repository, you must enable GitHub Actions for your fork and add the `WOKWI_CLI_TOKEN` secret.
110+
111+
Set the `WOKWI_CLI_TOKEN` secret in your fork under `Settings` > `Secrets and variables` > `Actions` > `New repository secret`.
112+
113+
Instructions for obtaining the `WOKWI_CLI_TOKEN` are in the `README.md` (see the Usage section).

README.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,7 @@ To configure your AI agent to use the MCP server, add the following to your agen
7474

7575
## Development
7676

77-
Clone the repository, install the npm depenedencies, and then run the CLI:
78-
79-
```bash
80-
git clone https://github.com/wokwi/wokwi-cli
81-
cd wokwi-cli
82-
npm install
83-
npm start
84-
```
85-
86-
To pass command line arguments to the cli, use `npm start -- [arguments]`. For example, to see the help screen, run:
87-
88-
```
89-
npm start -- -h
90-
```
77+
All information about developing the Wokwi CLI can be found in [DEVELOPMENT.md](DEVELOPMENT.md).
9178

9279
## License
9380

eslint.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { defineConfig } from 'eslint/config';
22
import eslint from '@eslint/js';
3-
import eslintConfigPrettier from 'eslint-config-prettier';
43
import tseslint from 'typescript-eslint';
54

65
export default defineConfig(
@@ -66,7 +65,4 @@ export default defineConfig(
6665
'no-undef': 'off',
6766
},
6867
},
69-
70-
// Prettier config (must be last to override conflicting rules)
71-
eslintConfigPrettier,
7268
);

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
"clean": "pnpm -r run clean",
1010
"lint": "eslint .",
1111
"lint:fix": "eslint . --fix",
12+
"format": "prettier --write packages scripts test",
13+
"format:check": "prettier --check packages scripts test",
1214
"test": "pnpm run test:vitest && pnpm run test:embed:playwright && pnpm run test:cli:integration",
1315
"test:vitest": "pnpm run lint && vitest --run",
1416
"test:embed:playwright": "playwright test test/wokwi-embed",
1517
"test:embed:playwright:ui": "playwright test test/wokwi-embed --ui",
16-
"test:cli:integration": "bash scripts/test-cli-integration.sh",
18+
"test:cli:integration": "pnpm exec tsx scripts/test-cli-integration.ts",
19+
"package": "pnpm -r run package",
1720
"cli": "tsx packages/wokwi-cli/src/main.ts",
1821
"prepare": "husky install"
1922
},
@@ -28,11 +31,10 @@
2831
"@playwright/test": "^1.48.0",
2932
"esbuild": "^0.25.2",
3033
"eslint": "^9.39.1",
31-
"eslint-config-prettier": "^10.1.8",
3234
"husky": "^8.0.0",
3335
"jiti": "^2.6.1",
3436
"lint-staged": "^15.4.3",
35-
"prettier": "^3.5.0",
37+
"prettier": "^3.6.2",
3638
"rimraf": "^5.0.0",
3739
"tsx": "^4.19.2",
3840
"typescript": "^5.9.3",

0 commit comments

Comments
 (0)