First commit
This commit is contained in:
61
hGameTest/node_modules/haxe/lib/cache.js
generated
vendored
Normal file
61
hGameTest/node_modules/haxe/lib/cache.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
var os = require('os');
|
||||
var fs = require('fs');
|
||||
var fsx = require('fs-extra')
|
||||
var Download = require('download');
|
||||
var downloadStatus = require('download-status');
|
||||
var crypto = require('crypto');
|
||||
|
||||
var cacheFolder = os.homedir() + '/.haxe_cache';
|
||||
if(!fs.existsSync(cacheFolder)){
|
||||
fs.mkdirSync(cacheFolder);
|
||||
}
|
||||
|
||||
var getHash = function ( data ) {
|
||||
var generator = crypto.createHash('sha1');
|
||||
generator.update( data )
|
||||
return generator.digest('hex')
|
||||
}
|
||||
|
||||
function Cache(){
|
||||
|
||||
this.download = function(url, targetFolder, callback){
|
||||
console.log(url);
|
||||
var hash = getHash(url);
|
||||
var ref = this;
|
||||
if(fs.existsSync(cacheFolder + '/' + hash)){
|
||||
console.log("using cached version");
|
||||
ref.extract(hash,targetFolder,callback);
|
||||
} else {
|
||||
console.log("Downloading...")
|
||||
Download(url,cacheFolder + '/' + hash,{ extract: true, strip: 1 })
|
||||
.then(() => {
|
||||
console.log('done!');
|
||||
ref.extract(hash,targetFolder,callback);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err + " : Unable to download or extract " + url);
|
||||
callback(err);
|
||||
});
|
||||
/*Download({ extract: true, strip: 1 })
|
||||
.get( url )
|
||||
.dest( cacheFolder + '/' + hash )
|
||||
.use(downloadStatus())
|
||||
.run( function(err,files){
|
||||
if( err ) {
|
||||
console.error("Unable to download or extract " + url);
|
||||
callback(err);
|
||||
}
|
||||
ref.extract(hash,targetFolder,callback);
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
this.extract = function(hash, targetFolder, callback){
|
||||
var url = cacheFolder + '/' + hash;
|
||||
fsx.copySync(url, targetFolder);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = Cache;
|
||||
19
hGameTest/node_modules/haxe/lib/clear-task.js
generated
vendored
Normal file
19
hGameTest/node_modules/haxe/lib/clear-task.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var fsx = require('fs-extra');
|
||||
var vars = require(__dirname + '/vars');
|
||||
|
||||
var ClearTask = function () {
|
||||
};
|
||||
|
||||
ClearTask.prototype.run = function(executeNextStep) {
|
||||
console.log('clean folder');
|
||||
try{
|
||||
fsx.removeSync(vars.haxe.dir);
|
||||
fsx.removeSync(vars.haxelib.dir);
|
||||
fsx.removeSync(vars.neko.dir);
|
||||
} catch(error){
|
||||
console.error(error);
|
||||
}
|
||||
executeNextStep();
|
||||
};
|
||||
|
||||
module.exports.ClearTask = ClearTask;
|
||||
17
hGameTest/node_modules/haxe/lib/download-haxe-task.js
generated
vendored
Normal file
17
hGameTest/node_modules/haxe/lib/download-haxe-task.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var haxeUrl = require(__dirname + '/haxe-url');
|
||||
var Cache = require(__dirname + '/cache');
|
||||
var vars = require(__dirname + '/vars');
|
||||
var os = require('os');
|
||||
|
||||
var DownloadHaxeTask = function (version) {
|
||||
this.haxeVersion = version;
|
||||
};
|
||||
|
||||
DownloadHaxeTask.prototype.run = function(executeNextStep) {
|
||||
console.log("Getting Haxe " + this.haxeVersion + " for " + os.platform() );
|
||||
var url = haxeUrl(os.platform(), os.arch(), this.haxeVersion, false);
|
||||
var cache = new Cache();
|
||||
cache.download( url , vars.haxe.dir, executeNextStep );
|
||||
};
|
||||
|
||||
module.exports.DownloadHaxeTask = DownloadHaxeTask;
|
||||
17
hGameTest/node_modules/haxe/lib/download-haxelib-task.js
generated
vendored
Normal file
17
hGameTest/node_modules/haxe/lib/download-haxelib-task.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var Cache = require(__dirname + '/cache');
|
||||
var vars = require(__dirname + '/vars');
|
||||
var os = require('os');
|
||||
|
||||
var DownloadHaxelibTask = function (version) {
|
||||
this.haxelibVersion = version;
|
||||
};
|
||||
|
||||
DownloadHaxelibTask.prototype.run = function(executeNextStep) {
|
||||
console.log("Getting Haxelib " + this.haxelibVersion );
|
||||
var filename = this.haxelibVersion + ".tar.gz";
|
||||
var url = "https://github.com/HaxeFoundation/haxelib/archive/" + filename;
|
||||
var cache = new Cache();
|
||||
cache.download( url , vars.haxelib.dir, executeNextStep );
|
||||
};
|
||||
|
||||
module.exports.DownloadHaxelibTask = DownloadHaxelibTask;
|
||||
37
hGameTest/node_modules/haxe/lib/download-neko-task.js
generated
vendored
Normal file
37
hGameTest/node_modules/haxe/lib/download-neko-task.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var Cache = require(__dirname + '/cache');
|
||||
var vars = require(__dirname + '/vars');
|
||||
var os = require('os');
|
||||
|
||||
var DownloadNekoTask = function (version) {
|
||||
this.nekoVersion = version;
|
||||
};
|
||||
|
||||
DownloadNekoTask.prototype.run = function(executeNextStep) {
|
||||
console.log("Getting NekoVM " + this.nekoVersion );
|
||||
var version = this.nekoVersion.split('.').join('-');
|
||||
var plateform="";
|
||||
switch ( os.platform() ) {
|
||||
case 'linux':
|
||||
plateform = 'linux.tar.gz';
|
||||
if( os.arch() == 'x64' ) {
|
||||
plateform = 'linux64.tar.gz';
|
||||
}
|
||||
break;
|
||||
case 'darwin':
|
||||
plateform = 'osx64.tar.gz';
|
||||
break;
|
||||
case 'win32':
|
||||
plateform = 'win.zip';
|
||||
case 'win64':
|
||||
plateform = 'win64.zip';
|
||||
break;
|
||||
default:
|
||||
console.error('Haxe is not compatible with your platform');
|
||||
throw 'error';
|
||||
}
|
||||
var url = "https://github.com/HaxeFoundation/neko/releases/download/v"+version+"/neko-"+this.nekoVersion+"-"+plateform;
|
||||
var cache = new Cache();
|
||||
cache.download( url , vars.neko.dir, executeNextStep );
|
||||
};
|
||||
|
||||
module.exports.DownloadNekoTask = DownloadNekoTask;
|
||||
12
hGameTest/node_modules/haxe/lib/env.js
generated
vendored
Normal file
12
hGameTest/node_modules/haxe/lib/env.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
var vars = require('./vars');
|
||||
var env = module.exports = {};
|
||||
|
||||
function merge( base , obj ) {
|
||||
for( k in obj ) {
|
||||
base[k] = obj[k];
|
||||
}
|
||||
}
|
||||
|
||||
merge( env, process.env );
|
||||
merge( env, vars.env );
|
||||
|
||||
50
hGameTest/node_modules/haxe/lib/executable.js
generated
vendored
Normal file
50
hGameTest/node_modules/haxe/lib/executable.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
var spawn = require('child_process').spawn;
|
||||
var env = require('./env');
|
||||
|
||||
|
||||
/**
|
||||
creates a function that pipes arguments and process to an executable function
|
||||
**/
|
||||
var cli = function( executable ) {
|
||||
return function(){
|
||||
args = process.argv.slice(2);
|
||||
cp = executable.apply(null, args);
|
||||
|
||||
cp.stdout.pipe(process.stdout);
|
||||
cp.stderr.pipe(process.stderr);
|
||||
cp.on('exit', process.exit);
|
||||
cp.on('error', function(err){
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
process.on('SIGTERM', function() {
|
||||
cp.kill('SIGTERM');
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
creates a function that calls cli command + argus
|
||||
appends functions arguments to command
|
||||
*/
|
||||
var executable = function(command, args) {
|
||||
var exe = function() {
|
||||
var _args = ( args || [] ).slice(0);
|
||||
for( a in arguments ) {
|
||||
_args.push( arguments[a] );
|
||||
}
|
||||
|
||||
var cp = spawn( command, _args, {
|
||||
env: env
|
||||
});
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
exe.cli = cli( exe );
|
||||
|
||||
return exe;
|
||||
}
|
||||
|
||||
module.exports = executable;
|
||||
64
hGameTest/node_modules/haxe/lib/haxe-url.js
generated
vendored
Normal file
64
hGameTest/node_modules/haxe/lib/haxe-url.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
|
||||
module.exports = function ( platform, arch, majorVersion, nightly ) {
|
||||
|
||||
var version = majorVersion;
|
||||
var isNightly = !!nightly;
|
||||
|
||||
var url;
|
||||
switch ( isNightly ) {
|
||||
case true:
|
||||
url = 'http://hxbuilds.s3-website-us-east-1.amazonaws.com/builds/haxe/';
|
||||
switch( platform ) {
|
||||
case 'linux':
|
||||
url += 'linux';
|
||||
switch( arch ) {
|
||||
case 'x64':
|
||||
url += '64';
|
||||
break;
|
||||
case 'ia32':
|
||||
url += '32';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'darwin':
|
||||
url += 'mac';
|
||||
break;
|
||||
case 'win32':
|
||||
case 'win64':
|
||||
url += 'windows';
|
||||
break;
|
||||
}
|
||||
url += '/haxe_'+nightly+'.tar.gz';
|
||||
break;
|
||||
default:
|
||||
url = 'http://haxe.org/website-content/downloads/' + version + '/downloads/haxe-' + version + '-';
|
||||
switch ( platform ) {
|
||||
case 'linux':
|
||||
url += 'linux';
|
||||
switch( arch ) {
|
||||
case 'x64':
|
||||
url += '64';
|
||||
break;
|
||||
case 'ia32':
|
||||
url += '32';
|
||||
break;
|
||||
}
|
||||
url += '.tar.gz';
|
||||
break;
|
||||
case 'darwin':
|
||||
url += 'osx';
|
||||
url += '.tar.gz';
|
||||
break;
|
||||
case 'win32':
|
||||
case 'win64':
|
||||
url += 'win';
|
||||
url += '.zip';
|
||||
break;
|
||||
default:
|
||||
console.error('Haxe is not compatible with your platform');
|
||||
throw 'error';
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
22
hGameTest/node_modules/haxe/lib/install-haxelib-dependencies-task.js
generated
vendored
Normal file
22
hGameTest/node_modules/haxe/lib/install-haxelib-dependencies-task.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var proc = require('child_process');
|
||||
|
||||
var InstallHaxelibDependenciesTask = function (deps) {
|
||||
this.dependencies = deps;
|
||||
};
|
||||
|
||||
InstallHaxelibDependenciesTask.prototype.run = function(executeNextStep) {
|
||||
var options = {
|
||||
cwd : process.env.INIT_CWD
|
||||
}
|
||||
console.log("Installing Haxelib Dependencies to " + options.cwd );
|
||||
proc.spawnSync("haxelib", ["newrepo"], options);
|
||||
for(var module in this.dependencies ){
|
||||
if(module != "haxe" && module != "haxelib" && module != "neko"){
|
||||
console.log(module + ":" + this.dependencies[module]);
|
||||
proc.spawnSync("haxelib", ["install",module,this.dependencies[module]], options);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
module.exports.InstallHaxelibDependenciesTask = InstallHaxelibDependenciesTask;
|
||||
4
hGameTest/node_modules/haxe/lib/package-config.js
generated
vendored
Normal file
4
hGameTest/node_modules/haxe/lib/package-config.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
module.exports = function(key) {
|
||||
return process.env[ 'npm_package_haxeDependencies_' + key ];
|
||||
}
|
||||
5
hGameTest/node_modules/haxe/lib/path.js
generated
vendored
Normal file
5
hGameTest/node_modules/haxe/lib/path.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(p) {
|
||||
return path.join(__dirname, '..', p);
|
||||
}
|
||||
28
hGameTest/node_modules/haxe/lib/task-runner.js
generated
vendored
Normal file
28
hGameTest/node_modules/haxe/lib/task-runner.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
var path = require('path');
|
||||
|
||||
var TaskRunner = function(){
|
||||
this.taskList = [];
|
||||
this.currentTaskIndex = 0;
|
||||
this.run = function () {
|
||||
var exitTask = {
|
||||
run: function () {
|
||||
console.log("END");
|
||||
process.exit(0);
|
||||
}
|
||||
};
|
||||
this.addTask(exitTask);
|
||||
this.taskList[0].run(this.delegate(this));
|
||||
};
|
||||
|
||||
this.addTask = function (task) {
|
||||
this.taskList.push(task);
|
||||
};
|
||||
|
||||
this.delegate = function(self){
|
||||
return function () {
|
||||
self.currentTaskIndex++;
|
||||
self.taskList[self.currentTaskIndex].run(self.delegate(self));
|
||||
};
|
||||
}
|
||||
}
|
||||
module.exports.TaskRunner = TaskRunner;
|
||||
30
hGameTest/node_modules/haxe/lib/vars.js
generated
vendored
Normal file
30
hGameTest/node_modules/haxe/lib/vars.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var path = require('path');
|
||||
var packagePath = require('./path');
|
||||
|
||||
var downloadsPath = packagePath('downloads');
|
||||
var haxeDir = path.join(downloadsPath, 'haxe');
|
||||
var haxelibDir = path.join(downloadsPath, 'haxelib');
|
||||
var nekoDir = path.join(downloadsPath, 'neko');
|
||||
|
||||
var vars = module.exports = {
|
||||
haxe : {
|
||||
dir: haxeDir,
|
||||
path: path.join(haxeDir, 'haxe')
|
||||
},
|
||||
neko : {
|
||||
dir: nekoDir,
|
||||
path: path.join(nekoDir, 'neko')
|
||||
},
|
||||
haxelib : {
|
||||
dir: haxelibDir,
|
||||
path: path.join(haxeDir, 'haxe'),
|
||||
args: [
|
||||
'-cp', path.join(haxelibDir, 'src'),
|
||||
'--run', 'tools.haxelib.Main'
|
||||
]
|
||||
},
|
||||
env : {
|
||||
HAXELIB_PATH : packagePath('.haxelib'),
|
||||
HAXE_STD_PATH : path.join(haxeDir, 'std')
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user