Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/playwright-chromium/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright-core/lib/cli/cli');

const { program } = require('playwright-core/lib/program');
program.parse(process.argv);
3 changes: 2 additions & 1 deletion packages/playwright-core/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright-core/lib/cli/cli');
const { program } = require('./lib/cli/programWithTestStub');
program.parse(process.argv);
1 change: 0 additions & 1 deletion packages/playwright-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"./lib/image_tools/compare": "./lib/image_tools/compare.js",
"./lib/image_tools/imageChannel": "./lib/image_tools/imageChannel.js",
"./lib/image_tools/colorUtils": "./lib/image_tools/colorUtils.js",
"./lib/cli/cli": "./lib/cli/cli.js",
"./lib/cli/program": "./lib/cli/program.js",
"./lib/server/registry/index": "./lib/server/registry/index.js",
"./lib/remote/playwrightServer": "./lib/remote/playwrightServer.js",
Expand Down
3 changes: 1 addition & 2 deletions packages/playwright-core/src/cli/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import os from 'os';
import path from 'path';
import type { Command } from '../utilsBundle';
import { program } from '../utilsBundle';
export { program } from '../utilsBundle';
import { runDriver, runServer, printApiJson, launchBrowserServer } from './driver';
import type { OpenTraceViewerOptions } from '../server/trace/viewer/traceViewer';
import { openTraceInBrowser, openTraceViewerApp } from '../server/trace/viewer/traceViewer';
Expand Down Expand Up @@ -690,5 +691,3 @@ function buildBasePlaywrightCLICommand(cliTargetLang: string | undefined): strin
}
}
}

export default program;
7 changes: 2 additions & 5 deletions packages/playwright-core/src/cli/cli.ts → ...right-core/src/cli/programWithTestStub.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

/**
* Copyright (c) Microsoft Corporation.
*
Expand All @@ -19,7 +17,8 @@
/* eslint-disable no-console */

import { getPackageManager, gracefullyProcessExitDoNotHang } from '../utils';
import program from './program';
import { program } from './program';
export { program } from './program';

