chore: move browserPaths to utils, enforce more deps (#3584)

This commit is contained in:
Dmitry Gozman 2020-08-22 21:15:03 -07:00 committed by GitHub
parent 4025f9f1ef
commit 2e1493a5fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 14 additions and 13 deletions

View File

@ -24,8 +24,8 @@ import { getProxyForUrl } from 'proxy-from-env';
import * as URL from 'url';
import * as util from 'util';
import { assert, getFromENV } from '../utils/utils';
import * as browserPaths from './browserPaths';
import { BrowserName, BrowserPlatform, BrowserDescriptor } from './browserPaths';
import * as browserPaths from '../utils/browserPaths';
import { BrowserName, BrowserPlatform, BrowserDescriptor } from '../utils/browserPaths';
// `https-proxy-agent` v5 is written in Typescript and exposes generated types.
// However, as of June 2020, its types are generated with tsconfig that enables

View File

@ -19,7 +19,7 @@ import * as fs from 'fs';
import * as path from 'path';
import * as util from 'util';
import * as removeFolder from 'rimraf';
import * as browserPaths from './browserPaths';
import * as browserPaths from '../utils/browserPaths';
import * as browserFetcher from './browserFetcher';
import { getFromENV } from '../utils/utils';

View File

@ -19,7 +19,7 @@ import * as os from 'os';
import * as path from 'path';
import * as util from 'util';
import { BrowserContext, verifyProxySettings, validateBrowserContextOptions } from '../browserContext';
import * as browserPaths from '../install/browserPaths';
import * as browserPaths from '../utils/browserPaths';
import { ConnectionTransport, WebSocketTransport } from '../transport';
import { BrowserOptions, Browser, BrowserProcess } from '../browser';
import { launchProcess, Env, waitForLine, envArrayToObject } from './processLauncher';

View File

@ -23,7 +23,7 @@ import { kBrowserCloseMessageId } from './crConnection';
import { rewriteErrorMessage } from '../../utils/stackTrace';
import { BrowserTypeBase } from '../browserType';
import { ConnectionTransport, ProtocolRequest } from '../../transport';
import type { BrowserDescriptor } from '../../install/browserPaths';
import type { BrowserDescriptor } from '../../utils/browserPaths';
import { CRDevTools } from './crDevTools';
import { BrowserOptions } from '../../browser';
import * as types from '../../types';

View File

@ -24,7 +24,7 @@ import { BrowserTypeBase } from './browserType';
import { Env } from './processLauncher';
import { ConnectionTransport } from '../transport';
import { BrowserOptions } from '../browser';
import { BrowserDescriptor } from '../install/browserPaths';
import { BrowserDescriptor } from '../utils/browserPaths';
import * as types from '../types';
export class Firefox extends BrowserTypeBase {

View File

@ -18,7 +18,7 @@ import { Chromium } from './chromium/chromium';
import { WebKit } from './webkit';
import { Firefox } from './firefox';
import { selectors } from '../selectors';
import * as browserPaths from '../install/browserPaths';
import * as browserPaths from '../utils/browserPaths';
export class Playwright {
readonly selectors = selectors;

View File

@ -19,7 +19,7 @@ import * as path from 'path';
import * as os from 'os';
import { spawn } from 'child_process';
import { getUbuntuVersion } from '../utils/ubuntuVersion';
import { linuxLddDirectories, windowsExeAndDllDirectories, BrowserDescriptor } from '../install/browserPaths.js';
import { linuxLddDirectories, windowsExeAndDllDirectories, BrowserDescriptor } from '../utils/browserPaths.js';
const accessAsync = util.promisify(fs.access.bind(fs));
const checkExecutable = (filePath: string) => accessAsync(filePath, fs.constants.X_OK).then(() => true).catch(e => false);

View File

@ -22,7 +22,7 @@ import { kBrowserCloseMessageId } from '../webkit/wkConnection';
import { BrowserTypeBase } from './browserType';
import { ConnectionTransport } from '../transport';
import { BrowserOptions } from '../browser';
import { BrowserDescriptor } from '../install/browserPaths';
import { BrowserDescriptor } from '../utils/browserPaths';
import * as types from '../types';
export class WebKit extends BrowserTypeBase {

View File

@ -18,8 +18,8 @@
import { execSync } from 'child_process';
import * as os from 'os';
import * as path from 'path';
import { getUbuntuVersionSync } from '../utils/ubuntuVersion';
import { getFromENV } from '../utils/utils';
import { getUbuntuVersionSync } from './ubuntuVersion';
import { getFromENV } from './utils';
export type BrowserName = 'chromium'|'webkit'|'firefox';
export type BrowserPlatform = 'win32'|'win64'|'mac10.13'|'mac10.14'|'mac10.15'|'ubuntu18.04'|'ubuntu20.04';

View File

@ -74,6 +74,7 @@ const DEPS = new Map([
['src/common/', ['src/common/']],
['src/protocol/', ['src/protocol/', 'src/utils/']],
['src/install/', ['src/install/', 'src/utils/']],
['src/server/chromium/', ['src/server/chromium/', 'src/utils/', 'src/', 'src/common/', 'src/server/']],
['src/client/', ['src/client/', 'src/utils/', 'src/protocol/', 'src/server/chromium/protocol.ts']],
]);

View File

@ -4,7 +4,7 @@ const fs = require('fs');
const util = require('util');
const path = require('path');
const {spawn} = require('child_process');
const browserPaths = require('playwright/lib/install/browserPaths.js');
const browserPaths = require('playwright/lib/utils/browserPaths.js');
const readdirAsync = util.promisify(fs.readdir.bind(fs));
const readFileAsync = util.promisify(fs.readFile.bind(fs));

View File

@ -74,7 +74,7 @@ Example:
// 4. Generate types.
console.log('\nGenerating protocol types...');
const browser = { name: browserName, revision };
const browserPaths = require('../lib/install/browserPaths');
const browserPaths = require('../lib/utils/browserPaths');
const browserDir = browserPaths.browserDirectory(browserPaths.browsersPath(ROOT_PATH), browser);
const executablePath = browserPaths.executablePath(browserDir, browser);
await protocolGenerator.generateProtocol(browserName, executablePath).catch(console.warn);