-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add files for web extension and disable the winston-based logger * Copy logger from VSCodeVim that is compatible both with Node and browser and fix build config for it * Fix browser logger to filter by log levels * Fix .gitignore * Configure to run tests on browser * Update .vscodeignore * Update vscode-web:prepublish script * Fix vscode:prepublish script to run both compiling for node and web * Fix web-extension.webpack.config.js to exclude test code in production build
- Loading branch information
Showing
18 changed files
with
1,466 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ out | |
dist | ||
node_modules | ||
.vscode-test/ | ||
.vscode-test-web/ | ||
*.vsix | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "compile-web", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": [ | ||
"$ts-webpack", | ||
"$tslint-webpack" | ||
] | ||
}, | ||
{ | ||
"type": "npm", | ||
"script": "watch-web", | ||
"group": "build", | ||
"isBackground": true, | ||
"problemMatcher": [ | ||
"$ts-webpack-watch", | ||
"$tslint-webpack-watch" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
.vscode | ||
.vscode-test | ||
.vscode-test-web | ||
.github | ||
node_modules | ||
yarn.lock | ||
out/ | ||
src/ | ||
.gitignore | ||
vsc-extension-quickstart.md | ||
.eslintignore | ||
.prettierignore | ||
**/tsconfig.json | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts | ||
**/webpack.config.js | ||
azure-pipelines.yml | ||
**/*webpack.config.js | ||
keybindings.json | ||
DEVELOPMENT.md | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
//@ts-check | ||
'use strict'; | ||
|
||
//@ts-check | ||
/** @typedef {import('webpack').Configuration} WebpackConfig **/ | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
const config = /** @type WebpackConfig */ { | ||
context: path.dirname(__dirname), | ||
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production') | ||
target: 'webworker', // extensions run in a webworker context | ||
entry: { | ||
'extension': './src/web/extension.ts', | ||
}, | ||
resolve: { | ||
mainFields: ['browser', 'module', 'main'], // look for `browser` entry point in imported node modules | ||
extensions: ['.ts', '.js'], // support ts-files and js-files | ||
alias: { | ||
// provides alternate implementation for node module and source files | ||
vs: path.resolve(__dirname, '..', 'src', 'vs'), | ||
platform: path.resolve(__dirname, '..', 'src', 'platform', 'browser'), | ||
}, | ||
fallback: { | ||
// Webpack 5 no longer polyfills Node.js core modules automatically. | ||
// see https://webpack.js.org/configuration/resolve/#resolvefallback | ||
// for the list of Node.js core module polyfills. | ||
'assert': require.resolve('assert') | ||
}, | ||
}, | ||
module: { | ||
rules: [{ | ||
test: /\.ts$/, | ||
exclude: /node_modules/, | ||
use: [{ | ||
loader: 'ts-loader' | ||
}] | ||
}] | ||
}, | ||
plugins: [ | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', // provide a shim for the global `process` variable | ||
}), | ||
], | ||
externals: { | ||
'vscode': 'commonjs vscode', // ignored because it doesn't exist | ||
}, | ||
performance: { | ||
hints: false | ||
}, | ||
output: { | ||
filename: '[name].js', | ||
path: path.join(__dirname, '../dist/web'), | ||
libraryTarget: 'commonjs' | ||
}, | ||
devtool: 'nosources-source-map' // create a source map that points to the original source file | ||
}; | ||
|
||
module.exports = (env, argv) => { | ||
if (argv.mode !== 'production') { | ||
config.entry['test/suite/index'] = './src/web/test/suite/index.ts' | ||
} | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,30 @@ | ||
/** | ||
* This file is derived from VSCodeVim/Vim. | ||
*/ | ||
import { ILogger } from "src/platform/common/logger"; | ||
import { LoggerImpl } from "platform/loggerImpl"; | ||
import { IConfiguration } from "src/configuration/iconfiguration"; | ||
|
||
import * as vscode from "vscode"; | ||
import * as winston from "winston"; | ||
import { ConsoleForElectron } from "winston-console-for-electron"; | ||
import TransportStream from "winston-transport"; | ||
import { IConfiguration } from "./configuration/iconfiguration"; | ||
export class Logger { | ||
private static readonly cache = new Map<string, ILogger>(); | ||
private static configuration: IConfiguration | undefined = undefined; | ||
|
||
/** | ||
* Implementation of Winston transport | ||
* Displays VS Code message to user | ||
*/ | ||
class VsCodeMessage extends TransportStream { | ||
public log(info: { level: string; message: string }, callback: () => void) { | ||
switch (info.level) { | ||
case "error": | ||
vscode.window.showErrorMessage(info.message, "Dismiss"); | ||
break; | ||
case "warn": | ||
vscode.window.showWarningMessage(info.message, "Dismiss"); | ||
break; | ||
case "info": | ||
case "verbose": | ||
case "debug": | ||
vscode.window.showInformationMessage(info.message, "Dismiss"); | ||
break; | ||
static get(prefix: string): ILogger { | ||
let logger = Logger.cache.get(prefix); | ||
if (logger === undefined) { | ||
logger = LoggerImpl.get(prefix); | ||
if (Logger.configuration) { | ||
logger.configChanged(Logger.configuration); | ||
} | ||
Logger.cache.set(prefix, logger); | ||
} | ||
|
||
if (callback) { | ||
callback(); | ||
return logger; | ||
} | ||
|
||
static configChanged(configuration: IConfiguration): void { | ||
Logger.configuration = configuration; | ||
for (const logger of this.cache.values()) { | ||
logger.configChanged(configuration); | ||
} | ||
} | ||
} | ||
|
||
export let logger = winston.createLogger({ | ||
format: winston.format.simple(), | ||
transports: [ | ||
new ConsoleForElectron({ | ||
level: "error", | ||
silent: false, | ||
}), | ||
new VsCodeMessage({ | ||
level: "error", | ||
silent: false, | ||
}), | ||
], | ||
}); | ||
|
||
export function initializeLogger(configuration: IConfiguration) { | ||
logger = winston.createLogger({ | ||
format: winston.format.simple(), | ||
transports: [ | ||
new ConsoleForElectron({ | ||
level: configuration.debug.loggingLevelForConsole, | ||
silent: configuration.debug.silent, | ||
}), | ||
new VsCodeMessage({ | ||
level: configuration.debug.loggingLevelForAlert, | ||
silent: configuration.debug.silent, | ||
}), | ||
], | ||
}); | ||
} | ||
export const logger = Logger.get(""); // Default logger, which is not recommended to use. Prefixed loggers should be used instead. |
Oops, something went wrong.