diff --git a/build/client.js b/build/client.js index a35bdbc..fbf53f8 100755 --- a/build/client.js +++ b/build/client.js @@ -7,6 +7,12 @@ const prepare = require('./prepare'); const debug = require('../tasks/debug'); +const generate = () => function generate() { + return new Haxe().haxelib([ + 'run', 'protohx', 'generate', 'protohx.json' + ]); +}; + const build = () => function build() { const argv = yargs.argv; 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())); diff --git a/config/deploy.rb b/config/deploy.rb index 88b1b07..57f0372 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -24,4 +24,4 @@ set :gulp_target_path, -> { release_path } set :gulp_tasks, 'client' set :gulp_flags, '--no-color' set :gulp_roles, :web -# before 'deploy:updated', 'gulp' +before 'deploy:updated', 'gulp' diff --git a/package.json b/package.json index 0baec3d..2a36e7c 100755 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "plugin-error": "^0.1.2", "progress": "^2.0.0", "promise-streams": "^2.1.1", + "tar": "^4.2.0", "tmp-file": "^2.0.1", "unzip-stream": "^0.2.1", "yargs": "^10.0.3" diff --git a/tasks/haxe.js b/tasks/haxe.js index 12c947b..a456234 100755 --- a/tasks/haxe.js +++ b/tasks/haxe.js @@ -1,5 +1,4 @@ const fs = require('fs'); -const os = require('os'); const path = require('path'); const tmp = require('tmp-file'); const exec = require('./exec'); @@ -15,9 +14,9 @@ const log = require('fancy-log'); class Haxe extends Sdk { getBin(name) { - if (os.type() === 'Windows_NT') { + if (Sdk.System.isWindows) { return `${this.binPath}/${name}.exe`; - } else if (os.type() === 'Linux') { + } else if (Sdk.System.isLinux) { const binPath = `${this.binPath}/${name}`; fs.chmodSync(binPath, 0o755); return binPath; @@ -50,12 +49,10 @@ class Haxe extends Sdk { } 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`; - } else if (os.type() === 'Linux') { - let arch = null; - if (os.arch() === 'ia32') { arch = '32'} - if (os.arch() === 'x64') { arch = '64'} + } else if (Sdk.System.isLinux) { + let arch = Sdk.System.archInt; 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) { 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) { diff --git a/tasks/sdk.js b/tasks/sdk.js index 10a8cda..00fffb2 100755 --- a/tasks/sdk.js +++ b/tasks/sdk.js @@ -3,11 +3,37 @@ const fs = require('fs'); const ps = require('promise-streams'); const got = require('got'); const unzip = require('unzip-stream'); +const tar = require('tar'); const ProgressBar = require('progress'); const colors = require('ansi-colors'); 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 { static set 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}); let stream = got.stream(this.link); stream = stream.on('downloadProgress', (p) => bar.update(p.percent)); - //stream = stream.pipe(fs.createWriteStream(this.path + '.zip')); if (this.link.endsWith('.zip')) { stream = stream.pipe(unzip.Extract({path: this.path})); } else if (this.link.endsWith('tar.gz')) { - // ToDo: unpack tar.gz - //stream = stream.pipe(gunzip()).pipe(untar()) + stream = stream.pipe(tar.x({C: this.path})); } else { stream = stream.pipe(fs.createWriteStream(this.path)); } @@ -70,4 +94,6 @@ class Sdk { } } +Sdk.System = System; + module.exports = Sdk; \ No newline at end of file