Download and start Sonarr using gulp (Can work on UI without VS)
This commit is contained in:
parent
8fede1efc9
commit
05dc68d689
|
@ -130,3 +130,4 @@ output/*
|
||||||
#OS X metadata files
|
#OS X metadata files
|
||||||
._*
|
._*
|
||||||
|
|
||||||
|
_start
|
||||||
|
|
|
@ -8,5 +8,4 @@ require('./less.js');
|
||||||
require('./stripBom.js');
|
require('./stripBom.js');
|
||||||
require('./imageMin.js');
|
require('./imageMin.js');
|
||||||
require('./webpack.js');
|
require('./webpack.js');
|
||||||
|
require('./start.js');
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
// will download and run sonarr (server) in a non-windows enviroment
|
||||||
|
// you can use this if you don't care about the server code and just want to work
|
||||||
|
// with the web code.
|
||||||
|
|
||||||
|
var http = require('http');
|
||||||
|
var gulp = require('gulp');
|
||||||
|
var fs = require('fs');
|
||||||
|
var targz = require('tar.gz');
|
||||||
|
var del = require('del');
|
||||||
|
var print = require('gulp-print');
|
||||||
|
var spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
function download(url, dest, cb) {
|
||||||
|
console.log('Downloading ' + url + ' to ' + dest);
|
||||||
|
var file = fs.createWriteStream(dest);
|
||||||
|
var request = http.get(url, function (response) {
|
||||||
|
response.pipe(file);
|
||||||
|
file.on('finish', function () {
|
||||||
|
console.log('Download completed');
|
||||||
|
file.close(cb);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLatest(cb) {
|
||||||
|
var req = http.get('http://services.sonarr.tv/v1/update/develop?os=osx', function (response) {
|
||||||
|
response.on('data', function (data) {
|
||||||
|
var updatePackage = JSON.parse(data).updatePackage;
|
||||||
|
console.log('Latest version avilable: ' + updatePackage.version + ' Release Date: ' + updatePackage.releaseDate);
|
||||||
|
cb(updatePackage);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', function (e) {
|
||||||
|
console.log('problem with request: ' + e.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function extract(source, dest, cb) {
|
||||||
|
console.log('extracting download page to ' + dest);
|
||||||
|
new targz().extract(source, dest, function (err) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
console.log('Update package extracted.');
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
gulp.task('getSonarr', function () {
|
||||||
|
|
||||||
|
//gulp.src('/Users/kayone/git/Sonarr/_start/2.0.0.3288/NzbDrone/*.*')
|
||||||
|
// .pipe(print())
|
||||||
|
// .pipe(gulp.dest('./_output
|
||||||
|
|
||||||
|
//return;
|
||||||
|
try {
|
||||||
|
fs.mkdirSync('./_start/');
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code != 'EEXIST') {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getLatest(function (package) {
|
||||||
|
var packagePath = "./_start/" + package.filename;
|
||||||
|
var dirName = "./_start/" + package.version;
|
||||||
|
download(package.url, packagePath, function () {
|
||||||
|
extract(packagePath, dirName, function () {
|
||||||
|
// clean old binaries
|
||||||
|
console.log('Cleaning old binaries')
|
||||||
|
del.sync(['./_output/*', '!./_output/UI/']);
|
||||||
|
console.log('copying binaries to target');
|
||||||
|
gulp.src(dirName + '/NzbDrone/*.*')
|
||||||
|
.pipe(gulp.dest('./_output/'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('startSonarr', function () {
|
||||||
|
|
||||||
|
var ls = spawn('mono', ['--debug', './_output/NzbDrone.exe']);
|
||||||
|
|
||||||
|
ls.stdout.on('data', function (data) {
|
||||||
|
process.stdout.write('' + data);
|
||||||
|
});
|
||||||
|
|
||||||
|
ls.stderr.on('data', function (data) {
|
||||||
|
process.stdout.write('' + data);
|
||||||
|
});
|
||||||
|
|
||||||
|
ls.on('close', function (code) {
|
||||||
|
console.log('child process exited with code ' + code);
|
||||||
|
});
|
||||||
|
});
|
|
@ -24,9 +24,9 @@
|
||||||
"gulp-jshint": "1.11.2",
|
"gulp-jshint": "1.11.2",
|
||||||
"gulp-less": "3.0.3",
|
"gulp-less": "3.0.3",
|
||||||
"gulp-print": "1.1.0",
|
"gulp-print": "1.1.0",
|
||||||
"gulp-replace": "0.5.2",
|
"gulp-replace": "0.5.3",
|
||||||
"gulp-stripbom": "1.0.4",
|
|
||||||
"gulp-run": "1.6.8",
|
"gulp-run": "1.6.8",
|
||||||
|
"gulp-stripbom": "1.0.4",
|
||||||
"gulp-webpack": "1.5.0",
|
"gulp-webpack": "1.5.0",
|
||||||
"gulp-wrap": "0.11.0",
|
"gulp-wrap": "0.11.0",
|
||||||
"handlebars": "3.0.3",
|
"handlebars": "3.0.3",
|
||||||
|
@ -34,6 +34,7 @@
|
||||||
"jshint-stylish": "2.0.1",
|
"jshint-stylish": "2.0.1",
|
||||||
"run-sequence": "1.1.1",
|
"run-sequence": "1.1.1",
|
||||||
"streamqueue": "1.1.0",
|
"streamqueue": "1.1.0",
|
||||||
|
"tar.gz": "^0.1.1",
|
||||||
"webpack": "1.10.1"
|
"webpack": "1.10.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue