Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: move last rpc files to their place (#3604)

Dmitry Gozmana099e941d689
diff --git a/index.js b/index.js
index 8785e3336c..538dac6584 100644
--- a/index.js
+++ b/index.js
@@ -16,7 +16,7 @@
const { Playwright } = require('./lib/server/playwright');
const { Electron } = require('./lib/server/electron/electron');
-const { setupInProcess } = require('./lib/rpc/inprocess');
+const { setupInProcess } = require('./lib/inprocess');
const path = require('path');
const playwright = new Playwright(__dirname, require(path.join(__dirname, 'browsers.json'))['browsers']);
diff --git a/packages/common/index.js b/packages/common/index.js
index 5509391c8f..8c14f60ade 100644
--- a/packages/common/index.js
+++ b/packages/common/index.js
@@ -15,6 +15,6 @@
*/
const { Playwright } = require('./lib/server/playwright');
-const { setupInProcess } = require('./lib/rpc/inprocess');
+const { setupInProcess } = require('./lib/inprocess');
module.exports = setupInProcess(new Playwright(__dirname, require('./browsers.json')['browsers']));
diff --git a/packages/playwright-driver/main.js b/packages/playwright-driver/main.js
index 7f6f890726..66eecd5599 100644
--- a/packages/playwright-driver/main.js
+++ b/packages/playwright-driver/main.js
@@ -35,5 +35,5 @@ const util = require('util');
return;
}
- require('../../lib/rpc/server');
+ require('../../lib/server');
})();
diff --git a/packages/playwright-electron/index.js b/packages/playwright-electron/index.js
index 8d3ff68d5a..92c8d8fb98 100644
--- a/packages/playwright-electron/index.js
+++ b/packages/playwright-electron/index.js
@@ -16,7 +16,7 @@
const { Playwright } = require('./lib/server/playwright');
const { Electron } = require('./lib/server/electron/electron');
-const { setupInProcess } = require('./lib/rpc/inprocess');
+const { setupInProcess } = require('./lib/inprocess');
const playwright = new Playwright(__dirname, require('./browsers.json')['browsers']);
playwright.electron = new Electron();
diff --git a/src/rpc/browserServerImpl.ts b/src/browserServerImpl.ts
similarity index 87%
rename from src/rpc/browserServerImpl.ts
rename to src/browserServerImpl.ts
index e89dcf3c81..9ef52b5535 100644
--- a/src/rpc/browserServerImpl.ts
+++ b/src/browserServerImpl.ts
@@ -14,20 +14,20 @@
* limitations under the License.
*/
-import { LaunchServerOptions } from '../client/types';
-import { BrowserTypeBase } from '../server/browserType';
+import { LaunchServerOptions } from './client/types';
+import { BrowserTypeBase } from './server/browserType';
import * as ws from 'ws';
-import { helper } from '../server/helper';
-import { Browser } from '../server/browser';
+import { helper } from './server/helper';
+import { Browser } from './server/browser';
import { ChildProcess } from 'child_process';
import { EventEmitter } from 'ws';
-import { DispatcherScope, DispatcherConnection } from './server/dispatcher';
-import { BrowserTypeDispatcher } from './server/browserTypeDispatcher';
-import { BrowserDispatcher } from './server/browserDispatcher';
-import { BrowserContextDispatcher } from './server/browserContextDispatcher';
-import { BrowserNewContextParams, BrowserContextChannel } from '../protocol/channels';
-import { BrowserServerLauncher, BrowserServer } from '../client/browserType';
-import { envObjectToArray } from '../client/clientHelper';
+import { DispatcherScope, DispatcherConnection } from './dispatchers/dispatcher';
+import { BrowserTypeDispatcher } from './dispatchers/browserTypeDispatcher';
+import { BrowserDispatcher } from './dispatchers/browserDispatcher';
+import { BrowserContextDispatcher } from './dispatchers/browserContextDispatcher';
+import { BrowserNewContextParams, BrowserContextChannel } from './protocol/channels';
+import { BrowserServerLauncher, BrowserServer } from './client/browserType';
+import { envObjectToArray } from './client/clientHelper';
export class BrowserServerLauncherImpl implements BrowserServerLauncher {
private _browserType: BrowserTypeBase;
diff --git a/src/rpc/server/browserContextDispatcher.ts b/src/dispatchers/browserContextDispatcher.ts
similarity index 96%
rename from src/rpc/server/browserContextDispatcher.ts
rename to src/dispatchers/browserContextDispatcher.ts
index d483560fde..8e458b9dd3 100644
--- a/src/rpc/server/browserContextDispatcher.ts
+++ b/src/dispatchers/browserContextDispatcher.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { BrowserContext } from '../../server/browserContext';
+import { BrowserContext } from '../server/browserContext';
import { Dispatcher, DispatcherScope, lookupDispatcher } from './dispatcher';
import { PageDispatcher, BindingCallDispatcher, WorkerDispatcher } from './pageDispatcher';
-import * as channels from '../../protocol/channels';
+import * as channels from '../protocol/channels';
import { RouteDispatcher, RequestDispatcher } from './networkDispatchers';
-import { CRBrowserContext } from '../../server/chromium/crBrowser';
+import { CRBrowserContext } from '../server/chromium/crBrowser';
import { CDPSessionDispatcher } from './cdpSessionDispatcher';
export class BrowserContextDispatcher extends Dispatcher<BrowserContext, channels.BrowserContextInitializer> implements channels.BrowserContextChannel {
diff --git a/src/rpc/server/browserDispatcher.ts b/src/dispatchers/browserDispatcher.ts
similarity index 93%
rename from src/rpc/server/browserDispatcher.ts
rename to src/dispatchers/browserDispatcher.ts
index 6a927f8467..4d0f3b0ac2 100644
--- a/src/rpc/server/browserDispatcher.ts
+++ b/src/dispatchers/browserDispatcher.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { Browser } from '../../server/browser';
-import * as channels from '../../protocol/channels';
+import { Browser } from '../server/browser';
+import * as channels from '../protocol/channels';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import { CDPSessionDispatcher } from './cdpSessionDispatcher';
import { Dispatcher, DispatcherScope } from './dispatcher';
-import { CRBrowser } from '../../server/chromium/crBrowser';
+import { CRBrowser } from '../server/chromium/crBrowser';
import { PageDispatcher } from './pageDispatcher';
export class BrowserDispatcher extends Dispatcher<Browser, channels.BrowserInitializer> implements channels.BrowserChannel {
diff --git a/src/rpc/server/browserTypeDispatcher.ts b/src/dispatchers/browserTypeDispatcher.ts
similarity index 93%
rename from src/rpc/server/browserTypeDispatcher.ts
rename to src/dispatchers/browserTypeDispatcher.ts
index 48d68ca3eb..c4728167c0 100644
--- a/src/rpc/server/browserTypeDispatcher.ts
+++ b/src/dispatchers/browserTypeDispatcher.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import { BrowserTypeBase, BrowserType } from '../../server/browserType';
+import { BrowserTypeBase, BrowserType } from '../server/browserType';
import { BrowserDispatcher } from './browserDispatcher';
-import * as channels from '../../protocol/channels';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
import { BrowserContextDispatcher } from './browserContextDispatcher';
diff --git a/src/rpc/server/cdpSessionDispatcher.ts b/src/dispatchers/cdpSessionDispatcher.ts
similarity index 91%
rename from src/rpc/server/cdpSessionDispatcher.ts
rename to src/dispatchers/cdpSessionDispatcher.ts
index b748b27f1a..59d3ee1782 100644
--- a/src/rpc/server/cdpSessionDispatcher.ts
+++ b/src/dispatchers/cdpSessionDispatcher.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { CRSession, CRSessionEvents } from '../../server/chromium/crConnection';
-import * as channels from '../../protocol/channels';
+import { CRSession, CRSessionEvents } from '../server/chromium/crConnection';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
export class CDPSessionDispatcher extends Dispatcher<CRSession, channels.CDPSessionInitializer> implements channels.CDPSessionChannel {
diff --git a/src/rpc/server/consoleMessageDispatcher.ts b/src/dispatchers/consoleMessageDispatcher.ts
similarity index 91%
rename from src/rpc/server/consoleMessageDispatcher.ts
rename to src/dispatchers/consoleMessageDispatcher.ts
index 572be021fc..3960d84af4 100644
--- a/src/rpc/server/consoleMessageDispatcher.ts
+++ b/src/dispatchers/consoleMessageDispatcher.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { ConsoleMessage } from '../../server/console';
-import * as channels from '../../protocol/channels';
+import { ConsoleMessage } from '../server/console';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
import { createHandle } from './elementHandlerDispatcher';
diff --git a/src/rpc/server/dialogDispatcher.ts b/src/dispatchers/dialogDispatcher.ts
similarity index 92%
rename from src/rpc/server/dialogDispatcher.ts
rename to src/dispatchers/dialogDispatcher.ts
index 78d61c3d15..1e6e4006c4 100644
--- a/src/rpc/server/dialogDispatcher.ts
+++ b/src/dispatchers/dialogDispatcher.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { Dialog } from '../../server/dialog';
-import * as channels from '../../protocol/channels';
+import { Dialog } from '../server/dialog';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
export class DialogDispatcher extends Dispatcher<Dialog, channels.DialogInitializer> implements channels.DialogChannel {
diff --git a/src/rpc/server/dispatcher.ts b/src/dispatchers/dispatcher.ts
similarity index 95%
rename from src/rpc/server/dispatcher.ts
rename to src/dispatchers/dispatcher.ts
index e1392b1d53..4a4d07b802 100644
--- a/src/rpc/server/dispatcher.ts
+++ b/src/dispatchers/dispatcher.ts
@@ -15,11 +15,11 @@
*/
import { EventEmitter } from 'events';
-import { helper } from '../../server/helper';
-import * as channels from '../../protocol/channels';
-import { serializeError } from '../../protocol/serializers';
-import { createScheme, Validator, ValidationError } from '../../protocol/validator';
-import { assert, debugAssert } from '../../utils/utils';
+import { helper } from '../server/helper';
+import * as channels from '../protocol/channels';
+import { serializeError } from '../protocol/serializers';
+import { createScheme, Validator, ValidationError } from '../protocol/validator';
+import { assert, debugAssert } from '../utils/utils';
export const dispatcherSymbol = Symbol('dispatcher');
diff --git a/src/rpc/server/downloadDispatcher.ts b/src/dispatchers/downloadDispatcher.ts
similarity index 94%
rename from src/rpc/server/downloadDispatcher.ts
rename to src/dispatchers/downloadDispatcher.ts
index 0487b18869..d53e766161 100644
--- a/src/rpc/server/downloadDispatcher.ts
+++ b/src/dispatchers/downloadDispatcher.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { Download } from '../../server/download';
-import * as channels from '../../protocol/channels';
+import { Download } from '../server/download';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
import { StreamDispatcher } from './streamDispatcher';
diff --git a/src/rpc/server/electronDispatcher.ts b/src/dispatchers/electronDispatcher.ts
similarity index 97%
rename from src/rpc/server/electronDispatcher.ts
rename to src/dispatchers/electronDispatcher.ts
index 27d30496c3..e3d7703a09 100644
--- a/src/rpc/server/electronDispatcher.ts
+++ b/src/dispatchers/electronDispatcher.ts
@@ -15,8 +15,8 @@
*/
import { Dispatcher, DispatcherScope, lookupDispatcher } from './dispatcher';
-import { Electron, ElectronApplication, ElectronPage } from '../../server/electron/electron';
-import * as channels from '../../protocol/channels';
+import { Electron, ElectronApplication, ElectronPage } from '../server/electron/electron';
+import * as channels from '../protocol/channels';
import { BrowserContextDispatcher } from './browserContextDispatcher';
import { PageDispatcher } from './pageDispatcher';
import { parseArgument, serializeResult } from './jsHandleDispatcher';
diff --git a/src/rpc/server/elementHandlerDispatcher.ts b/src/dispatchers/elementHandlerDispatcher.ts
similarity index 97%
rename from src/rpc/server/elementHandlerDispatcher.ts
rename to src/dispatchers/elementHandlerDispatcher.ts
index 434d8638c9..74f7a008c3 100644
--- a/src/rpc/server/elementHandlerDispatcher.ts
+++ b/src/dispatchers/elementHandlerDispatcher.ts
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-import { ElementHandle } from '../../server/dom';
-import * as js from '../../server/javascript';
-import * as channels from '../../protocol/channels';
+import { ElementHandle } from '../server/dom';
+import * as js from '../server/javascript';
+import * as channels from '../protocol/channels';
import { DispatcherScope, lookupNullableDispatcher } from './dispatcher';
import { JSHandleDispatcher, serializeResult, parseArgument } from './jsHandleDispatcher';
import { FrameDispatcher } from './frameDispatcher';
diff --git a/src/rpc/server/frameDispatcher.ts b/src/dispatchers/frameDispatcher.ts
similarity index 98%
rename from src/rpc/server/frameDispatcher.ts
rename to src/dispatchers/frameDispatcher.ts
index f12302718f..52426c1161 100644
--- a/src/rpc/server/frameDispatcher.ts
+++ b/src/dispatchers/frameDispatcher.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { Frame, NavigationEvent } from '../../server/frames';
-import * as channels from '../../protocol/channels';
+import { Frame, NavigationEvent } from '../server/frames';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope, lookupNullableDispatcher, existingDispatcher } from './dispatcher';
import { ElementHandleDispatcher, createHandle } from './elementHandlerDispatcher';
import { parseArgument, serializeResult } from './jsHandleDispatcher';
diff --git a/src/rpc/server/jsHandleDispatcher.ts b/src/dispatchers/jsHandleDispatcher.ts
similarity index 94%
rename from src/rpc/server/jsHandleDispatcher.ts
rename to src/dispatchers/jsHandleDispatcher.ts
index 69668f9a98..225181f45b 100644
--- a/src/rpc/server/jsHandleDispatcher.ts
+++ b/src/dispatchers/jsHandleDispatcher.ts
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-import * as js from '../../server/javascript';
-import * as channels from '../../protocol/channels';
+import * as js from '../server/javascript';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
import { createHandle } from './elementHandlerDispatcher';
-import { parseSerializedValue, serializeValue } from '../../protocol/serializers';
+import { parseSerializedValue, serializeValue } from '../protocol/serializers';
export class JSHandleDispatcher extends Dispatcher<js.JSHandle, channels.JSHandleInitializer> implements channels.JSHandleChannel {
diff --git a/src/rpc/server/networkDispatchers.ts b/src/dispatchers/networkDispatchers.ts
similarity index 96%
rename from src/rpc/server/networkDispatchers.ts
rename to src/dispatchers/networkDispatchers.ts
index af55900f94..e37040439f 100644
--- a/src/rpc/server/networkDispatchers.ts
+++ b/src/dispatchers/networkDispatchers.ts
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-import { Request, Response, Route } from '../../server/network';
-import * as channels from '../../protocol/channels';
+import { Request, Response, Route } from '../server/network';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope, lookupNullableDispatcher, existingDispatcher } from './dispatcher';
import { FrameDispatcher } from './frameDispatcher';
diff --git a/src/rpc/server/pageDispatcher.ts b/src/dispatchers/pageDispatcher.ts
similarity index 96%
rename from src/rpc/server/pageDispatcher.ts
rename to src/dispatchers/pageDispatcher.ts
index 57dd91221b..e2782094ba 100644
--- a/src/rpc/server/pageDispatcher.ts
+++ b/src/dispatchers/pageDispatcher.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import { BrowserContext } from '../../server/browserContext';
-import { Frame } from '../../server/frames';
-import { Request } from '../../server/network';
-import { Page, Worker } from '../../server/page';
-import * as channels from '../../protocol/channels';
+import { BrowserContext } from '../server/browserContext';
+import { Frame } from '../server/frames';
+import { Request } from '../server/network';
+import { Page, Worker } from '../server/page';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope, lookupDispatcher, lookupNullableDispatcher } from './dispatcher';
-import { parseError, serializeError } from '../../protocol/serializers';
+import { parseError, serializeError } from '../protocol/serializers';
import { ConsoleMessageDispatcher } from './consoleMessageDispatcher';
import { DialogDispatcher } from './dialogDispatcher';
import { DownloadDispatcher } from './downloadDispatcher';
@@ -28,8 +28,8 @@ import { FrameDispatcher } from './frameDispatcher';
import { RequestDispatcher, ResponseDispatcher, RouteDispatcher } from './networkDispatchers';
import { serializeResult, parseArgument } from './jsHandleDispatcher';
import { ElementHandleDispatcher, createHandle } from './elementHandlerDispatcher';
-import { FileChooser } from '../../server/fileChooser';
-import { CRCoverage } from '../../server/chromium/crCoverage';
+import { FileChooser } from '../server/fileChooser';
+import { CRCoverage } from '../server/chromium/crCoverage';
export class PageDispatcher extends Dispatcher<Page, channels.PageInitializer> implements channels.PageChannel {
private _page: Page;
diff --git a/src/rpc/server/playwrightDispatcher.ts b/src/dispatchers/playwrightDispatcher.ts
similarity index 88%
rename from src/rpc/server/playwrightDispatcher.ts
rename to src/dispatchers/playwrightDispatcher.ts
index 41e533a538..f4b0a56aba 100644
--- a/src/rpc/server/playwrightDispatcher.ts
+++ b/src/dispatchers/playwrightDispatcher.ts
@@ -14,14 +14,14 @@
* limitations under the License.
*/
-import { Playwright } from '../../server/playwright';
-import * as channels from '../../protocol/channels';
+import { Playwright } from '../server/playwright';
+import * as channels from '../protocol/channels';
import { BrowserTypeDispatcher } from './browserTypeDispatcher';
import { Dispatcher, DispatcherScope } from './dispatcher';
import { SelectorsDispatcher } from './selectorsDispatcher';
-import { Electron } from '../../server/electron/electron';
+import { Electron } from '../server/electron/electron';
import { ElectronDispatcher } from './electronDispatcher';
-import { DeviceDescriptors } from '../../server/deviceDescriptors';
+import { DeviceDescriptors } from '../server/deviceDescriptors';
export class PlaywrightDispatcher extends Dispatcher<Playwright, channels.PlaywrightInitializer> implements channels.PlaywrightChannel {
constructor(scope: DispatcherScope, playwright: Playwright) {
diff --git a/src/rpc/server/selectorsDispatcher.ts b/src/dispatchers/selectorsDispatcher.ts
similarity index 90%
rename from src/rpc/server/selectorsDispatcher.ts
rename to src/dispatchers/selectorsDispatcher.ts
index 308bb754f8..53e2ad6a44 100644
--- a/src/rpc/server/selectorsDispatcher.ts
+++ b/src/dispatchers/selectorsDispatcher.ts
@@ -15,10 +15,10 @@
*/
import { Dispatcher, DispatcherScope } from './dispatcher';
-import * as channels from '../../protocol/channels';
-import { Selectors } from '../../server/selectors';
+import * as channels from '../protocol/channels';
+import { Selectors } from '../server/selectors';
import { ElementHandleDispatcher } from './elementHandlerDispatcher';
-import * as dom from '../../server/dom';
+import * as dom from '../server/dom';
export class SelectorsDispatcher extends Dispatcher<Selectors, channels.SelectorsInitializer> implements channels.SelectorsChannel {
constructor(scope: DispatcherScope, selectors: Selectors) {
diff --git a/src/rpc/server/streamDispatcher.ts b/src/dispatchers/streamDispatcher.ts
similarity index 95%
rename from src/rpc/server/streamDispatcher.ts
rename to src/dispatchers/streamDispatcher.ts
index 997270465f..2649ccd675 100644
--- a/src/rpc/server/streamDispatcher.ts
+++ b/src/dispatchers/streamDispatcher.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import * as channels from '../../protocol/channels';
+import * as channels from '../protocol/channels';
import { Dispatcher, DispatcherScope } from './dispatcher';
import * as stream from 'stream';
diff --git a/src/rpc/inprocess.ts b/src/inprocess.ts
similarity index 84%
rename from src/rpc/inprocess.ts
rename to src/inprocess.ts
index 7a54b1f426..5e45091fd9 100644
--- a/src/rpc/inprocess.ts
+++ b/src/inprocess.ts
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-import { DispatcherConnection } from './server/dispatcher';
-import type { Playwright as PlaywrightImpl } from '../server/playwright';
-import type { Playwright as PlaywrightAPI } from '../client/playwright';
-import { PlaywrightDispatcher } from './server/playwrightDispatcher';
-import { Connection } from '../client/connection';
+import { DispatcherConnection } from './dispatchers/dispatcher';
+import type { Playwright as PlaywrightImpl } from './server/playwright';
+import type { Playwright as PlaywrightAPI } from './client/playwright';
+import { PlaywrightDispatcher } from './dispatchers/playwrightDispatcher';
+import { Connection } from './client/connection';
import { BrowserServerLauncherImpl } from './browserServerImpl';
-import { isUnderTest } from '../utils/utils';
+import { isUnderTest } from './utils/utils';
export function setupInProcess(playwright: PlaywrightImpl): PlaywrightAPI {
const clientConnection = new Connection();
diff --git a/src/rpc/server.ts b/src/server.ts
similarity index 78%
rename from src/rpc/server.ts
rename to src/server.ts
index 05949e08f6..0055cee82a 100644
--- a/src/rpc/server.ts
+++ b/src/server.ts
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-import { Transport } from '../protocol/transport';
-import { DispatcherConnection } from './server/dispatcher';
-import { Playwright } from '../server/playwright';
-import { PlaywrightDispatcher } from './server/playwrightDispatcher';
-import { Electron } from '../server/electron/electron';
-import { gracefullyCloseAll } from '../server/processLauncher';
+import { Transport } from './protocol/transport';
+import { DispatcherConnection } from './dispatchers/dispatcher';
+import { Playwright } from './server/playwright';
+import { PlaywrightDispatcher } from './dispatchers/playwrightDispatcher';
+import { Electron } from './server/electron/electron';
+import { gracefullyCloseAll } from './server/processLauncher';
const dispatcherConnection = new DispatcherConnection();
const transport = new Transport(process.stdout, process.stdin);
diff --git a/test/playwright.fixtures.ts b/test/playwright.fixtures.ts
index 2b5dbb72b6..29de3c4d38 100644
--- a/test/playwright.fixtures.ts
+++ b/test/playwright.fixtures.ts
@@ -117,7 +117,7 @@ registerWorkerFixture('playwright', async({browserName}, test) => {
const {coverage, uninstall} = installCoverageHooks(browserName);
if (options.WIRE) {
const connection = new Connection();
- const spawnedProcess = childProcess.fork(path.join(__dirname, '..', 'lib', 'rpc', 'server'), [], {
+ const spawnedProcess = childProcess.fork(path.join(__dirname, '..', 'lib', 'server'), [], {
stdio: 'pipe',
detached: true,
});
diff --git a/utils/check_deps.js b/utils/check_deps.js
index abd943d8f2..b36b4be2db 100644
--- a/utils/check_deps.js
+++ b/utils/check_deps.js
@@ -37,6 +37,12 @@ async function checkDeps() {
sourceFiles.filter(x => !x.fileName.includes('node_modules')).map(x => visit(x, x.fileName));
for (const error of errors)
console.log(error);
+ if (errors.length) {
+ console.log(`--------------------------------------------------------`);
+ console.log(`Changing the project structure or adding new components?`);
+ console.log(`Update DEPS in //${path.relative(root, __filename)}.`);
+ console.log(`--------------------------------------------------------`);
+ }
process.exit(errors.length ? 1 : 0);
function visit(node, fileName) {
@@ -57,19 +63,15 @@ async function checkDeps() {
if (fromDirectory === toDirectory)
return true;
- if (['src/rpc/server/', 'src/rpc/'].includes(fromDirectory))
- return true; // Temporary.
-
while (!DEPS[from]) {
if (from.endsWith('/'))
from = from.substring(0, from.length - 1);
if (from.lastIndexOf('/') === -1)
- break;
+ throw new Error(`Cannot find DEPS for ${fromDirectory}`);
from = from.substring(0, from.lastIndexOf('/') + 1);
}
- const deps = DEPS[from] || [`+${fromDirectory}`];
- for (const dep of deps) {
+ for (const dep of DEPS[from]) {
if (to === dep || toDirectory === dep)
return true;
if (dep.endsWith('**')) {
@@ -84,34 +86,36 @@ async function checkDeps() {
const DEPS = {};
-// No deps for code shared between node and page.
-DEPS['src/server/common/'] = [];
-
DEPS['src/protocol/'] = ['src/utils/'];
DEPS['src/install/'] = ['src/utils/'];
// Client depends on chromium protocol for types.
DEPS['src/client/'] = ['src/utils/', 'src/protocol/', 'src/server/chromium/protocol.ts'];
+DEPS['src/dispatchers/'] = ['src/utils/', 'src/protocol/', 'src/server/**'];
+
+// Generic dependencies for server-side code.
DEPS['src/server/'] = [
'src/utils/',
- 'src/server/common/',
- 'src/server/injected/',
'src/generated/',
- // TODO: remove the server->debug dependency.
+ // Can depend on files directly in the server directory.
+ 'src/server/',
+ // Can depend on any files in these subdirectories.
+ 'src/server/common/**',
+ 'src/server/injected/**',
'src/server/debug/**',
];
-// Strict deps for injected code.
+// No dependencies for code shared between node and page.
+DEPS['src/server/common/'] = [];
+
+// Strict dependencies for injected code.
// TODO: remove the injected->types dependency.
DEPS['src/server/injected/'] = ['src/server/common/', 'src/server/types.ts'];
-DEPS['src/server/debug/'] = [...DEPS['src/server/'], 'src/server/', 'src/server/debug/**'];
+DEPS['src/server/electron/'] = [...DEPS['src/server/'], 'src/server/chromium/'];
-DEPS['src/server/chromium/'] = [...DEPS['src/server/'], 'src/server/'];
-DEPS['src/server/electron/'] = [...DEPS['src/server/'], 'src/server/', 'src/server/chromium/'];
-DEPS['src/server/firefox/'] = [...DEPS['src/server/'], 'src/server/'];
-DEPS['src/server/webkit/'] = [...DEPS['src/server/'], 'src/server/'];
DEPS['src/server/playwright.ts'] = [...DEPS['src/server/'], 'src/server/chromium/', 'src/server/webkit/', 'src/server/firefox/'];
+DEPS['src/server.ts'] = DEPS['src/inprocess.ts'] = DEPS['src/browserServerImpl.ts'] = ['src/**'];
checkDeps();