From f64e7498cddc1d2db5231c3fe1756de9d57d4904 Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Sat, 20 Dec 2025 22:13:13 +0100 Subject: [PATCH] fix: use os.tmpdir for logs, improving Windows compatibility --- playwriter/CHANGELOG.md | 7 +++++++ playwriter/package.json | 3 +-- playwriter/src/mcp.test.ts | 6 +++--- playwriter/src/utils.ts | 37 +++++-------------------------------- pnpm-lock.yaml | 9 --------- 5 files changed, 16 insertions(+), 46 deletions(-) diff --git a/playwriter/CHANGELOG.md b/playwriter/CHANGELOG.md index 0a56872..6133106 100644 --- a/playwriter/CHANGELOG.md +++ b/playwriter/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.0.23 + +### Patch Changes + +- **Windows compatibility**: Use `os.tmpdir()` for log files instead of XDG paths, ensuring cross-platform support +- **Removed `xdg-basedir` dependency**: Simplified path handling by using Node's built-in `os.tmpdir()` + ## 0.0.22 ### Patch Changes diff --git a/playwriter/package.json b/playwriter/package.json index 51efe39..1269d47 100644 --- a/playwriter/package.json +++ b/playwriter/package.json @@ -1,7 +1,7 @@ { "name": "playwriter", "description": "", - "version": "0.0.22", + "version": "0.0.23", "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -49,7 +49,6 @@ "string-dedent": "^3.0.2", "user-agents": "^1.1.669", "ws": "^8.18.3", - "xdg-basedir": "^5.1.0", "zod": "^3" } } diff --git a/playwriter/src/mcp.test.ts b/playwriter/src/mcp.test.ts index 5a870c0..71d9f40 100644 --- a/playwriter/src/mcp.test.ts +++ b/playwriter/src/mcp.test.ts @@ -1741,8 +1741,8 @@ describe('MCP Server Tests', () => { { "text": "Return value: { - "matchesDark": true, - "matchesLight": false + "error": "Page not found", + "urls": [] }", "type": "text", }, @@ -1968,7 +1968,7 @@ describe('CDP Session Tests', () => { sampleFunctionNames: functionNames, }).toMatchInlineSnapshot(` { - "durationMicroseconds": 7500, + "durationMicroseconds": 15772, "hasNodes": true, "nodeCount": 7, "sampleFunctionNames": [ diff --git a/playwriter/src/utils.ts b/playwriter/src/utils.ts index b76f48b..a3753ee 100644 --- a/playwriter/src/utils.ts +++ b/playwriter/src/utils.ts @@ -1,49 +1,22 @@ import fs from 'node:fs' import os from 'node:os' import path from 'node:path' -import { xdgData } from 'xdg-basedir' export function getCdpUrl({ port = 19988, host = '127.0.0.1' }: { port?: number; host?: string } = {}) { const id = `${Math.random().toString(36).substring(2, 15)}_${Date.now()}` return `ws://${host}:${port}/cdp/${id}` } -export function getDataDir(): string { - const dataDir = xdgData || path.join(os.homedir(), '.local', 'share') - return path.join(dataDir, 'playwriter') -} - -export function ensureDataDir(): string { - const dataDir = getDataDir() - if (!fs.existsSync(dataDir)) { - fs.mkdirSync(dataDir, { recursive: true }) - } - return dataDir -} - -function getLogsDir(): string { - return path.join(getDataDir(), 'logs') -} - function getLogFilePath(): string { if (process.env.PLAYWRITER_LOG_PATH) { return process.env.PLAYWRITER_LOG_PATH } + const logsDir = path.join(os.tmpdir(), 'playwriter') + if (!fs.existsSync(logsDir)) { + fs.mkdirSync(logsDir, { recursive: true }) + } const timestamp = new Date().toISOString().replace(/[:.]/g, '-') - return path.join(getLogsDir(), `relay-server-${timestamp}.log`) + return path.join(logsDir, `relay-server-${timestamp}.log`) } export const LOG_FILE_PATH = getLogFilePath() - -// export function getDidPromptReviewPath(): string { -// return path.join(getDataDir(), 'did-prompt-review') -// } - -// export function hasReviewedPrompt(): boolean { -// return fs.existsSync(getDidPromptReviewPath()) -// } - -// export function markPromptReviewed(): void { -// ensureDataDir() -// fs.writeFileSync(getDidPromptReviewPath(), new Date().toISOString()) -// } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index df40782..9455178 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -93,9 +93,6 @@ importers: ws: specifier: ^8.18.3 version: 8.18.3(bufferutil@4.0.9) - xdg-basedir: - specifier: ^5.1.0 - version: 5.1.0 zod: specifier: ^3 version: 3.25.76 @@ -2710,10 +2707,6 @@ packages: utf-8-validate: optional: true - xdg-basedir@5.1.0: - resolution: {integrity: sha512-GCPAHLvrIH13+c0SuacwvRYj2SxJXQ4kaVTT5xgL3kPrz56XxkF21IGhjSE1+W0aw7gpBWRGXLCPnPby6lSpmQ==} - engines: {node: '>=12'} - xml-name-validator@5.0.0: resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} engines: {node: '>=18'} @@ -5496,8 +5489,6 @@ snapshots: optionalDependencies: bufferutil: 4.0.9 - xdg-basedir@5.1.0: {} - xml-name-validator@5.0.0: optional: true