From 1b9caa32657774bfee1a5ba503a4e59a983ee40d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Jan 2016 15:52:06 -0500 Subject: [PATCH] Remove Update Notifier --- src/main.ts | 42 ++++++++++++++++-------------------- src/utils/ManifestUtils.ts | 34 ----------------------------- src/utils/UpdateNotifier.ts | 43 ------------------------------------- 3 files changed, 19 insertions(+), 100 deletions(-) delete mode 100644 src/utils/ManifestUtils.ts delete mode 100644 src/utils/UpdateNotifier.ts diff --git a/src/main.ts b/src/main.ts index 1dc5237..26141ee 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,24 +1,20 @@ -'use strict'; - -import { commands, languages, ExtensionContext } from 'vscode'; -import { linearizeXml, XmlDocumentFormattingProvider, XmlRangeFormattingProvider } from './features/xmlFormatting'; -import { evaluateXPath } from './features/xmlXPathEngine'; -import { checkForUpdates } from './utils/UpdateNotifier'; - -export function activate(ctx: ExtensionContext) { - // check for update - checkForUpdates(); - - // register palette commands - ctx.subscriptions.push(commands.registerTextEditorCommand('xmltools.linearizeXml', linearizeXml)); - ctx.subscriptions.push(commands.registerTextEditorCommand('xmltools.evaluateXPath', evaluateXPath)); - - // alias for editor.action.format - ctx.subscriptions.push(commands.registerTextEditorCommand('xmlTools.formatXml', () => { - commands.executeCommand('editor.action.format'); - })); - - // register formatting providers - ctx.subscriptions.push(languages.registerDocumentFormattingEditProvider('xml', new XmlDocumentFormattingProvider())); - ctx.subscriptions.push(languages.registerDocumentRangeFormattingEditProvider('xml', new XmlRangeFormattingProvider())); +'use strict'; + +import { commands, languages, ExtensionContext } from 'vscode'; +import { linearizeXml, XmlDocumentFormattingProvider, XmlRangeFormattingProvider } from './features/xmlFormatting'; +import { evaluateXPath } from './features/xmlXPathEngine'; + +export function activate(ctx: ExtensionContext) { + // register palette commands + ctx.subscriptions.push(commands.registerTextEditorCommand('xmltools.linearizeXml', linearizeXml)); + ctx.subscriptions.push(commands.registerTextEditorCommand('xmltools.evaluateXPath', evaluateXPath)); + + // alias for editor.action.format + ctx.subscriptions.push(commands.registerTextEditorCommand('xmlTools.formatXml', () => { + commands.executeCommand('editor.action.format'); + })); + + // register formatting providers + ctx.subscriptions.push(languages.registerDocumentFormattingEditProvider('xml', new XmlDocumentFormattingProvider())); + ctx.subscriptions.push(languages.registerDocumentRangeFormattingEditProvider('xml', new XmlRangeFormattingProvider())); } \ No newline at end of file diff --git a/src/utils/ManifestUtils.ts b/src/utils/ManifestUtils.ts deleted file mode 100644 index 2645359..0000000 --- a/src/utils/ManifestUtils.ts +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -import { extensions, Extension } from 'vscode'; - -export class ExtensionManifestReader { - constructor(extensionId: string) { - this._extension = extensions.getExtension(extensionId); - this.refresh(); - } - - private _extension: Extension - - name: string; - version: string; - publisher: string; - displayName: string; - description: string; - categories: string[]; - keywords: string[]; - icon: string; - - refresh(): void { - let manifest = this._extension.packageJSON; - - this.name = manifest.name; - this.version = manifest.version; - this.publisher = manifest.publisher; - this.displayName = manifest.displayName; - this.description = manifest.description; - this.categories = manifest.categories; - this.keywords = manifest.keywords; - this.icon = manifest.icon; - } -} \ No newline at end of file diff --git a/src/utils/UpdateNotifier.ts b/src/utils/UpdateNotifier.ts deleted file mode 100644 index 8b62fc4..0000000 --- a/src/utils/UpdateNotifier.ts +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -import { window, commands } from 'vscode'; -import { ExtensionManifestReader } from './ManifestUtils'; - -let req = require('request'); -let semver = require('semver'); - -export function checkForUpdates() { - let manifestReader: ExtensionManifestReader = new ExtensionManifestReader('DotJoshJohnson.xml'); - let currentVersion = manifestReader.version; - - // use the GitHub api to determine the latest released version - let url = 'https://api.github.com/repos/DotJoshJohnson/vscode-xml/releases/latest'; - let options = { - url: url, - headers: { - // the GitHub API requires a user agent header - // we are spoofing a Chrome user agent string here - 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36' - } - } - - req(options, (error, response, body) => { - if (!error && response.statusCode == 200) { - let release = JSON.parse(body); - let latestVersion = release.name.substring(1); // the release/tag is prefixed with a "v" - - if (!release.draft && semver.gt(latestVersion, currentVersion)) { - let updateNowLabel = 'Open Extension Manager'; - window.showInformationMessage(`Version ${latestVersion} of the ${manifestReader.displayName} extension is available.`, updateNowLabel).then((clicked) => { - if (clicked == updateNowLabel) { - commands.executeCommand('workbench.extensions.action.listExtensions', manifestReader.displayName); - } - }); - } - } - - else { - console.log('XML Tools: Failed to get latest release information from GitHub.'); - } - }); -} \ No newline at end of file