Skip to content

Commit 74d3aa2

Browse files
committed
feat: add format check to CI workflow, update .gitignore and .prettierignore, and improve code formatting across multiple files
1 parent b5ddc20 commit 74d3aa2

File tree

21 files changed

+146
-94
lines changed

21 files changed

+146
-94
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
run: pnpm run build
2525
- name: Install Playwright browsers
2626
run: pnpm exec playwright install --with-deps
27+
- name: Format check
28+
run: pnpm run format:check
2729
- name: Run vitest tests
2830
run: pnpm run test:vitest
2931
- name: Run Playwright embed tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ screenshot.png
77
playwright-report/
88
test-results/
99
test-project/
10+
wokwi-part-tests/

.prettierignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Ignore node_modules
2+
node_modules/
3+
4+
# Ignore build outputs
5+
dist/
6+
build/
7+
8+
# Ignore logs
9+
*.log
10+
11+
# Ignore package-lock.json if present
12+
package-lock.json
13+
14+
# Ignore Arduino-specific files
15+
*.hex
16+
*.elf
17+
*.bin
18+
19+
# Ignore OS-specific files
20+
.DS_Store
21+
Thumbs.db
22+
23+
# repo specific ignores
24+
playwright-report/
25+
test-results/
26+
test-project/
27+
wokwi-part-tests/
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export const DEFAULT_SERVER = process.env.WOKWI_CLI_SERVER ?? 'wss://wokwi.com/api/ws/beta';
2-

