Skip to content

Commit

Permalink
Merge pull request #341 from Microsoft/csharp-o-github-releases
Browse files Browse the repository at this point in the history
Use auth tokens for downloading omnisharp builds from GitHub
  • Loading branch information
jrieken committed Nov 20, 2015
2 parents e5e7912 + e3c9e05 commit bd854fc
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 107 deletions.
54 changes: 46 additions & 8 deletions extensions/csharp-o/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,60 @@
var gulp = require('gulp');
var decompress = require('gulp-decompress');
var download = require('gulp-download');
var es = require('event-stream');
var GitHub = require('github-releases');
var tmp = require('tmp');
var vfs = require('vinyl-fs');
var del = require('del');
var fs = require('fs');
var join = require('path').join;
var path = require('path');

tmp.setGracefulCleanup();

function downloadOmnisharp(version) {
var result = es.through();

function onError(err) {
result.emit('error', err);
}

var repo = new GitHub({
repo: 'OmniSharp/omnisharp-roslyn',
token: process.env['GITHUB_TOKEN']
});

repo.getReleases({ tag_name: version }, function (err, releases) {
if (err) { return onError(err); }
if (!releases.length) { return onError(new Error('Release not found')); }
if (!releases[0].assets.length) { return onError(new Error('Assets not found')); }

repo.downloadAsset(releases[0].assets[0], function (err, istream) {
if (err) { return onError(err); }

tmp.file(function (err, tmpPath, fd, cleanupCallback) {
if (err) { return onError(err); }

var ostream = fs.createWriteStream(null, { fd: fd });
ostream.once('error', onError);
istream.once('error', onError);
ostream.once('finish', function () {
vfs.src(tmpPath).pipe(result);
});
istream.pipe(ostream);
});
});
});

return result;
}

gulp.task('omnisharp:clean', function () {
return del('bin');
});

gulp.task('omnisharp:fetch', ['omnisharp:clean'], function () {

var release = 'https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.5.6/omnisharp.tar.gz';

return download(release)
return downloadOmnisharp('v1.5.6')
.pipe(decompress({strip: 1}))
.pipe(gulp.dest('bin'))
.pipe(gulp.dest('bin'));
});

