From 18938398a129767508ffa586db95549258a12685 Mon Sep 17 00:00:00 2001 From: vince-fugnitto Date: Wed, 27 Nov 2019 11:20:48 -0500 Subject: [PATCH] Remove '@theia/bunyan' extension Fixes #6637 Motivation: - the extension is not used by any other extension present in the main repo. - the extension is not part of the `example-browser` or `example-electron` application, therefore it cannot be tested properly. - since it is not part of any other extension, or tested, it is likely to be un-maintained. Signed-off-by: vince-fugnitto --- .travis.yml | 1 - CHANGELOG.md | 3 +- packages/bunyan/README.md | 9 - packages/bunyan/compile.tsconfig.json | 11 - packages/bunyan/package.json | 47 ---- .../bunyan/src/node/bunyan-backend-module.ts | 23 -- .../bunyan/src/node/bunyan-logger-server.ts | 221 ------------------ packages/bunyan/src/package.spec.ts | 21 -- tsconfig.json | 3 - 9 files changed, 2 insertions(+), 337 deletions(-) delete mode 100644 packages/bunyan/README.md delete mode 100644 packages/bunyan/compile.tsconfig.json delete mode 100644 packages/bunyan/package.json delete mode 100644 packages/bunyan/src/node/bunyan-backend-module.ts delete mode 100644 packages/bunyan/src/node/bunyan-logger-server.ts delete mode 100644 packages/bunyan/src/package.spec.ts diff --git a/.travis.yml b/.travis.yml index 3883b53806037..f5f6552332632 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ cache: - examples/browser/node_modules - examples/electron/node_modules - node_modules - - packages/bunyan/node_modules - packages/callhierarchy/node_modules - packages/console/node_modules - packages/core/node_modules diff --git a/CHANGELOG.md b/CHANGELOG.md index cc61e649bb4d2..6e74a531c3e11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ Breaking changes: allowing them to break out and manipulate shared data as cookies, local storage or even start service workers for the main window as well as for each other. Now each webview will be deployed on own origin by default. - Webview origin pattern can be configured with `THEIA_WEBVIEW_EXTERNAL_ENDPOINT` env variable. The default value is `{{uuid}}.webview.{{hostname}}`. - Here `{{uuid}}` and `{{hostname}}` are placeholders which get replaced at runtime with proper webview uuid + Here `{{uuid}}` and `{{hostname}}` are placeholders which get replaced at runtime with proper webview uuid and [hostname](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/hostname) correspondingly. - To switch to unsecure mode as before configure `THEIA_WEBVIEW_EXTERNAL_ENDPOINT` with `{{hostname}}` as a value. You can also drop `{{uuid}}.` prefix, in this case, webviews still will be able to access each other but not the main window. @@ -34,6 +34,7 @@ Breaking changes: Most browsers define a page as served from secure context if its url has `https` scheme. For local testing `localhost` is treated as a secure context as well. Unfortunately, it does not work nicely in FireFox, since it does not treat subdomains of localhost as secure as well, compare to Chrome. If you want to test with FireFox you can configure it as described [here](https://github.com/eclipse-theia/theia/pull/6465#issuecomment-556443218). + - [bunyan] removed `@theia/bunyan` extension []() ## v0.12.0 diff --git a/packages/bunyan/README.md b/packages/bunyan/README.md deleted file mode 100644 index 0dc9db7d8249d..0000000000000 --- a/packages/bunyan/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Theia bunyan Logger Extension - -This extension provides the [`bunyan`](https://www.npmjs.com/package/bunyan)-based logger implementation for Theia. - -See [here](https://www.theia-ide.org/doc/index.html) for a detailed documentation. - -## License -- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/) -- [δΈ€ (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp) diff --git a/packages/bunyan/compile.tsconfig.json b/packages/bunyan/compile.tsconfig.json deleted file mode 100644 index 4c867a02d2696..0000000000000 --- a/packages/bunyan/compile.tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../configs/base.tsconfig", - "compilerOptions": { - "rootDir": "src", - "outDir": "lib", - "baseUrl": "." - }, - "include": [ - "src" - ] -} \ No newline at end of file diff --git a/packages/bunyan/package.json b/packages/bunyan/package.json deleted file mode 100644 index 93db7e10a9963..0000000000000 --- a/packages/bunyan/package.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "name": "@theia/bunyan", - "version": "0.12.0", - "description": "Theia - bunyan Logger Extension", - "dependencies": { - "@theia/core": "^0.12.0", - "@types/bunyan": "^1.8.0", - "bunyan": "^1.8.10" - }, - "publishConfig": { - "access": "public" - }, - "theiaExtensions": [ - { - "backend": "lib/node/bunyan-backend-module" - } - ], - "keywords": [ - "theia-extension" - ], - "license": "EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0", - "repository": { - "type": "git", - "url": "https://github.com/eclipse-theia/theia.git" - }, - "bugs": { - "url": "https://github.com/eclipse-theia/theia/issues" - }, - "homepage": "https://github.com/eclipse-theia/theia", - "files": [ - "lib", - "src" - ], - "scripts": { - "prepare": "yarn run clean && yarn run build", - "clean": "theiaext clean", - "build": "theiaext build", - "watch": "theiaext watch", - "test": "theiaext test" - }, - "devDependencies": { - "@theia/ext-scripts": "^0.12.0" - }, - "nyc": { - "extends": "../../configs/nyc.json" - } -} diff --git a/packages/bunyan/src/node/bunyan-backend-module.ts b/packages/bunyan/src/node/bunyan-backend-module.ts deleted file mode 100644 index 4566dc83637e4..0000000000000 --- a/packages/bunyan/src/node/bunyan-backend-module.ts +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import { interfaces, ContainerModule } from 'inversify'; -import { ILoggerServer } from '@theia/core/lib/common/logger-protocol'; -import { BunyanLoggerServer } from './bunyan-logger-server'; - -export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => { - rebind(ILoggerServer).to(BunyanLoggerServer).inSingletonScope(); -}); diff --git a/packages/bunyan/src/node/bunyan-logger-server.ts b/packages/bunyan/src/node/bunyan-logger-server.ts deleted file mode 100644 index ead92aea2fc22..0000000000000 --- a/packages/bunyan/src/node/bunyan-logger-server.ts +++ /dev/null @@ -1,221 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 Ericsson and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -import * as bunyan from 'bunyan'; -import { inject, injectable, postConstruct } from 'inversify'; -import { LoggerWatcher } from '@theia/core/lib/common/logger-watcher'; -import { LogLevelCliContribution } from '@theia/core/lib/node/logger-cli-contribution'; -import { ILoggerServer, ILoggerClient, ILogLevelChangedEvent, LogLevel, rootLoggerName } from '@theia/core/lib/common/logger-protocol'; - -@injectable() -export class BunyanLoggerServer implements ILoggerServer { - - /* Root logger and all child logger array. */ - private readonly loggers = new Map(); - - /* Logger client to send notifications to. */ - private client: ILoggerClient | undefined = undefined; - - @inject(LoggerWatcher) - protected watcher: LoggerWatcher; - - @inject(LogLevelCliContribution) - protected cli: LogLevelCliContribution; - - @postConstruct() - protected init(): void { - /* Create the root logger by default. */ - const opts = this.makeLoggerOptions(rootLoggerName); - const rootOpts = Object.assign(opts, { name: 'Theia' }); - const logger = bunyan.createLogger(rootOpts); - this.loggers.set(rootLoggerName, logger); - - this.cli.onLogConfigChanged(() => this.updateLogLevels()); - } - - protected updateLogLevels(): void { - for (const loggerName of this.loggers.keys()) { - const newLevel = this.cli.logLevelFor(loggerName); - this.setLogLevel(loggerName, newLevel); - } - } - - protected makeLoggerOptions(name: string): { - logger: string; - level: number; - } { - return { - logger: name, - level: this.toBunyanLevel(this.cli.logLevelFor(name)), - }; - } - - dispose(): void { - // no-op - } - - /* Create a logger child of the root logger. See the bunyan child - * documentation. */ - child(name: string): Promise { - if (name.length === 0) { - return Promise.reject(new Error("Can't create a logger with an empty name.")); - } - - if (this.loggers.has(name)) { - /* Logger already exists. */ - return Promise.resolve(); - } - - const rootLogger = this.loggers.get(rootLoggerName); - if (rootLogger === undefined) { - throw new Error('No root logger.'); - } - - const opts = this.makeLoggerOptions(name); - const logger = rootLogger.child(opts); - this.loggers.set(name, logger); - - return Promise.resolve(); - } - - /* Set the client to receive notifications on. */ - setClient(client: ILoggerClient | undefined): void { - this.client = client; - } - - /** - * Set the log level for a logger. logLevel should be one of Theia's - * LogLevel. - */ - setLogLevel(name: string, newLogLevel: number): Promise { - const logger = this.loggers.get(name); - if (logger === undefined) { - throw new Error(`No logger named ${name}.`); - } - - // Does the log level really change? - const newBunyanLogLevel = this.toBunyanLevel(newLogLevel); - if (newBunyanLogLevel === logger.level()) { - return Promise.resolve(); - } - - logger.level(newBunyanLogLevel); - - const changedEvent: ILogLevelChangedEvent = { - loggerName: name, - newLogLevel: newLogLevel, - }; - - /* Notify the frontend. */ - if (this.client !== undefined) { - this.client.onLogLevelChanged(changedEvent); - } - - /* Notify the backend. */ - this.watcher.fireLogLevelChanged(changedEvent); - - return Promise.resolve(); - } - - /* Get the log level for a logger. */ - getLogLevel(name: string): Promise { - const logger = this.loggers.get(name); - if (logger === undefined) { - throw new Error(`No logger named ${name}.`); - } - - return Promise.resolve( - this.toTheiaLevel(logger.level()) - ); - } - - /* Log a message to a logger. */ - // tslint:disable-next-line:no-any - log(name: string, logLevel: number, message: any, params: any[]): Promise { - const logger = this.loggers.get(name); - if (logger === undefined) { - throw new Error(`No logger named ${name}.`); - } - - switch (logLevel) { - case LogLevel.TRACE: - logger.trace(message, params); - break; - case LogLevel.DEBUG: - logger.debug(message, params); - break; - case LogLevel.INFO: - logger.info(message, params); - break; - case LogLevel.WARN: - logger.warn(message, params); - break; - case LogLevel.ERROR: - logger.error(message, params); - break; - case LogLevel.FATAL: - logger.fatal(message, params); - break; - default: - logger.info(message, params); - break; - } - return Promise.resolve(); - } - - /* Convert Theia's log levels to bunyan's. */ - protected toBunyanLevel(logLevel: number): number { - switch (logLevel) { - case LogLevel.FATAL: - return bunyan.FATAL; - case LogLevel.ERROR: - return bunyan.ERROR; - case LogLevel.WARN: - return bunyan.WARN; - case LogLevel.INFO: - return bunyan.INFO; - case LogLevel.DEBUG: - return bunyan.DEBUG; - case LogLevel.TRACE: - return bunyan.TRACE; - default: - return bunyan.INFO; - } - } - - /** - * Convert Bunyan's log levels to Theia's. - */ - protected toTheiaLevel(bunyanLogLevel: number | string): number { - switch (Number(bunyanLogLevel)) { - case bunyan.FATAL: - return LogLevel.FATAL; - case bunyan.ERROR: - return LogLevel.ERROR; - case bunyan.WARN: - return LogLevel.WARN; - case bunyan.INFO: - return LogLevel.INFO; - case bunyan.DEBUG: - return LogLevel.DEBUG; - case bunyan.TRACE: - return LogLevel.TRACE; - default: - return LogLevel.INFO; - } - } - -} diff --git a/packages/bunyan/src/package.spec.ts b/packages/bunyan/src/package.spec.ts deleted file mode 100644 index 88c14dc79022e..0000000000000 --- a/packages/bunyan/src/package.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -/******************************************************************************** - * Copyright (C) 2018 TypeFox and others. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the Eclipse - * Public License v. 2.0 are satisfied: GNU General Public License, version 2 - * with the GNU Classpath Exception which is available at - * https://www.gnu.org/software/classpath/license.html. - * - * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - ********************************************************************************/ - -describe('bunyan package', () => { - - it('support code coverage statistics', () => true); - -}); diff --git a/tsconfig.json b/tsconfig.json index 42d04f1a9c071..e10ed4853e031 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -97,9 +97,6 @@ "@theia/editorconfig/lib/*": [ "packages/editorconfig/src/*" ], - "@theia/bunyan/lib/*": [ - "packages/bunyan/src/*" - ], "@theia/console/lib/*": [ "packages/console/src/*" ],