瀏覽代碼

Adds better support for insiders version

main
Eric Amodio 4 年之前
父節點
當前提交
25ecfbe6f2
共有 15 個文件被更改,包括 176 次插入123 次删除
  1. +2
    -5
      .github/workflows/cd-insiders.yml
  2. +1
    -0
      .vscodeignore
  3. +2
    -1
      package.json
  4. +25
    -0
      scripts/applyPatchForInsiders.js
  5. +0
    -0
      scripts/generateEmojiShortcodeMap.js
  6. +4
    -5
      src/commands/setViewsLayout.ts
  7. +2
    -1
      src/configuration.ts
  8. +0
    -6
      src/constants.ts
  9. +11
    -1
      src/container.ts
  10. +19
    -3
      src/extension.ts
  11. +2
    -2
      src/keyboard.ts
  12. +1
    -1
      src/logger.ts
  13. +9
    -1
      src/messages.ts
  14. +2
    -1
      src/terminal.ts

+ 2
- 5
.github/workflows/cd-insiders.yml 查看文件

@ -58,11 +58,8 @@ jobs:
node-version: '12.x'
- name: Install
run: yarn
- name: Patch README.md
run: node -e "var insert = fs.readFileSync('./README.insiders.md'); var d = fs.readFileSync('./README.md'); fs.writeFileSync('./README.md', insert + '\n' + d);"
- name: Patch package.json
run: |
node -e "var d = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/New_York' })); var p = require('./package.json'); p = JSON.stringify({...p, name: p.name + '-insiders', displayName: p.displayName + ' (Insiders)', version: '' + d.getFullYear() + '.' + (d.getMonth() + 1) + '.' + d.getDate() + String(d.getHours()).padStart(2, '0') }); fs.writeFileSync('./package.json', p);"
- name: Apply insiders patch
run: yarn run patch-insiders
- name: Setup Environment
run: node -e "console.log('PACKAGE_VERSION=' + require('./package.json').version + '\nPACKAGE_NAME=' + require('./package.json').name + '-' + require('./package.json').version)" >> $GITHUB_ENV
- name: Package extension

+ 1
- 0
.vscodeignore 查看文件

@ -6,6 +6,7 @@ dist/webviews/*.css
emoji/**
images/docs/**
node_modules/**
scripts/**
src/**
test/**
**/*.fig

+ 2
- 1
package.json 查看文件

