[build] generate proto clasess
This commit is contained in:
@@ -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) {
|
||||
|
||||
32
tasks/sdk.js
32
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;
|
||||
Reference in New Issue
Block a user