From 8f3fb4474cdd8f56a94d6659124d4d7ddbbf8db7 Mon Sep 17 00:00:00 2001 From: shmyga Date: Wed, 25 Apr 2018 15:37:59 +0300 Subject: [PATCH] [gulp] update --- ansible/roles/build/tasks/main.yml | 2 +- build/client.js | 140 ------------------ build/server.js | 47 ------ gulpfile.js | 34 +++-- .../usr/share/applications/tankz.desktop | 9 -- src/client/html/index.html | 28 ---- src/client/html/js/swf.js | 88 ----------- 7 files changed, 24 insertions(+), 324 deletions(-) delete mode 100755 build/client.js delete mode 100755 build/server.js delete mode 100644 src/client/debian/usr/share/applications/tankz.desktop delete mode 100644 src/client/html/index.html delete mode 100644 src/client/html/js/swf.js diff --git a/ansible/roles/build/tasks/main.yml b/ansible/roles/build/tasks/main.yml index 1225248..fc11f17 100644 --- a/ansible/roles/build/tasks/main.yml +++ b/ansible/roles/build/tasks/main.yml @@ -6,6 +6,6 @@ remote_src: true - name: "Gulp build" - command: "/usr/local/bin/gulp default" + command: "/usr/local/lib/npm/bin/gulp default" args: chdir: "{{ deploy_release_dir }}" diff --git a/build/client.js b/build/client.js deleted file mode 100755 index 1441a3a..0000000 --- a/build/client.js +++ /dev/null @@ -1,140 +0,0 @@ -const gulp = require('gulp'); -const concat = require('gulp-concat'); -const uglify = require('gulp-uglify'); -const babel = require('gulp-babel'); -const template = require('gulp-template'); -const {Haxe, FlashPlayer} = require('gulp-haxetool'); -const version = require('./version'); -const prepare = require('./prepare'); -const generate = prepare.generate; -const Debug = require('./debug'); -const webserver = require('gulp-webserver'); -const run = require('gulp-run'); -const tail = require('./tail'); -const deb = require('gulp-debian'); -const dateformat = require('dateformat'); - - -const build = (platform, values, debug) => function build() { - const build = dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'); - let macro = [`CompilationOption.set('build','${build}')`]; - if (debug) macro = macro.concat(debug.macro()); - return gulp.src('.') - .pipe(new Haxe().openfl({ - command: 'build', - platform: platform, - version: version, - debug: debug, - values: {...values, proto_debug:debug}, - macro: macro, - })) - .pipe(gulp.dest(`target/${platform}`)); -}; - -const flashIndex = function() { - return gulp.src('src/client/html/index.html') - .pipe(template({ - scripts: ['app.min.js'], - swf: 'tankz.swf' - })) - .pipe(gulp.dest('target/flash')) -}; - -const flashJs = function() { - const src = [ - 'src/client/html/js/*.js' - ]; - return gulp.src(src) - .pipe(babel({presets: ['es2015']})) - .pipe(uglify()) - .pipe(concat('app.min.js')) - .pipe(gulp.dest('target/flash')) -}; - -const webapp = function () { - return gulp.src('src/webapp/*').pipe(gulp.dest('target')); -}; - - -const buildDeb = gulp.series( - () => gulp.src('src/client/debian/**/*').pipe(gulp.dest('target/debian')), - () => gulp.src('target/linux/**/*').pipe(gulp.dest('target/debian/usr/share/tankz')), - () => gulp.src('target/debian/*') - .pipe(deb({ - package: 'tankz', - version: version, - section: 'base', - priority: 'optional', - architecture: 'all', - maintainer: 'shmyga ', - description: 'Tank\'z', - changelog: [], - postinst: [ - 'if [ "$1" = "configure" ] && [ -x "`which update-menus 2>/dev/null`" ] ; then\n' + - ' update-menus\n' + - 'fi' - ], - _target: '/', - _out: 'target', - _clean: false, - _verbose: true - })) -); - - -exports['client:flash:html'] = gulp.parallel(flashIndex, flashJs); -exports['client:flash'] = gulp.series(prepare(Haxe.ID), generate(), build('flash'), exports['client:flash:html']); -exports['client:html5'] = gulp.series(prepare(Haxe.ID), generate(), build('html5')); -exports['client:html5-dom'] = gulp.series(prepare(Haxe.ID), generate(), build('html5', {dom:true})); -exports['client:linux'] = gulp.series(prepare(Haxe.ID), generate(), build('linux')); -exports['client:webapp'] = webapp; -exports['client:deb'] = buildDeb; -exports['client'] = gulp.series( - prepare(Haxe.ID), - generate(), - gulp.parallel(build('flash'), build('html5'), build('linux')), - exports['client:flash:html'], - webapp, - buildDeb, -); - - - -const testFlash = function() { - const debug = new Debug(); - return build('flash', {}, debug)() - .pipe(new FlashPlayer().run(true)) - .pipe(debug.run()); -}; - -const testHtml5 = (dom) => function() { - return gulp.series( - build('html5', {dom:dom}), - () => gulp.src('target/html5').pipe(webserver({ - host: 'localhost', port: 3000, - open: true, - fallback: 'index.html' - })) - )(); -}; - -const testLinux = () => { - const debug = new Debug(); - return gulp.series( - build('linux', {}, debug), - () => gulp.src('target/linux/tankz') - .pipe(run('./tankz', {cwd: 'target/linux', verbosity: 1})) - .pipe(tail(Debug.log)) - //.pipe(gulp.dest('target/log')) - )(); -}; - - - -exports['client:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), generate(), testFlash); -exports['client:html5:test'] = gulp.series(prepare(Haxe.ID), generate(), testHtml5()); -exports['client:html5-dom:test'] = gulp.series(prepare(Haxe.ID), generate(), testHtml5(true)); -exports['client:linux:test'] = gulp.series(prepare(Haxe.ID), generate(), testLinux); -exports['client:test'] = exports['client:flash:test']; - - diff --git a/build/server.js b/build/server.js deleted file mode 100755 index 7bfe5a2..0000000 --- a/build/server.js +++ /dev/null @@ -1,47 +0,0 @@ -const gulp = require('gulp'); -const {Haxe, Neko} = require('gulp-haxetool'); -const version = require('./version'); -const prepare = require('./prepare'); -const generate = prepare.generate; -const Debug = require('./debug'); -const dateformat = require('dateformat'); - - -const build = () => function build(debug) { - const build = dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss'); - let macro = [`CompilationOption.set('build','${build}')`]; - if (debug) macro = macro.concat(debug.macro()); - return gulp.src('.') - .pipe(new Haxe().build({ - platform: 'neko', - version: version, - lib: [ - 'protohx:0.4.6', - 'haxework:git', - 'haxe-crypto:0.0.7', - 'yield:1.1.2', - ], - cp: [ - 'src/common/haxe', - 'src/server/haxe', - 'src-gen/haxe', - ], - main: 'ru.m.tankz.server.Server', - outputFile: 'server.n', - debug: debug, - macro: macro, - values: {proto_debug: debug} - })) - .pipe(gulp.dest('target')); -}; - -const test = (build) => function test() { - const debug = new Debug(); - return build(debug) - .pipe(new Neko().run('localhost')) - .pipe(debug.run()); -}; - - -exports['server'] = gulp.series(prepare(Haxe.ID), generate(), build()); -exports['server:test'] = gulp.series(prepare(Haxe.ID), generate(), test(build())); diff --git a/gulpfile.js b/gulpfile.js index d1febbf..74aed62 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,6 @@ "use strict"; const gulp = require('gulp'); -const clean = require('gulp-clean'); +const gulpClean = require('gulp-clean'); const Config = require('./config.json'); const packageInfo = require('./package.json'); const {Sdk, Haxe, Project} = require('gulp-haxetool'); @@ -11,28 +11,22 @@ if (Config.SdkDir) { Sdk.dir = Config.SdkDir; } -exports.clean = () => { - return gulp.src('target/*', {read: false}).pipe(clean()); +exports.clean = function clean() { + return gulp.src('target/*', {read: false}).pipe(gulpClean()); }; -exports.generate = () => { +exports.generate = function generate() { return new Haxe().haxelib([ 'run', 'protohx', 'generate', 'protohx.json' ]); }; -exports.install = () => { +exports.install = function install() { return new Haxe().install(packageInfo.haxeDependencies); }; /** * ToDo: - * install before build? - * generate before build? - * [haxe] generate project.xml | project.hxp (http://www.openfl.org/lime/docs/project-files/hxp-format/) - * [haxe] another /tmp/build directories for another builds - * debug without sockets? - * linux deb package * windows target * window exe package (innosetup) * flash html wrapper @@ -41,7 +35,10 @@ exports.install = () => { const config = new Project.Config({ meta: { title: 'Tank\'z', + filename: 'tankz', + icon: 'resources/images/tank/player/tank_p3_0-0.png', pack: 'ru.m.tankz', + author: 'shmyga ', company: 'MegaLoMania', version: packageInfo.version, }, @@ -97,3 +94,18 @@ const server = new Project( main: 'ru.m.tankz.server.Server', }) ).bind(module, gulp); + +/** + * default + */ +module.exports.default = gulp.series( + exports.clean, + exports.install, + exports.generate, + module.exports['client:flash:build'], + module.exports['client:html5:build'], + module.exports['client:linux:build'], + module.exports['server:neko:build'], + module.exports['client:flash:pack'], + module.exports['client:linux:pack'], +); \ No newline at end of file diff --git a/src/client/debian/usr/share/applications/tankz.desktop b/src/client/debian/usr/share/applications/tankz.desktop deleted file mode 100644 index 88dba30..0000000 --- a/src/client/debian/usr/share/applications/tankz.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Type=Application -Comment=Tank'z game -Exec=bash -c 'cd "/usr/share/tankz" && ./tankz' -Icon=/usr/share/tankz/resources/images/tank/player/tank_p3_0-0.png -Name=Tank'z -Categories=Game -Terminal=false diff --git a/src/client/html/index.html b/src/client/html/index.html deleted file mode 100644 index 217ae12..0000000 --- a/src/client/html/index.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Tank'z - <% scripts.forEach(function(script) { %> - - <% }); %> - - - -
- - - \ No newline at end of file diff --git a/src/client/html/js/swf.js b/src/client/html/js/swf.js deleted file mode 100644 index d2e7a63..0000000 --- a/src/client/html/js/swf.js +++ /dev/null @@ -1,88 +0,0 @@ -class Swf { - - constructor(element, swf, options) { - this.id = Math.floor(Math.random() * 10000); - this.options = Object.assign({ - quality: "high", - wMode: "opaque", - width: "100%", - height: "100%", - vars: {}, - }, options); - this.element = element; - this.swf = swf; - this.data = { - params: { - id: this.id, - quality: this.options.quality, - allowScriptAccess: "always", - allowFullScreen: true, - wMode: this.options.wMode, - //base: base, - swLiveConnect: true - }, - properties: { - name: this.id, - width: this.options.width, - height: this.options.height - }, - vars: this.options.vars - }; - this.swf = Swf.buildFlashElement(swf, this.data); - this.element.appendChild(this.swf); - } - - static toFlashVars(object, base) { - var queryString = []; - for (var key in object) { - var value = object[key]; - if (base) key = base + ":" + key; - var result; - switch (typeof value) { - case "object": - result = this.toFlashVars(value, key); - break; - case "array": - var qs = {}; - value.each(function (val, i) { - qs[i] = val; - }); - result = this.toFlashVars(qs, key); - break; - default: - result = key + "=" + encodeURIComponent(value); - } - if (value != null) queryString.push(result); - } - return queryString.join("&"); - } - - static buildFlashElement(path, options) { - var params = options.params; - var vars = options.vars; - var properties = options.properties; - - params.flashVars = this.toFlashVars(vars); - var isIE = /*@cc_on!@*/false; - if (isIE) { - properties.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; - params.movie = path; - } else { - properties.type = "application/x-shockwave-flash"; - } - properties.data = path; - - var build = ""; - } - build += ""; - - var div = document.createElement("div"); - div.innerHTML = build; - return div.firstChild; - } - -}