chore: fix check-deps (#4801)
This commit is contained in:
Родитель
a7f4c69a60
Коммит
cc32217e84
|
@ -18,7 +18,6 @@ import { Dispatcher, DispatcherScope, existingDispatcher } from './dispatcher';
|
|||
import { Android, AndroidDevice, SocketBackend } from '../server/android/android';
|
||||
import * as channels from '../protocol/channels';
|
||||
import { BrowserContextDispatcher } from './browserContextDispatcher';
|
||||
import { Events } from '../client/events';
|
||||
|
||||
export class AndroidDispatcher extends Dispatcher<Android, channels.AndroidInitializer> implements channels.AndroidChannel {
|
||||
constructor(scope: DispatcherScope, android: Android) {
|
||||
|
@ -176,8 +175,8 @@ export class AndroidDeviceDispatcher extends Dispatcher<AndroidDevice, channels.
|
|||
export class AndroidSocketDispatcher extends Dispatcher<SocketBackend, channels.AndroidSocketInitializer> implements channels.AndroidSocketChannel {
|
||||
constructor(scope: DispatcherScope, socket: SocketBackend) {
|
||||
super(scope, socket, 'AndroidSocket', {}, true);
|
||||
socket.on(Events.AndroidSocket.Data, (data: Buffer) => this._dispatchEvent('data', { data: data.toString('base64') }));
|
||||
socket.on(Events.AndroidSocket.Close, () => {
|
||||
socket.on('data', (data: Buffer) => this._dispatchEvent('data', { data: data.toString('base64') }));
|
||||
socket.on('close', () => {
|
||||
this._dispatchEvent('close');
|
||||
this._dispose();
|
||||
});
|
||||
|
|
|
@ -34,7 +34,12 @@ async function checkDeps() {
|
|||
});
|
||||
const sourceFiles = program.getSourceFiles();
|
||||
const errors = [];
|
||||
const usedDeps = new Set();
|
||||
sourceFiles.filter(x => !x.fileName.includes('node_modules')).map(x => visit(x, x.fileName));
|
||||
for (const key of Object.keys(DEPS)) {
|
||||
if (!usedDeps.has(key) && DEPS[key].length)
|
||||
errors.push(`Stale DEPS entry "${key}"`);
|
||||
}
|
||||
for (const error of errors)
|
||||
console.log(error);
|
||||
if (errors.length) {
|
||||
|
@ -56,10 +61,10 @@ async function checkDeps() {
|
|||
}
|
||||
|
||||
function allowImport(from, to) {
|
||||
if (!to.startsWith('src' + path.sep))
|
||||
if (!to.startsWith(src + path.sep))
|
||||
return true;
|
||||
from = from.substring(from.indexOf('src' + path.sep)).replace(/\\/g, '/');
|
||||
to = to.substring(to.indexOf('src' + path.sep)).replace(/\\/g, '/');
|
||||
from = path.relative(root, from).replace(/\\/g, '/');
|
||||
to = path.relative(root, to).replace(/\\/g, '/');
|
||||
const fromDirectory = from.substring(0, from.lastIndexOf('/') + 1);
|
||||
const toDirectory = to.substring(0, to.lastIndexOf('/') + 1);
|
||||
if (fromDirectory === toDirectory)
|
||||
|
@ -73,6 +78,7 @@ async function checkDeps() {
|
|||
from = from.substring(0, from.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
usedDeps.add(from);
|
||||
for (const dep of DEPS[from]) {
|
||||
if (to === dep || toDirectory === dep)
|
||||
return true;
|
||||
|
@ -113,9 +119,8 @@ DEPS['src/server/common/'] = [];
|
|||
DEPS['src/server/injected/'] = ['src/server/common/'];
|
||||
|
||||
// Electron and Clank use chromium internally.
|
||||
DEPS['src/server/android/'] = [...DEPS['src/server/'], 'src/server/chromium/', 'src/protocol/transport.ts'];
|
||||
DEPS['src/server/android/'] = [...DEPS['src/server/'], 'src/server/chromium/', 'src/protocol/'];
|
||||
DEPS['src/server/electron/'] = [...DEPS['src/server/'], 'src/server/chromium/'];
|
||||
DEPS['src/server/clank/'] = [...DEPS['src/server/'], 'src/server/chromium/'];
|
||||
|
||||
DEPS['src/server/playwright.ts'] = [...DEPS['src/server/'], 'src/server/chromium/', 'src/server/webkit/', 'src/server/firefox/', 'src/server/android/', 'src/server/electron/'];
|
||||
DEPS['src/driver.ts'] = DEPS['src/inprocess.ts'] = DEPS['src/browserServerImpl.ts'] = ['src/**'];
|
||||
|
|
Загрузка…
Ссылка в новой задаче