packages/wokwi-cli/src/main.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import chalkTemplate from 'chalk-template';
33
import { createWriteStream, existsSync, readFileSync, writeFileSync } from 'fs';
44
import path, { join } from 'path';
55
import YAML from 'yaml';
6-
import { APIClient, type APIEvent, type ChipsLogPayload, type SerialMonitorDataPayload } from 'wokwi-client-js';
6+
import {
7+
APIClient,
8+
type APIEvent,
9+
type ChipsLogPayload,
10+
type SerialMonitorDataPayload,
11+
} from 'wokwi-client-js';
712
import { WebSocketTransport } from './transport/WebSocketTransport.js';
813
import { DEFAULT_SERVER } from './constants.js';
914
import { createSerialMonitorWritable } from './utils/serialMonitorWritable.js';
@@ -297,7 +302,10 @@ async function main() {
297302

298303
for (const chip of chips) {
299304
await client.fileUpload(`${chip.name}.chip.json`, readFileSync(chip.jsonPath, 'utf-8'));
300-
await client.fileUpload(`${chip.name}.chip.wasm`, new Uint8Array(readFileSync(chip.wasmPath)));
305+
await client.fileUpload(
306+
`${chip.name}.chip.wasm`,
307+
new Uint8Array(readFileSync(chip.wasmPath)),
308+
);
301309
}
302310

303311
const promises = [];
@@ -374,7 +382,7 @@ async function main() {
374382

375383
if (promises.length === 0) {
376384
// wait forever
377-
await new Promise(() => { });
385+
await new Promise(() => {});
378386
}
379387

380388
// wait until the scenario finishes or a timeout occurs

packages/wokwi-cli/src/mcp/MCPServer.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Server as McpServer } from '@modelcontextprotocol/sdk/server/index.js';
22
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3-
import {
4-
CallToolRequestSchema,
3+
import {
4+
CallToolRequestSchema,
55
ListToolsRequestSchema,
66
ListResourcesRequestSchema,
7-
ReadResourceRequestSchema
7+
ReadResourceRequestSchema,
88
} from '@modelcontextprotocol/sdk/types.js';
99
import { readVersion } from '../readVersion.js';
1010
import { SimulationManager } from './SimulationManager.js';
@@ -25,16 +25,19 @@ export class WokwiMCPServer {
2525

2626
constructor(private readonly options: MCPServerOptions) {
2727
const { version } = readVersion();
28-
29-
this.server = new McpServer({
30-
name: 'wokwi-cli',
31-
version,
32-
}, {
33-
capabilities: {
34-
tools: {},
35-
resources: {},
28+
29+
this.server = new McpServer(
30+
{
31+
name: 'wokwi-cli',
32+
version,
3633
},
37-
});
34+
{
35+
capabilities: {
36+
tools: {},
37+
resources: {},
38+
},
39+
},
40+
);
3841

3942
this.simulationManager = new SimulationManager(options.rootDir, options.token, options.quiet);
4043
this.tools = new WokwiMCPTools(this.simulationManager);
@@ -64,7 +67,7 @@ export class WokwiMCPServer {
6467
async start() {
6568
const transport = new StdioServerTransport();
6669
await this.server.connect(transport);
67-
70+
6871
if (!this.options.quiet) {
6972
console.error('Wokwi MCP Server started');
7073
}
@@ -74,4 +77,4 @@ export class WokwiMCPServer {
7477
await this.simulationManager.cleanup();
7578
await this.server.close();
7679
}
77-
}
80+
}

packages/wokwi-cli/src/mcp/SimulationManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ export class SimulationManager {
110110

111111
for (const chip of chips) {
112112
await this.client.fileUpload(`${chip.name}.chip.json`, readFileSync(chip.jsonPath, 'utf-8'));
113-
await this.client.fileUpload(`${chip.name}.chip.wasm`, new Uint8Array(readFileSync(chip.wasmPath)));
113+
await this.client.fileUpload(
114+
`${chip.name}.chip.wasm`,
115+
new Uint8Array(readFileSync(chip.wasmPath)),
116+
);
114117
}
115118

116119
// Start simulation

packages/wokwi-cli/src/mcp/WokwiMCPTools.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export class WokwiMCPTools {
1414
properties: {
1515
projectPath: {
1616
type: 'string',
17-
description: 'Path to the project directory (optional, defaults to current directory)',
17+
description:
18+
'Path to the project directory (optional, defaults to current directory)',
1819
},
1920
},
2021
},
@@ -135,7 +136,10 @@ export class WokwiMCPTools {
135136
];
136137
}
137138

138-
async callTool(name: string, args: any): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
139+
async callTool(
140+
name: string,
141+
args: any,
142+
): Promise<{ content: Array<{ type: 'text'; text: string }> }> {
139143
try {
140144
switch (name) {
141145
case 'wokwi_start_simulation':
@@ -239,4 +243,4 @@ export class WokwiMCPTools {
239243
};
240244
}
241245
}
242-
}
246+
}

packages/wokwi-cli/src/mcp/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export { SimulationManager } from './SimulationManager.js';
33
export { WokwiMCPTools } from './WokwiMCPTools.js';
44
export { WokwiMCPResources } from './WokwiMCPResources.js';
55
export type { MCPServerOptions } from './MCPServer.js';
6-
export type { SimulationStatus } from './SimulationManager.js';
6+
export type { SimulationStatus } from './SimulationManager.js';

packages/wokwi-cli/src/transport/WebSocketTransport.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export class WebSocketTransport implements ITransport {
2020

2121
private socket: WebSocket;
2222
private connectionAttempts = 0;
23-
23+
2424
// to suppress close events when intentionally closing
25-
private ignoreClose = false;
26-
25+
private ignoreClose = false;
26+
2727
// retryable error statuses
28-
private readonly errorStates = [
28+
private readonly errorStates = [
2929
ErrorStatus.RequestTimeout,
3030
ErrorStatus.ServiceUnavailable,
3131
ErrorStatus.CfRequestTimeout,
@@ -35,7 +35,7 @@ export class WebSocketTransport implements ITransport {
3535
private readonly token: string,
3636
private readonly server: string,
3737
private readonly version: string,
38-
private readonly sha: string
38+
private readonly sha: string,
3939
) {
4040
this.socket = this.createSocket();
4141
}

0 commit comments

Comments
 (0)