[project] added

This commit is contained in:
2018-04-05 18:03:55 +03:00
parent f94eb8745c
commit 294fab3279
8 changed files with 445 additions and 112 deletions

View File

@@ -77,9 +77,29 @@ class Haxe extends Sdk {
}
haxelib(args) {
const haxelibBin = this.haxelibBin;
//return exec(this.binPath, [path.basename(haxelibBin)].concat(args).join(' '));
return exec('.', [haxelibBin].concat(args).join(' '));
return exec('.', [this.haxelibBin].concat(args).join(' '));
}
openfl(command, platform, config, debug=false) {
log(this.tag, colors.cyan('openfl', platform));
const buildDir = path.join(os.tmpdir(), 'build', config.name);
mkdirp.sync(buildDir);
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.xml')));
const project = projectTemplate({...config, buildDir: buildDir});
fs.writeFileSync(path.resolve(buildDir, 'project.xml'), project);
const args = ['-cwd', buildDir, 'run', 'openfl', command, platform];
if (debug) {
args.push('-debug');
}
const target = path.resolve(buildDir, platform, 'bin');
rmdir(target);
return this.haxelib(args).then(() => vfs.src(`${target}/**/*`));
}
build(platform, config) {
}
install(packages) {
@@ -132,108 +152,8 @@ class Haxe extends Sdk {
return promise;
}
/**
*
* @param params
* @returns {*}
*
* {
* command: 'build',
* platform: 'flash',
* version: '1.0.0',
* lib: {},
* values: {},
* macro: [],
* outputFile: 'out.swf',
* debug: false
* }
*/
openfl(params) {
params = Object.assign({
title: null,
pack: null,
company: null,
version: null,
lib: [],
cp: [],
asset: [],
main: null,
values: {},
macro: [],
outputFile: null,
debug: false
}, params);
const files = [];
let stream = null;
const bufferContents = (file, enc, callback) => {
// ToDo: check file not stream
files.push(file);
callback();
};
const endStream = (callback) => {
log(this.tag, colors.cyan(`openfl ${params.command} ${params.platform}`));
if (!Array.isArray(params.lib)) {
params.lib = Object.entries(params.lib).map(([k, v]) => ({name: k, version: v.split('@')[0]}));
}
params.cp = params.cp.map(item => path.resolve(files[0].path, item));
params.asset = params.asset.map(item => path.resolve(files[0].path, item));
const buildDir = path.join(os.tmpdir(), 'build', params.outputFile);
params.buildDir = buildDir;
mkdirp.sync(params.buildDir);
const projectTemplate = template(fs.readFileSync(path.resolve(__dirname, '..', 'template/project.xml')));
const project = projectTemplate(params);
fs.writeFileSync(path.resolve(buildDir, 'project.xml'), project);
const args = ['-cwd', params.buildDir, 'run', 'openfl', params.command, params.platform];
if (params.debug) {
args.push('-debug');
}
const target = `${buildDir}/${params.platform}/bin`;
rmdir(target);
this.haxelib(args).then(() => {
vfs.src(`${target}/**/*`).pipe(through.obj((file, enc, cb) => {
stream.push(file);
cb();
}, (cb) => {
callback();
cb();
}));
//callback();
}).catch((error) => {
stream.emit('error', new PluginError({plugin: this.name, message: error}));
callback();
});
};
return stream = through.obj(bufferContents, endStream);
}
/**
*
* @param params
*
* {
* platform: 'neko',
* version: '1.0.0',
* values: {},
* macro: [],
* lib: [],
* src: [],
* main: 'Main.hx',
* outputFile: 'out.n',
* debug: false,
* }
*/
build(params) {
_build(params) {
params = Object.assign({
version: null,
values: {},