Skip to content

Commit

Permalink
chore: move browserPaths to utils, enforce more deps (#3584)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgozman authored Aug 23, 2020
1 parent 4025f9f commit 2e1493a
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/install/browserFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/install/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/server/browserType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/server/chromium/chromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/server/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/server/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/server/validateDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/server/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/install/browserPaths.ts → src/utils/browserPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions utils/check_deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']],
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion utils/roll_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2e1493a

Please sign in to comment.