Kaynağa Gözat

Updates dependencies & more

Adds bundle analyzer
Adds circular deps analyzer
Switches to es2018 output
Removes many circular dependencies
main
Eric Amodio 5 yıl önce
ebeveyn
işleme
8e58858346
12 değiştirilmiş dosya ile 1205 ekleme ve 646 silme
  1. +666
    -164
      package-lock.json
  2. +11
    -7
      package.json
  3. +1
    -7
      src/config.ts
  4. +16
    -43
      src/configuration.ts
  5. +66
    -6
      src/container.ts
  6. +3
    -3
      src/extension.ts
  7. +22
    -20
      src/logger.ts
  8. +1
    -1
      src/ui/ipc.ts
  9. +3
    -3
      tsconfig.json
  10. +6
    -5
      ui.tsconfig.json
  11. +26
    -3
      webpack.config.js

+ 666
- 164
package-lock.json
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 11
- 7
package.json Dosyayı Görüntüle

@ -4865,6 +4865,8 @@
}
},
"scripts": {
"analyze:bundle": "webpack --env.analyzeBundle",
"analyze:deps": "webpack --env.analyzeDeps",
"build": "webpack --env.development",
"bundle": "webpack --env.production",
"clean": "git clean -Xdf -e !.cache-images -e !node_modules -e !node_modules/**/*",
@ -4889,9 +4891,10 @@
"vsls": "0.3.967"
},
"devDependencies": {
"@types/lodash-es": "4.17.1",
"@types/lodash-es": "4.17.2",
"@types/node": "10.1.4",
"clean-webpack-plugin": "1.0.1",
"circular-dependency-plugin": "5.0.2",
"css-loader": "2.1.0",
"html-webpack-inline-source-plugin": "0.0.10",
"html-webpack-plugin": "3.2.0",
@ -4901,15 +4904,16 @@
"prettier": "1.16.4",
"prettier-tslint": "0.4.2",
"sass-loader": "7.1.0",
"terser-webpack-plugin": "1.2.2",
"tslint": "5.12.1",
"terser-webpack-plugin": "1.2.3",
"tslint": "5.13.0",
"tslint-loader": "3.5.4",
"tslint-prettiest": "0.0.1",
"ts-loader": "5.3.3",
"typescript": "3.2.4",
"vsce": "1.57.0",
"vscode": "1.1.29",
"webpack": "4.29.3",
"webpack-cli": "3.2.3"
"vsce": "1.57.1",
"vscode": "1.1.30",
"webpack": "4.29.5",
"webpack-cli": "3.2.3",
"webpack-bundle-analyzer": "3.0.4"
}
}

src/ui/config.ts → src/config.ts Dosyayı Görüntüle

