diff --git a/.gitignore b/.gitignore index b461f882f4..c18246b6f6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ project/project project/target public/trans public/compiled +public/vendor/stockfish public/images/?N-bg.svg public/piece/alpha public/piece/cburnett diff --git a/.gitmodules b/.gitmodules index 0976bcbd4e..24f38fafb5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,19 +22,12 @@ [submodule "public/vendor/shepherd"] path = public/vendor/shepherd url = https://github.com/HubSpot/shepherd -[submodule "public/vendor/stockfish.js"] - path = public/vendor/stockfish.js - url = https://github.com/niklasf/stockfish.js [submodule "public/vendor/flatpickr"] path = public/vendor/flatpickr url = https://github.com/chmln/flatpickr [submodule "public/vendor/bar-rating"] path = public/vendor/bar-rating url = https://github.com/antennaio/jquery-bar-rating -[submodule "public/vendor/stockfish.pexe"] - path = public/vendor/stockfish.pexe - url = https://github.com/niklasf/stockfish.pexe - branch = ddugovic [submodule "public/vendor/jquery-textcomplete"] path = public/vendor/jquery-textcomplete url = https://github.com/yuku-t/jquery-textcomplete diff --git a/public/vendor/stockfish.js b/public/vendor/stockfish.js deleted file mode 160000 index 96ca31e5a4..0000000000 --- a/public/vendor/stockfish.js +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 96ca31e5a405e68196cbd880dd652c48a948eb2f diff --git a/public/vendor/stockfish.pexe b/public/vendor/stockfish.pexe deleted file mode 160000 index a8bee13f7b..0000000000 --- a/public/vendor/stockfish.pexe +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a8bee13f7b45ad965499766e0c1c5d905a5c67fd diff --git a/ui/ceval/src/ctrl.js b/ui/ceval/src/ctrl.js index 3fb3aadb92..7d6bd18c5c 100644 --- a/ui/ceval/src/ctrl.js +++ b/ui/ceval/src/ctrl.js @@ -30,9 +30,9 @@ module.exports = function(opts) { var isDeeper = m.prop(false); var pool = makePool(stockfishProtocol, { - asmjs: '/assets/vendor/stockfish.js/stockfish.js?v=18', - pnacl: pnaclSupported && '/assets/vendor/stockfish.pexe/nacl/stockfish.nmf?v=16', - wasm: wasmSupported && '/assets/vendor/stockfish.js/stockfish.wasm.js?v=18', + asmjs: lichess.assetUrl('/assets/vendor/stockfish/stockfish.js'), + pnacl: pnaclSupported && lichess.assetUrl('/assets/vendor/stockfish/stockfish.nmf'), + wasm: wasmSupported && lichess.assetUrl('/assets/vendor/stockfish/stockfish.wasm.js'), onCrash: opts.onCrash }, { minDepth: minDepth, diff --git a/ui/site/gulpfile.js b/ui/site/gulpfile.js index ea856a9068..ea60173723 100644 --- a/ui/site/gulpfile.js +++ b/ui/site/gulpfile.js @@ -5,6 +5,8 @@ var browserify = require('browserify'); var uglify = require('gulp-uglify'); var streamify = require('gulp-streamify'); var concat = require('gulp-concat'); +var request = require('request'); +var download = require('gulp-download-stream'); var destination = '../../public/compiled/'; var onError = function(error) { @@ -31,6 +33,34 @@ gulp.task('ab', function() { } }); +function latestGithubRelease(repo, cb) { + request({ + url: 'https://api.github.com/repos/' + repo + '/releases/latest', + headers: { + 'User-Agent': 'lila/gulpfile.js' + } + }, function(err, res, body) { + var release = JSON.parse(body); + cb(release.assets.map(function (asset) { + return asset.browser_download_url; + })); + }); +} + +gulp.task('stockfish.pexe', function() { + latestGithubRelease('niklasf/stockfish.pexe', function(urls) { + download(urls) + .pipe(gulp.dest('../../public/vendor/stockfish/')); + }); +}); + +gulp.task('stockfish.js', function() { + latestGithubRelease('niklasf/stockfish.js', function(urls) { + download(urls) + .pipe(gulp.dest('../../public/vendor/stockfish/')); + }); +}); + gulp.task('prod-source', function() { return browserify('./src/index.js', { standalone: standalone @@ -78,8 +108,10 @@ gulp.task('standalones', function() { .pipe(gulp.dest(destination)); }); -gulp.task('dev', ['jquery-fill', 'ab', 'standalones', 'dev-source'], makeBundle('lichess.site.source.js')); -gulp.task('prod', ['jquery-fill', 'ab', 'standalones', 'prod-source'], makeBundle('lichess.site.source.min.js')); +var tasks = ['jquery-fill', 'ab', 'standalones', 'stockfish.pexe', 'stockfish.js']; + +gulp.task('dev', tasks.concat(['dev-source']), makeBundle('lichess.site.source.js')); +gulp.task('prod', tasks.concat(['prod-source']), makeBundle('lichess.site.source.min.js')); gulp.task('default', ['dev'], function() { return gulp.watch('src/*.js', ['dev']); diff --git a/ui/site/package.json b/ui/site/package.json index 2fe2359cdf..90013f7208 100644 --- a/ui/site/package.json +++ b/ui/site/package.json @@ -11,9 +11,11 @@ "devDependencies": { "browserify": "^14", "gulp": "^3", + "gulp-download-stream": "0.0.13", "gulp-streamify": "^1", "gulp-uglify": "^2", "gulp-util": "^3", + "request": "^2.81.0", "uglify-js": "^2", "vinyl-source-stream": "^1" },