[build] generate proto clasess

This commit is contained in:
2018-01-01 20:35:28 +03:00
parent 61b78ad4d9
commit f1156d0779
5 changed files with 45 additions and 14 deletions

View File

@@ -7,6 +7,12 @@ const prepare = require('./prepare');
const debug = require('../tasks/debug'); const debug = require('../tasks/debug');
const generate = () => function generate() {
return new Haxe().haxelib([
'run', 'protohx', 'generate', 'protohx.json'
]);
};
const build = () => function build() { const build = () => function build() {
const argv = yargs.argv; const argv = yargs.argv;
return gulp.src('.') return gulp.src('.')
@@ -28,5 +34,5 @@ const test = (build) => function test() {
}; };
exports['client'] = gulp.series(prepare(Haxe.ID), build()); exports['client'] = gulp.series(prepare(Haxe.ID), generate(), build());
exports['client:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), test(build())); exports['client:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), test(build()));

View File

@@ -24,4 +24,4 @@ set :gulp_target_path, -> { release_path }
set :gulp_tasks, 'client' set :gulp_tasks, 'client'
set :gulp_flags, '--no-color' set :gulp_flags, '--no-color'
set :gulp_roles, :web set :gulp_roles, :web
# before 'deploy:updated', 'gulp' before 'deploy:updated', 'gulp'

View File

@@ -14,6 +14,7 @@
"plugin-error": "^0.1.2", "plugin-error": "^0.1.2",
"progress": "^2.0.0", "progress": "^2.0.0",
"promise-streams": "^2.1.1", "promise-streams": "^2.1.1",
"tar": "^4.2.0",
"tmp-file": "^2.0.1", "tmp-file": "^2.0.1",
"unzip-stream": "^0.2.1", "unzip-stream": "^0.2.1",
"yargs": "^10.0.3" "yargs": "^10.0.3"

View File

@@ -1,5 +1,4 @@
const fs = require('fs'); const fs = require('fs');
const os = require('os');
const path = require('path'); const path = require('path');
const tmp = require('tmp-file'); const tmp = require('tmp-file');
const exec = require('./exec'); const exec = require('./exec');
@@ -15,9 +14,9 @@ const log = require('fancy-log');
class Haxe extends Sdk { class Haxe extends Sdk {
getBin(name) { getBin(name) {
if (os.type() === 'Windows_NT') { if (Sdk.System.isWindows) {
return `${this.binPath}/${name}.exe`; return `${this.binPath}/${name}.exe`;
} else if (os.type() === 'Linux') { } else if (Sdk.System.isLinux) {
const binPath = `${this.binPath}/${name}`; const binPath = `${this.binPath}/${name}`;
fs.chmodSync(binPath, 0o755); fs.chmodSync(binPath, 0o755);
return binPath; return binPath;
@@ -50,12 +49,10 @@ class Haxe extends Sdk {
} }
get link() { get link() {
if (os.type() === 'Windows_NT') { if (Sdk.System.isWindows) {
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`; return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-win.zip`;
} else if (os.type() === 'Linux') { } else if (Sdk.System.isLinux) {
let arch = null; let arch = Sdk.System.archInt;
if (os.arch() === 'ia32') { arch = '32'}
if (os.arch() === 'x64') { arch = '64'}
return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`; return `https://github.com/HaxeFoundation/haxe/releases/download/${this.version}/haxe-${this.version}-linux${arch}.tar.gz`;
} }
} }
@@ -66,7 +63,8 @@ class Haxe extends Sdk {
haxelib(args) { haxelib(args) {
const haxelibBin = this.haxelibBin; const haxelibBin = this.haxelibBin;
return exec(this.binPath, [path.basename(haxelibBin)].concat(args).join(' ')); //return exec(this.binPath, [path.basename(haxelibBin)].concat(args).join(' '));
return exec('.', [haxelibBin].concat(args).join(' '));
} }
install(packages) { install(packages) {

View File

@@ -3,11 +3,37 @@ const fs = require('fs');
const ps = require('promise-streams'); const ps = require('promise-streams');
const got = require('got'); const got = require('got');
const unzip = require('unzip-stream'); const unzip = require('unzip-stream');
const tar = require('tar');
const ProgressBar = require('progress'); const ProgressBar = require('progress');
const colors = require('ansi-colors'); const colors = require('ansi-colors');
const log = require('fancy-log'); const log = require('fancy-log');
class System {
static get isWindows() {
return os.type() === 'Windows_NT';
}
static get isLinux() {
return os.type() === 'Linux';
}
static get archInt() {
if (os.arch() === 'ia32') return 32;
if (os.arch() === 'x64') return 64;
}
static get isArch32() {
return this.archInt === 32;
}
static get isArch64() {
return this.archInt === 64;
}
}
class Sdk { class Sdk {
static set dir(value) { static set dir(value) {
Sdk._dir = value Sdk._dir = value
@@ -56,12 +82,10 @@ class Sdk {
const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true}); const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true});
let stream = got.stream(this.link); let stream = got.stream(this.link);
stream = stream.on('downloadProgress', (p) => bar.update(p.percent)); stream = stream.on('downloadProgress', (p) => bar.update(p.percent));
//stream = stream.pipe(fs.createWriteStream(this.path + '.zip'));
if (this.link.endsWith('.zip')) { if (this.link.endsWith('.zip')) {
stream = stream.pipe(unzip.Extract({path: this.path})); stream = stream.pipe(unzip.Extract({path: this.path}));
} else if (this.link.endsWith('tar.gz')) { } else if (this.link.endsWith('tar.gz')) {
// ToDo: unpack tar.gz stream = stream.pipe(tar.x({C: this.path}));
//stream = stream.pipe(gunzip()).pipe(untar())
} else { } else {
stream = stream.pipe(fs.createWriteStream(this.path)); stream = stream.pipe(fs.createWriteStream(this.path));
} }
@@ -70,4 +94,6 @@ class Sdk {
} }
} }
Sdk.System = System;
module.exports = Sdk; module.exports = Sdk;