Skip to content

Commit 73b6913

Browse files
authored
[playwright-browser-tunnel] Add playwright-versioning and remove semver-coersion (#5669)
* feat: playwright-versioning Allow manually passing in the version of playwright to use for the tunnel and still default to the playwright-core version if not provided. This allows us to use the tunnel with different versions of playwright without needing to update the tunnel package itself. * bugfix: remove-semver-coercion Remove semver coercion from the Playwright version in the handshake message. This allows for more flexible version handling and avoids issues with prerelease version formats. * misc: rush-change
1 parent 4c0ac8e commit 73b6913

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

apps/playwright-browser-tunnel/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@rushstack/terminal": "workspace:*",
4949
"@rushstack/ts-command-line": "workspace:*",
5050
"string-argv": "~0.3.1",
51-
"semver": "~7.5.4",
5251
"ws": "~8.14.1",
5352
"playwright": "1.56.1"
5453
},

apps/playwright-browser-tunnel/src/PlaywrightBrowserTunnel.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { once } from 'node:events';
66

77
import type { BrowserServer, BrowserType, LaunchOptions } from 'playwright-core';
88
import { type RawData, WebSocket, type WebSocketServer } from 'ws';
9-
import semver from 'semver';
109

1110
import { TerminalProviderSeverity, TerminalStreamWritable, type ITerminal } from '@rushstack/terminal';
1211
import { Executable, FileSystem, Async } from '@rushstack/node-core-library';
@@ -48,7 +47,7 @@ export interface IHandshake {
4847
action: 'handshake';
4948
browserName: BrowserName;
5049
launchOptions: LaunchOptions;
51-
playwrightVersion: semver.SemVer;
50+
playwrightVersion: string;
5251
}
5352

5453
type TunnelMode = 'poll-connection' | 'wait-for-incoming-connection';
@@ -432,10 +431,7 @@ export class PlaywrightTunnel {
432431
if (action !== 'handshake') {
433432
throw new Error(`Invalid action: ${action}. Expected 'handshake'.`);
434433
}
435-
const playwrightVersionSemver: semver.SemVer | null = semver.coerce(playwrightVersion);
436-
if (!playwrightVersionSemver) {
437-
throw new Error(`Invalid Playwright version: ${playwrightVersion}. Must be a valid semver version.`);
438-
}
434+
439435
if (!isValidBrowserName(browserName)) {
440436
throw new Error(
441437
`Invalid browser name: ${browserName}. Must be one of ${Array.from(validBrowserNames).join(', ')}.`
@@ -445,7 +441,7 @@ export class PlaywrightTunnel {
445441
return {
446442
action,
447443
launchOptions: launchOptions as LaunchOptions,
448-
playwrightVersion: playwrightVersionSemver,
444+
playwrightVersion,
449445
browserName
450446
};
451447
}

apps/playwright-browser-tunnel/src/tunneledBrowserConnection/TunneledBrowserConnection.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ import type {
2323
} from './ITunneledBrowserConnection';
2424
import { DEFAULT_LISTEN_PORT, SUPPORTED_BROWSER_NAMES } from './constants';
2525

26-
const { version: playwrightVersion } = playwrightPackageJson;
27-
2826
/**
2927
* Creates a tunneled WebSocket endpoint that a local Playwright client can connect to.
3028
* @beta
3129
*/
3230
export async function tunneledBrowserConnection(
3331
logger: ITerminal,
34-
port: number = DEFAULT_LISTEN_PORT
32+
port: number = DEFAULT_LISTEN_PORT,
33+
playwrightVersion: string = playwrightPackageJson.version
3534
): Promise<IDisposableTunneledBrowserConnection> {
3635
// Server that remote peer (actual browser host) connects to
3736
const remoteWsServer: WebSocketServer = new WebSocketServer({ port });
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/playwright-browser-tunnel",
5+
"comment": "Add playwright-versioning and remove semver",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/playwright-browser-tunnel"
10+
}

common/config/subspaces/default/pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/reviews/api/playwright-browser-tunnel.api.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import type { Browser } from 'playwright-core';
88
import { ITerminal } from '@rushstack/terminal';
99
import type { LaunchOptions } from 'playwright-core';
10-
import semver from 'semver';
1110

1211
// @beta
1312
export type BrowserName = 'chromium' | 'firefox' | 'webkit';
@@ -43,7 +42,7 @@ export interface IHandshake {
4342
// (undocumented)
4443
launchOptions: LaunchOptions;
4544
// (undocumented)
46-
playwrightVersion: semver.SemVer;
45+
playwrightVersion: string;
4746
}
4847

4948
// @beta
@@ -112,7 +111,7 @@ export class PlaywrightTunnel {
112111
}
113112

114113
// @beta
115-
export function tunneledBrowserConnection(logger: ITerminal, port?: number): Promise<IDisposableTunneledBrowserConnection>;
114+
export function tunneledBrowserConnection(logger: ITerminal, port?: number, playwrightVersion?: string): Promise<IDisposableTunneledBrowserConnection>;
116115

117116
// @beta
118117
export type TunnelStatus = 'waiting-for-connection' | 'browser-server-running' | 'stopped' | 'setting-up-browser-server' | 'error';

vscode-extensions/playwright-local-browser-server-vscode-extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "playwright-local-browser-server",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/microsoft/rushstack.git",

0 commit comments

Comments
 (0)