Skip to content

Commit

Permalink
deps: upgrade+update
Browse files Browse the repository at this point in the history
`yarn audit` reports 16k issues with our packages. This commit brings it
down to zero. We should keep running `yarn upgrade` in the future, in
order to develop against the same dependencies as our clients.

Since `sinon` was bumped, some old behaviour seems to have changed.
Fixed the parts of the tests where the failures occured.

Signed-off-by: Paul Maréchal <[email protected]>
  • Loading branch information
paul-marechal committed Aug 15, 2019
1 parent 9105c43 commit d4d38b0
Show file tree
Hide file tree
Showing 31 changed files with 3,585 additions and 4,384 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cache:
# All directories need to be listed here, because Travis does not support globs.
# Auto generated by scripts/prepare-travis
# start_cache_directories
- /tmp/vscode-ripgrep-cache-1.2.4
- /tmp/vscode-ripgrep-cache-1.5.6
- dev-packages/application-manager/node_modules
- dev-packages/application-package/node_modules
- dev-packages/electron/node_modules
Expand Down
5 changes: 2 additions & 3 deletions dev-packages/application-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
"bunyan": "^1.8.10",
"circular-dependency-plugin": "^5.0.0",
"copy-webpack-plugin": "^4.5.0",
"css-loader": "^0.28.1",
"css-loader": "^3.2.0",
"electron-rebuild": "^1.5.11",
"file-loader": "^1.1.11",
"font-awesome-webpack": "0.0.5-beta.2",
"ignore-loader": "^0.1.2",
"less": "^3.0.3",
"source-map-loader": "^0.2.1",
Expand All @@ -44,7 +43,7 @@
"umd-compat-loader": "^2.1.1",
"url-loader": "^1.1.2",
"webpack": "^4.0.0",
"webpack-cli": "2.0.12",
"webpack-cli": "^3.3.6",
"worker-loader": "^1.1.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/application-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/request": "^2.0.3",
"@types/semver": "^5.4.0",
"@types/write-json-file": "^2.2.1",
"changes-stream": "^2.2.0",
"changes-stream": "jcrugzz/changes-stream#cbfd7d6",
"is-electron": "^2.1.0",
"request": "^2.82.0",
"semver": "^5.4.1",
Expand Down
2 changes: 1 addition & 1 deletion dev-packages/ext-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"ext:compile:clean": "rimraf lib",
"ext:lint": "tslint -c ../../configs/build.tslint.json --project compile.tsconfig.json",
"ext:watch": "tsc -w -p compile.tsconfig.json",
"ext:test": "nyc mocha --opts ../../configs/mocha.opts \"./lib/**/*.*spec.js\"",
"ext:test": "nyc mocha --exit --opts ../../configs/mocha.opts \"./lib/**/*.*spec.js\"",
"ext:test:watch": "mocha -w --opts ../../configs/mocha.opts \"./lib/**/*.*spec.js\"",
"ext:test:clean": "rimraf .nyc_output && rimraf coverage"
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
"@types/node": "~10.3.6",
"@types/sinon": "^2.3.5",
"@types/temp": "^0.8.29",
"@types/webdriverio": "^4.7.0",
"@types/uuid": "^3.4.3",
"@types/webdriverio": "^4.7.0",
"chai": "^4.1.0",
"chai-string": "^1.4.0",
"concurrently": "^3.5.0",
"electron-mocha": "~3.5.0",
"electron-mocha": "^8.1.1",
"ignore-styles": "^5.0.1",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"jsdom": "^11.5.1",
"lerna": "^2.2.0",
"mocha": "^3.4.2",
"nyc": "^11.0.3",
"remap-istanbul": "^0.9.5",
"mocha": "^6.2.0",
"nyc": "^14.1.1",
"remap-istanbul": "^0.13.0",
"rimraf": "^2.6.1",
"sinon": "^3.3.0",
"sinon": "^7.4.1",
"temp": "^0.8.3",
"tslint": "^5.12.0",
"tslint-language-service": "^0.9.9",
Expand Down
13 changes: 10 additions & 3 deletions packages/callhierarchy/src/browser/callhierarchy-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ILanguageClient } from '@theia/languages/lib/browser';
import {
ReferencesRequest, DocumentSymbolRequest, DefinitionRequest, TextDocumentPositionParams,
TextDocumentIdentifier, SymbolInformation, Location, Position, DocumentSymbol, ReferenceParams
TextDocumentIdentifier, SymbolInformation, Location, Position, DocumentSymbol, ReferenceParams, LocationLink
} from 'monaco-languageclient/lib/services';
import * as utils from './utils';
import { ILogger, Disposable } from '@theia/core';
Expand Down Expand Up @@ -59,7 +59,7 @@ export class CallHierarchyContext implements Disposable {

// Definition can be null
// tslint:disable-next-line:no-null-keyword
let locations: Location | Location[] | null = null;
let locations: Location | Location[] | LocationLink[] | null = null;
try {
locations = await this.languageClient.sendRequest(DefinitionRequest.type, <TextDocumentPositionParams>{
position: Position.create(line, character),
Expand All @@ -70,8 +70,15 @@ export class CallHierarchyContext implements Disposable {
}
if (!locations) {
return undefined;
} else if (Array.isArray(locations)) {
for (const loc of locations) {
if (Location.is(loc)) {
return loc;
}
}
} else {
return locations;
}
return Array.isArray(locations) ? locations[0] : locations;
}

async getCallerReferences(definition: Location): Promise<Location[]> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@ import { MessageService } from '../../common/message-service';
import { WindowService } from '../window/window-service';
import { BrowserKeyboardLayoutProvider } from './browser-keyboard-layout-provider';
import { Key } from './keys';
import { enableJSDOM } from '../test/jsdom';

describe('browser keyboard layout provider', function (): void {

let stubOSX: sinon.SinonStub;
let stubWindows: sinon.SinonStub;
let stubNavigator: sinon.SinonStub;

let disableJSDOM: () => void;

beforeEach(() => {
disableJSDOM = enableJSDOM();
});

const setup = (system: 'mac' | 'win' | 'linux') => {
switch (system) {
case 'mac':
Expand Down Expand Up @@ -59,6 +66,7 @@ describe('browser keyboard layout provider', function (): void {
};

afterEach(() => {
disableJSDOM();
stubOSX.restore();
stubWindows.restore();
stubNavigator.restore();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/logger-frontend-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const loggerFrontendModule = new ContainerModule(bind => {
const loggerWatcher = ctx.container.get(LoggerWatcher);
const connection = ctx.container.get(WebSocketConnectionProvider);
const target = connection.createProxy<ILoggerServer>(loggerPath, loggerWatcher.getLoggerClient());
function get<K extends keyof ILoggerServer>(_: ILoggerServer, property: K): ILoggerServer[K] {
function get<K extends keyof ILoggerServer>(_: ILoggerServer, property: K): ILoggerServer[K] | ILoggerServer['log'] {
if (property === 'log') {
return (name, logLevel, message, params) => {
ConsoleLogger.log(name, logLevel, message, params);
Expand Down
2 changes: 1 addition & 1 deletion packages/cpp/src/browser/cpp-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class CppCommandContribution implements CommandContribution {
}
const docIdentifier = TextDocumentIdentifier.create(uri.toString());
const languageClient = await this.clientContribution.languageClient;
const sourceUri: string | undefined = await languageClient.sendRequest(SwitchSourceHeaderRequest.type, docIdentifier);
const sourceUri: string | undefined = await languageClient.sendRequest(SwitchSourceHeaderRequest.type.method, docIdentifier);
if (sourceUri !== undefined) {
open(this.openerService, new URI(sourceUri.toString()));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/src/browser/debug-session-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export class DebugSessionConnection implements Disposable {
return emitter;
}
protected newEmitter(): Emitter<DebugProtocol.Event | DebugExitEvent> {
const emitter = new Emitter();
const emitter = new Emitter<DebugProtocol.Event | DebugExitEvent>();
this.checkDisposed();
this.toDispose.push(emitter);
return emitter;
Expand Down
22 changes: 11 additions & 11 deletions packages/editor-preview/src/browser/editor-preview-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// disable no-unused-expression for chai.
// tslint:disable:no-any no-unused-expression

import {enableJSDOM} from '@theia/core/lib/browser/test/jsdom';
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
const disableJsDom = enableJSDOM();

import URI from '@theia/core/lib/common/uri';
Expand All @@ -38,9 +38,9 @@ sinon.stub(mockEditorWidget, 'id').get(() => 'mockEditorWidget');

const mockPreviewWidget = sinon.createStubInstance(EditorPreviewWidget);
sinon.stub(mockPreviewWidget, 'id').get(() => 'mockPreviewWidget');
sinon.stub(mockPreviewWidget, 'disposed').get(() => ({connect: () => 1}));
sinon.stub(mockPreviewWidget, 'disposed').get(() => ({ connect: () => 1 }));
let onPinnedListeners: Function[] = [];
sinon.stub(mockPreviewWidget, 'onPinned').get(() => (fn: Function) => onPinnedListeners.push(fn));
mockPreviewWidget['onPinned'] = (fn: Function) => onPinnedListeners.push(fn);

const mockEditorManager = sinon.createStubInstance(EditorManager);
mockEditorManager.getOrCreateByUri = sinon.stub().returns(mockEditorWidget);
Expand All @@ -53,7 +53,7 @@ mockWidgetManager.onDidCreateWidget = sinon.stub().callsFake((fn: Function) => o
const mockShell = sinon.createStubInstance(ApplicationShell);

const mockPreference = sinon.createStubInstance(PreferenceServiceImpl);
mockPreference.onPreferenceChanged = sinon.stub().returns({dispose: () => {}});
mockPreference.onPreferenceChanged = sinon.stub().returns({ dispose: () => { } });

let testContainer: Container;

Expand Down Expand Up @@ -85,22 +85,22 @@ describe('editor-preview-manager', () => {

it('should handle preview requests if editor.enablePreview enabled', async () => {
(mockPreference.get as sinon.SinonStub).returns(true);
expect(await previewManager.canHandle(new URI(), {preview: true})).to.be.greaterThan(0);
expect(await previewManager.canHandle(new URI(), { preview: true })).to.be.greaterThan(0);
});
it('should not handle preview requests if editor.enablePreview disabled', async () => {
(mockPreference.get as sinon.SinonStub).returns(false);
expect(await previewManager.canHandle(new URI(), {preview: true})).to.equal(0);
expect(await previewManager.canHandle(new URI(), { preview: true })).to.equal(0);
});
it('should not handle requests that are not preview or currently being previewed', async () => {
expect(await previewManager.canHandle(new URI())).to.equal(0);
});
it('should create a preview editor and replace where required.', async () => {
const w = await previewManager.open(new URI(), {preview: true});
const w = await previewManager.open(new URI(), { preview: true });
expect(w instanceof EditorPreviewWidget).to.be.true;
expect((w as any).replaceEditorWidget.calledOnce).to.be.false;

// Replace the EditorWidget with another open call to an editor that doesn't exist.
const afterReplace = await previewManager.open(new URI(), {preview: true});
const afterReplace = await previewManager.open(new URI(), { preview: true });
expect((afterReplace as any).replaceEditorWidget.calledOnce).to.be.true;

// Ensure the same preview widget was re-used.
Expand All @@ -114,7 +114,7 @@ describe('editor-preview-manager', () => {

// Activate existing preview
mockEditorWidget.parent = mockPreviewWidget;
expect(await previewManager.open(new URI(), {preview: true})).to.equal(mockPreviewWidget);
expect(await previewManager.open(new URI(), { preview: true })).to.equal(mockPreviewWidget);
// Ensure it is not pinned.
expect((mockPreviewWidget.pinEditorWidget as sinon.SinonStub).calledOnce).to.be.false;

Expand All @@ -124,9 +124,9 @@ describe('editor-preview-manager', () => {
});
it('should should transition the editor to perminent on pin events.', async () => {
// Fake creation call.
await onCreateListners.pop()!({factoryId: EditorPreviewWidgetFactory.ID, widget: mockPreviewWidget});
await onCreateListners.pop()!({ factoryId: EditorPreviewWidgetFactory.ID, widget: mockPreviewWidget });
// Fake pinned call
onPinnedListeners.pop()!({preview: mockPreviewWidget, editorWidget: mockEditorWidget});
onPinnedListeners.pop()!({ preview: mockPreviewWidget, editorWidget: mockEditorWidget });

expect(mockPreviewWidget.dispose.calledOnce).to.be.true;
expect(mockEditorWidget.close.calledOnce).to.be.false;
Expand Down
2 changes: 1 addition & 1 deletion packages/git/src/browser/git-repository-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('GitRepositoryProvider', () => {
testContainer.bind(LabelProvider).toConstantValue(<LabelProvider>{});

sinon.stub(mockWorkspaceService, 'onWorkspaceChanged').value(mockRootChangeEmitter.event);
sinon.stub(mockFileSystemWatcher, 'onFilesChanged').value(mockFileChangeEmitter.event);
(mockFileSystemWatcher['onFilesChanged'] as any) = mockFileChangeEmitter.event;
});

it('should adds all existing git repo(s) on theia loads', async () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/java/src/browser/java-client-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ export class JavaClientContribution extends BaseLanguageClientContribution {
}

protected onReady(languageClient: ILanguageClient): void {
languageClient.onNotification(ActionableNotification.type, this.showActionableMessage.bind(this));
languageClient.onNotification(StatusNotification.type, this.showStatusMessage.bind(this));
languageClient.onRequest(ExecuteClientCommand.type, params => this.commandService.executeCommand(params.command, ...params.arguments));
languageClient.onNotification(ActionableNotification.type.method, this.showActionableMessage.bind(this));
languageClient.onNotification(StatusNotification.type.method, this.showStatusMessage.bind(this));
languageClient.onRequest(ExecuteClientCommand.type.method, params => this.commandService.executeCommand(params.command, ...params.arguments));
super.onReady(languageClient);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/java/src/browser/java-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class JavaCommandContribution implements CommandContribution, MenuContrib
commands.registerCommand(JAVA_COMPILE_WORKSPACE, {
execute: async (fullCompile: boolean) => {
const languageClient = await this.javaClientContribution.languageClient;
const result = await languageClient.sendRequest(CompileWorkspaceRequest.type, fullCompile);
const result = await languageClient.sendRequest(CompileWorkspaceRequest.type.method, fullCompile);
if (result === CompileWorkspaceStatus.SUCCEED) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/java/src/browser/java-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class JavaResource implements Resource {
readContents(options: { encoding?: string }): Promise<string> {
const uri = this.uri.toString();
return this.clientContribution.languageClient.then(languageClient =>
languageClient.sendRequest(ClassFileContentsRequest.type, { uri }).then(content =>
languageClient.sendRequest(ClassFileContentsRequest.type.method, { uri }).then((content: string) =>
content || ''
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class SemanticHighlightFeature extends TextDocumentFeature<TextDocumentRe
}

protected registerLanguageProvider(): Disposable {
this._client.onNotification(SemanticHighlight.type, this.consumeSemanticHighlighting.bind(this));
this._client.onNotification(SemanticHighlight.type.method, this.consumeSemanticHighlighting.bind(this));
return Disposable.create(() => this.toDispose.dispose());
}

Expand Down
4 changes: 2 additions & 2 deletions packages/navigator/src/browser/navigator-model.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ describe('FileNavigatorModel', () => {

sinon.stub(mockWorkspaceService, 'onWorkspaceChanged').value(mockWorkspaceServiceEmitter.event);
sinon.stub(mockWorkspaceService, 'onWorkspaceLocationChanged').value(mockWorkspaceOnLocationChangeEmitter.event);
sinon.stub(mockFileSystemWatcher, 'onFilesChanged').value(mockFileChangeEmitter.event);
sinon.stub(mockFileSystemWatcher, 'onDidMove').value(mockFileMoveEmitter.event);
(mockFileSystemWatcher['onFilesChanged'] as any) = mockFileChangeEmitter.event;
(mockFileSystemWatcher['onDidMove'] as any) = mockFileMoveEmitter.event;
sinon.stub(mockFileNavigatorTree, 'onChanged').value(mockTreeChangeEmitter.event);
sinon.stub(mockTreeExpansionService, 'onExpansionChanged').value(mockExpansionChangeEmitter.event);

Expand Down
14 changes: 7 additions & 7 deletions packages/plugin-ext/src/common/rpc-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ export interface RPCProtocol {
/**
* Returns a proxy to an object addressable/named in the plugin process or in the main process.
*/
getProxy<T>(proxyId: ProxyIdentifier<T>): T;
getProxy<T extends object>(proxyId: ProxyIdentifier<T>): T;

/**
* Register manually created instance.
*/
set<T, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R;
set<T extends object, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R;

}

export class ProxyIdentifier<T> {
export class ProxyIdentifier<T extends object> {
public readonly id: string;
constructor(public readonly isMain: boolean, id: string | T) {
// TODO this is nasty, rewrite this
this.id = id.toString();
this.id = typeof id === 'object' ? id.toString() : id;
}
}

export function createProxyIdentifier<T>(identifier: string): ProxyIdentifier<T> {
export function createProxyIdentifier<T extends object>(identifier: string): ProxyIdentifier<T> {
return new ProxyIdentifier(false, identifier);
}

Expand Down Expand Up @@ -82,14 +82,14 @@ export class RPCProtocolImpl implements RPCProtocol {
this.pendingRPCReplies = {};
this.multiplexor = new RPCMultiplexer(connection, msg => this.receiveOneMessage(msg), remoteHostID);
}
getProxy<T>(proxyId: ProxyIdentifier<T>): T {
getProxy<T extends object>(proxyId: ProxyIdentifier<T>): T {
if (!this.proxies[proxyId.id]) {
this.proxies[proxyId.id] = this.createProxy(proxyId.id);
}
return this.proxies[proxyId.id];
}

set<T, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R {
set<T extends object, R extends T>(identifier: ProxyIdentifier<T>, instance: R): R {
this.locals[identifier.id] = instance;
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ctx = self as any;
const pluginsApiImpl = new Map<string, typeof theia>();
const pluginsModulesNames = new Map<string, Plugin>();

const emitter = new Emitter();
const emitter = new Emitter<{}>();
const rpc = new RPCProtocolImpl({
onMessage: emitter.event,
send: (m: {}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class HostedPluginProcess implements ServerPluginRunner {
const cp = this.childProcess;
this.childProcess = undefined;

const emitter = new Emitter();
const emitter = new Emitter<{}>();
cp.on('message', message => {
emitter.fire(JSON.parse(message));
});
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/hosted/node/plugin-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ process.on('rejectionHandled', (promise: Promise<any>) => {
}
});

const emitter = new Emitter();
const emitter = new Emitter<{}>();
const rpc = new RPCProtocolImpl({
onMessage: emitter.event,
send: (m: {}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/main/browser/plugin-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class PluginWorker {
private worker: Worker;
public readonly rpc: RPCProtocol;
constructor() {
const emitter = new Emitter();
const emitter = new Emitter<{}>();
this.worker = new (require('../../hosted/browser/worker/worker-main'));
this.worker.onmessage = message => {
emitter.fire(message.data);
Expand Down
Loading

0 comments on commit d4d38b0

Please sign in to comment.