@ -1,4 +1,5 @@
'use strict';
import { TraceLevel } from './logger';
export interface Config {
blame: {
@ -157,13 +158,6 @@ export enum KeyMap {
None = 'none'
}
export enum TraceLevel {
Silent = 'silent',
Errors = 'errors',
Verbose = 'verbose',
Debug = 'debug'
}
export enum StatusBarCommand {
DiffWithPrevious = 'gitlens.diffWithPrevious',
DiffWithWorking = 'gitlens.diffWithWorking',

+ 16
- 43
src/configuration.ts Dosyayı Görüntüle

@ -1,5 +1,5 @@
'use strict';
export * from './ui/config';
export * from './config';
import {
ConfigurationChangeEvent,
@ -10,11 +10,9 @@ import {
Uri,
workspace
} from 'vscode';
import { Config } from './config';
import { extensionId } from './constants';
import { Container } from './container';
import { clearGravatarCache } from './git/gitService';
import { Functions } from './system';
import { Config } from './ui/config';
const emptyConfig: any = new Proxy<any>({} as Config, {
get(target, propKey, receiver) {
@ -22,6 +20,11 @@ const emptyConfig: any = new Proxy({} as Config, {
}
});
export interface ConfigurationWillChangeEvent {
change: ConfigurationChangeEvent;
transform?(e: ConfigurationChangeEvent): ConfigurationChangeEvent;
}
export class Configuration {
static configure(context: ExtensionContext) {
context.subscriptions.push(
@ -34,51 +37,21 @@ export class Configuration {
return this._onDidChange.event;
}
private readonly _configAffectedByMode: string[];
constructor() {
this._configAffectedByMode = [
`gitlens.${this.name('mode').value}`,
`gitlens.${this.name('modes').value}`,
`gitlens.${this.name('blame')('toggleMode').value}`,
`gitlens.${this.name('codeLens').value}`,
`gitlens.${this.name('currentLine').value}`,
`gitlens.${this.name('heatmap')('toggleMode').value}`,
`gitlens.${this.name('hovers').value}`,
`gitlens.${this.name('recentChanges')('toggleMode').value}`,
`gitlens.${this.name('statusBar').value}`,
`gitlens.${this.name('views')('compare').value}`,
`gitlens.${this.name('views')('fileHistory').value}`,
`gitlens.${this.name('views')('lineHistory').value}`,
`gitlens.${this.name('views')('repositories').value}`,
`gitlens.${this.name('views')('search').value}`
];
private _onWillChange = new EventEmitter<ConfigurationWillChangeEvent>();
get onWillChange(): Event<ConfigurationWillChangeEvent> {
return this._onWillChange.event;
}
private onConfigurationChanged(e: ConfigurationChangeEvent) {
if (!e.affectsConfiguration(extensionId, null!)) return;
Container.resetConfig();
if (configuration.changed(e, configuration.name('defaultGravatarsStyle').value)) {
clearGravatarCache();
}
const evt: ConfigurationWillChangeEvent = {
change: e
};
this._onWillChange.fire(evt);
if (
configuration.changed(e, configuration.name('mode').value) ||
configuration.changed(e, configuration.name('modes').value)
) {
const original = e.affectsConfiguration;
e = {
...e,
affectsConfiguration: (section: string, resource?: Uri) => {
if (this._configAffectedByMode.some(n => section.startsWith(n))) {
return true;
}
return original(section, resource);
}
} as ConfigurationChangeEvent;
if (evt.transform !== undefined) {
e = evt.transform(e);
}
this._onDidChange.fire(e);

+ 66
- 6
src/container.ts Dosyayı Görüntüle

@ -1,14 +1,16 @@
'use strict';
import { commands, Disposable, ExtensionContext } from 'vscode';
import { commands, ConfigurationChangeEvent, Disposable, ExtensionContext, Uri } from 'vscode';
import { FileAnnotationController } from './annotations/fileAnnotationController';
import { LineAnnotationController } from './annotations/lineAnnotationController';
import { GitCodeLensController } from './codelens/codeLensController';
import { Commands, ToggleFileBlameCommandArgs } from './commands';
import { AnnotationsToggleMode, Config, configuration } from './configuration';
import { AnnotationsToggleMode, Config, configuration, ConfigurationWillChangeEvent } from './configuration';
import { GitFileSystemProvider } from './git/fsProvider';
import { GitService } from './git/gitService';
import { clearGravatarCache } from './git/gitService';
import { LineHoverController } from './hovers/lineHoverController';
import { Keyboard } from './keyboard';
import { Logger, TraceLevel } from './logger';
import { StatusBarController } from './statusbar/statusBarController';
import { GitDocumentTracker } from './trackers/gitDocumentTracker';
import { GitLineTracker } from './trackers/gitLineTracker';
@ -23,6 +25,11 @@ import { SettingsEditor } from './webviews/settingsEditor';
import { WelcomeEditor } from './webviews/welcomeEditor';
export class Container {
private static _configsAffectedByMode: string[] | undefined;
private static _applyModeConfigurationTransformBound:
| ((e: ConfigurationChangeEvent) => ConfigurationChangeEvent)
| undefined;
static initialize(context: ExtensionContext, config: Config) {
this._context = context;
this._config = Container.applyMode(config);
@ -111,6 +118,30 @@ export class Container {
}
context.subscriptions.push(new GitFileSystemProvider());
context.subscriptions.push(configuration.onWillChange(this.onConfigurationChanging, this));
}
private static onConfigurationChanging(e: ConfigurationWillChangeEvent) {
this._config = undefined;
if (configuration.changed(e.change, configuration.name('outputLevel').value)) {
Logger.level = configuration.get<TraceLevel>(configuration.name('outputLevel').value);
}
if (configuration.changed(e.change, configuration.name('defaultGravatarsStyle').value)) {
clearGravatarCache();
}
if (
configuration.changed(e.change, configuration.name('mode').value) ||
configuration.changed(e.change, configuration.name('modes').value)
) {
if (this._applyModeConfigurationTransformBound === undefined) {
this._applyModeConfigurationTransformBound = this.applyModeConfigurationTransform.bind(this);
}
e.transform = this._applyModeConfigurationTransformBound;
}
}
private static _codeLensController: GitCodeLensController;
@ -235,10 +266,6 @@ export class Container {
return this._welcomeEditor;
}
static resetConfig() {
this._config = undefined;
}
private static applyMode(config: Config) {
if (!config.mode.active) return config;
@ -308,4 +335,37 @@ export class Container {
return config;
}
private static applyModeConfigurationTransform(e: ConfigurationChangeEvent): ConfigurationChangeEvent {
if (this._configsAffectedByMode === undefined) {
this._configsAffectedByMode = [
`gitlens.${configuration.name('mode').value}`,
`gitlens.${configuration.name('modes').value}`,
`gitlens.${configuration.name('blame')('toggleMode').value}`,
`gitlens.${configuration.name('codeLens').value}`,
`gitlens.${configuration.name('currentLine').value}`,
`gitlens.${configuration.name('heatmap')('toggleMode').value}`,
`gitlens.${configuration.name('hovers').value}`,
`gitlens.${configuration.name('recentChanges')('toggleMode').value}`,
`gitlens.${configuration.name('statusBar').value}`,
`gitlens.${configuration.name('views')('compare').value}`,
`gitlens.${configuration.name('views')('fileHistory').value}`,
`gitlens.${configuration.name('views')('lineHistory').value}`,
`gitlens.${configuration.name('views')('repositories').value}`,
`gitlens.${configuration.name('views')('search').value}`
];
}
const original = e.affectsConfiguration;
return {
...e,
affectsConfiguration: (section: string, resource?: Uri) => {
if (this._configsAffectedByMode && this._configsAffectedByMode.some(n => section.startsWith(n))) {
return true;
}
return original(section, resource);
}
};
}
}

+ 3
- 3
src/extension.ts Dosyayı Görüntüle

@ -1,14 +1,14 @@
'use strict';
import { commands, ExtensionContext, extensions, window, workspace } from 'vscode';
import { Commands, registerCommands } from './commands';
import { ModeConfig } from './config';
import { Config, configuration, Configuration } from './configuration';
import { CommandContext, extensionQualifiedId, GlobalState, GlyphChars, setCommandContext } from './constants';
import { Container } from './container';
import { GitCommit, GitService, GitUri } from './git/gitService';
import { Logger } from './logger';
import { Logger, TraceLevel } from './logger';
import { Messages } from './messages';
import { Strings, Versions } from './system';
import { ModeConfig } from './ui/config';
// import { Telemetry } from './telemetry';
export async function activate(context: ExtensionContext) {
@ -17,7 +17,7 @@ export async function activate(context: ExtensionContext) {
// Pretend we are enabled (until we know otherwise) and set the view contexts to reduce flashing on load
setCommandContext(CommandContext.Enabled, true);
Logger.configure(context, o => {
Logger.configure(context, configuration.get<TraceLevel>(configuration.name('outputLevel').value), o => {
if (o instanceof GitUri) {
return `GitUri(${o.toString(true)}${o.repoPath ? ` repoPath=${o.repoPath}` : ''}${
o.sha ? ` sha=${o.sha}` : ''

+ 22
- 20
src/logger.ts Dosyayı Görüntüle

@ -1,11 +1,15 @@
'use strict';
import { ConfigurationChangeEvent, ExtensionContext, OutputChannel, Uri, window } from 'vscode';
import { configuration, TraceLevel } from './configuration';
import { ExtensionContext, OutputChannel, Uri, window } from 'vscode';
import { extensionOutputChannelName } from './constants';
import { getCorrelationContext } from './system';
// import { Telemetry } from './telemetry';
export { TraceLevel } from './configuration';
export enum TraceLevel {
Silent = 'silent',
Errors = 'errors',
Verbose = 'verbose',
Debug = 'debug'
}
const ConsolePrefix = `[${extensionOutputChannelName}]`;
@ -18,32 +22,30 @@ export interface LogCorrelationContext {
}
export class Logger {
static level: TraceLevel = TraceLevel.Silent;
static output: OutputChannel | undefined;
static customLoggableFn: ((o: object) => string | undefined) | undefined;
static configure(context: ExtensionContext, loggableFn?: (o: any) => string | undefined) {
static configure(context: ExtensionContext, level: TraceLevel, loggableFn?: (o: any) => string | undefined) {
this.customLoggableFn = loggableFn;
context.subscriptions.push(configuration.onDidChange(this.onConfigurationChanged, this));
this.onConfigurationChanged(configuration.initializingChangeEvent);
this.level = level;
}
private static onConfigurationChanged(e: ConfigurationChangeEvent) {
const section = configuration.name('outputLevel').value;
if (configuration.changed(e, section)) {
this.level = configuration.get<TraceLevel>(section);
if (this.level === TraceLevel.Silent) {
if (this.output !== undefined) {
this.output.dispose();
this.output = undefined;
}
}
else {
this.output = this.output || window.createOutputChannel(extensionOutputChannelName);
private static _level: TraceLevel = TraceLevel.Silent;
static get level() {
return this._level;
}
static set level(value: TraceLevel) {
this._level = value;
if (value === TraceLevel.Silent) {
if (this.output !== undefined) {
this.output.dispose();
this.output = undefined;
}
}
else {
this.output = this.output || window.createOutputChannel(extensionOutputChannelName);
}
}
static debug(message: string, ...params: any[]): void;

+ 1
- 1
src/ui/ipc.ts Dosyayı Görüntüle

@ -1,5 +1,5 @@
'use strict';
import { Config } from './config';
import { Config } from '../config';
export interface Bootstrap {
config: Config;

+ 3
- 3
tsconfig.json Dosyayı Görüntüle

@ -3,17 +3,17 @@
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"lib": ["es2015", "es2016", "es2017"],
"lib": ["es2018"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": false,
"outDir": "dist",
"rootDir": "./src",
"rootDir": "src",
"sourceMap": true,
"strict": true,
"target": "es2017"
"target": "es2018"
},
"exclude": ["node_modules", "test", "src/ui"]
}

+ 6
- 5
ui.tsconfig.json Dosyayı Görüntüle

@ -1,19 +1,20 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "dom.iterable", "es2015", "es2015.iterable", "es2016"],
"module": "es2015",
"lib": ["dom", "dom.iterable", "es2018"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": false,
"outDir": "dist/ui",
"rootDir": "./src/ui",
"rootDir": "src",
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "es2016"
"target": "es2018"
},
"include": ["src/ui/**/*"],
"include": ["src/config.ts", "src/ui/**/*"],
"exclude": ["node_modules"]
}

+ 26
- 3
webpack.config.js Dosyayı Görüntüle

@ -3,7 +3,9 @@ const fs = require('fs');
const glob = require('glob');
const path = require('path');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const CleanPlugin = require('clean-webpack-plugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const HtmlInlineSourcePlugin = require('html-webpack-inline-source-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
@ -12,7 +14,9 @@ const TerserPlugin = require('terser-webpack-plugin');
module.exports = function(env, argv) {
env = env || {};
env.production = Boolean(env.production);
env.analyzeBundle = Boolean(env.analyzeBundle);
env.analyzeDeps = Boolean(env.analyzeDeps);
env.production = env.analyzeBundle || Boolean(env.production);
env.optimizeImages = env.production || Boolean(env.optimizeImages);
if (!env.optimizeImages && !fs.existsSync(path.resolve(__dirname, 'images/settings'))) {
@ -57,6 +61,25 @@ module.exports = function(env, argv) {
function getExtensionConfig(env) {
const plugins = [new CleanPlugin(['dist'], { verbose: false }), new webpack.IgnorePlugin(/^spawn-sync$/)];
if (env.analyzeDeps) {
plugins.push(
new CircularDependencyPlugin({
cwd: __dirname,
exclude: /node_modules/,
failOnError: false,
onDetected({ module: webpackModuleRecord, paths, compilation }) {
if (paths.some(p => /container\.ts/.test(p))) return;
compilation.warnings.push(new Error(paths.join(' -> ')));
}
})
);
}
if (env.analyzeBundle) {
plugins.push(new BundleAnalyzerPlugin());
}
return {
name: 'extension',
entry: './src/extension.ts',
@ -107,7 +130,7 @@ function getExtensionConfig(env) {
exprContextCritical: false
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json']
},
plugins: plugins,
stats: {
@ -258,7 +281,7 @@ function getUIConfig(env) {
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
modules: [path.resolve(__dirname, 'src/ui'), 'node_modules']
},
plugins: plugins,

Yükleniyor…
İptal
Kaydet