function printPlaywrightTestError(command: string) {
const packages: string[] = [];
Expand Down Expand Up @@ -66,5 +65,3 @@ function addExternalPlaywrightTestCommands() {

if (!process.env.PW_LANG_NAME)
addExternalPlaywrightTestCommands();

program.parse(process.argv);
2 changes: 1 addition & 1 deletion packages/playwright-core/src/outofprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PlaywrightClient {
private _closePromise = new ManualPromise<void>();

constructor(env: any) {
this._driverProcess = childProcess.fork(path.join(__dirname, 'cli', 'cli.js'), ['run-driver'], {
this._driverProcess = childProcess.fork(path.join(__dirname, '..', 'cli.js'), ['run-driver'], {
stdio: 'pipe',
detached: true,
env: {
Expand Down
4 changes: 3 additions & 1 deletion packages/playwright-ct-core/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright/lib/cli');

const { program } = require('./lib/program');
program.parse(process.argv);
2 changes: 1 addition & 1 deletion packages/playwright-ct-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"types": "./index.d.ts",
"default": "./index.js"
},
"./cli": "./cli.js",
"./lib/mount": "./lib/mount.js",
"./lib/program": "./lib/program.js",
"./plugin": "./plugin.js",
"./types/component": {
"types": "./types/component.d.ts"
Expand Down
17 changes: 17 additions & 0 deletions packages/playwright-ct-core/src/program.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export { program } from 'playwright/lib/program';
4 changes: 3 additions & 1 deletion packages/playwright-ct-react/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-ct-react17/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-ct-solid/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-ct-svelte/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-ct-vue/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-ct-vue2/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@playwright/experimental-ct-core/cli');

const { program } = require('@playwright/experimental-ct-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-firefox/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright-core/lib/cli/cli');

const { program } = require('playwright-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright/cli');

const { program } = require('playwright/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright-webkit/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('playwright-core/lib/cli/cli');

const { program } = require('playwright-core/lib/program');
program.parse(process.argv);
4 changes: 3 additions & 1 deletion packages/playwright/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('./lib/cli');

const { program } = require('./lib/program');
program.parse(process.argv);
3 changes: 1 addition & 2 deletions packages/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
"require": "./index.js",
"default": "./index.js"
},
"./cli": "./cli.js",
"./package.json": "./package.json",
"./lib/cli": "./lib/cli.js",
"./lib/program": "./lib/program.js",
"./lib/transform/babelBundle": "./lib/transform/babelBundle.js",
"./lib/transform/compilationCache": "./lib/transform/compilationCache.js",
"./lib/transform/esmLoader": "./lib/transform/esmLoader.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/playwright/src/DEPS.list
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ common/
./utils.ts
./utilsBundle.ts

[cli.ts]
[program.ts]
**

[index.ts]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import type { FullResult, TestError } from '../types/testReporter';
import type { TraceMode } from '../types/test';
import { builtInReporters, defaultReporter, defaultTimeout } from './common/config';
import type { FullConfigInternal } from './common/config';
import program from 'playwright-core/lib/cli/program';
import { program } from 'playwright-core/lib/cli/program';
export { program } from 'playwright-core/lib/cli/program';
import type { ReporterDescription } from '../types/test';
import { prepareErrorStack } from './reporters/base';
import { registerESMLoader } from './common/esmLoaderHost';
Expand Down Expand Up @@ -289,7 +290,7 @@ function restartWithExperimentalTsEsm(configFile: string | null): boolean {
return false;
// Node.js < 20
if (!require('node:module').register) {
const innerProcess = (require('child_process') as typeof import('child_process')).fork(require.resolve('./cli'), process.argv.slice(2), {
const innerProcess = (require('child_process') as typeof import('child_process')).fork(require.resolve('../cli'), process.argv.slice(2), {
env: {
...process.env,
PW_TS_ESM_LEGACY_LOADER_ON: '1',
Expand Down Expand Up @@ -346,5 +347,3 @@ addTestCommand(program);
addShowReportCommand(program);
addListFilesCommand(program);
addMergeReportsCommand(program);

program.parse(process.argv);
2 changes: 1 addition & 1 deletion tests/config/remoteServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class RunServer implements PlaywrightServer {
_wsEndpoint!: string;

async start(childProcess: CommonFixtures['childProcess'], mode?: 'extension' | 'default', env?: NodeJS.ProcessEnv) {
const command = ['node', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'), 'run-server'];
const command = ['node', path.join(__dirname, '..', '..', 'packages', 'playwright-core', 'cli.js'), 'run-server'];
if (mode === 'extension')
command.push('--mode=extension');
this._process = childProcess({
Expand Down
2 changes: 1 addition & 1 deletion tests/library/inspector/inspectorTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class CLIMock {
constructor(childProcess: CommonFixtures['childProcess'], browserName: string, channel: string | undefined, headless: boolean | undefined, args: string[], executablePath: string | undefined, autoExitWhen: string | undefined) {
const nodeArgs = [
'node',
path.join(__dirname, '..', '..', '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'),
path.join(__dirname, '..', '..', '..', 'packages', 'playwright-core', 'cli.js'),
'codegen',
...args,
`--browser=${browserName}`,
Expand Down
2 changes: 1 addition & 1 deletion utils/build/run-driver-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ SCRIPT_PATH="$(cd "$(dirname "$0")" ; pwd -P)"
if [ -z "$PLAYWRIGHT_NODEJS_PATH" ]; then
PLAYWRIGHT_NODEJS_PATH="$SCRIPT_PATH/node"
fi
"$PLAYWRIGHT_NODEJS_PATH" "$SCRIPT_PATH/package/lib/cli/cli.js" "$@"
"$PLAYWRIGHT_NODEJS_PATH" "$SCRIPT_PATH/package/cli.js" "$@"