[build] remove deprecated gulp-utils

This commit is contained in:
2017-12-30 17:53:25 +03:00
parent 0dd878224b
commit ecb0629494
12 changed files with 93 additions and 135 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,7 @@ out/
*.ids
*.stackdump
.idea/
.ideaDataSources/
config.json
package-lock.json
/node_modules

View File

@@ -7,7 +7,10 @@ const packages = [
{name:'lime', version:'5.3.0'},
'promhx',
'protohx',
'haxework',
//'haxework',
{name:'haxework', git:'git@bitbucket.org:shmyga/haxework.git'},
'orm',
];

View File

@@ -3,9 +3,12 @@ const os = require('os');
const gulp = require('gulp');
const clean = require('gulp-clean');
const Sdk = require('./tasks/sdk');
const FlashPlayer = require('./tasks/flashplayer');
const Config = require('./config.json');
const prepare = require('./build/prepare');
//FlashPlayer.VERSION = '25.0.0.171';
if (Config.SdkDir) {
Sdk.dir = Config.SdkDir;
}

View File

@@ -3,29 +3,19 @@
"version": "0.0.1",
"private": true,
"devDependencies": {
"async": "^2.1.2",
"dateformat": "^2.0.0",
"fs-extra": "^3.0.1",
"ansi-colors": "^1.0.1",
"async": "^2.6.0",
"download": "^6.2.5",
"fancy-log": "^1.3.2",
"fs-extra": "^5.0.0",
"got": "^8.0.1",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-add-src": "^0.2.0",
"gulp-cat": "^0.3.3",
"gulp-clean": "^0.3.2",
"gulp-exec": "^2.1.3",
"gulp-gunzip": "^1.0.0",
"gulp-mark": "0.0.2",
"gulp-replace-task": "^0.11.0",
"gulp-sequence": "^0.4.6",
"gulp-ssh": "^0.6.0",
"gulp-untar": "0.0.6",
"gulp-unzip": "^0.2.0",
"merge-stream": "^1.0.1",
"plugin-error": "^0.1.2",
"progress": "^2.0.0",
"request": "^2.81.0",
"request-progress": "^3.0.0",
"tail": "^1.2.2",
"promise-streams": "^2.1.1",
"tmp-file": "^2.0.1",
"vinyl-source-stream": "^1.1.0",
"yargs": "^8.0.2"
},
"dependencies": {}
"unzip-stream": "^0.2.1",
"yargs": "^10.0.3"
}
}

View File

@@ -1,17 +1,14 @@
const fs = require('fs');
const tmp = require('tmp-file');
const gutil = require('gulp-util');
const exec = require('./exec');
const download = require('./download');
const unzip = require('gulp-unzip');
const gulp = require('gulp');
const through = require('through2');
const mark = require('gulp-mark');
const replace = require('gulp-replace-task');
const col = gutil.colors;
//const mark = require('gulp-mark');
//const replace = require('gulp-replace-task');
const Sdk = require('./sdk');
// ToDo: remove gutil
class AdobeAir extends Sdk {
get adtBin() {

View File

@@ -1,21 +1,20 @@
const gulp = require('gulp');
const gutil = require('gulp-util');
const col = gutil.colors;
const net = require('net');
const through = require('through2');
const colors = require('ansi-colors');
const log = require('fancy-log');
const color = (level) => {
return {
'[DEBUG]': col.white,
'[INFO]': col.cyan,
'[ERROR]': col.red,
'[WARNING]': col.yellow,
}[level] || col.reset;
'[DEBUG]': colors.white,
'[INFO]': colors.cyan,
'[ERROR]': colors.red,
'[WARNING]': colors.yellow,
}[level] || colors.reset;
};
const log = (line) => {
const _log = (line) => {
const result = line.split(' ');
console.log(col.gray(result[0]) + ' ' + color(result[1])(result.slice(1).join(' ')));
console.log(colors.gray(result[0]) + ' ' + color(result[1])(result.slice(1).join(' ')));
};
module.exports = () => {
@@ -30,7 +29,7 @@ module.exports = () => {
socket.on("data", (data) => {
const lines = data.toString().split('\n');
for (let line of lines) if (line.length > 2) {
log(line);
_log(line);
}
});
socket.on("close", () => {
@@ -40,7 +39,7 @@ module.exports = () => {
callback();
});
});
gutil.log(col.green('[debug]'), col.cyan('listen on'), col.magenta(`${debug.host}:${debug.port}`));
log(colors.green('[debug]'), colors.cyan('listen on'), colors.magenta(`${debug.host}:${debug.port}`));
server.listen(debug.port, debug.host);
})
};

