chore: refactor internal cli commands to use commander (#12146)
This commit is contained in:
parent
7ee35ae30d
commit
47cc7c4ae8
|
|
@ -218,6 +218,33 @@ program
|
||||||
launchGridAgent(options.agentId, options.gridUrl);
|
launchGridAgent(options.agentId, options.gridUrl);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command('run-driver', { hidden: true })
|
||||||
|
.action(function(options) {
|
||||||
|
runDriver();
|
||||||
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command('run-server', { hidden: true })
|
||||||
|
.option('--port <port>', 'Server port')
|
||||||
|
.action(function(options) {
|
||||||
|
runServer(options.port ? +options.port : undefined).catch(logErrorAndExit);
|
||||||
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command('print-api-json', { hidden: true })
|
||||||
|
.action(function(options) {
|
||||||
|
printApiJson();
|
||||||
|
});
|
||||||
|
|
||||||
|
program
|
||||||
|
.command('launch-server', { hidden: true })
|
||||||
|
.requiredOption('--browser <browserName>', 'Browser name, one of "chromium", "firefox" or "webkit"')
|
||||||
|
.option('--config <path-to-config-file>', 'JSON file with launchServer options')
|
||||||
|
.action(function(options) {
|
||||||
|
launchBrowserServer(options.browserName, options.config);
|
||||||
|
});
|
||||||
|
|
||||||
program
|
program
|
||||||
.command('show-trace [trace...]')
|
.command('show-trace [trace...]')
|
||||||
.option('-b, --browser <browserType>', 'browser to use, one of cr, chromium, ff, firefox, wk, webkit', 'chromium')
|
.option('-b, --browser <browserType>', 'browser to use, one of cr, chromium, ff, firefox, wk, webkit', 'chromium')
|
||||||
|
|
@ -270,17 +297,7 @@ if (!process.env.PW_LANG_NAME) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.argv[2] === 'run-driver')
|
program.parse(process.argv);
|
||||||
runDriver();
|
|
||||||
else if (process.argv[2] === 'run-server')
|
|
||||||
runServer(process.argv[3] ? +process.argv[3] : undefined).catch(logErrorAndExit);
|
|
||||||
else if (process.argv[2] === 'print-api-json')
|
|
||||||
printApiJson();
|
|
||||||
else if (process.argv[2] === 'launch-server')
|
|
||||||
launchBrowserServer(process.argv[3], process.argv[4]).catch(logErrorAndExit);
|
|
||||||
else
|
|
||||||
program.parse(process.argv);
|
|
||||||
|
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
browser: string;
|
browser: string;
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ if (mode === 'service') {
|
||||||
|
|
||||||
if (mode === 'service2') {
|
if (mode === 'service2') {
|
||||||
config.webServer = {
|
config.webServer = {
|
||||||
command: 'npx playwright run-server 3333',
|
command: 'npx playwright run-server --port=3333',
|
||||||
port: 3333,
|
port: 3333,
|
||||||
reuseExistingServer: true,
|
reuseExistingServer: true,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class OutOfProcessPlaywrightServer {
|
||||||
private _receivedPortPromise: Promise<string>;
|
private _receivedPortPromise: Promise<string>;
|
||||||
|
|
||||||
constructor(port: number, proxyPort: number) {
|
constructor(port: number, proxyPort: number) {
|
||||||
this._driverProcess = childProcess.fork(path.join(__dirname, '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'), ['run-server', port.toString()], {
|
this._driverProcess = childProcess.fork(path.join(__dirname, '..', 'packages', 'playwright-core', 'lib', 'cli', 'cli.js'), ['run-server', '--port', port.toString()], {
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
detached: true,
|
detached: true,
|
||||||
env: {
|
env: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue