mirror of
https://github.com/microsoft/playwright.git
synced 2024-09-11 20:37:54 +03:00
chore: split cli processing into cli endpoint and program (#29131)
This commit is contained in:
parent
1ce3ca25a2
commit
cec2ff1772
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -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';
|
||||
@ -690,5 +691,3 @@ function buildBasePlaywrightCLICommand(cliTargetLang: string | undefined): strin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default program;
|
||||
|
7
packages/playwright-core/src/cli/cli.ts → packages/playwright-core/src/cli/programWithTestStub.ts
Executable file → Normal file
7
packages/playwright-core/src/cli/cli.ts → packages/playwright-core/src/cli/programWithTestStub.ts
Executable file → Normal file
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
@ -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[] = [];
|
||||
@ -66,5 +65,3 @@ function addExternalPlaywrightTestCommands() {
|
||||
|
||||
if (!process.env.PW_LANG_NAME)
|
||||
addExternalPlaywrightTestCommands();
|
||||
|
||||
program.parse(process.argv);
|
@ -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: {
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
|
17
packages/playwright-ct-core/src/program.ts
Normal file
17
packages/playwright-ct-core/src/program.ts
Normal file
@ -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';
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
@ -3,7 +3,7 @@ common/
|
||||
./utils.ts
|
||||
./utilsBundle.ts
|
||||
|
||||
[cli.ts]
|
||||
[program.ts]
|
||||
**
|
||||
|
||||
[index.ts]
|
||||
|
@ -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';
|
||||
@ -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',
|
||||
@ -346,5 +347,3 @@ addTestCommand(program);
|
||||
addShowReportCommand(program);
|
||||
addListFilesCommand(program);
|
||||
addMergeReportsCommand(program);
|
||||
|
||||
program.parse(process.argv);
|
@ -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({
|
||||
|
@ -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}`,
|
||||
|
@ -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" "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user