chore: change import assert to readFile (#368)

This commit is contained in:
Max Schmitt 2025-05-07 11:30:01 +02:00 committed by GitHub
parent 35e6c49d7c
commit 91ae93c167
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 6 deletions

View File

@ -37,7 +37,8 @@ jobs:
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18'
# https://github.com/microsoft/playwright-mcp/issues/344
node-version: '18.19'
cache: 'npm'
- name: Install dependencies

View File

@ -18,14 +18,12 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { CallToolRequestSchema, ListToolsRequestSchema, Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
import { zodToJsonSchema } from 'zod-to-json-schema';
import { Context } from './context.js';
import { Context, packageJSON } from './context.js';
import { snapshotTools, screenshotTools } from './tools.js';
import type { Config } from '../config.js';
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
import packageJSON from '../package.json' with { type: 'json' };
export async function createConnection(config: Config): Promise<Connection> {
const allTools = config.vision ? screenshotTools : snapshotTools;
const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability));

View File

@ -15,6 +15,7 @@
*/
import fs from 'node:fs';
import url from 'node:url';
import os from 'node:os';
import path from 'node:path';
@ -381,3 +382,6 @@ async function createUserDataDir(browserConfig: Config['browser']) {
export async function generateLocator(locator: playwright.Locator): Promise<string> {
return (locator as any)._generateLocatorString();
}
const __filename = url.fileURLToPath(import.meta.url);
export const packageJSON = JSON.parse(fs.readFileSync(path.join(path.dirname(__filename), '..', 'package.json'), 'utf8'));

View File

@ -20,8 +20,7 @@ import { startHttpTransport, startStdioTransport } from './transport.js';
import { resolveConfig } from './config.js';
import type { Connection } from './connection.js';
import packageJSON from '../package.json' with { type: 'json' };
import { packageJSON } from './context.js';
program
.version('Version ' + packageJSON.version)