├── .gitignore ├── .haxelib └── .exist ├── .travis.yml ├── LICENSE ├── README.md ├── appveyor.yml ├── bin ├── haxe ├── haxelib └── neko ├── index.js ├── install.js ├── lib ├── cache.js ├── clear-task.js ├── download-haxe-task.js ├── download-haxelib-task.js ├── download-neko-task.js ├── env.js ├── executable.js ├── haxe-url.js ├── install-haxelib-dependencies-task.js ├── package-config.js ├── path.js ├── task-runner.js └── vars.js ├── package.json └── test ├── Main.hx ├── main.js ├── package.json └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | downloads 2 | .haxelib/* 3 | !.haxelib/.exist 4 | node_modules/ 5 | npm-debug.log -------------------------------------------------------------------------------- /.haxelib/.exist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HaxeFoundation/npm-haxe/7aec55dfbe30f13c6f85e10012d79b1fd40abe22/.haxelib/.exist -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | os: 4 | - linux 5 | 6 | node_js: 7 | - "stable" 8 | - "6" 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Haxe Foundation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # npm-haxe v5 2 | [![TravisCI Build Status](https://travis-ci.org/HaxeFoundation/npm-haxe.svg?branch=master)](https://travis-ci.org/HaxeFoundation/npm-haxe) 3 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/HaxeFoundation/npm-haxe?branch=master&svg=true)](https://ci.appveyor.com/project/HaxeFoundation/npm-haxe) 4 | [![dependencies Status](https://david-dm.org/HaxeFoundation/npm-haxe/status.svg)](https://david-dm.org/HaxeFoundation/npm-haxe) 5 | 6 | Installs [Haxe](http://haxe.org) using [Node Package Manager](https://www.npmjs.com/) aka `npm` 7 | 8 | **WARNING : The version contains breaking changes from npm-haxe v4** 9 | 10 | ## Key-features 11 | 12 | * Global or per-project, sandboxed, standard Haxe installation 13 | * Includes [Haxelib](http://lib.haxe.org/) 14 | * Includes [Neko](https://nekovm.org) 15 | * Support both Haxelib and NPM dependencies 16 | * Tested on Ubuntu/Linux and Windows 17 | 18 | ## Usage 19 | 20 | ### CLI installation 21 | 22 | ```bash 23 | npm install haxe 24 | ``` 25 | 26 | By default, this will make `haxe` and `haxelib` available to [npm scripts](https://docs.npmjs.com/misc/scripts) only, 27 | with haxelib repository sandboxed to your current working directory. 28 | 29 | To have `haxe` and `haxelib` commands available globally, use the `-g` flag. 30 | This will also make the haxelib repo global. 31 | 32 | ### Package.json sample 33 | 34 | ```js 35 | { 36 | "scripts":{ 37 | "postinstall": "haxelib --always install build.hxml", 38 | "build": "haxe build.hxml" 39 | }, 40 | "dependencies": { 41 | "haxe": "^5.0.0" // the npm haxe module 42 | }, 43 | "haxeDependencies": { 44 | "haxe": "3.4.7", // haxe version 45 | "haxelib": "3.3.0", // haxelib version 46 | "neko": "2.2.0", // neko version 47 | "pixijs": "4.5.5", // additionnal haxelib dependency 48 | "tamina": "git+https://github.com/damoebius/taminahx.git" //haxelib git dependency 49 | } 50 | } 51 | ``` 52 | 53 | Please notice the `--always` flag in the `haxelib` command, to avoid having to confirm haxelibs installation. 54 | 55 | ### Running Haxe from NodeJS 56 | 57 | This package also comes with the minimal bindings to run the Haxe compiler from NodeJS. 58 | 59 | 60 | ```js 61 | var haxe = require('haxe').haxe; 62 | var haxelib = require('haxe').haxelib; 63 | 64 | // all commands return a ChildProcess instance 65 | 66 | haxe( "-version" ); 67 | haxelib( "install", "hxnodejs" ); 68 | 69 | var server = haxe("--wait", "6000"); 70 | ``` 71 | 72 | See also [test.js](https://github.com/HaxeFoundation/npm-haxe/blob/master/test/test.js) 73 | 74 | 75 | ### Configuration options 76 | 77 | The following configuration options can be set in your package.json. 78 | 79 | Please note they must be set before installing the package. 80 | 81 | ```json 82 | "haxeDependencies": { 83 | "haxe": "3.4.7", 84 | "haxelib": "3.3.0", 85 | "neko": "2.2.0", 86 | "pixijs": "4.5.5", 87 | "perfjs": "1.1.18" 88 | } 89 | ``` 90 | 91 | #### Version 92 | 93 | See [Haxe Download list](http://haxe.org/download/list/). 94 | Please notice the directory name in the archive must match. 95 | 96 | In this case, the `haxeDependencies.haxe` value is still used, and must match the one of the directory extracted from the archive. 97 | 98 | #### Haxelib 99 | 100 | `haxeDependencies.haxelib` must match a release from the [official Haxelib repo](https://github.com/HaxeFoundation/haxelib/releases) 101 | 102 | ### Known issues 103 | 104 | The package relies on the `node` command, which [has issues on some Ubuntu versions] (http://stackoverflow.com/questions/21168141/cannot-install-packages-using-node-package-manager-in-ubuntu). 105 | 106 | If you get an error similar to this : 107 | ``` 108 | sh: 1: node: not found 109 | npm WARN This failure might be due to the use of legacy binary "node" 110 | npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian 111 | ``` 112 | Just install the `nodejs-legacy` package: 113 | ```bash 114 | sudo apt-get install nodejs-legacy 115 | ``` 116 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | environment: 4 | global: 5 | nodejs_version: "LTS" 6 | 7 | install: 8 | - ps: Install-Product node $env:nodejs_version 9 | - node --version 10 | - npm --version 11 | 12 | build: off 13 | 14 | test_script: 15 | - npm test 16 | -------------------------------------------------------------------------------- /bin/haxe: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('haxe').haxe.cli(); 3 | -------------------------------------------------------------------------------- /bin/haxelib: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('haxe').haxelib.cli(); 3 | -------------------------------------------------------------------------------- /bin/neko: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('haxe').neko.cli(); 3 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 2 | var executable = require('./lib/executable'); 3 | var vars = require('./lib/vars'); 4 | 5 | module.exports = { 6 | haxe: executable( vars.haxe.path, vars.haxe.args ), 7 | haxelib: executable( vars.haxelib.path, vars.haxelib.args ), 8 | neko: executable( vars.neko.path, vars.neko.args ) 9 | } 10 | 11 | -------------------------------------------------------------------------------- /install.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var os = require('os'); 3 | var fsx = require('fs-extra'); 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var packageConfig = require('./lib/package-config'); 7 | var haxeUrl = require('./lib/haxe-url'); 8 | var vars = require('./lib/vars'); 9 | var localConfig = require('./package.json'); 10 | var Cache = require('./lib/cache'); 11 | var TaskRunner = require('./lib/task-runner').TaskRunner; 12 | var ClearTask = require('./lib/clear-task').ClearTask; 13 | var DownloadHaxeTask = require('./lib/download-haxe-task').DownloadHaxeTask; 14 | var DownloadHaxelibTask = require('./lib/download-haxelib-task').DownloadHaxelibTask; 15 | var DownloadNekoTask = require('./lib/download-neko-task').DownloadNekoTask; 16 | var InstallHaxelibDependenciesTask = require('./lib/install-haxelib-dependencies-task').InstallHaxelibDependenciesTask; 17 | 18 | 19 | function findPackageJson() { 20 | var startPath = process.cwd(); 21 | var ignore = 0; 22 | 23 | var searchPath = path.join(startPath + '/..'); 24 | var fileFound = false; 25 | var nextPath = ''; 26 | var numSearch = 0; 27 | 28 | while (!fileFound) { 29 | searchPath = nextPath || searchPath; 30 | numSearch++; 31 | if(numSearch>4){ 32 | return false; 33 | } 34 | try { 35 | fs.statSync(path.join(searchPath + '/package.json')); 36 | if (ignore > 0) { 37 | ignore--; 38 | } else { 39 | fileFound = true; 40 | } 41 | } catch (err) {} 42 | 43 | nextPath = path.join(searchPath + '/..'); 44 | if (nextPath === path.normalize('/') || nextPath === '.' || nextPath === '..') { 45 | break; 46 | } 47 | } 48 | 49 | if (fileFound) { 50 | return { 51 | read: function () { 52 | return fs.readFileSync(path.join(searchPath + '/package.json'), 'utf8'); 53 | }, 54 | parse: function () { 55 | return JSON.parse(fs.readFileSync(path.join(searchPath + '/package.json'), 'utf8')); 56 | }, 57 | path: path.join(searchPath + '/package.json') 58 | }; 59 | } 60 | 61 | return false; 62 | }; 63 | var pack = findPackageJson(); 64 | 65 | function getHaxeDependencies(){ 66 | var deps; 67 | 68 | try { 69 | deps = pack.parse().haxeDependencies; 70 | } catch (error){ 71 | console.warn('no dependencies'); 72 | } 73 | 74 | return deps; 75 | } 76 | 77 | function getVersion(module){ 78 | var envVersion = packageConfig(module); 79 | var packageVersion; 80 | 81 | try { 82 | packageVersion = getHaxeDependencies()[module]; 83 | } catch (error){ 84 | console.warn('using default '+ module +' version'); 85 | } 86 | 87 | var localFallbackVersion = localConfig.haxeDependencies[module]; 88 | 89 | return packageVersion || envVersion || localFallbackVersion; 90 | } 91 | 92 | var runner = new TaskRunner(); 93 | 94 | runner.addTask(new ClearTask()); 95 | runner.addTask(new DownloadHaxeTask(getVersion('haxe'))); 96 | runner.addTask(new DownloadHaxelibTask(getVersion('haxelib'))); 97 | runner.addTask(new DownloadNekoTask(getVersion('neko'))); 98 | runner.addTask(new InstallHaxelibDependenciesTask(getHaxeDependencies())); 99 | 100 | runner.run(); 101 | -------------------------------------------------------------------------------- /lib/cache.js: -------------------------------------------------------------------------------- 1 | var os = require('os'); 2 | var fs = require('fs'); 3 | var fsx = require('fs-extra') 4 | var Download = require('download'); 5 | var downloadStatus = require('download-status'); 6 | var crypto = require('crypto'); 7 | 8 | var cacheFolder = os.homedir() + '/.haxe_cache'; 9 | if(!fs.existsSync(cacheFolder)){ 10 | fs.mkdirSync(cacheFolder); 11 | } 12 | 13 | var getHash = function ( data ) { 14 | var generator = crypto.createHash('sha1'); 15 | generator.update( data ) 16 | return generator.digest('hex') 17 | } 18 | 19 | function Cache(){ 20 | this.download = function(url, targetFolder, callback, err){ 21 | console.log(url); 22 | var hash = getHash(url); 23 | var ref = this; 24 | if(fs.existsSync(cacheFolder + '/' + hash)){ 25 | console.log("using cached version"); 26 | ref.extract(hash,targetFolder,callback); 27 | } else { 28 | if (err === undefined) { 29 | err = (err) => { 30 | console.error(err + " : Unable to download or extract " + url); 31 | process.exit(9); 32 | } 33 | } 34 | 35 | var rejectUnauthorized = process.env["NODE_TLS_REJECT_UNAUTHORIZED"] !== "0"; 36 | console.log("Downloading..."); 37 | 38 | var options = { 39 | extract: true, 40 | strip: 1, 41 | rejectUnauthorized: rejectUnauthorized 42 | }; 43 | 44 | Download(url, cacheFolder + '/' + hash, options) 45 | .then(() => { 46 | console.log('done!'); 47 | ref.extract(hash,targetFolder,callback); 48 | }) 49 | .catch(err); 50 | } 51 | } 52 | 53 | this.extract = function(hash, targetFolder, callback){ 54 | var url = cacheFolder + '/' + hash; 55 | fsx.copySync(url, targetFolder); 56 | callback(); 57 | } 58 | } 59 | 60 | 61 | module.exports = Cache; -------------------------------------------------------------------------------- /lib/clear-task.js: -------------------------------------------------------------------------------- 1 | var fsx = require('fs-extra'); 2 | var vars = require(__dirname + '/vars'); 3 | 4 | var ClearTask = function () { 5 | }; 6 | 7 | ClearTask.prototype.run = function(executeNextStep) { 8 | console.log('clean folder'); 9 | try{ 10 | fsx.removeSync(vars.haxe.dir); 11 | fsx.removeSync(vars.haxelib.dir); 12 | fsx.removeSync(vars.neko.dir); 13 | } catch(error){ 14 | console.error(error); 15 | } 16 | executeNextStep(); 17 | }; 18 | 19 | module.exports.ClearTask = ClearTask; 20 | -------------------------------------------------------------------------------- /lib/download-haxe-task.js: -------------------------------------------------------------------------------- 1 | var haxeUrl = require(__dirname + '/haxe-url'); 2 | var Cache = require(__dirname + '/cache'); 3 | var vars = require(__dirname + '/vars'); 4 | var os = require('os'); 5 | 6 | var DownloadHaxeTask = function (version) { 7 | this.haxeVersion = version; 8 | }; 9 | 10 | DownloadHaxeTask.prototype.run = function(executeNextStep) { 11 | console.log("Getting Haxe " + this.haxeVersion + " for " + os.platform() ); 12 | var url = haxeUrl(os.platform(), os.arch(), this.haxeVersion, false); 13 | var cache = new Cache(); 14 | cache.download( url , vars.haxe.dir, executeNextStep ); 15 | }; 16 | 17 | module.exports.DownloadHaxeTask = DownloadHaxeTask; -------------------------------------------------------------------------------- /lib/download-haxelib-task.js: -------------------------------------------------------------------------------- 1 | var Cache = require(__dirname + '/cache'); 2 | var vars = require(__dirname + '/vars'); 3 | var os = require('os'); 4 | 5 | var DownloadHaxelibTask = function (version) { 6 | this.haxelibVersion = version; 7 | }; 8 | 9 | DownloadHaxelibTask.prototype.run = function(executeNextStep) { 10 | console.log("Getting Haxelib " + this.haxelibVersion ); 11 | var filename = this.haxelibVersion + ".tar.gz"; 12 | var url = "https://github.com/HaxeFoundation/haxelib/archive/" + filename; 13 | var cache = new Cache(); 14 | cache.download( url , vars.haxelib.dir, executeNextStep ); 15 | }; 16 | 17 | module.exports.DownloadHaxelibTask = DownloadHaxelibTask; -------------------------------------------------------------------------------- /lib/download-neko-task.js: -------------------------------------------------------------------------------- 1 | var Cache = require(__dirname + '/cache'); 2 | var vars = require(__dirname + '/vars'); 3 | var os = require('os'); 4 | 5 | var DownloadNekoTask = function (version) { 6 | this.nekoVersion = version; 7 | }; 8 | 9 | DownloadNekoTask.prototype.run = function(executeNextStep) { 10 | console.log("Getting NekoVM " + this.nekoVersion ); 11 | var version = this.nekoVersion.split('.').join('-'); 12 | var osPlatform = os.platform() 13 | var plateform=""; 14 | switch ( osPlatform ) { 15 | case 'linux': 16 | plateform = 'linux.tar.gz'; 17 | if( os.arch() == 'x64' ) { 18 | plateform = 'linux64.tar.gz'; 19 | } 20 | break; 21 | case 'darwin': 22 | plateform = 'osx64.tar.gz'; 23 | break; 24 | case 'win32': 25 | plateform = 'win.zip'; 26 | break; 27 | case 'win64': 28 | plateform = 'win64.zip'; 29 | break; 30 | default: 31 | console.error('Haxe is not compatible with your platform'); 32 | throw 'error'; 33 | } 34 | var url = "https://github.com/HaxeFoundation/neko/releases/download/v"+version+"/neko-"+this.nekoVersion+"-"+plateform; 35 | var cache = new Cache(); 36 | cache.download( url , vars.neko.dir, executeNextStep, (err) => { 37 | if (osPlatform == 'win64'){ 38 | // fallback to win32 39 | plateform = 'win.zip'; 40 | url = "https://github.com/HaxeFoundation/neko/releases/download/v"+version+"/neko-"+this.nekoVersion+"-"+plateform; 41 | cache.download( url , vars.neko.dir, executeNextStep); 42 | } else { 43 | console.error(err + " : Unable to download or extract " + url); 44 | process.exit(9); 45 | } 46 | } ); 47 | }; 48 | 49 | module.exports.DownloadNekoTask = DownloadNekoTask; -------------------------------------------------------------------------------- /lib/env.js: -------------------------------------------------------------------------------- 1 | var vars = require('./vars'); 2 | var env = module.exports = {}; 3 | 4 | function merge( base , obj ) { 5 | for( k in obj ) { 6 | base[k] = obj[k]; 7 | } 8 | } 9 | 10 | merge( env, vars.env ); 11 | merge( env, process.env ); 12 | -------------------------------------------------------------------------------- /lib/executable.js: -------------------------------------------------------------------------------- 1 | var spawn = require('child_process').spawn; 2 | var env = require('./env'); 3 | 4 | 5 | /** 6 | creates a function that pipes arguments and process to an executable function 7 | **/ 8 | var cli = function( executable ) { 9 | return function(){ 10 | args = process.argv.slice(2); 11 | cp = executable.apply(null, args); 12 | 13 | cp.stdout.pipe(process.stdout); 14 | cp.stderr.pipe(process.stderr); 15 | cp.on('exit', process.exit); 16 | cp.on('error', function(err){ 17 | console.error(err); 18 | }); 19 | 20 | process.on('SIGTERM', function() { 21 | cp.kill('SIGTERM'); 22 | process.exit(1); 23 | }); 24 | } 25 | } 26 | 27 | /** 28 | creates a function that calls cli command + argus 29 | appends functions arguments to command 30 | */ 31 | var executable = function(command, args) { 32 | var exe = function() { 33 | var _args = ( args || [] ).slice(0); 34 | for( a in arguments ) { 35 | _args.push( arguments[a] ); 36 | } 37 | 38 | var cp = spawn( command, _args, { 39 | env: env 40 | }); 41 | 42 | return cp; 43 | } 44 | 45 | exe.cli = cli( exe ); 46 | 47 | return exe; 48 | } 49 | 50 | module.exports = executable; -------------------------------------------------------------------------------- /lib/haxe-url.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function ( platform, arch, majorVersion, nightly ) { 3 | 4 | var version = majorVersion; 5 | var isNightly = !!nightly; 6 | 7 | var url; 8 | switch ( isNightly ) { 9 | case true: 10 | url = 'https://build.haxe.org/builds/haxe/'; 11 | switch( platform ) { 12 | case 'linux': 13 | url += 'linux'; 14 | switch( arch ) { 15 | case 'x64': 16 | url += '64'; 17 | break; 18 | case 'ia32': 19 | url += '32'; 20 | break; 21 | } 22 | break; 23 | case 'darwin': 24 | url += 'mac'; 25 | break; 26 | case 'win32': 27 | case 'win64': 28 | url += 'windows'; 29 | break; 30 | } 31 | url += '/haxe_'+nightly+'.tar.gz'; 32 | break; 33 | default: 34 | url = 'https://haxe.org/website-content/downloads/' + version + '/downloads/haxe-' + version + '-'; 35 | switch ( platform ) { 36 | case 'linux': 37 | url += 'linux'; 38 | switch( arch ) { 39 | case 'x64': 40 | url += '64'; 41 | break; 42 | case 'ia32': 43 | url += '32'; 44 | break; 45 | } 46 | url += '.tar.gz'; 47 | break; 48 | case 'darwin': 49 | url += 'osx'; 50 | url += '.tar.gz'; 51 | break; 52 | case 'win32': 53 | case 'win64': 54 | url += 'win'; 55 | url += '.zip'; 56 | break; 57 | default: 58 | console.error('Haxe is not compatible with your platform'); 59 | throw 'error'; 60 | } 61 | } 62 | 63 | return url; 64 | } 65 | -------------------------------------------------------------------------------- /lib/install-haxelib-dependencies-task.js: -------------------------------------------------------------------------------- 1 | var haxelib = require('..').haxelib; 2 | var proc = require('child_process'); 3 | 4 | var InstallHaxelibDependenciesTask = function (deps) { 5 | this.dependencies = deps; 6 | }; 7 | 8 | InstallHaxelibDependenciesTask.prototype.run = function(executeNextStep) { 9 | console.log("Installing Haxelib Dependencies" ); 10 | var options = { 11 | cwd : process.env.INIT_CWD, 12 | stdio: [process.stdin, process.stdout, process.stderr], 13 | encoding: 'utf-8' 14 | } 15 | 16 | for(var module in this.dependencies ){ 17 | if(module != "haxe" && module != "haxelib" && module != "neko"){ 18 | var version = this.dependencies[module]; 19 | if (version !== undefined && version.indexOf("git+") == 0){ 20 | var gitRepo = version.substring(4, version.length); 21 | console.log(module + ":" + gitRepo); 22 | var branch = null; 23 | var args = ["git", module]; 24 | if (gitRepo.indexOf("#") != -1){ 25 | var split = gitRepo.split("#"); 26 | gitRepo = split[0]; 27 | branch = split[1]; 28 | args.push(gitRepo); 29 | args.push(branch); 30 | } else { 31 | args.push(gitRepo); 32 | } 33 | args.push("--never"); 34 | console.log("haxelib", args); 35 | var r = proc.spawnSync("haxelib", args, options); 36 | 37 | } else { 38 | console.log(module + ":" + version); 39 | var r = proc.spawnSync("haxelib", ["install", module, version, "--never"], options); 40 | } 41 | } 42 | } 43 | }; 44 | 45 | module.exports.InstallHaxelibDependenciesTask = InstallHaxelibDependenciesTask; 46 | -------------------------------------------------------------------------------- /lib/package-config.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = function(key) { 3 | return process.env[ 'npm_package_haxeDependencies_' + key ]; 4 | } -------------------------------------------------------------------------------- /lib/path.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | module.exports = function(p) { 4 | return path.join(__dirname, '..', p); 5 | } -------------------------------------------------------------------------------- /lib/task-runner.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | 3 | var TaskRunner = function(){ 4 | this.taskList = []; 5 | this.currentTaskIndex = 0; 6 | this.run = function () { 7 | var exitTask = { 8 | run: function () { 9 | console.log("END"); 10 | process.exit(0); 11 | } 12 | }; 13 | this.addTask(exitTask); 14 | this.taskList[0].run(this.delegate(this)); 15 | }; 16 | 17 | this.addTask = function (task) { 18 | this.taskList.push(task); 19 | }; 20 | 21 | this.delegate = function(self){ 22 | return function () { 23 | self.currentTaskIndex++; 24 | self.taskList[self.currentTaskIndex].run(self.delegate(self)); 25 | }; 26 | } 27 | } 28 | module.exports.TaskRunner = TaskRunner; -------------------------------------------------------------------------------- /lib/vars.js: -------------------------------------------------------------------------------- 1 | var path = require('path'); 2 | var packagePath = require('./path'); 3 | 4 | var downloadsPath = packagePath('downloads'); 5 | var haxeDir = path.join(downloadsPath, 'haxe'); 6 | var haxelibDir = path.join(downloadsPath, 'haxelib'); 7 | var nekoDir = path.join(downloadsPath, 'neko'); 8 | 9 | var vars = module.exports = { 10 | haxe : { 11 | dir: haxeDir, 12 | path: path.join(haxeDir, 'haxe') 13 | }, 14 | neko : { 15 | dir: nekoDir, 16 | path: path.join(nekoDir, 'neko') 17 | }, 18 | haxelib : { 19 | dir: haxelibDir, 20 | path: path.join(nekoDir, 'neko'), 21 | args: [ 22 | path.join(haxelibDir, 'run.n') 23 | ] 24 | }, 25 | env : { 26 | HAXELIB_PATH : packagePath('.haxelib'), 27 | HAXE_STD_PATH : path.join(haxeDir, 'std') 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "haxe", 3 | "version": "5.2.1", 4 | "homepage": "http://haxe.org/", 5 | "description": "Wrapper of Haxe, an open source toolkit based on a modern, high level, strictly typed programming language, a cross-compiler, a complete cross-platform standard library and ways to access each platform's native capabilities.", 6 | "keywords": [ 7 | "compiler", 8 | "language", 9 | "haxe", 10 | "wrapper" 11 | ], 12 | "scripts": { 13 | "install": "node install.js", 14 | "test": "cd test && npm pack .. && npm install && node test.js" 15 | }, 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/HaxeFoundation/npm-haxe.git" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/HaxeFoundation/npm-haxe/issues" 22 | }, 23 | "directories": { 24 | "bin": "./bin" 25 | }, 26 | "author": "clemos", 27 | "contributors": [ 28 | "damoebius" 29 | ], 30 | "license": "MIT", 31 | "os": [ 32 | "win32", 33 | "win64", 34 | "darwin", 35 | "linux" 36 | ], 37 | "cpu": [ 38 | "x64", 39 | "ia32" 40 | ], 41 | "engines" : { "node" : ">=8.0.0" }, 42 | "dependencies": { 43 | "download": "7.1.0", 44 | "download-status": "2.2.1", 45 | "fs-extra": "8.1.0" 46 | }, 47 | "haxeDependencies": { 48 | "haxe": "3.4.7", 49 | "haxelib": "3.3.0", 50 | "neko": "2.2.0" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /test/Main.hx: -------------------------------------------------------------------------------- 1 | import pixi.core.graphics.Graphics; 2 | 3 | class Main { 4 | 5 | static function main() { 6 | var graphic = new Graphics(); 7 | graphic.beginFill(0xFF0000, 0.4); 8 | graphic.drawRect(200, 150, 400, 300); 9 | graphic.endFill(); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /test/main.js: -------------------------------------------------------------------------------- 1 | // Generated by Haxe 3.4.7 2 | (function () { "use strict"; 3 | var Main = function() { }; 4 | Main.main = function() { 5 | var graphic = new PIXI.Graphics(); 6 | graphic.beginFill(16711680,0.4); 7 | graphic.drawRect(200,150,400,300); 8 | graphic.endFill(); 9 | }; 10 | var pixi_core_renderers_webgl_filters_CurrentState = function() { }; 11 | Main.main(); 12 | })(); 13 | -------------------------------------------------------------------------------- /test/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "node test.js && haxe -main Main -js main.js -lib pixijs" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "gulp": "^4.0.0", 13 | "haxe": "file:haxe-5.2.1.tgz" 14 | }, 15 | "haxeDependencies": { 16 | "haxe": "3.4.7", 17 | "haxelib": "3.3.0", 18 | "neko": "2.2.0", 19 | "pixijs": "4.5.5", 20 | "tamina": "git+https://github.com/damoebius/taminahx.git" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | console.log("start test"); 3 | 4 | var assert = require('assert'); 5 | var fsx = require('fs-extra'); 6 | var haxe = require('haxe').haxe; 7 | var haxelib = require('haxe').haxelib; 8 | var neko = require('haxe').neko; 9 | 10 | assert.ok(fsx.pathExistsSync("node_modules/haxe/downloads/haxe/std/Any.hx")) 11 | assert.ok(fsx.pathExistsSync("node_modules/haxe/downloads/haxelib/haxelib.json")) 12 | assert.ok(fsx.pathExistsSync("node_modules/haxe/downloads/neko/README.md")) 13 | 14 | assert.ok(haxe); 15 | assert.ok(haxelib); 16 | assert.ok(neko); 17 | 18 | var haxeProcess = haxe( "-version" ); 19 | 20 | haxeProcess.stderr.on('data', (data) => { 21 | //console.log('ee '+data.toString('utf8')); 22 | assert.ok(data.toString('utf8').indexOf('3.4.7') >= 0); 23 | }); 24 | 25 | var haxelibProcess = haxelib( "help" ); 26 | 27 | haxelibProcess.stderr.on('data', (data) => { 28 | //console.log('ee '+data.toString('utf8')); 29 | assert.ok(data.toString('utf8').indexOf('3.3.0') >= 0); 30 | }); 31 | 32 | var nekoProcess = neko( "-version" ); 33 | 34 | nekoProcess.stderr.on('data', (data) => { 35 | //console.log('ee '+data.toString('utf8')); 36 | assert.ok(data.toString('utf8').indexOf('2.1.0') >= 0); 37 | }); 38 | 39 | 40 | console.log("end test"); 41 | --------------------------------------------------------------------------------