From 2b703fb66ad215df8ffa13f518a40b99d65bb779 Mon Sep 17 00:00:00 2001 From: shmyga Date: Mon, 26 Aug 2019 14:43:58 +0300 Subject: [PATCH] [project] add LinuxArchivePacker --- haxetool/haxe.js | 12 +++++++++--- haxetool/project.js | 26 +++++++++++++++++++++++++- package.json | 4 +++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/haxetool/haxe.js b/haxetool/haxe.js index fcc7a58..a04b96c 100755 --- a/haxetool/haxe.js +++ b/haxetool/haxe.js @@ -8,7 +8,7 @@ const Env = require('./env'); const Neko = require('./neko'); const vfs = require('vinyl-fs'); const template = require('lodash.template'); - +const rename = require('gulp-rename'); class Haxe extends Sdk { @@ -98,10 +98,16 @@ class Haxe extends Sdk { const target = path.resolve(buildDir, platform, 'bin'); fse.emptyDirSync(target); const result = { - 'android': 'app/build/outputs/apk/*.apk', + 'android': 'app/build/outputs/apk/*-debug.apk', 'flash': '*.swf', }[platform] || '**/*'; - return this.haxelib(args).then(() => vfs.src(`${target}/${result}`)); + return this.haxelib(args).then(() => { + let r = vfs.src(`${target}/${result}`); + if (platform === 'android') { + r = r.pipe(rename(`${config.meta.filename}_${config.meta.version}.apk`)); + } + return r; + }); } build(platform, config, debug=false) { diff --git a/haxetool/project.js b/haxetool/project.js index 28b156d..587b260 100644 --- a/haxetool/project.js +++ b/haxetool/project.js @@ -18,7 +18,8 @@ const {BuildSystem, Platform, Config} = require('./core'); const vfs = require('vinyl-fs'); const rename = require('gulp-rename'); const template = require('lodash.template'); - +const tar = require('gulp-tar'); +const gzip = require('gulp-gzip'); const streamToPromise = (stream) => { return new Promise((resolve, reject) => { @@ -219,6 +220,29 @@ LinuxDEBPacker.NAME = 'deb'; Packer.register(Platform.LINUX, LinuxDEBPacker.NAME, LinuxDEBPacker); +/** + * + */ +class LinuxArchivePacker extends Packer { + + constructor(config) { + super(config, Platform.LINUX); + } + + call() { + const target = this.targetPath; + const archiveName = `${this.config.meta.filename}_${this.config.meta.version}.tar`; + return gulp.src(`${target}/**/*`) + .pipe(tar(archiveName)) + .pipe(gzip()) + .pipe(gulp.dest(path.join(target, '..', 'archive'))) + } +} + +LinuxArchivePacker.NAME = 'archive'; + +Packer.register(Platform.LINUX, LinuxArchivePacker.NAME, LinuxArchivePacker); + /** * */ diff --git a/package.json b/package.json index 207862b..677de57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-haxetool", - "version": "0.0.21", + "version": "0.0.22", "description": "HaXe Tool for Gulp", "main": "index.js", "dependencies": { @@ -11,8 +11,10 @@ "got": "^8.3.0", "gulp": "^4.0.0", "gulp-debian": "^0.1.9", + "gulp-gzip": "^1.4.2", "gulp-rename": "^1.2.2", "gulp-spawn": "^0.4.0", + "gulp-tar": "^3.0.0", "gulp-webserver": "^0.9.1", "lodash.defaults": "^4.2.0", "lodash.template": "^4.4.0",