Compare commits
168 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5dc698be9d | |||
| 1bf334399b | |||
| a30db5fc5d | |||
| 77cfcf0da4 | |||
| d8541a82ac | |||
| 489bd0f0fe | |||
| a3f30bf783 | |||
| 61ff0b1052 | |||
| e02d39a6bf | |||
| ca414f03db | |||
| 4200724316 | |||
| 686f67fac2 | |||
| 494618cca1 | |||
| 86fe200bfd | |||
| c272f52994 | |||
| 93ed48a537 | |||
| 740e3f441d | |||
| 8204feadaa | |||
| cdf53e133b | |||
| 65c07d4e4a | |||
| 4c3443655e | |||
| 6d20d4da22 | |||
| b72b14b6c3 | |||
| 9134bcf351 | |||
| 1c0d8d0fc0 | |||
| a7c3fda721 | |||
| 7d75480a6f | |||
| 67361b27e1 | |||
| 3b6f9ff4b7 | |||
| 6fcfb10e38 | |||
| 06cab4f43b | |||
| 2cacd8340b | |||
| 0e90ac9f16 | |||
| efd3f78c9d | |||
| 54967d1ab0 | |||
| bb489a3cb7 | |||
| 6097c20204 | |||
| 39665a8d5c | |||
| f49ece0c86 | |||
| 5aca22d28e | |||
| e79b0fb23e | |||
| cac698609c | |||
| b040337a94 | |||
| 06d7730802 | |||
| ad4da1d193 | |||
| 5927b45e70 | |||
| e4155c8fed | |||
| e91f5b52af | |||
| 3b1d5a9fe1 | |||
| 3ac298fe4f | |||
| 229f0516c6 | |||
| 29d5f6aaeb | |||
| 174599df30 | |||
| 3ca6bbbda2 | |||
| 97dbd37068 | |||
| b615e125c0 | |||
| c34f6719b5 | |||
| 2342fe6fdd | |||
| 333cc697c3 | |||
| ece4b2d62a | |||
| ba62973dca | |||
| 9b5892e6ad | |||
| f7ad9a8e83 | |||
| 7c1331bed8 | |||
| e55dacf8c8 | |||
| ec79ff85d4 | |||
| 99a8cbe9b3 | |||
| f458298ffb | |||
| c3fa94a2e5 | |||
| 961f72b1d9 | |||
| d91d91fc2b | |||
| 273bfa3e4d | |||
| 31b01469c7 | |||
| b94d0c3719 | |||
| 275a7b025b | |||
| 71d7b97736 | |||
| faf0a85b36 | |||
| 56578c09b1 | |||
| 6ad1ec436c | |||
| 62461dbc41 | |||
| 7f34aa8854 | |||
| 76072f6df9 | |||
| 83daa5553b | |||
| ff09ef6755 | |||
| 85c8831248 | |||
| 3d2ae606ef | |||
| d4f27aea7f | |||
| 87abd1a295 | |||
| 9fd462da2f | |||
| 60849404a2 | |||
| 00fa37fff0 | |||
| 270350fda6 | |||
| dd2aa5a831 | |||
| afc7140b6b | |||
| 1d47091304 | |||
| 36bbdd4aa9 | |||
| e73804a4dd | |||
| bd1152357e | |||
| c53f229848 | |||
| 3cb81249d8 | |||
| 518fbc7280 | |||
| dd5607886a | |||
| 666774b5b5 | |||
| 3f75ae462e | |||
| dacb31fd67 | |||
| d4e62c668e | |||
| b267d9ba41 | |||
| 75932723ac | |||
| 28442e6714 | |||
| 9bb3b76a65 | |||
| 6702ce326a | |||
| 27075a778d | |||
| 368195be77 | |||
| b11ce7540c | |||
| 069c910b7b | |||
| 934c7bb3d5 | |||
| 8c8a1eddd7 | |||
| 3eea6784dd | |||
| cef44e9b77 | |||
| b6f555c223 | |||
| 87cacafd3e | |||
| 9caa365a3e | |||
| e7e80f5a2c | |||
| 4284c399dd | |||
| 89eeeda575 | |||
| 3b1b82dc40 | |||
| a9a97fefe1 | |||
| 12a7069a32 | |||
| 533ed8c500 | |||
| 875d6d0ff7 | |||
| ea2cfdf5ee | |||
| 60ebde86cc | |||
| d927887355 | |||
| 04280a3016 | |||
| 3c084b9573 | |||
| 708851cc40 | |||
| 2214dccd4a | |||
| ca9fced819 | |||
| 684b285217 | |||
| 1dc6243b75 | |||
| f1a8a7269f | |||
| 4e8830365e | |||
| 34e6f79096 | |||
| e58e22a329 | |||
| 4866e04c13 | |||
| bedcdfe26f | |||
| 5fe8618236 | |||
| 127377a92b | |||
| d6a083778a | |||
| a52eae6665 | |||
| 75ecf22ba9 | |||
| 7f444e93de | |||
| 818da103a8 | |||
| b565aaafc0 | |||
| 67282e2506 | |||
| 3c432a0d3a | |||
| a831244c3d | |||
| ad5532eaad | |||
| 8b03984ca8 | |||
| 953d57240f | |||
| dfb751ca12 | |||
| 0813ef0f67 | |||
| 1e12cad040 | |||
| 015b60ee24 | |||
| 66d3454129 | |||
| b385069ebb | |||
| 51879ed636 | |||
| c018684658 |
+2
-2
@@ -5,5 +5,5 @@ src
|
||||
nexe.exe
|
||||
nexe
|
||||
npm-debug.log
|
||||
# test/**/src
|
||||
test/**/out.nex
|
||||
examples/**/src
|
||||
examples/**/out.nex
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
### Nexe
|
||||
|
||||
[](https://gitter.im/jaredallard/nexe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://david-dm.org/crcn/nexe)
|
||||
[](http://waffle.io/jaredallard/nexe)
|
||||
|
||||
# NOTICE: Node 5.x.x is broken right now.
|
||||
[](https://gitter.im/crcn/nexe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://david-dm.org/crcn/nexe)
|
||||
[](http://waffle.io/crcn/nexe)
|
||||
|
||||
Nexe is a command-line utility that compiles your Node.js application into a single executable file.
|
||||
|
||||
@@ -138,12 +136,12 @@ var nexe = require('nexe');
|
||||
nexe.compile({
|
||||
input: 'input.js',
|
||||
output: 'path/to/bin',
|
||||
nodeVersion: '5.5.0',
|
||||
nodeVersion: '0.12.5',
|
||||
nodeTempDir: 'src',
|
||||
python: 'path/to/python',
|
||||
resourceFiles: [ 'path/to/a/file' ],
|
||||
flags: true,
|
||||
framework: "node" // node, nodejs, or iojs
|
||||
framework: "nodejs"
|
||||
}, function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
@@ -161,8 +159,8 @@ is still in works, so it is likely to change.
|
||||
"output": "nexe^$",
|
||||
"temp": "src",
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "5.5.0",
|
||||
"framework": "iojs",
|
||||
"version": "2.3.1",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
}
|
||||
@@ -176,4 +174,4 @@ Notes:
|
||||
|
||||
* __Jared Allard__ ([@jaredallard](https://github.com/jaredallard)) <[jaredallard@outlook.com](mailto:jaredallard@outlook.com)> (Active)
|
||||
* __Christopher Karper__ ([@ckarper](https://github.com/CKarper)) <[Christopher.Karper@gmail.com](mailto:Christopher.Karper@gmail.com)> (Active)
|
||||
* __Craig Condon__ ([@crcn](https://github.com/crcn)) <[craig.j.condon@gmail.com](mailto:craig.j.condon@gmail.com)> (Old Project Owner)
|
||||
* __Craig Jefferds__ ([@crcn](https://github.com/crcn)) <[craig.j.condon@gmail.com](mailto:craig.j.condon@gmail.com)> (Not Active)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
console.log("hello browser!");
|
||||
@@ -0,0 +1,19 @@
|
||||
var nexe = require('../..');
|
||||
|
||||
nexe.compile(
|
||||
{
|
||||
input: "./index.js",
|
||||
output: "./out.nex",
|
||||
nodeVersion: "3.0.0",
|
||||
framework: "iojs",
|
||||
nodeTempDir: "src",
|
||||
python: "python",
|
||||
flags: true,
|
||||
resourceFiles: ["./message.txt"]
|
||||
},
|
||||
function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
Hello World!!!
|
||||
@@ -0,0 +1,23 @@
|
||||
var http = require("http"),
|
||||
fs = require("fs"),
|
||||
path = require("path"),
|
||||
nexeres = require("nexeres"),
|
||||
childProc = require("child_process"),
|
||||
port = 1337;
|
||||
|
||||
//Fork a new process to execute the broser.js
|
||||
childProc.fork(path.join(__dirname, "browser.js"));
|
||||
if (false) {
|
||||
require("./browser.js"); //force the bundler to include the .js file
|
||||
}
|
||||
|
||||
//start a web server on specified port (or default if not given)
|
||||
console.log("started HTTP server on port %d", port = Number(process.argv.concat().pop()) || port);
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
//return the embeded file in response to any request
|
||||
|
||||
res.write(nexeres.get("message.txt"));
|
||||
|
||||
res.end();
|
||||
}).listen(port);
|
||||
@@ -0,0 +1 @@
|
||||
hello world!
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "./index.js",
|
||||
"browser": "./index.js"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
console.log("hello browser!");
|
||||
@@ -0,0 +1,18 @@
|
||||
var nexe = require('../..');
|
||||
|
||||
nexe.compile(
|
||||
{
|
||||
input: "./index.js",
|
||||
output: "./out.nex",
|
||||
nodeVersion: "3.0.0",
|
||||
nodeTempDir: "./src",
|
||||
framework: "iojs",
|
||||
python: 'python',
|
||||
flags: true
|
||||
},
|
||||
function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
var http = require("http"),
|
||||
fs = require("fs"),
|
||||
path = require("path"),
|
||||
nexeres = require("nexeres"),
|
||||
childProc = require("child_process"),
|
||||
port = 1337;
|
||||
|
||||
//Fork a new process to execute the broser.js
|
||||
childProc.fork(path.join(__dirname, "browser.js"));
|
||||
if (false) {
|
||||
require("./browser.js"); //force the bundler to include the .js file
|
||||
}
|
||||
|
||||
//start a web server on specified port (or default if not given)
|
||||
console.log("started HTTP server on port %d", port = Number(process.argv.concat().pop()) || port);
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
//return the embeded file in response to any request
|
||||
|
||||
res.write("Hello, world!");
|
||||
|
||||
res.end();
|
||||
}).listen(port);
|
||||
@@ -0,0 +1 @@
|
||||
hello world!
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "./index.js",
|
||||
"browser": "./index.js"
|
||||
}
|
||||
+151
-53
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2013 Craig Condon
|
||||
* Copyright (c) 2015-2016 Jared Allard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -22,66 +21,165 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
var mdeps = require("module-deps"),
|
||||
path = require("path"),
|
||||
spawn = require('child_process').spawn,
|
||||
fs = require("fs"),
|
||||
through = require("through2"),
|
||||
async = require("async"),
|
||||
browserify = require('browserify'),
|
||||
builtins = require("builtins"),
|
||||
_log = require("./log");
|
||||
var mdeps = require("module-deps"),
|
||||
through = require("through"),
|
||||
async = require("async"),
|
||||
builtins = require("builtins");
|
||||
|
||||
/**
|
||||
* User browserify to create a "packed" file.
|
||||
*
|
||||
* @param {String} input - input file
|
||||
* @param {String} nc - node compiler dir
|
||||
* @param {Function} complete - next function to call (async)
|
||||
**/
|
||||
function bundle (input, nc, complete) {
|
||||
var bundlePath = path.join(nc, "lib", "nexe.js");
|
||||
var ws = fs.createWriteStream(bundlePath);
|
||||
var proc = spawn('node', [path.join(__dirname, '../', 'node_modules/browserify/bin/cmd.js'), '--node', input ]);
|
||||
var _log = require("./log");
|
||||
|
||||
// TODO: Get path of nexe directory, and refer to it.
|
||||
function bundle (input, complete) {
|
||||
|
||||
proc.stdout.pipe(ws);
|
||||
async.waterfall([
|
||||
|
||||
proc.on('error', function(err) {
|
||||
console.error(err.toString('ascii'));
|
||||
_log('error', 'Failed to invoke browserify');
|
||||
process.exit(1);
|
||||
})
|
||||
/**
|
||||
* first we resolve all of the deps
|
||||
*/
|
||||
|
||||
proc.stderr.on('data', function(data) {
|
||||
console.error(data.toString('ascii'));
|
||||
_log('error', 'Browserify failed to launch');
|
||||
process.exit(1);
|
||||
});
|
||||
function resolveDeps (next) {
|
||||
|
||||
proc.on('close', function(code) {
|
||||
_log("Browserify finished");
|
||||
})
|
||||
|
||||
ws.on('error', function(err) {
|
||||
console.log(err);
|
||||
_log('error', 'Failed to save stdout to disk');
|
||||
process.exit(1);
|
||||
})
|
||||
var deps = [];
|
||||
|
||||
ws.on('close', function() {
|
||||
var source = fs.readFileSync(bundlePath, 'utf8');
|
||||
source = source.replace(/[^\x00-\x7F]/g, "");
|
||||
|
||||
// write the source modified to nexe.js
|
||||
fs.writeFile(bundlePath, source, 'utf8', function(err) {
|
||||
if(err) {
|
||||
_log('error', 'failed to save source');
|
||||
process.exit(1);
|
||||
var md = mdeps({
|
||||
xtransform: function (tr, file) {
|
||||
|
||||
var buffer = [];
|
||||
console.log(tr);
|
||||
|
||||
|
||||
return through(write, end);
|
||||
|
||||
var self = this;
|
||||
|
||||
|
||||
function write (chunk) {
|
||||
buffer.push(chunk.toString());
|
||||
// console.log(chunk.toString(""))
|
||||
console.log(tr);
|
||||
}
|
||||
|
||||
function end() {
|
||||
var content = buffer.join("");
|
||||
// console.log(content);
|
||||
/*
|
||||
// TODO add uglify flag
|
||||
var source = uglify.parse(content, {
|
||||
strict: false
|
||||
});
|
||||
source.figure_out_scope();
|
||||
source.compute_char_frequency();
|
||||
source.mangle_names();
|
||||
|
||||
// TODO - production
|
||||
content = source.print_to_string({
|
||||
ascii_only: true,
|
||||
quote_keys: true
|
||||
});*/
|
||||
|
||||
this.queue(content);
|
||||
this.queue(null);
|
||||
}
|
||||
|
||||
},
|
||||
filter: function (id) {
|
||||
if ([ 'nexeres', 'sys', 'readline' ].indexOf(id) > -1) { return false; }
|
||||
return !~builtins.indexOf(id);
|
||||
},
|
||||
extensions: [ '.js', '.json' ],
|
||||
ignoreMissing: true
|
||||
});
|
||||
|
||||
/** event for missing packages, fixes conditional requires **/
|
||||
md.on('missing', function(id, parent) {
|
||||
_log("warn", "couldn't find require '" + id + "', errors may occur.");
|
||||
});
|
||||
|
||||
md.pipe(through(function (chunk) {
|
||||
deps.push(chunk);
|
||||
}, function () {
|
||||
next(null, deps);
|
||||
}));
|
||||
|
||||
md.end({ file: input })
|
||||
|
||||
},
|
||||
|
||||
function bundleScript (deps, next) {
|
||||
var buffer = [loader.toString()];
|
||||
var dbuffer = [];
|
||||
|
||||
for (var i = deps.length; i--;) {
|
||||
var dep = deps[i];
|
||||
|
||||
var req = "function (require, module, exports, __dirname) { \n"
|
||||
if (dep.id.toLowerCase().indexOf(".json", dep.id.length - 5) !== -1) {
|
||||
//this is the result of require("someFile.json"), so we need to export it from the function
|
||||
req += "module.exports = "
|
||||
}
|
||||
if ((/^\#\!/).test(dep.source)) {
|
||||
dep.source = '//' + dep.source;
|
||||
}
|
||||
|
||||
req += dep.source + "}";
|
||||
|
||||
dbuffer.push(JSON.stringify(dep.id) + ": ["+req+", "+!!dep.entry+", "+JSON.stringify(dep.deps)+"]")
|
||||
}
|
||||
|
||||
complete();
|
||||
});
|
||||
});
|
||||
buffer = ["(" + loader.toString() + ").call(null, {"+dbuffer.join(",")+"}," + JSON.stringify(deps[deps.length-1].id) + ")"].toString();
|
||||
|
||||
next(null, buffer);
|
||||
}
|
||||
], complete)
|
||||
}
|
||||
|
||||
|
||||
var loader = function (deps, key) {
|
||||
var pathModule = global.require("path");
|
||||
var darr = [];
|
||||
var dir = global.require("path").dirname(process.execPath);
|
||||
|
||||
var argv3 = process.argv[3];
|
||||
if (argv3) {
|
||||
argv3 = pathModule.relative(pathModule.dirname(process.execPath), argv3);
|
||||
argv3 = pathModule.resolve(pathModule.dirname(key), argv3);
|
||||
}
|
||||
if (process.argv[2] == "--child_process" && deps[argv3]) {
|
||||
//we've been forked and should run the module specified by argv3[3] instead of the start up module
|
||||
key = argv3;
|
||||
process.argv.splice(2, 2); //restore the argv to [0] = executable, [1] = nexejs
|
||||
}
|
||||
else if (process.argv[2] == "--child_process") {
|
||||
//fork called, but for a module not bundled.
|
||||
argv3 = process.argv[3];
|
||||
process.argv.splice(1, 2); //restore the argv to [0] = executable, [1] = script
|
||||
global.require(argv3);
|
||||
return;
|
||||
}
|
||||
darr.push(deps[key]); //start up module.
|
||||
|
||||
function initModule (dep) {
|
||||
if (dep.module) return dep.module.exports;
|
||||
dep.module = { exports: {} };
|
||||
|
||||
dep[0](function (path) {
|
||||
var rdep = deps[dep[2][path]];
|
||||
var exports = rdep ? rdep.module ? rdep.module.exports : initModule(rdep) : global.require(path);
|
||||
return exports;
|
||||
}, dep.module, dep.module.exports, dir);
|
||||
|
||||
return dep.module.exports;
|
||||
}
|
||||
|
||||
//run the startup module
|
||||
darr.forEach(initModule);
|
||||
|
||||
return darr.filter(function (dep) {
|
||||
return dep[1];
|
||||
}).map(function (dep) {
|
||||
return dep.module || {};
|
||||
}).pop();
|
||||
}
|
||||
|
||||
module.exports = bundle;
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2013 Craig Condon
|
||||
* Copyright (c) 2015-2016 Jared Allard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -22,7 +21,7 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
|
||||
+39
-78
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
* Copyright (c) 2013 Craig Condon
|
||||
* Copyright (c) 2015-2016 Jared Allard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@@ -139,7 +138,7 @@ exports.compile = function (options, complete) {
|
||||
* first download node
|
||||
*/
|
||||
function downloadNode (next) {
|
||||
_downloadNode(version, options.nodeTempDir, nodeConfigureArgs, nodeMakeArgs, next);
|
||||
_downloadNode(version, options.nodeTempDir, next);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -149,7 +148,21 @@ exports.compile = function (options, complete) {
|
||||
function combineProject (nc, next) {
|
||||
nodeCompiler = nc;
|
||||
_log("bundle %s", options.input);
|
||||
bundle(options.input, nodeCompiler.dir, next);
|
||||
bundle(options.input, next);
|
||||
},
|
||||
|
||||
/**
|
||||
* write the bundle to the lib directory of the target node version
|
||||
*/
|
||||
|
||||
function writeBundle (source, next) {
|
||||
bundlePath = path.join(nodeCompiler.dir, "lib", "nexe.js");
|
||||
_log("bundle -> %s", bundlePath);
|
||||
|
||||
//Remove all non-ascii code from sources
|
||||
source = source.replace(/[^\x00-\x7F]/g, "");
|
||||
// same path as all the other JS files
|
||||
fs.writeFile(bundlePath, source, next);
|
||||
},
|
||||
|
||||
function embedResources(next) {
|
||||
@@ -183,37 +196,18 @@ exports.compile = function (options, complete) {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* monkeypatch child_process.js so nexejs knows when it is a forked process
|
||||
*/
|
||||
function monkeyPatchChildProc(next) {
|
||||
_monkeyPatchChildProcess(nodeCompiler, next);
|
||||
},
|
||||
|
||||
/**
|
||||
* If an old compiled executable exists in the Release directory, delete it.
|
||||
* This lets us see if the build failed by checking the existence of this file later.
|
||||
*/
|
||||
|
||||
function cleanUpOldExecutable (next) {
|
||||
fs.unlink(nodeCompiler.releasePath, function (err) {
|
||||
if (err) {
|
||||
if (err.code === "ENOENT") {
|
||||
next();
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
},
|
||||
/**
|
||||
* monkeypatch child_process.js so nexejs knows when it is a forked process
|
||||
*/
|
||||
function monkeyPatchChildProc(next) {
|
||||
_monkeyPatchChildProcess(nodeCompiler, next);
|
||||
},
|
||||
|
||||
/**
|
||||
* compile the node application
|
||||
*/
|
||||
|
||||
function makeExecutable (next) {
|
||||
function makeExe (next) {
|
||||
if(isWin) {
|
||||
_log("vcbuild [make stage]");
|
||||
} else {
|
||||
@@ -230,25 +224,6 @@ exports.compile = function (options, complete) {
|
||||
mkdirp(path.dirname(options.output), function(){ next(); });
|
||||
},
|
||||
|
||||
/**
|
||||
* Verify that the executable was compiled successfully
|
||||
*/
|
||||
|
||||
function checkThatExecutableExists (next) {
|
||||
fs.exists(nodeCompiler.releasePath, function (exists) {
|
||||
if (!exists) {
|
||||
_log("error",
|
||||
"The release executable has not been generated. " +
|
||||
"This indicates a failure in the build process. " +
|
||||
"There is likely additional information above."
|
||||
);
|
||||
throw new Error("The release executable was not built ('" + nodeCompiler.releasePath + "')");
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Copy the compilied binary to the output specified.
|
||||
*/
|
||||
@@ -276,13 +251,14 @@ exports.compile = function (options, complete) {
|
||||
* @param {function} complete, callback
|
||||
*/
|
||||
|
||||
function _downloadNode(version, directory, nodeConfigureArgs, nodeMakeArgs, complete) {
|
||||
function _downloadNode (version, directory, complete) {
|
||||
|
||||
var nodeFileDir = path.resolve(path.join(directory, framework, version)), // fixes #107, was process.cwd(), + rest.
|
||||
nodeFilePath = path.resolve(path.join(nodeFileDir, framework + "-" + version + ".tar.gz"));
|
||||
|
||||
|
||||
// might already be downloaded, and unzipped
|
||||
if (_getNodeCompiler(nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complete)) {
|
||||
if (_getNodeCompiler(nodeFileDir, complete)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -305,16 +281,11 @@ function _downloadNode(version, directory, nodeConfigureArgs, nodeMakeArgs, comp
|
||||
function downloadNode (next) {
|
||||
if (fs.existsSync(nodeFilePath)) return next();
|
||||
|
||||
var uri = framework;
|
||||
|
||||
if(framework==="node") {
|
||||
uri = 'nodejs'; // if node, use nodejs uri
|
||||
} else if(framework === 'nodejs') {
|
||||
framework = 'node'; // support nodejs, and node, as framework.
|
||||
}
|
||||
|
||||
var type = global.type;
|
||||
var url, prefix = "https://"+uri+".org/dist";
|
||||
var url, prefix = "https://"+framework+".org/dist";
|
||||
|
||||
// pick which url depending on the version
|
||||
if(framework==="nodejs") framework = "node"; // cmon node why can't you stay the same
|
||||
|
||||
if (version === "latest") {
|
||||
url = prefix + "/" + framework + "-" + version + ".tar.gz";
|
||||
@@ -364,7 +335,7 @@ function _downloadNode(version, directory, nodeConfigureArgs, nodeMakeArgs, comp
|
||||
*/
|
||||
|
||||
function (next, type) {
|
||||
_getNodeCompiler(nodeFileDir, nodeConfigureArgs, nodeMakeArgs, next, type)
|
||||
_getNodeCompiler(nodeFileDir, next, type)
|
||||
},
|
||||
|
||||
], complete);
|
||||
@@ -375,7 +346,7 @@ function _downloadNode(version, directory, nodeConfigureArgs, nodeMakeArgs, comp
|
||||
* it.
|
||||
*/
|
||||
|
||||
function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complete, type) {
|
||||
function _getNodeCompiler (nodeFileDir, complete, type) {
|
||||
var dir = _getFirstDirectory(nodeFileDir);
|
||||
|
||||
// standard
|
||||
@@ -423,9 +394,9 @@ function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complet
|
||||
make: function (next) {
|
||||
var cfg = "./configure", configure;
|
||||
if(isPy !== "python") {
|
||||
configure = spawn(isPy, [cfg].concat(nodeConfigureArgs), { cwd: dir });
|
||||
configure = spawn(isPy, [cfg], { cwd: dir });
|
||||
} else {
|
||||
configure = spawn(cfg, nodeConfigureArgs, { cwd: dir });
|
||||
configure = spawn(cfg, [], { cwd: dir });
|
||||
}
|
||||
|
||||
// local function, move to top eventually
|
||||
@@ -477,7 +448,7 @@ function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complet
|
||||
if (os.platform().match(/bsd$/) != null) {
|
||||
platformMake = "gmake";
|
||||
}
|
||||
var make = spawn(platformMake, nodeMakeArgs, { cwd: dir });
|
||||
var make = spawn(platformMake, [], { cwd: dir });
|
||||
make.stdout.pipe(process.stdout);
|
||||
make.stderr.pipe(process.stderr);
|
||||
make.on("close", function () {
|
||||
@@ -546,13 +517,7 @@ function _monkeyPatchMainJs (compiler, complete) {
|
||||
return ~content.indexOf("nexe");
|
||||
},
|
||||
function (content, next) {
|
||||
next(null, content.replace(/\(function\(process\) \{/,'\
|
||||
(function(process) {\n\
|
||||
process._eval = \'require("nexe");\';\n\
|
||||
if (process.argv[1] !== "nexe.js") {\n\
|
||||
process.argv.splice(1, 0, "nexe.js");\n\
|
||||
}\n\
|
||||
'))
|
||||
next(null, content.replace(/\(function\(process\) \{/,'(function(process) {\n process._eval = \'require("nexe");\';\n process.argv.splice(1, 0, "nexe.js");\n'))
|
||||
},
|
||||
complete
|
||||
);
|
||||
@@ -569,7 +534,7 @@ function _monkeyPatchChildProcess(compiler, complete) {
|
||||
return ~content.indexOf("--child_process");
|
||||
},
|
||||
function (content, next) {
|
||||
next(null, content.replace(/return spawn\(/, 'args.unshift("nexe.js", "--child_process");\n return spawn('));
|
||||
next(null, content.replace(/return spawn\(/, 'args.unshift("--child_process");\n return spawn('));
|
||||
},
|
||||
complete
|
||||
);
|
||||
@@ -589,7 +554,7 @@ function _monkeyPatchMainCc(compiler, complete) {
|
||||
function (content, next) {
|
||||
var lines = content.split('\n');
|
||||
var endLine = lines.indexOf(' option_end_index = i;'); // pre node 0.11.6 compat
|
||||
|
||||
|
||||
if(endLine !== -1) { // check if it succedded or not.
|
||||
lines[endLine] = ' option_end_index = 1;';
|
||||
_log("patched node.cc")
|
||||
@@ -662,7 +627,7 @@ function _logProgress (req) {
|
||||
*
|
||||
* @param {string} path - path to package.json
|
||||
* @param {object} options - fallback options
|
||||
*
|
||||
*
|
||||
* @todo implement options overriding package defaults.
|
||||
*
|
||||
* @return {object} nexe.compile options object
|
||||
@@ -689,12 +654,8 @@ exports.package = function(path, options) {
|
||||
input: (_package.nexe.input || options.i),
|
||||
output: (_package.nexe.output || options.o),
|
||||
flags: (_package.nexe.runtime.ignoreFlags || options.f),
|
||||
nodeConfigureArgs: (_package.nexe.runtime.nodeConfigureArgs || []),
|
||||
nodeMakeArgs: (_package.nexe.runtime.nodeMakeArgs || []),
|
||||
resourceFiles: (_package.nexe.resourceFiles),
|
||||
nodeVersion: (_package.nexe.runtime.version || options.r),
|
||||
nodeConfigureArgs: (_package.nexe.runtime.nodeConfigureArgs || []),
|
||||
nodeMakeArgs: (_package.nexe.runtime.nodeMakeArgs || []),
|
||||
python: (_package.nexe.python || options.p),
|
||||
nodeTempDir: (_package.nexe.temp || options.t),
|
||||
framework: (_package.nexe.runtime.framework || options.f)
|
||||
|
||||
+14
-19
@@ -3,7 +3,7 @@
|
||||
"name": "nexe",
|
||||
"description": "create single executables out of your [node/io].js applications",
|
||||
"license": "MIT",
|
||||
"version": "1.0.0",
|
||||
"version": "0.4.1",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Criag Condon",
|
||||
@@ -17,39 +17,34 @@
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"async": "1.5.2",
|
||||
"browserify": "^13.0.0",
|
||||
"builtins": "1.0.3",
|
||||
"colors": "^1.1.2",
|
||||
"glob": "^6.0.4",
|
||||
"insert-module-globals": "^7.0.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"module-deps": "^4.0.5",
|
||||
"async": "1.2.1",
|
||||
"builtins": "1.0.1",
|
||||
"colors": "^1.0.3",
|
||||
"glob": "^5.0.5",
|
||||
"mkdirp": "^0.5.0",
|
||||
"module-deps": "^3.6.4",
|
||||
"ncp": "^2.0.0",
|
||||
"outcome": "0.0.18",
|
||||
"progress": "^1.1.8",
|
||||
"request": "^2.67.0",
|
||||
"request": "^2.53.0",
|
||||
"sprintf": "~0.1.5",
|
||||
"step": "0.0.x",
|
||||
"tar.gz": "1.0.2",
|
||||
"through": "^2.3.8",
|
||||
"yargs": "^3.32.0"
|
||||
"tar.gz": "0.1.1",
|
||||
"through": "^2.3.6",
|
||||
"yargs": "^3.2.1"
|
||||
},
|
||||
"nexe": {
|
||||
"input": "./bin/nexe",
|
||||
"output": "nexe^$",
|
||||
"temp": "src",
|
||||
"runtime": {
|
||||
"framework": "nodejs",
|
||||
"version": "5.5.0",
|
||||
"framework": "iojs",
|
||||
"version": "2.3.1",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"preferGlobal": "true",
|
||||
"bin": {
|
||||
"nexe": "./bin/nexe"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodeunit": "^0.9.1"
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Test Express with nexe
|
||||
**/
|
||||
|
||||
console.log('express init');
|
||||
|
||||
var express = require('express');
|
||||
|
||||
var app = express();
|
||||
|
||||
app.get('/', function(req, res) {
|
||||
res.send('It works!');
|
||||
});
|
||||
|
||||
app.listen(8000, function() {
|
||||
console.log('Listening on port 8000');
|
||||
});
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "express-test",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"nexe": {
|
||||
"input": "./index.js",
|
||||
"output": "express-test^$",
|
||||
"temp": "src",
|
||||
"runtime": {
|
||||
"framework": "nodejs",
|
||||
"version": "5.5.0",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.13.4"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user