From 8df6b8072586b351871506acfb8ddc4c64eeb73b Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 29 Sep 2016 16:06:48 -0400 Subject: [PATCH] Updates to latest vscode extension template Removes typings (using npm instead) Fixes some promise catches --- .vscode/settings.json | 3 +-- .vscodeignore | 3 ++- package.json | 15 ++++++++------ src/commands/diffWithPrevious.ts | 14 ++++++------- src/commands/diffWithWorking.ts | 10 ++++----- src/commands/showBlame.ts | 4 ++-- src/commands/showBlameHistory.ts | 4 ++-- src/commands/toggleBlame.ts | 4 ++-- tsconfig.json | 4 +++- typings.json | 5 ----- typings/globals/tmp/index.d.ts | 45 ---------------------------------------- typings/globals/tmp/typings.json | 8 ------- typings/index.d.ts | 1 - typings/node.d.ts | 1 - typings/vscode-typings.d.ts | 1 - 15 files changed, 33 insertions(+), 89 deletions(-) delete mode 100644 typings.json delete mode 100644 typings/globals/tmp/index.d.ts delete mode 100644 typings/globals/tmp/typings.json delete mode 100644 typings/index.d.ts delete mode 100644 typings/node.d.ts delete mode 100644 typings/vscode-typings.d.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 42c684f..ca6b108 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,8 +2,7 @@ { "files.exclude": { "out": false, // set this to true to hide the "out" folder with the compiled JS files - "node_modules": true, - "typings": true + "node_modules": true }, "search.exclude": { "out": true, // set this to false to include "out" folder in search results diff --git a/.vscodeignore b/.vscodeignore index 2450088..20a6c06 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,6 +1,7 @@ images/*.gif -.vscode/** typings/** +.vscode/** +.vscode-test/** out/test/** test/** src/** diff --git a/package.json b/package.json index a1d7279..fe5b567 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ }, "publisher": "eamodio", "engines": { - "vscode": "^1.3.0" + "vscode": "^1.5.0" }, "license": "SEE LICENSE IN LICENSE", "displayName": "GitLens", @@ -217,18 +217,21 @@ "lodash.debounce": "^4.0.8", "lodash.escaperegexp": "^4.1.2", "lodash.isequal": "^4.4.0", - "lodash": "^4.16.1", "moment": "^2.15.1", - "spawn-rx": "^2.0.1", + "spawn-rx": "^2.0.3", "tmp": "^0.0.29" }, "devDependencies": { "typescript": "^2.0.3", - "vscode": "^0.11.17" + "vscode": "^1.0.0", + "mocha": "^3.1.0", + "@types/node": "^6.0.41", + "@types/mocha": "^2.2.32", + "@types/tmp": "^0.0.31" }, "scripts": { - "vscode:prepublish": "node ./node_modules/vscode/bin/compile && tsc", - "compile": "node ./node_modules/vscode/bin/compile -watch -p ./", + "vscode:prepublish": "tsc -p ./", + "compile": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", "pack": "git clean -xdf && npm install && vsce package", "pub": "git clean -xdf --exclude=node_modules/ && npm install && vsce publish" diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index 388b9e7..0ad6ebe 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -19,7 +19,6 @@ export default class DiffWithPreviousCommand extends EditorCommand { } return this.git.getBlameForLine(uri.fsPath, line) - .catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', `getBlameForLine(${line})`, ex)) .then(blame => { if (!blame) return; @@ -27,16 +26,17 @@ export default class DiffWithPreviousCommand extends EditorCommand { const commit = blame.commit; if (commit.isUncommitted) { return this.git.getBlameForLine(commit.previousUri.fsPath, blame.line.originalLine + 1, commit.previousSha, commit.repoPath) - .catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', `getBlameForLine(${blame.line.originalLine}, ${commit.previousSha})`, ex)) .then(prevBlame => { if (!prevBlame) return; const prevCommit = prevBlame.commit; return commands.executeCommand(Commands.DiffWithPrevious, commit.previousUri, commit.repoPath, commit.previousSha, commit.previousUri, prevCommit.sha, prevCommit.uri, blame.line.originalLine); - }); + }) + .catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', `getBlameForLine(${blame.line.originalLine}, ${commit.previousSha})`, ex)); } return commands.executeCommand(Commands.DiffWithPrevious, commit.uri, commit.repoPath, commit.sha, commit.uri, commit.previousSha, commit.previousUri, line); - }); + }) + .catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', `getBlameForLine(${line})`, ex)); } if (!compareWithSha) { @@ -44,8 +44,8 @@ export default class DiffWithPreviousCommand extends EditorCommand { } return Promise.all([this.git.getVersionedFile(shaUri.fsPath, repoPath, sha), this.git.getVersionedFile(compareWithUri.fsPath, repoPath, compareWithSha)]) - .catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', 'getVersionedFile', ex)) - .then(values => commands.executeCommand(BuiltInCommands.Diff, Uri.file(values[1]), Uri.file(values[0]), `${path.basename(compareWithUri.fsPath)} (${compareWithSha}) ↔ ${path.basename(shaUri.fsPath)} (${sha})`) - .then(() => commands.executeCommand(BuiltInCommands.RevealLine, {lineNumber: line, at: 'center'}))); + .then(values => commands.executeCommand(BuiltInCommands.Diff, Uri.file(values[1]), Uri.file(values[0]), `${path.basename(compareWithUri.fsPath)} (${compareWithSha}) ↔ ${path.basename(shaUri.fsPath)} (${sha})`)) + .then(() => commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' })) + .catch(ex => console.error('[GitLens.DiffWithPreviousCommand]', 'getVersionedFile', ex)); } } \ No newline at end of file diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index 4d1310d..8124b93 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -19,7 +19,6 @@ export default class DiffWithWorkingCommand extends EditorCommand { } return this.git.getBlameForLine(uri.fsPath, line) - .catch(ex => console.error('[GitLens.DiffWithWorkingCommand]', `getBlameForLine(${line})`, ex)) .then(blame => { if (!blame) return; @@ -29,12 +28,13 @@ export default class DiffWithWorkingCommand extends EditorCommand { return commands.executeCommand(Commands.DiffWithWorking, commit.uri, commit.repoPath, commit.previousSha, commit.previousUri, blame.line.line + 1); } return commands.executeCommand(Commands.DiffWithWorking, commit.uri, commit.repoPath, commit.sha, commit.uri, line) - }); + }) + .catch(ex => console.error('[GitLens.DiffWithWorkingCommand]', `getBlameForLine(${line})`, ex)); }; return this.git.getVersionedFile(shaUri.fsPath, repoPath, sha) - .catch(ex => console.error('[GitLens.DiffWithWorkingCommand]', 'getVersionedFile', ex)) - .then(compare => commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), uri, `${path.basename(shaUri.fsPath)} (${sha}) ↔ ${path.basename(uri.fsPath)}`) - .then(() => commands.executeCommand(BuiltInCommands.RevealLine, {lineNumber: line, at: 'center'}))); + .then(compare => commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), uri, `${path.basename(shaUri.fsPath)} (${sha}) ↔ ${path.basename(uri.fsPath)}`)) + .then(() => commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' })) + .catch(ex => console.error('[GitLens.DiffWithWorkingCommand]', 'getVersionedFile', ex)); } } diff --git a/src/commands/showBlame.ts b/src/commands/showBlame.ts index c6fa749..7e1dcfd 100644 --- a/src/commands/showBlame.ts +++ b/src/commands/showBlame.ts @@ -21,7 +21,7 @@ export default class ShowBlameCommand extends EditorCommand { } return this.git.getBlameForLine(uri.fsPath, editor.selection.active.line) - .catch(ex => console.error('[GitLens.ShowBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex)) - .then(blame => this.annotationController.showBlameAnnotation(editor, blame && blame.commit.sha)); + .then(blame => this.annotationController.showBlameAnnotation(editor, blame && blame.commit.sha)) + .catch(ex => console.error('[GitLens.ShowBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex)); } } \ No newline at end of file diff --git a/src/commands/showBlameHistory.ts b/src/commands/showBlameHistory.ts index 5179120..bda732c 100644 --- a/src/commands/showBlameHistory.ts +++ b/src/commands/showBlameHistory.ts @@ -20,7 +20,7 @@ export default class ShowBlameHistoryCommand extends EditorCommand { } return this.git.getBlameLocations(uri.fsPath, range) - .catch(ex => console.error('[GitLens.ShowBlameHistoryCommand]', 'getBlameLocations', ex)) - .then(locations => commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations)); + .then(locations => commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations)) + .catch(ex => console.error('[GitLens.ShowBlameHistoryCommand]', 'getBlameLocations', ex)); } } \ No newline at end of file diff --git a/src/commands/toggleBlame.ts b/src/commands/toggleBlame.ts index fa3af71..aea0774 100644 --- a/src/commands/toggleBlame.ts +++ b/src/commands/toggleBlame.ts @@ -21,8 +21,8 @@ export default class ToggleBlameCommand extends EditorCommand { } return this.git.getBlameForLine(uri.fsPath, editor.selection.active.line) - .catch(ex => console.error('[GitLens.ToggleBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex)) - .then(blame => this.blameController.toggleBlameAnnotation(editor, blame && blame.commit.sha)); + .then(blame => this.blameController.toggleBlameAnnotation(editor, blame && blame.commit.sha)) + .catch(ex => console.error('[GitLens.ToggleBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex)); } } diff --git a/tsconfig.json b/tsconfig.json index 26c47ec..11282c9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,9 @@ "module": "commonjs", "target": "es6", "outDir": "out", - "noLib": true, + "lib": [ + "es6" + ], "sourceMap": true, "rootDir": "." }, diff --git a/typings.json b/typings.json deleted file mode 100644 index 89a1408..0000000 --- a/typings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "globalDependencies": { - "tmp": "registry:dt/tmp#0.0.0+20160514170650" - } -} diff --git a/typings/globals/tmp/index.d.ts b/typings/globals/tmp/index.d.ts deleted file mode 100644 index 5ae8593..0000000 --- a/typings/globals/tmp/index.d.ts +++ /dev/null @@ -1,45 +0,0 @@ -// Generated by typings -// Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5d6115f046550714a28caa3555f47a1aec114fe5/tmp/tmp.d.ts -declare module "tmp" { - - namespace tmp { - interface Options extends SimpleOptions { - mode?: number; - } - - interface SimpleOptions { - prefix?: string; - postfix?: string; - template?: string; - dir?: string; - tries?: number; - keep?: boolean; - unsafeCleanup?: boolean; - } - - interface SynchrounousResult { - name: string; - fd: number; - removeCallback: () => void; - } - - function file(callback: (err: any, path: string, fd: number, cleanupCallback: () => void) => void): void; - function file(config: Options, callback?: (err: any, path: string, fd: number, cleanupCallback: () => void) => void): void; - - function fileSync(config?: Options): SynchrounousResult; - - function dir(callback: (err: any, path: string, cleanupCallback: () => void) => void): void; - function dir(config: Options, callback?: (err: any, path: string, cleanupCallback: () => void) => void): void; - - function dirSync(config?: Options): SynchrounousResult; - - function tmpName(callback: (err: any, path: string) => void): void; - function tmpName(config: SimpleOptions, callback?: (err: any, path: string) => void): void; - - function tmpNameSync(config?: SimpleOptions): string; - - function setGracefulCleanup(): void; - } - - export = tmp; -} diff --git a/typings/globals/tmp/typings.json b/typings/globals/tmp/typings.json deleted file mode 100644 index f69d10a..0000000 --- a/typings/globals/tmp/typings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resolution": "main", - "tree": { - "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5d6115f046550714a28caa3555f47a1aec114fe5/tmp/tmp.d.ts", - "raw": "registry:dt/tmp#0.0.0+20160514170650", - "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/5d6115f046550714a28caa3555f47a1aec114fe5/tmp/tmp.d.ts" - } -} diff --git a/typings/index.d.ts b/typings/index.d.ts deleted file mode 100644 index f98d791..0000000 --- a/typings/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// diff --git a/typings/node.d.ts b/typings/node.d.ts deleted file mode 100644 index 5ed7730..0000000 --- a/typings/node.d.ts +++ /dev/null @@ -1 +0,0 @@ -/// \ No newline at end of file diff --git a/typings/vscode-typings.d.ts b/typings/vscode-typings.d.ts deleted file mode 100644 index 5590dc8..0000000 --- a/typings/vscode-typings.d.ts +++ /dev/null @@ -1 +0,0 @@ -///