Skip to content

Commit 72a5ddb

Browse files
fix: update main entry and bin configuration in wokwi-cli package (#37)
1 parent 8208d70 commit 72a5ddb

File tree

7 files changed

+269
-6
lines changed

7 files changed

+269
-6
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ jobs:
2626
run: pnpm exec playwright install --with-deps
2727
- name: Format check
2828
run: pnpm run format:check
29+
- name: Lint check
30+
run: pnpm run lint
31+
- name: Test creating CLI packages
32+
run: pnpm --filter wokwi-cli run package
33+
- name: Test Packing the packages
34+
run: pnpm -r pack
2935
- name: Run vitest tests
3036
run: pnpm run test:vitest
3137
- name: Run Playwright embed tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ playwright-report/
88
test-results/
99
test-project/
1010
wokwi-part-tests/
11+
12+
# Ignore packed tarballs
13+
wokwi-cli-*.tgz
14+
wokwi-client-js-*.tgz

DEVELOPMENT.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,100 @@ If you fork the repository, you must enable GitHub Actions for your fork and add
111111
Set the `WOKWI_CLI_TOKEN` secret in your fork under `Settings` > `Secrets and variables` > `Actions` > `New repository secret`.
112112

113113
Instructions for obtaining the `WOKWI_CLI_TOKEN` are in the `README.md` (see the Usage section).
114+
115+
116+
## Deployment
117+
118+
Packages are published manually using `pnpm` tools. Before publishing, ensure you have:
119+
- Updated the version number in the package's `package.json`
120+
- Committed all changes
121+
- Built and tested the packages
122+
123+
### Publishing wokwi-cli
124+
125+
The `wokwi-cli` package includes binary executables for multiple platforms. To publish:
126+
127+
1. Navigate to the package directory:
128+
```bash
129+
cd packages/wokwi-cli
130+
```
131+
132+
2. Clean previous builds:
133+
```bash
134+
pnpm clean
135+
```
136+
137+
3. Build the package:
138+
```bash
139+
pnpm build
140+
```
141+
142+
4. Package binaries for all platforms (optional, for verification):
143+
This is used only in CI to produce platform-specific binaries, those are not published to npm.
144+
```bash
145+
pnpm package
146+
```
147+
This creates platform-specific binaries in `dist/bin/` using `pkg`.
148+
149+
5. Create the tarball (optional, for verification):
150+
```bash
151+
pnpm pack
152+
```
153+
154+
6. Publish to npm:
155+
```bash
156+
pnpm publish
157+
```
158+
159+
### Publishing wokwi-client-js
160+
161+
The `wokwi-client-js` package is a JavaScript library without binaries. To publish:
162+
163+
1. Navigate to the package directory:
164+
```bash
165+
cd packages/wokwi-client-js
166+
```
167+
168+
2. Clean previous builds:
169+
```bash
170+
pnpm clean
171+
```
172+
173+
3. Build the package:
174+
```bash
175+
pnpm build
176+
```
177+
178+
4. Create the tarball (optional, for verification):
179+
```bash
180+
pnpm pack
181+
```
182+
183+
5. Publish to npm:
184+
```bash
185+
pnpm publish
186+
```
187+
188+
### Publishing both packages
189+
190+
To publish both packages in sequence:
191+
192+
```bash
193+
# Publish wokwi-client-js first (it's a dependency of wokwi-cli)
194+
cd packages/wokwi-client-js
195+
pnpm clean && pnpm build && pnpm publish
196+
197+
# Then publish wokwi-cli
198+
cd ../wokwi-cli
199+
pnpm clean && pnpm build && pnpm publish
200+
```
201+
202+
### Test GitHub Actions publishing (optional)
203+
GitHub Actions are set up to publish CLI tool compiled for multiple platforms. To test the publishing commands locally, you can run:
204+
205+
```bash
206+
pnpm run build && pnpm --filter wokwi-cli run package
207+
```
208+
209+
It should produce the platform-specific binaries in `packages/wokwi-cli/dist/bin/`.
210+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"test:embed:playwright": "playwright test test/wokwi-embed",
1717
"test:embed:playwright:ui": "playwright test test/wokwi-embed --ui",
1818
"test:cli:integration": "pnpm exec tsx scripts/test-cli-integration.ts",
19-
"package": "pnpm --filter wokwi-cli run package",
2019
"cli": "tsx packages/wokwi-cli/src/main.ts",
2120
"prepare": "husky install"
2221
},
@@ -36,6 +35,7 @@
3635
"lint-staged": "^15.4.3",
3736
"prettier": "^3.6.2",
3837
"rimraf": "^5.0.0",
38+
"shx": "^0.4.0",
3939
"tsx": "^4.19.2",
4040
"typescript": "^5.9.3",
4141
"typescript-eslint": "^8.46.3",

packages/wokwi-cli/package.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22
"name": "wokwi-cli",
33
"version": "0.18.3",
44
"description": "Wokwi Simulator CLI (for CI and local development)",
5-
"main": "index.js",
5+
"main": "dist/cli.cjs",
66
"type": "module",
7+
"bin": {
8+
"wokwi-cli": "dist/cli.cjs"
9+
},
10+
"files": [
11+
"dist/bin/version.json",
12+
"dist/cli.cjs",
13+
"README.md",
14+
"LICENSE"
15+
],
716
"scripts": {
8-
"prebuild": "pnpm run clean",
9-
"build": "tsc && pnpm run bundle",
17+
"prepack": "shx cp ../../README.md . && shx cp ../../LICENSE .",
18+
"postpack": "shx rm README.md LICENSE",
19+
"build": "tsc --noEmit && pnpm run bundle",
1020
"bundle": "node tools/bundle.js",
1121
"package": "pnpm run build && pkg --public -o dist/bin/wokwi-cli -t node20-linuxstatic-arm64,node20-linuxstatic-x64,node20-macos-arm64,node20-macos-x64,node20-win-x64 dist/cli.cjs",
1222
"clean": "rimraf dist",

packages/wokwi-client-js/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
}
2525
},
2626
"files": [
27-
"dist"
27+
"dist",
28+
"README.md",
29+
"LICENSE"
2830
],
2931
"scripts": {
30-
"prebuild": "pnpm run clean",
32+
"prepack": "shx cp ../../README.md . && shx cp ../../LICENSE .",
33+
"postpack": "shx rm README.md LICENSE",
3134
"build": "tsc && pnpm run build:browser",
3235
"build:browser": "node tools/bundle-browser.js",
3336
"clean": "rimraf dist",

0 commit comments

Comments
 (0)