[gulp] update
This commit is contained in:
@@ -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 }}"
|
||||
|
||||
140
build/client.js
140
build/client.js
@@ -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 <shmyga.z@gmail.com>',
|
||||
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'];
|
||||
|
||||
|
||||
@@ -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()));
|
||||
34
gulpfile.js
34
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 <shmyga.z@gmail.com>',
|
||||
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'],
|
||||
);
|
||||
@@ -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
|
||||
@@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Tank'z</title>
|
||||
<% scripts.forEach(function(script) { %>
|
||||
<script type="text/javascript" src="<%-script%>"></script>
|
||||
<% }); %>
|
||||
<style type="text/css">
|
||||
html, body, #container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
<script type="text/javascript">
|
||||
new Swf(
|
||||
document.getElementById('container'),
|
||||
'<%-swf%>',
|
||||
);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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 = "<object id=\"" + params.id + "\"";
|
||||
for (var property in properties) build += " " + property + "=\"" + properties[property] + "\"";
|
||||
build += ">";
|
||||
for (var param in params) {
|
||||
if (params[param]) build += "<param name=\"" + param + "\" value=\"" + params[param] + "\" />";
|
||||
}
|
||||
build += "</object>";
|
||||
|
||||
var div = document.createElement("div");
|
||||
div.innerHTML = build;
|
||||
return div.firstChild;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user