diff --git a/config.example.json b/config.example.json index ce6ff44..d866b9d 100755 --- a/config.example.json +++ b/config.example.json @@ -1,7 +1,8 @@ { - "SdkDir": "C:\\sdk", - "SSH": { - "PrivateKey": null, - "Passphrase": null - } + "SdkDir": "C:\\sdk", + "PublishDir": "", + "SSH": { + "PrivateKey": null, + "Passphrase": null + } } diff --git a/config.shmyga.ru.json b/config.shmyga.ru.json index 2375f9c..7037124 100644 --- a/config.shmyga.ru.json +++ b/config.shmyga.ru.json @@ -1,7 +1,9 @@ { - "SdkDir": "/home/holop/sdk", - "SSH": { - "PrivateKey": null, - "Passphrase": null - } + "SdkDir": "/home/holop/sdk", + "PublishDir": "/opt/repo/tankz", + "PublishUrl": "https://shmyga.ru/repo/tankz", + "SSH": { + "PrivateKey": null, + "Passphrase": null + } } diff --git a/gulpfile.js b/gulpfile.js index d1c1f93..a5b253c 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,9 @@ const gulpClean = require('gulp-clean'); const Config = require('./config.json'); const packageInfo = require('./package.json'); const {Sdk, Haxe, Project, FlashPlayer} = require('gulp-haxetool'); +const path = require('path'); +const fs = require('fs'); +const through = require('through2'); const dateformat = require('dateformat'); const argv = require('yargs').argv; @@ -27,7 +30,7 @@ exports.generate = function generate() { }); }; -exports.levels = function () { +exports.levels = function levels() { return gulp.src("./src/common/level/*").pipe(foreach(function (stream, file) { const type = file.path.substr(file.path.lastIndexOf("/") + 1); gulp.src("./src/common/level/" + type + "/*").pipe(foreach(function (stream, file) { @@ -155,6 +158,33 @@ const server = new Project( module.exports.generate ).bind(module, gulp); +/** + * publish + */ +exports.publish = function publish() { + const packages = []; + return gulp.src('target/client/@(android|archive|debian)/*') + .pipe(through.obj(function (file, enc, cb) { + const path = file.path.replace(file.base + '/', ''); + packages.push({ + type: path.split('/').shift(), + path: path, + filename: path.split('/').pop(), + url: `${Config.PublishUrl}/${path}`, + }); + this.push(file); + cb(null); + })) + .pipe(gulp.dest(Config.PublishDir)) + .on('end', function () { + fs.writeFileSync(path.join(Config.PublishDir, 'packages.json'), JSON.stringify({ + 'name': packageInfo.name, + 'version': packageInfo.version, + 'packages': packages, + }, null, 4)); + }); +}; + /** * default */ @@ -166,6 +196,7 @@ module.exports.default = gulp.series( module.exports['client:html5:build'], module.exports['client:linux:build'], module.exports['client:linux:deb'], + module.exports['client:linux:archive'], module.exports['client:android:build'], module.exports['editor:flash:build'], @@ -173,4 +204,5 @@ module.exports.default = gulp.series( module.exports['editor:html5:build'], module.exports['server:neko:build'], + exports.publish, ); diff --git a/package.json b/package.json index d1f4717..703f3e8 100755 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "gulp-add": "0.0.2", "gulp-clean": "^0.4.0", "gulp-foreach": "^0.1.0", - "gulp-haxetool": "0.0.21", + "gulp-haxetool": "0.0.22", "gulp-zip": "^5.0.0", "yargs": "^13.2.4" }, diff --git a/src/client/haxe/ru/m/Device.hx b/src/client/haxe/ru/m/Device.hx index 50d67d3..13f8d22 100644 --- a/src/client/haxe/ru/m/Device.hx +++ b/src/client/haxe/ru/m/Device.hx @@ -7,7 +7,9 @@ class Device { ]; public static function isMobile():Bool { - #if js + #if android + return true; + #elseif js var userAgent = js.Browser.navigator.userAgent; for (mobile in MOBILES) { if (userAgent.indexOf(mobile) > -1) {