@ -8115,6 +8115,7 @@
"lint": "eslint src/**/*.ts --fix --cache",
"optimize:webviews": "webpack --config-name webviews --env.optimizeImages",
"pack": "vsce package --yarn",
"patch-insiders": "node ./scripts/applyPatchForInsiders.js",
"pretty": "prettier --config .prettierrc --loglevel warn --write .",
"pub": "vsce publish --yarn",
"rebuild": "yarn run reset && yarn run build",
@ -8124,7 +8125,7 @@
"watch:webviews": "webpack --watch --mode development --config-name webviews",
"update-dts": "pushd \"src/@types\" && npx vscode-dts dev && popd",
"update-dts:master": "pushd \"src/@types\" && npx vscode-dts master && popd",
"update-emoji": "node ./generateEmojiShortcodeMap.js",
"update-emoji": "node ./scripts/generateEmojiShortcodeMap.js",
"vscode:prepublish": "yarn run bundle"
},
"dependencies": {

+ 25
- 0
scripts/applyPatchForInsiders.js 查看文件

@ -0,0 +1,25 @@
/* eslint-disable import/order */
/* eslint-disable @typescript-eslint/no-var-requires */
'use strict';
const fs = require('fs');
// Patch README
const insert = fs.readFileSync('./README.insiders.md', { encoding: 'utf8' });
const data = fs.readFileSync('./README.md', { encoding: 'utf8' });
fs.writeFileSync('./README.md', `${insert}\n${data}`);
// Patch package.json
const date = new Date(new Date().toLocaleString('en-US', { timeZone: 'America/New_York' }));
let json = require('../package.json');
json = JSON.stringify({
...json,
name: `${json.name}-insiders`,
displayName: `${json.displayName} (Insiders)`,
version: `${String(date.getFullYear())}.${date.getMonth() + 1}.${date.getDate()}${String(date.getHours()).padStart(
2,
'0',
)}`,
preview: true,
});
fs.writeFileSync('./package.json', json);

generateEmojiShortcodeMap.js → scripts/generateEmojiShortcodeMap.js 查看文件


+ 4
- 5
src/commands/setViewsLayout.ts 查看文件

@ -1,7 +1,6 @@
'use strict';
import { commands, window } from 'vscode';
import { viewsConfigKeys } from '../configuration';
import { extensionId } from '../constants';
import { command, Command, Commands } from './common';
enum ViewsLayout {
@ -53,8 +52,8 @@ export class SetViewsLayoutCommand extends Command {
let count = 0;
while (count++ < 2) {
void (await commands.executeCommand('vscode.moveViews', {
viewIds: viewsConfigKeys.map(view => `${extensionId}.views.${view}`),
destinationId: `workbench.view.extension.${extensionId}`,
viewIds: viewsConfigKeys.map(view => `gitlens.views.${view}`),
destinationId: 'workbench.view.extension.gitlens',
}));
}
} catch {}
@ -66,13 +65,13 @@ export class SetViewsLayoutCommand extends Command {
let count = 0;
while (count++ < 2) {
void (await commands.executeCommand('vscode.moveViews', {
viewIds: viewsConfigKeys.map(view => `${extensionId}.views.${view}`),
viewIds: viewsConfigKeys.map(view => `gitlens.views.${view}`),
destinationId: 'workbench.view.scm',
}));
}
} catch {
for (const view of viewsConfigKeys) {
void (await commands.executeCommand(`${extensionId}.views.${view}.resetViewLocation`));
void (await commands.executeCommand(`gitlens.views.${view}.resetViewLocation`));
}
}

+ 2
- 1
src/configuration.ts 查看文件

@ -12,9 +12,10 @@ import {
workspace,
} from 'vscode';
import { Config } from './config';
import { extensionId } from './constants';
import { Objects } from './system';
const extensionId = 'gitlens';
type ConfigInspection<T> = {
key: string;
defaultValue?: T;

+ 0
- 6
src/constants.ts 查看文件

@ -3,12 +3,6 @@ import { commands, TextDocument, TextEditor, window } from 'vscode';
import { ViewShowBranchComparison } from './config';
import { SearchPattern } from './git/git';
export const applicationInsightsKey = 'a9c302f8-6483-4d01-b92c-c159c799c679';
export const extensionId = 'gitlens';
export const extensionOutputChannelName = 'GitLens';
export const extensionQualifiedId = `eamodio.${extensionId}`;
export const extensionTerminalName = 'GitLens';
export const quickPickTitleMaxChars = 80;
export enum BuiltInCommands {

+ 11
- 1
src/container.ts 查看文件

@ -38,7 +38,8 @@ export class Container {
| ((e: ConfigurationChangeEvent) => ConfigurationChangeEvent)
| undefined;
static initialize(context: ExtensionContext, config: Config) {
static initialize(extensionId: string, context: ExtensionContext, config: Config) {
this._extensionId = extensionId;
this._context = context;
this._config = Container.applyMode(config);
@ -171,6 +172,11 @@ export class Container {
return this._contributorsView;
}
private static _extensionId: string;
static get extensionId() {
return this._extensionId;
}
private static _fileAnnotationController: FileAnnotationController;
static get fileAnnotations() {
return this._fileAnnotationController;
@ -208,6 +214,10 @@ export class Container {
}
}
static get insiders() {
return this._extensionId.endsWith('-insiders');
}
private static _keyboard: Keyboard;
static get keyboard() {
return this._keyboard;

+ 19
- 3
src/extension.ts 查看文件

@ -1,8 +1,9 @@
'use strict';
import * as paths from 'path';
import { commands, ExtensionContext, extensions, window, workspace } from 'vscode';
import { Commands, registerCommands } from './commands';
import { configuration, Configuration } from './configuration';
import { ContextKeys, extensionQualifiedId, GlobalState, GlyphChars, setContext, SyncedState } from './constants';
import { ContextKeys, GlobalState, GlyphChars, setContext, SyncedState } from './constants';
import { Container } from './container';
import { Git, GitCommit } from './git/git';
import { GitService } from './git/gitService';
@ -15,6 +16,21 @@ import { ViewNode } from './views/nodes';
export async function activate(context: ExtensionContext) {
const start = process.hrtime();
let extensionId = 'eamodio.gitlens';
if (paths.basename(context.globalStorageUri.fsPath) === 'eamodio.gitlens-insiders') {
extensionId = 'eamodio.gitlens-insiders';
// Ensure that stable isn't also installed
const stable = extensions.getExtension('eamodio.gitlens');
if (stable != null) {
Logger.log('GitLens (Insiders) was NOT activated because GitLens is also installed');
void Messages.showInsidersErrorMessage();
return;
}
}
// Pretend we are enabled (until we know otherwise) and set the view contexts to reduce flashing on load
void setContext(ContextKeys.Enabled, true);
@ -42,7 +58,7 @@ export async function activate(context: ExtensionContext) {
return undefined;
});
const gitlens = extensions.getExtension(extensionQualifiedId)!;
const gitlens = extensions.getExtension(extensionId)!;
const gitlensVersion = gitlens.packageJSON.version;
const syncedVersion = context.globalState.get<string>(SyncedState.Version);
@ -108,7 +124,7 @@ export async function activate(context: ExtensionContext) {
return;
}
Container.initialize(context, cfg);
Container.initialize(extensionId, context, cfg);
registerCommands(context);

+ 2
- 2
src/keyboard.ts 查看文件

@ -1,6 +1,6 @@
'use strict';
import { commands, Disposable } from 'vscode';
import { ContextKeys, extensionId, setContext } from './constants';
import { ContextKeys, setContext } from './constants';
import { Logger } from './logger';
import { log } from './system';
@ -152,7 +152,7 @@ export class Keyboard implements Disposable {
constructor() {
const subscriptions = keys.map(key =>
commands.registerCommand(`${extensionId}.key.${key}`, () => this.execute(key), this),
commands.registerCommand(`gitlens.key.${key}`, () => this.execute(key), this),
);
this._disposable = Disposable.from(...subscriptions);
}

+ 1
- 1
src/logger.ts 查看文件

@ -1,10 +1,10 @@
'use strict';
import { ExtensionContext, ExtensionMode, OutputChannel, Uri, window } from 'vscode';
import { TraceLevel } from './configuration';
import { extensionOutputChannelName } from './constants';
import { getCorrelationContext, getNextCorrelationId } from './system';
const emptyStr = '';
const extensionOutputChannelName = 'GitLens';
const ConsolePrefix = `[${extensionOutputChannelName}]`;
export { TraceLevel } from './configuration';

+ 9
- 1
src/messages.ts 查看文件

@ -65,7 +65,7 @@ export class Messages {
static showGitDisabledErrorMessage() {
return Messages.showMessage(
'error',
'GitLens requires Git to be enabled. Please re-enable Git \u2014 set `git.enabled` to true and reload',
'GitLens requires Git to be enabled. Please re-enable Git \u2014 set `git.enabled` to true and reload.',
SuppressedMessages.GitDisabledWarning,
);
}
@ -78,6 +78,14 @@ export class Messages {
);
}
static showInsidersErrorMessage() {
return Messages.showMessage(
'error',
'GitLens (Insiders) cannot be used while GitLens is also installed. Please ensure that only one version of GitLens is installed.',
SuppressedMessages.GitDisabledWarning,
);
}
static showLineUncommittedWarningMessage(message: string): Promise<MessageItem | undefined> {
return Messages.showMessage(
'warn',

+ 2
- 1
src/terminal.ts 查看文件

@ -1,12 +1,13 @@
'use strict';
import { Disposable, Terminal, window } from 'vscode';
import { extensionTerminalName } from './constants';
import { Container } from './container';
let _terminal: Terminal | undefined;
let _terminalCwd: string | undefined;
let _disposable: Disposable | undefined;
const extensionTerminalName = 'GitLens';
function ensureTerminal(cwd: string): Terminal {
if (_terminal === undefined) {
_terminal = window.createTerminal(extensionTerminalName);

Loading…
取消
儲存