[neko] added
This commit is contained in:
@@ -4,11 +4,13 @@ const colors = require('ansi-colors');
|
|||||||
const log = require('fancy-log');
|
const log = require('fancy-log');
|
||||||
|
|
||||||
const TAG = colors.green('[exec]');
|
const TAG = colors.green('[exec]');
|
||||||
|
const verbose = process.argv.indexOf('--verbose') > -1;
|
||||||
|
|
||||||
const queue = async.queue((task, done) => {
|
const queue = async.queue((task, done) => {
|
||||||
//log(TAG, colors.magenta(task.command));
|
if (verbose) log(TAG, colors.magenta(task.command));
|
||||||
//process.chdir(task.dir);
|
//process.chdir(task.dir);
|
||||||
child_process.exec(task.command, {cwd: task.dir, maxBuffer: 1024 * 5000}, (err, stdout, stderr) => {
|
child_process.exec(task.command, {cwd: task.dir, maxBuffer: 1024 * 5000}, (err, stdout, stderr) => {
|
||||||
|
if (verbose) log(TAG, err ? colors.red(err) : '', stdout, colors.red(stderr));
|
||||||
if (err) {
|
if (err) {
|
||||||
task.failure(stderr || stdout || err);
|
task.failure(stderr || stdout || err);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const fse = require('fs-extra');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const exec = require('./exec');
|
const exec = require('./exec');
|
||||||
const Sdk = require('./sdk');
|
const Sdk = require('./sdk');
|
||||||
|
const Neko = require('./neko');
|
||||||
const colors = require('ansi-colors');
|
const colors = require('ansi-colors');
|
||||||
const log = require('fancy-log');
|
const log = require('fancy-log');
|
||||||
const vfs = require('vinyl-fs');
|
const vfs = require('vinyl-fs');
|
||||||
@@ -39,6 +40,7 @@ class Haxe extends Sdk {
|
|||||||
|
|
||||||
constructor(version) {
|
constructor(version) {
|
||||||
super(Haxe.ID, version || Haxe.VERSION);
|
super(Haxe.ID, version || Haxe.VERSION);
|
||||||
|
this.neko = new Neko();
|
||||||
}
|
}
|
||||||
|
|
||||||
get prepared() {
|
get prepared() {
|
||||||
@@ -50,6 +52,7 @@ class Haxe extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
|
this.neko.activate()
|
||||||
process.env.HAXE_VERSION = this.version;
|
process.env.HAXE_VERSION = this.version;
|
||||||
process.env.HAXE_STD_PATH = path.join(this.binPath, 'std');
|
process.env.HAXE_STD_PATH = path.join(this.binPath, 'std');
|
||||||
process.env.HAXE_HOME = this.binPath;
|
process.env.HAXE_HOME = this.binPath;
|
||||||
@@ -59,7 +62,7 @@ class Haxe extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
return super.prepare().then(() => this.activate());
|
return Promise.all([this.neko.prepare(), super.prepare()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
get link() {
|
get link() {
|
||||||
@@ -81,6 +84,7 @@ class Haxe extends Sdk {
|
|||||||
|
|
||||||
openfl(command, platform, config, debug=false) {
|
openfl(command, platform, config, debug=false) {
|
||||||
log(this.tag, colors.cyan(`openfl build ${platform}`));
|
log(this.tag, colors.cyan(`openfl build ${platform}`));
|
||||||
|
this.activate()
|
||||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
@@ -99,6 +103,7 @@ class Haxe extends Sdk {
|
|||||||
|
|
||||||
build(platform, config, debug=false) {
|
build(platform, config, debug=false) {
|
||||||
log(this.tag, colors.cyan(`build ${platform}`));
|
log(this.tag, colors.cyan(`build ${platform}`));
|
||||||
|
this.activate()
|
||||||
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
const buildDir = path.join(os.tmpdir(), 'build', config.name);
|
||||||
fse.ensureDirSync(buildDir);
|
fse.ensureDirSync(buildDir);
|
||||||
|
|
||||||
@@ -130,6 +135,7 @@ class Haxe extends Sdk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
install(packages) {
|
install(packages) {
|
||||||
|
this.activate()
|
||||||
let promise = this.haxelib(['setup', path.join(this.path, 'lib')]);
|
let promise = this.haxelib(['setup', path.join(this.path, 'lib')]);
|
||||||
const next = (args) => () => {
|
const next = (args) => () => {
|
||||||
log(this.tag, colors.cyan('haxelib', 'install'), colors.magenta(args[1]));
|
log(this.tag, colors.cyan('haxelib', 'install'), colors.magenta(args[1]));
|
||||||
|
|||||||
83
haxetool/neko.js
Normal file
83
haxetool/neko.js
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
const os = require('os');
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const run = require('../run/index');
|
||||||
|
const Sdk = require('./sdk');
|
||||||
|
const System = Sdk.System;
|
||||||
|
|
||||||
|
|
||||||
|
class NekoLink {
|
||||||
|
|
||||||
|
static get type() {
|
||||||
|
switch (os.type()) {
|
||||||
|
case 'Linux': return 'linux';
|
||||||
|
case 'Windows_NT': return 'win';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static get arch() {
|
||||||
|
switch (os.arch()) {
|
||||||
|
case 'ia32': return '';
|
||||||
|
case 'x64': return '64';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static get ext() {
|
||||||
|
switch (os.type()) {
|
||||||
|
case 'Linux': return 'tar.gz';
|
||||||
|
case 'Windows_NT': return 'zip';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static get(version) {
|
||||||
|
const vv = version.split('\.').join('-');
|
||||||
|
const filename = `neko-${version}-${NekoLink.type}${NekoLink.arch}.${NekoLink.ext}`;
|
||||||
|
return `https://github.com/HaxeFoundation/neko/releases/download/v${vv}/${filename}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Neko extends Sdk {
|
||||||
|
|
||||||
|
constructor(version) {
|
||||||
|
super(Neko.ID, version || Neko.VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
get link() {
|
||||||
|
return NekoLink.get(this.version);
|
||||||
|
}
|
||||||
|
|
||||||
|
get prepared() {
|
||||||
|
try {
|
||||||
|
return fs.existsSync(this.nekoBin);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
activate() {
|
||||||
|
process.env.NEKO_INSTPATH = this.path;
|
||||||
|
if (process.env.PATH.split(path.delimiter).indexOf(this.path) === -1) {
|
||||||
|
process.env.PATH = [process.env.PATH, this.path].join(path.delimiter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get nekoBin() {
|
||||||
|
let binname = 'neko';
|
||||||
|
if (os.type() == 'Windows_NT') binname += '.exe';
|
||||||
|
return path.join(this.path, binname);
|
||||||
|
}
|
||||||
|
|
||||||
|
run(filename, params) {
|
||||||
|
this.activate();
|
||||||
|
console.log(`${this.nekoBin} ${filename}`);
|
||||||
|
return run(`${this.nekoBin} ${filename}`, params).exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Neko.ID = 'neko'
|
||||||
|
|
||||||
|
Neko.VERSION_2_2_0 = '2.2.0';
|
||||||
|
Neko.VERSION = Neko.VERSION_2_2_0;
|
||||||
|
|
||||||
|
module.exports = Neko;
|
||||||
@@ -5,6 +5,7 @@ const fs = require('fs');
|
|||||||
const fse = require('fs-extra');
|
const fse = require('fs-extra');
|
||||||
const Haxe = require('./haxe');
|
const Haxe = require('./haxe');
|
||||||
const FlashPlayer = require('./flashplayer');
|
const FlashPlayer = require('./flashplayer');
|
||||||
|
const Neko = require('./neko');
|
||||||
const debug = require('./debug');
|
const debug = require('./debug');
|
||||||
const webserver = require('gulp-webserver');
|
const webserver = require('gulp-webserver');
|
||||||
const run = require('../run/index');
|
const run = require('../run/index');
|
||||||
@@ -311,12 +312,17 @@ class NekoRunner extends Runner {
|
|||||||
|
|
||||||
constructor(config, debug) {
|
constructor(config, debug) {
|
||||||
super(config, Platform.NEKO, debug);
|
super(config, Platform.NEKO, debug);
|
||||||
|
this.neko = new Neko();
|
||||||
|
}
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
return this.neko.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
call() {
|
call() {
|
||||||
const target = this.targetPath;
|
const target = this.targetPath;
|
||||||
const filename = path.resolve(target, this.config.meta.filename+'.n');
|
const filename = path.resolve(target, this.config.meta.filename+'.n');
|
||||||
const result = gulp.src(filename).pipe(run("neko <%=file.path%>", {cwd: target}));
|
const result = this.neko.run(filename, {cwd: target, verbosity: 0});
|
||||||
return this.log(result);
|
return this.log(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ class Sdk {
|
|||||||
} else if (this.link.endsWith('tar.gz')) {
|
} else if (this.link.endsWith('tar.gz')) {
|
||||||
stream = stream.pipe(tar.x({C: this.path, strip: strip}));
|
stream = stream.pipe(tar.x({C: this.path, strip: strip}));
|
||||||
} else {
|
} else {
|
||||||
stream = stream.pipe(fs.createWriteStream(this.path));
|
stream = stream.pipe(fs.createWriteStream(path.join(this.path, this.link.split('/').pop())));
|
||||||
}
|
}
|
||||||
return ps.wait(stream);
|
return ps.wait(stream);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user