Skip to content

Commit 22806db

Browse files
committed
refactor: integrate wokwi-client-js and enhance wokwi-cli functionality
- Introduced a new package, wokwi-client-js, to encapsulate API client functionality and transport mechanisms. - Updated wokwi-cli to utilize the new wokwi-client-js for API interactions, improving modularity and maintainability. - Refactored various components in wokwi-cli to support the new client structure, including changes to file uploads and command handling. - Enhanced error handling and connection management in the WebSocket transport layer. - Added new bundling script for the CLI and improved project structure for better organization. - Updated package.json and lock files to reflect new dependencies and scripts.
1 parent 357f613 commit 22806db

27 files changed

+682
-412
lines changed

package.json

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"clean": "pnpm -r run clean",
1010
"lint": "eslint .",
1111
"lint:fix": "eslint . --fix",
12-
"test": "npm run lint && vitest --run",
12+
"test": "pnpm run lint && vitest --run",
1313
"cli": "tsx packages/wokwi-cli/src/main.ts",
1414
"prepare": "husky install"
1515
},
@@ -19,17 +19,6 @@
1919
"type": "git",
2020
"url": "https://github.com/wokwi/wokwi-cli"
2121
},
22-
"dependencies": {
23-
"@clack/prompts": "^0.7.0",
24-
"@iarna/toml": "2.2.5",
25-
"@modelcontextprotocol/sdk": "^1.0.0",
26-
"arg": "^5.0.2",
27-
"chalk": "^5.3.0",
28-
"chalk-template": "^1.1.0",
29-
"pngjs": "^7.0.0",
30-
"ws": "^8.13.0",
31-
"yaml": "^2.3.1"
32-
},
3322
"devDependencies": {
3423
"@eslint/js": "^9.39.1",
3524
"esbuild": "^0.25.2",

packages/wokwi-cli/package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
"main": "index.js",
66
"type": "module",
77
"scripts": {
8-
"build": "node tools/build.js",
9-
"package": "npm 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",
8+
"prebuild": "pnpm run clean",
9+
"build": "tsc && pnpm run bundle",
10+
"bundle": "node tools/bundle.js",
11+
"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",
12+
"clean": "rimraf dist",
13+
"lint": "eslint src/**/*.ts",
14+
"lint:fix": "eslint src/**/*.ts --fix",
1015
"cli": "tsx src/main.ts",
11-
"test": "npm run lint && vitest --run",
16+
"test": "pnpm run lint && vitest --run",
1217
"test:watch": "vitest --watch"
1318
},
1419
"keywords": [
@@ -41,6 +46,7 @@
4146
"chalk": "^5.3.0",
4247
"chalk-template": "^1.1.0",
4348
"pngjs": "^7.0.0",
49+
"wokwi-client-js": "workspace:*",
4450
"ws": "^8.13.0",
4551
"yaml": "^2.3.1"
4652
},

packages/wokwi-cli/src/TestScenario.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import chalkTemplate from 'chalk-template';
2-
import type { APIClient } from './APIClient.js';
2+
import type { APIClient } from 'wokwi-client-js';
33

44
export interface IScenarioCommand {
55
/** Validates the input to the command. Throws an exception of the input is not valid */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const DEFAULT_SERVER = process.env.WOKWI_CLI_SERVER ?? 'wss://wokwi.com/api/ws/beta';
2+

0 commit comments

Comments
 (0)