[gulp] udpate project

This commit is contained in:
2018-04-04 22:49:03 +03:00
parent c70eed8a06
commit 01f811ebd2
5 changed files with 64 additions and 95 deletions

View File

@@ -1,36 +0,0 @@
const {Haxe, AdobeAir, FlashPlayer} = require('gulp-haxetool');
const packageInfo = require('../package.json');
const prepareOne = (value) => {
switch (value) {
case Haxe.ID:
const haxe = new Haxe();
return haxe.prepare().then(() => haxe.install(packageInfo.haxeDependencies));
case AdobeAir.ID:
return new AdobeAir().prepare();
case FlashPlayer.ID:
return new FlashPlayer().prepare();
default:
throw Error(`Unknown target: ${value}`)
}
};
const prepare = (...targets) => function prepare() {
const tasks = targets.map((target) => prepareOne(target));
return Promise.all(tasks);
};
const update = () => {
return new Haxe().upgrade();
};
const generate = () => function generate() {
return new Haxe().haxelib([
'run', 'protohx', 'generate', 'protohx.json'
]);
};
module.exports = prepare;
module.exports.update = update;
module.exports.generate = generate;

View File

@@ -9,7 +9,6 @@ const webserver = require('gulp-webserver');
const run = require('gulp-run');
const tail = require('./tail');
const deb = require('gulp-debian');
const dateformat = require('dateformat');
/**
*
@@ -33,6 +32,19 @@ class Config {
this.values = values;
this.macro = macro;
}
update({name, version, lib=[], cp=[], main=null, values={}, macro=[]}) {
return new Config({
name: name || this.name,
version: version || this.version,
//lib: this.lib.concat(lib), //ToDo: check if object
lib: this.lib,
cp: this.cp.concat(cp),
main: main || this.main,
values: {...this.values, ...values},
macro: this.macro.concat(macro),
})
}
}
/**
@@ -52,8 +64,7 @@ class Builder {
}
macro(debug) {
const build = dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss');
let macro = [`CompilationOption.set('build','${build}')`];
let macro = [];
if (debug) {
macro = macro.concat(debug.macro());
}
@@ -86,6 +97,9 @@ class OpenFLBuilder extends Builder {
command: 'build',
platform: this.platform,
version: this.config.version,
lib: this.config.lib,
cp: this.config.cp,
main: this.config.main,
debug: debug,
values: this.config.values,
macro: this.macro(debug),
@@ -112,10 +126,10 @@ class HaxeBuilder extends Builder {
lib: this.config.lib,
cp: this.config.cp,
main: this.config.main,
outputFile: this.config.name + '.n', // ToDo: for neko only
debug: debug,
values: this.config.values,
macro: this.macro(debug),
values: this.config.values
outputFile: this.config.name + '.n', // ToDo: for neko only
}))
.pipe(gulp.dest(`${this.target}/${this.platform}`));
}