gulp.task('omnisharp:fixscripts', ['omnisharp:fetch'], function () {
Expand All @@ -38,7 +76,7 @@ exec "$DIR/packages/dnx-mono.1.0.0-beta4/bin/dnx" "$DNX_APPBASE" run "$@"\n\

var promises = Object.keys(_fixes).map(function (key) {
return new Promise(function(resolve, reject) {
fs.writeFile(join(__dirname, key), _fixes[key], function (err) {
fs.writeFile(path.join(__dirname, key), _fixes[key], function (err) {
if (err) {
reject(err);
} else {
Expand Down
199 changes: 100 additions & 99 deletions extensions/csharp-o/package.json
Original file line number Diff line number Diff line change
@@ -1,101 +1,102 @@
{
"name": "csharp-o",
"version": "0.1.0",
"publisher": "vscode",
"engines": {
"node": "^4.0.0",
"vscode": "*"
},
"activationEvents": [
"onLanguage:csharp",
"onCommand:o.restart",
"onCommand:o.pickProjectAndStart",
"onCommand:o.restore",
"onCommand:o.execute",
"onCommand:o.showOutput",
"onCommand:o.execute",
"onCommand:o.execute-last-command"
],
"main": "./out/omnisharpMain",
"scripts": {
"postinstall": "node ./node_modules/gulp/bin/gulp.js omnisharp",
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../gulpfile.plugins.js compile-plugin:csharp-o ./tsconfig.json"
},
"dependencies": {
"applicationinsights": "0.15.6",
"run-in-terminal": "*",
"semver": "*"
},
"devDependencies": {
"del": "^2.0.2",
"gulp": "^3.8.9",
"gulp-decompress": "^1.2.0",
"gulp-download": "^0.0.1",
"typescript": "^1.6.2"
},
"extensionDependencies": [
"vscode.csharp"
],
"contributes": {
"commands": [
{
"command": "o.restart",
"title": "Restart OmniSharp",
"category": "OmniSharp"
},
{
"command": "o.pickProjectAndStart",
"title": "Select Project",
"category": "OmniSharp"
},
{
"command": "o.restore",
"title": "Restore Packages",
"category": "dnx"
},
{
"command": "o.execute",
"title": "Run Command",
"category": "dnx"
}
],
"keybindings": [
{
"command": "o.showOutput",
"key": "Ctrl+L L",
"mac": "Cmd+L L"
},
{
"command": "o.execute",
"key": "Ctrl+L Shift+R",
"mac": "Cmd+L Shift+R"
},
{
"command": "o.execute-last-command",
"key": "Ctrl+L R",
"mac": "Cmd+L R"
},
{
"key": "shift+0",
"command": "^acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible && editorLangId == 'csharp' && suggestionSupportsAcceptOnKey"
},
{
"key": "shift+9",
"command": "^acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible && editorLangId == 'csharp' && suggestionSupportsAcceptOnKey"
},
{
"key": ".",
"command": "^acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible && editorLangId == 'csharp' && suggestionSupportsAcceptOnKey"
}
],
"snippets": [
{
"language": "csharp",
"path": "./snippets/csharp.json"
}
]
}
"name": "csharp-o",
"version": "0.1.0",
"publisher": "vscode",
"engines": {
"node": "^4.0.0",
"vscode": "*"
},
"activationEvents": [
"onLanguage:csharp",
"onCommand:o.restart",
"onCommand:o.pickProjectAndStart",
"onCommand:o.restore",
"onCommand:o.execute",
"onCommand:o.showOutput",
"onCommand:o.execute",
"onCommand:o.execute-last-command"
],
"main": "./out/omnisharpMain",
"scripts": {
"postinstall": "node ./node_modules/gulp/bin/gulp.js omnisharp",
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../gulpfile.plugins.js compile-plugin:csharp-o ./tsconfig.json"
},
"dependencies": {
"run-in-terminal": "*",
"semver": "*"
},
"devDependencies": {
"del": "^2.0.2",
"event-stream": "^3.3.2",
"github-releases": "^0.3.0",
"gulp": "^3.8.9",
"gulp-decompress": "^1.2.0",
"tmp": "0.0.28",
"vinyl-fs": "^2.2.1"
},
"extensionDependencies": [
"vscode.csharp"
],
"contributes": {
"commands": [
{
"command": "o.restart",
"title": "Restart OmniSharp",
"category": "OmniSharp"
},
{
"command": "o.pickProjectAndStart",
"title": "Select Project",
"category": "OmniSharp"
},
{
"command": "o.restore",
"title": "Restore Packages",
"category": "dnx"
},
{
"command": "o.execute",
"title": "Run Command",
"category": "dnx"
}
],
"keybindings": [
{
"command": "o.showOutput",
"key": "Ctrl+L L",
"mac": "Cmd+L L"
},
{
"command": "o.execute",
"key": "Ctrl+L Shift+R",
"mac": "Cmd+L Shift+R"
},
{
"command": "o.execute-last-command",
"key": "Ctrl+L R",
"mac": "Cmd+L R"
},
{
"key": "shift+0",
"command": "^acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible && editorLangId == 'csharp' && suggestionSupportsAcceptOnKey"
},
{
"key": "shift+9",
"command": "^acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible && editorLangId == 'csharp' && suggestionSupportsAcceptOnKey"
},
{
"key": ".",
"command": "^acceptSelectedSuggestion",
"when": "editorTextFocus && suggestWidgetVisible && editorLangId == 'csharp' && suggestionSupportsAcceptOnKey"
}
],
"snippets": [
{
"language": "csharp",
"path": "./snippets/csharp.json"
}
]
}
}

0 comments on commit bd854fc

Please sign in to comment.