View File

@@ -1,24 +0,0 @@
'use strict';
const path = require('path');
const request = require('request');
const progress = require('request-progress');
const source = require('vinyl-source-stream');
const gutil = require('gulp-util');
module.exports = (url) => {
const name = path.basename(url);
let stream = null;
return stream = progress(request({url: url, encoding: null}, function(error, response, body) {
try {
if (error) throw error;
if (response.statusCode !== 200) throw `${response.statusCode} ${response.statusMessage}`;
} catch (e) {
this.emit('error', new gutil.PluginError({plugin: 'download', message: e}));
}
}))
.on('error', (e) => stream.emit('error', e))
.on('progress', (p) => stream.emit('progress', p))
.pipe(source(name));
};

View File

@@ -1,14 +1,12 @@
const gutil = require('gulp-util');
const child_process = require('child_process');
const async = require('async');
const col = gutil.colors;
const Promise = require("bluebird");
const colors = require('ansi-colors');
const log = require('fancy-log');
const TAG = col.green('[exec]');
const TAG = colors.green('[exec]');
const queue = async.queue((task, done) => {
//gutil.log(TAG, col.magenta(task.command));
//log(TAG, colors.magenta(task.command));
//process.chdir(task.dir);
child_process.exec(task.command, {cwd: task.dir, maxBuffer: 1024 * 5000}, (err, stdout, stderr) => {
if (err) {

View File

@@ -2,14 +2,13 @@ const path = require('path');
const fs = require('fs');
const fse = require('fs-extra');
const os = require('os');
const gunzip = require('gulp-gunzip');
const untar = require('gulp-untar');
const through = require('through2');
const gulp = require('gulp');
const gutil = require('gulp-util');
const Sdk = require('./sdk');
const exec = require('./exec');
const col = gutil.colors;
const PluginError = require('plugin-error');
const colors = require('ansi-colors');
const log = require('fancy-log');
class FlashPlayer extends Sdk {
@@ -35,6 +34,7 @@ class FlashPlayer extends Sdk {
const extract = (debug) => {
const v = this.version.split('.');
const playerPath = this.playerPath(debug);
// ToDo: fix
const archive = `${playerPath}/flashplayer${v[0]}_${v[1]}r${v[2]}_${v[3]}_linux_sa${debug ? '_debug' : ''}.${arch}.tar.gz`;
return gulp.src(archive)
.pipe(gunzip()).pipe(untar())
@@ -120,20 +120,20 @@ class FlashPlayer extends Sdk {
run(debug) {
let stream = null;
const bufferContents = (file, enc, callback) => {
gutil.log(this.tag, col.cyan("run"), col.magenta(file.path));
log(this.tag, colors.cyan("run"), colors.magenta(file.path));
FlashPlayer.trust(file.path);
FlashPlayer.enableLog();
exec('.', [this.flashPlayerBin(debug), file.path].join(' ')).then(() => {
stream.emit('end');
callback();
}).catch((error) => {
stream.emit('error', new gutil.PluginError({plugin: this.tag, message: error}));
stream.emit('error', new PluginError({plugin: this.tag, message: error}));
callback();
});
//stream.push(file);
// ToDo: watch when file is exists
// or create log file in FlashPlayer.enableLog()?
/*stream.push(new gutil.File({
/*stream.push(new Vinyl({
path: FlashPlayer.log
}));*/
stream.push(file);

View File

@@ -2,14 +2,14 @@ const fs = require('fs');
const os = require('os');
const path = require('path');
const tmp = require('tmp-file');
const gutil = require('gulp-util');
const exec = require('./exec');
const download = require('./download');
const gulp = require('gulp');
const through = require('through2');
const col = gutil.colors;
const Sdk = require('./sdk');
const dateformat = require('dateformat');
const Vinyl = require('vinyl');
const PluginError = require('plugin-error');
const colors = require('ansi-colors');
const log = require('fancy-log');
class Haxe extends Sdk {
@@ -26,15 +26,7 @@ class Haxe extends Sdk {
}
get binPath() {
if (os.type() === 'Windows_NT') {
if (this.intVersion >= 342) {
return `${this.path}`;
} else {
return `${this.path}/haxe-${this.version}`;
}
} else if (os.type() === 'Linux') {
return `${this.path}/haxe-${this.version}`;
}
return `${this.path}/haxe-${this.version}`;
}
get haxeBin() {
@@ -80,7 +72,7 @@ class Haxe extends Sdk {
install(packages) {
let promise = this.haxelib(['setup', `${this.path}/lib`]);
const next = (args) => () => {
gutil.log(this.tag, col.cyan('haxelib', 'install'), col.magenta(args[1]));
log(this.tag, colors.cyan('haxelib', 'install'), colors.magenta(args[1]));
return this.haxelib(args);
};
@@ -146,7 +138,7 @@ class Haxe extends Sdk {
};
const endStream = (callback) => {
gutil.log(this.tag, col.cyan("openfl", params.command, params.platform), '=>', col.magenta(params.outputFile));
log(this.tag, colors.cyan("openfl", params.command, params.platform), '=>', colors.magenta(params.outputFile));
const args = ['-cwd', files[0].path, 'run', 'openfl', params.command, params.platform];
if (params.values) for (let key of Object.keys(params.values)) {
const value = params.values[key];
@@ -163,28 +155,29 @@ class Haxe extends Sdk {
args.push(`--app-file=${name}`);
if (params.version) args.push(`--meta-version=${params.version}`);
//if (params.build) args.push(`--haxedef=BUILD="${params.build}"`);
args.push(`--haxeflag="--macro=CompilationOption.set('build','${params.build}')"`);
args.push(`--haxeflag="--macro CompilationOption.set('build','${params.build}')"`);
let debug = null;
if (params.debug) {
debug = {
host: 'localhost',
port: 6000 + Math.floor(Math.random() * 1000),
};
args.push(`--haxeflag="--macro=CompilationOption.set('debug.address','${debug.host}')"`);
args.push(`--haxeflag="--macro=CompilationOption.set('debug.port','${debug.port}')"`);
args.push(`--haxeflag="--macro CompilationOption.set('debug.address','${debug.host}')"`);
args.push(`--haxeflag="--macro CompilationOption.set('debug.port','${debug.port}')"`);
args.push('-debug');
}
//console.log('haxelib', args.join(' '));
this.haxelib(args).then(() => {
const out = new gutil.File({
const out = new Vinyl({
path: params.outputFile,
contents: fs.createReadStream(`${dir}/flash/bin/${name}.swf`)
//contents: fs.createReadStream(`${dir}/flash/bin/${name}.swf`),
contents: fs.readFileSync(`${dir}/flash/bin/${name}.swf`),
});
out.debug = debug;
stream.push(out);
callback();
}).catch((error) => {
stream.emit('error', new gutil.PluginError({plugin: this.name, message: error}));
stream.emit('error', new PluginError({plugin: this.name, message: error}));
callback();
});
};
@@ -225,7 +218,7 @@ class Haxe extends Sdk {
};
const endStream = (callback) => {
gutil.log(this.tag, col.cyan("haxe", params.platform), '=>', col.magenta(params.outputFile));
log(this.tag, colors.cyan("haxe", params.platform), '=>', colors.magenta(params.outputFile));
const args = [];
args.push('-main', params.main);
for (const lib of params.lib) {
@@ -262,15 +255,16 @@ class Haxe extends Sdk {
}
//console.log('haxe', args.join(' '));
this.haxe(args).then(() => {
const out = new gutil.File({
const out = new Vinyl({
path: params.outputFile,
contents: fs.createReadStream(tmpFile.path)
//contents: fs.createReadStream(tmpFile.path),
contents: fs.readFileSync(tmpFile.path),
});
out.debug = debug;
stream.push(out);
callback();
}).catch((error) => {
stream.emit('error', new gutil.PluginError({plugin: this.name, message: error}));
stream.emit('error', new PluginError({plugin: this.name, message: error}));
callback();
});
};

View File

@@ -1,8 +1,8 @@
const exec = require('./exec');
const gutil = require('gulp-util');
const through = require('through2');
const col = gutil.colors;
const PluginError = require('plugin-error');
const colors = require('ansi-colors');
const log = require('fancy-log');
class Neko {
@@ -13,7 +13,7 @@ class Neko {
run() {
let stream = null;
const bufferContents = (file, enc, callback) => {
gutil.log(this.tag, col.cyan("run"), col.magenta(file.path));
log(this.tag, colors.cyan("run"), colors.magenta(file.path));
exec('.', ['neko', file.path].join(' '))
.then(() => {
@@ -21,7 +21,7 @@ class Neko {
callback();
})
.catch((error) => {
stream.emit('error', new gutil.PluginError({plugin: this.tag, message: error}));
stream.emit('error', new PluginError({plugin: this.tag, message: error}));
callback();
});

View File

@@ -1,13 +1,12 @@
const os = require('os');
const gulp = require('gulp');
const gutil = require('gulp-util');
const col = gutil.colors;
const download = require('./download');
const unzip = require('gulp-unzip');
const gunzip = require('gulp-gunzip');
const untar = require('gulp-untar');
const Promise = require('bluebird');
const fs = require('fs');
const ps = require('promise-streams');
const got = require('got');
const unzip = require('unzip-stream');
const ProgressBar = require('progress');
const colors = require('ansi-colors');
const log = require('fancy-log');
class Sdk {
static set dir(value) {
@@ -24,7 +23,7 @@ class Sdk {
constructor(name, version) {
this.name = name;
this.tag = col.green(`[${name}]`);
this.tag = colors.green(`[${name}]`);
this.version = version;
this.path = Sdk.path(name, version);
}
@@ -49,27 +48,25 @@ class Sdk {
}
prepare() {
gutil.log(this.tag, `version: ${col.magenta(this.version)}`);
return new Promise((success, fail) => {
if (this.prepared) {
success();
log(this.tag, `version: ${colors.magenta(this.version)}`);
if (this.prepared) {
return Promise.resolve();
} else {
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())
} else {
const bar = new ProgressBar(`${this.tag} [:bar] :percent :etas`, {width: 40, total: 1000, clear: true});
let stream = download(this.link)
.on('error', fail)
.on('progress', (p) => bar.update(p.percent))
.on('end', () => bar.update(1));
if (this.link.endsWith('.zip')) {
stream = stream.pipe(unzip());
} else if (this.link.endsWith('tar.gz')) {
stream = stream.pipe(gunzip()).pipe(untar())
}
return stream
.pipe(gulp.dest(this.path))
.on('end', success)
.on('error', fail);
stream = stream.pipe(fs.createWriteStream(this.path));
}
});
return ps.wait(stream);
}
}
}