Skip to content

Commit 137aa28

Browse files
committed
chore: generate config section from config.d.ts
1 parent 64f65cc commit 137aa28

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ npx @playwright/mcp@latest --config path/to/config.json
451451
<details>
452452
<summary>Configuration file schema</summary>
453453

454+
<!--- Config generated by update-readme.js -->
455+
454456
```typescript
455457
{
456458
/**
@@ -576,6 +578,18 @@ npx @playwright/mcp@latest --config path/to/config.json
576578
*/
577579
outputDir?: string;
578580

581+
network?: {
582+
/**
583+
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
584+
*/
585+
allowedOrigins?: string[];
586+
587+
/**
588+
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
589+
*/
590+
blockedOrigins?: string[];
591+
};
592+
579593
/**
580594
* Specify the attribute to use for test ids, defaults to "data-testid".
581595
*/
@@ -597,8 +611,11 @@ npx @playwright/mcp@latest --config path/to/config.json
597611
* Whether to send image responses to the client. Can be "allow", "omit", or "auto". Defaults to "auto", which sends images if the client can display them.
598612
*/
599613
imageResponses?: 'allow' | 'omit';
600-
};
614+
}
601615
```
616+
617+
<!--- End of config generated section -->
618+
602619
</details>
603620

604621
### Standalone MCP server

update-readme.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,38 @@ async function updateOptions(content) {
135135
]);
136136
}
137137

138+
/**
139+
* @param {string} content
140+
* @returns {Promise<string>}
141+
*/
142+
async function updateConfig(content) {
143+
console.log('Updating config schema from config.d.ts...');
144+
const configPath = path.join(__dirname, 'config.d.ts');
145+
const configContent = await fs.promises.readFile(configPath, 'utf-8');
146+
147+
// Extract the Config type definition
148+
const configTypeMatch = configContent.match(/export type Config = (\{[\s\S]*?\n\});/);
149+
if (!configTypeMatch)
150+
throw new Error('Config type not found in config.d.ts');
151+
152+
const configType = configTypeMatch[1]; // Use capture group to get just the object definition
153+
154+
const startMarker = `<!--- Config generated by ${path.basename(__filename)} -->`;
155+
const endMarker = `<!--- End of config generated section -->`;
156+
return updateSection(content, startMarker, endMarker, [
157+
'```typescript',
158+
configType,
159+
'```',
160+
]);
161+
}
162+
138163
async function updateReadme() {
139164
const readmePath = path.join(__dirname, 'README.md');
140165
const readmeContent = await fs.promises.readFile(readmePath, 'utf-8');
141166
const withTools = await updateTools(readmeContent);
142167
const withOptions = await updateOptions(withTools);
143-
await fs.promises.writeFile(readmePath, withOptions, 'utf-8');
168+
const withConfig = await updateConfig(withOptions);
169+
await fs.promises.writeFile(readmePath, withConfig, 'utf-8');
144170
console.log('README updated successfully');
145171
}
146172

0 commit comments

Comments
 (0)