Compare commits
275 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba351e0e3a | |||
| dc76aea5c8 | |||
| 72afbe68a4 | |||
| ad83cf769f | |||
| 8395f588a3 | |||
| df3d667e4e | |||
| f928f3e758 | |||
| 2f4356d6d2 | |||
| 5cd8b5f177 | |||
| de58ad2593 | |||
| b822f58973 | |||
| de23c5e4c8 | |||
| 8f96b2bca9 | |||
| 968d68b218 | |||
| 5136d3ebe9 | |||
| 6a52ab861d | |||
| 9b2b340f6d | |||
| 03374f9f47 | |||
| 5d56a05531 | |||
| c113fbc731 | |||
| 1e2522852f | |||
| f6b8affdbf | |||
| 2b027229f1 | |||
| 970817e0f4 | |||
| 23947c6d80 | |||
| 88e5e05d49 | |||
| 541765e1d1 | |||
| 0c401f3c1e | |||
| f6a18e18db | |||
| da7b6af0fa | |||
| 694602fa22 | |||
| 7994dc56c4 | |||
| f8b9de750f | |||
| cfd01c60c6 | |||
| 4899c1983b | |||
| 040e3c39a6 | |||
| ebdd8055bd | |||
| 220836ea2f | |||
| 599858f799 | |||
| b526d16298 | |||
| d9d43332c6 | |||
| 42314a7083 | |||
| f690b81a97 | |||
| 6faed1838f | |||
| 841f22f0bb | |||
| ab1d92cf68 | |||
| 208c2b2b56 | |||
| 3b25e7409b | |||
| aa6988c85f | |||
| a8c13a436b | |||
| f50e94a781 | |||
| 71f39e5a11 | |||
| ae4baad4f3 | |||
| 0ffbb5be66 | |||
| 97f6f71788 | |||
| 6a07ea62ea | |||
| ce2db38b92 | |||
| f75948b7e8 | |||
| 36a31b1048 | |||
| b25643483e | |||
| 3f997ca93a | |||
| 6273bd2e9a | |||
| 4d8a1849e8 | |||
| df246cd2fc | |||
| ea38821fd4 | |||
| bbe26640df | |||
| 54675f0e23 | |||
| 3ac02efd18 | |||
| b100922d91 | |||
| 87660c3682 | |||
| 635cd62196 | |||
| 336a5ea2e3 | |||
| 7fe0d207de | |||
| 3e708ca916 | |||
| de84339c80 | |||
| fb81a9c75e | |||
| 0e34905ddc | |||
| c1e7416644 | |||
| 53daa903ea | |||
| 9e2a5f1c78 | |||
| 82a6e8f1c7 | |||
| 7641afa5a4 | |||
| 34210a3bd6 | |||
| 6ce224d6e4 | |||
| 53a9c5a210 | |||
| 727f081e87 | |||
| 907be00fdc | |||
| 14d1ec38d1 | |||
| de531ba750 | |||
| a497851a74 | |||
| 915181d0b0 | |||
| 002727e10f | |||
| a9aa1f81fa | |||
| 16139e1dc7 | |||
| 2bc181f2ab | |||
| 4c80d88013 | |||
| 36094e8d47 | |||
| af42599a15 | |||
| 78ca929350 | |||
| 024b9f8cb3 | |||
| 312a63a0b6 | |||
| 995e03eeea | |||
| b803ae7ddd | |||
| d2e954b5ab | |||
| ec421204d0 | |||
| 292063c482 | |||
| a0a82e9547 | |||
| e1b30b86ae | |||
| 4c88a01003 | |||
| 5dbd6b4048 | |||
| ce6c570c01 | |||
| 44581eb3d3 | |||
| d4be3712cd | |||
| 882c838cb5 | |||
| e6e49bbbd9 | |||
| 0ae40b9a3c | |||
| 879b1598bc | |||
| 5c40ca30af | |||
| afb143daf4 | |||
| 3dd5a2102f | |||
| 2cfd10261a | |||
| e7c7878675 | |||
| 3b42e4a5e8 | |||
| c9431fc206 | |||
| dd68923607 | |||
| 8901e4a2fa | |||
| 38a920be24 | |||
| ce7a36958f | |||
| b0644f0d62 | |||
| 4e402bf937 | |||
| 5a3bbbad3a | |||
| 1d14ca6359 | |||
| 1114a581ae | |||
| 7ab7f986cf | |||
| 1d09a6b001 | |||
| 636268504e | |||
| e8dead82bb | |||
| d2d703e9ea | |||
| 09f36c48e0 | |||
| 6e2870e5d0 | |||
| cd0e5a012c | |||
| 17fe557afa | |||
| e4a8d86237 | |||
| 7b3bcac07c | |||
| fb637e0da3 | |||
| 17c506c9cc | |||
| 7a25c2bfd9 | |||
| f784c79ca1 | |||
| bd75617a2a | |||
| b7ffb8266a | |||
| 08b7ad765d | |||
| 3a7eb91d3b | |||
| a0017ed3fe | |||
| d4205a70c3 | |||
| 380b0e9541 | |||
| 86fa69920c | |||
| 3144ae8d6f | |||
| 322f432756 | |||
| dcf44f7a80 | |||
| 7b68d7bfee | |||
| 1684c8fe5d | |||
| 2c132110b9 | |||
| cf97acfcdb | |||
| a1405a3b36 | |||
| 6c844fa5f7 | |||
| a40454a5ae | |||
| 94c5a54d5f | |||
| 99e228a145 | |||
| 564dffe925 | |||
| 7b9f235715 | |||
| e7b28d0aa5 | |||
| bc37c3ce7b | |||
| 87c5e1df7d | |||
| 05ecc6b8a5 | |||
| e89844fa78 | |||
| 0637e17eb0 | |||
| c8562c384d | |||
| c07e1d62c7 | |||
| ec60175d8f | |||
| 81192a7b3a | |||
| 029487c187 | |||
| 71eef791c6 | |||
| e1eaaa2bfc | |||
| 7ef54aa56f | |||
| c09bca3462 | |||
| 552158485c | |||
| 553d9a2fff | |||
| fcd2acfed6 | |||
| 5c20233ba5 | |||
| 3a74fddcf6 | |||
| 839741d36f | |||
| 9080b05b72 | |||
| de0a2cd517 | |||
| 0f038b1de1 | |||
| d7a909da71 | |||
| aeeb24c757 | |||
| 3cc7c68b12 | |||
| 9247016635 | |||
| bc4f50f69b | |||
| 8a0121023e | |||
| 7308d9665d | |||
| 95afa87f71 | |||
| adff5a3a7c | |||
| 9f86d88ec5 | |||
| fd01aac2e7 | |||
| 9d372ffecd | |||
| 5148a0b980 | |||
| a20406b427 | |||
| f74a47f483 | |||
| 1e982d0e82 | |||
| 7fd13d837c | |||
| 932db9813d | |||
| a0202559bc | |||
| c9025d1c74 | |||
| fb57b09e66 | |||
| 9742681c09 | |||
| ca3ab97bee | |||
| 078540697c | |||
| c583e2f029 | |||
| 5a7a7c9fe5 | |||
| 0868535bbe | |||
| 2164621498 | |||
| 2683359460 | |||
| 94a82867fe | |||
| a91d0428df | |||
| 1dee735cdb | |||
| ed36ebb795 | |||
| 10af1803ab | |||
| 9f93ac0e1e | |||
| 66bde4c761 | |||
| 3803fdaf15 | |||
| 847616a295 | |||
| 085e475bd4 | |||
| 273e864e07 | |||
| 46b2761db8 | |||
| 254615894f | |||
| 1aa897e132 | |||
| 8552619bc5 | |||
| 9007a080cf | |||
| 46503af805 | |||
| 758803540b | |||
| 424a7bdcbb | |||
| d44199e592 | |||
| 7d783ced63 | |||
| 85b9250b9a | |||
| b2871f09cd | |||
| 6ff539b4e6 | |||
| e8ea712a45 | |||
| c3c1ddaaf0 | |||
| b89f9650c5 | |||
| b78cea8c35 | |||
| ddea854649 | |||
| 0281273cd0 | |||
| 336a30e7c0 | |||
| 4f9c040d74 | |||
| cdbdbfbb0d | |||
| 63ba6a307b | |||
| bea9181be6 | |||
| 6a62ea8f10 | |||
| f1a0eb88fd | |||
| e43a473559 | |||
| 207e381309 | |||
| 14005e70d9 | |||
| d6b65478ce | |||
| 11aaccdf66 | |||
| 45dd2d2680 | |||
| a1a06e310c | |||
| 716d947914 | |||
| 5076c15e76 | |||
| 2995a3d916 | |||
| d0e259be6f | |||
| b2f621d7d0 | |||
| a2f6492d71 | |||
| c8aa6a8326 | |||
| 9b82355175 |
+13
-7
@@ -1,9 +1,15 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
*.nex
|
||||
src
|
||||
nexe.exe
|
||||
nexe
|
||||
temp/
|
||||
node_modules
|
||||
npm-debug.log
|
||||
examples/**/src
|
||||
examples/**/out.nex
|
||||
test/**/src
|
||||
test/**/out.nex
|
||||
test/**/test.nex
|
||||
test/**/tmp
|
||||
test/**/node_modules
|
||||
test/**/*.map
|
||||
test/src
|
||||
test/test.log
|
||||
test-results.xml
|
||||
src
|
||||
.idea
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
test
|
||||
src
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
### Nexe
|
||||
<p align="center"><img src="https://cloud.githubusercontent.com/assets/2391349/23598327/a17bb68a-01ee-11e7-8f55-88a5fc96e997.png" /></p>
|
||||
|
||||
[](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)
|
||||
<p align="center">
|
||||
<a href="https://circleci.com/gh/jaredallard/nexe"><img src="https://img.shields.io/circleci/project/jaredallard/nexe.svg" alt="Build Status"></a>
|
||||
<a href="https://www.npmjs.com/package/nexe"><img src="https://img.shields.io/npm/dt/nexe.svg" alt="Downloads"></a>
|
||||
<a href="https://www.npmjs.com/package/nexe"><img src="https://img.shields.io/npm/v/nexe.svg" alt="Version"></a>
|
||||
<a href="https://www.npmjs.com/package/nexe"><img src="https://img.shields.io/npm/l/nexe.svg" alt="License"></a>
|
||||
</p>
|
||||
|
||||
Nexe is a command-line utility that compiles your Node.js application into a single executable file.
|
||||
<p align="center">Nexe is a command-line utility that compiles your Node.js application into a single executable file.</p>
|
||||
|
||||

|
||||

|
||||
|
||||
## Supporting nexe
|
||||
|
||||
nexe is a MIT license project. Please consider joining our [backers](https://github.com/nexe/nexe/BACKERS.md) by contributing to [nexe's Patreon](https://patreon.com/user?u=5264722).
|
||||
|
||||
### Motivation
|
||||
|
||||
@@ -43,7 +50,7 @@ In this case nexe won't bundle the file
|
||||
if (someCheck) {
|
||||
x = require("./ver1.js");
|
||||
} else {
|
||||
x = require("./var2.js");
|
||||
x = require("./ver2.js");
|
||||
}
|
||||
```
|
||||
|
||||
@@ -105,7 +112,7 @@ Via NPM:
|
||||
Or git:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/crcn/nexe.git
|
||||
git clone https://github.com/jaredallard/nexe.git
|
||||
```
|
||||
|
||||
### CLI Usage
|
||||
@@ -134,16 +141,33 @@ Options:
|
||||
var nexe = require('nexe');
|
||||
|
||||
nexe.compile({
|
||||
input: 'input.js',
|
||||
output: 'path/to/bin',
|
||||
nodeVersion: '0.12.5',
|
||||
nodeTempDir: 'src',
|
||||
python: 'path/to/python',
|
||||
resourceFiles: [ 'path/to/a/file' ],
|
||||
flags: true,
|
||||
framework: "nodejs"
|
||||
input: 'input.js', // where the input file is
|
||||
output: 'path/to/bin', // where to output the compiled binary
|
||||
nodeVersion: '5.5.0', // node version
|
||||
nodeTempDir: 'src', // where to store node source.
|
||||
nodeConfigureArgs: ['opt', 'val'], // for all your configure arg needs.
|
||||
nodeMakeArgs: ["-j", "4"], // when you want to control the make process.
|
||||
nodeVCBuildArgs: ["nosign", "x64"], // when you want to control the make process for windows.
|
||||
// By default "nosign" option will be specified
|
||||
// You can check all available options and its default values here:
|
||||
// https://github.com/nodejs/node/blob/master/vcbuild.bat
|
||||
python: 'path/to/python', // for non-standard python setups. Or python 3.x forced ones.
|
||||
resourceFiles: [ 'path/to/a/file' ], // array of files to embed.
|
||||
resourceRoot: [ 'path/' ], // where to embed the resourceFiles.
|
||||
flags: true, // use this for applications that need command line flags.
|
||||
jsFlags: "--use_strict", // v8 flags
|
||||
startupSnapshot: 'path/to/snapshot.js', // when you want to specify a script to be
|
||||
// added to V8's startup snapshot. This V8
|
||||
// feature deserializes a heap to save startup time.
|
||||
// More information in this blog post:
|
||||
// http://v8project.blogspot.de/2015/09/custom-startup-snapshots.html
|
||||
framework: "node" // node, nodejs, or iojs
|
||||
}, function(err) {
|
||||
console.log(err);
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
// do whatever
|
||||
});
|
||||
|
||||
```
|
||||
@@ -153,14 +177,20 @@ nexe.compile({
|
||||
As of 0.4.0 you can now embed nexe options into package.json. Note that this Format
|
||||
is still in works, so it is likely to change.
|
||||
|
||||
```
|
||||
```json
|
||||
"nexe": {
|
||||
"input": "./bin/nexe",
|
||||
"output": "nexe^$",
|
||||
"temp": "src",
|
||||
"browserify": {
|
||||
"requires": [],
|
||||
"excludes": [],
|
||||
"paths": []
|
||||
},
|
||||
"runtime": {
|
||||
"framework": "iojs",
|
||||
"version": "2.3.1",
|
||||
"framework": "node",
|
||||
"version": "5.6.0",
|
||||
"js-flags": "--use_strict",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
}
|
||||
@@ -169,9 +199,51 @@ is still in works, so it is likely to change.
|
||||
Notes:
|
||||
|
||||
* output: can use ^$ for platform specific file extension
|
||||
* js-flags: this is also known as v8 flags, and supports *all* v8 flags.
|
||||
|
||||
### Browserify Require Issues
|
||||
|
||||
If you have requires that aren't resolving well, you can do two things.
|
||||
|
||||
Try adding it to `nexe.browserify.requires` in your `package.json`
|
||||
|
||||
```json
|
||||
"nexe": {
|
||||
.......
|
||||
"browserify": {
|
||||
"requires": [
|
||||
{
|
||||
"file": "myfile.js",
|
||||
"expose": "mymodule"
|
||||
},
|
||||
"mymodule.js"
|
||||
],
|
||||
"excludes": [],
|
||||
"paths": []
|
||||
},
|
||||
.......
|
||||
}
|
||||
```
|
||||
|
||||
Or, if that doesn't work (it tends to not work sometimes), you can try altering
|
||||
browserify.paths like so:
|
||||
|
||||
```json
|
||||
"nexe": {
|
||||
.......
|
||||
"browserify": {
|
||||
"requires": []
|
||||
"excludes": [],
|
||||
"paths": ["/path/to/my/loc"]
|
||||
},
|
||||
.......
|
||||
}
|
||||
```
|
||||
|
||||
If it *still* doesn't work, file a bug with what you tried! (also try using `nexe@0.4.2`)
|
||||
|
||||
## Maintainers
|
||||
|
||||
* __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 Jefferds__ ([@crcn](https://github.com/crcn)) <[craig.j.condon@gmail.com](mailto:craig.j.condon@gmail.com)> (Not Active)
|
||||
* __Craig Condon__ ([@crcn](https://github.com/crcn)) <[craig.j.condon@gmail.com](mailto:craig.j.condon@gmail.com)> (Old Project Owner)
|
||||
|
||||
@@ -1,96 +1,115 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var path = require('path'),
|
||||
fs = require('fs'),
|
||||
nexe = require('../lib'),
|
||||
_log = require("../lib/log"),
|
||||
cli = require('yargs').
|
||||
fs = require('fs'),
|
||||
nexe = require('../lib'),
|
||||
_log = require("../lib/log"),
|
||||
cli = require('yargs').
|
||||
usage('Usage: $0 -i [sources] -o [binary]').
|
||||
options('i', {
|
||||
demand: true,
|
||||
alias: 'input',
|
||||
desc: 'The entry javascript files',
|
||||
default: process.cwd()
|
||||
demand: true,
|
||||
alias: 'input',
|
||||
desc: 'The entry javascript files',
|
||||
default: process.cwd()
|
||||
}).
|
||||
options('o', {
|
||||
demand: true,
|
||||
alias: 'output',
|
||||
desc: 'The output binary',
|
||||
default: "out.nex"
|
||||
demand: true,
|
||||
alias: 'output',
|
||||
desc: 'The output binary',
|
||||
default: "out.nex"
|
||||
}).
|
||||
options('r', {
|
||||
alias: 'runtime',
|
||||
default: 'latest',
|
||||
description: 'The node.js runtime to use'
|
||||
alias: 'runtime',
|
||||
default: 'latest',
|
||||
description: 'The node.js runtime to use'
|
||||
}).
|
||||
options('t', {
|
||||
alias: 'temp',
|
||||
default: './tmp/nexe',
|
||||
description: 'The path to store node.js sources'
|
||||
alias: 'temp',
|
||||
default: './tmp/nexe',
|
||||
description: 'The path to store node.js sources'
|
||||
}).
|
||||
options('f', {
|
||||
alias: 'flags',
|
||||
description: 'Don\'t parse node and v8 flags, pass through app flags',
|
||||
default: false
|
||||
alias: 'flags',
|
||||
description: 'Don\'t parse node and v8 flags, pass through app flags',
|
||||
default: false
|
||||
}).
|
||||
options('d', {
|
||||
alias: 'debug',
|
||||
default: false,
|
||||
description: 'generate and use source maps, large file size'
|
||||
}).
|
||||
options('j', {
|
||||
alias: 'jsFlags',
|
||||
default: false,
|
||||
description: 'v8 flags for runtime'
|
||||
}).
|
||||
options('v', {
|
||||
alias: 'version',
|
||||
description: 'Display version number'
|
||||
alias: 'version',
|
||||
description: 'Display version number'
|
||||
}).
|
||||
options('p', {
|
||||
alias: 'python',
|
||||
description: 'Set path of python to use.',
|
||||
default: 'python'
|
||||
alias: 'python',
|
||||
description: 'Set path of python to use.',
|
||||
default: 'python'
|
||||
}).
|
||||
options('F', {
|
||||
alias: 'framework',
|
||||
description: 'Set the framework to use',
|
||||
default: 'nodejs'
|
||||
alias: 'framework',
|
||||
description: 'Set the framework to use',
|
||||
default: 'nodejs'
|
||||
});
|
||||
|
||||
var argv = cli.argv;
|
||||
if(argv.h || argv.help) {
|
||||
cli.showHelp();
|
||||
process.exit();
|
||||
if (argv.h || argv.help) {
|
||||
cli.showHelp();
|
||||
process.exit();
|
||||
} else if (argv.v || argv.version) {
|
||||
var pkginfo = require('../package.json');
|
||||
console.log(pkginfo.version);
|
||||
process.exit();
|
||||
var pkginfo = require('../package.json');
|
||||
console.log(pkginfo.version);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Support network shares?
|
||||
**/
|
||||
function toAbsolute(pt) {
|
||||
if(pt.substr(0, 1) == "/") return pt;
|
||||
if(pt.substr(1, 3) == ":/") return pt; // for windows "c:/"
|
||||
return path.join(process.cwd(), pt);
|
||||
//already resolved?
|
||||
try{
|
||||
fs.accessSync(pt,fs.F_OK);
|
||||
return pt;
|
||||
}catch(e){}
|
||||
|
||||
if (pt.substr(0, 1) == "/") return pt; // for *nix "/"
|
||||
if (pt.substr(0, 2) == "\\\\") return pt; // for windows "\\"
|
||||
if (pt.substr(1, 3) == ":/") return pt; // for windows "c:/"
|
||||
|
||||
// otherwise...
|
||||
return path.join(process.cwd(), pt);
|
||||
}
|
||||
|
||||
if(fs.lstatSync(argv.i).isDirectory()) {
|
||||
opts = nexe.package(path.join(argv.i, "package.json"), argv);
|
||||
nexe.compile(opts, function(error) {
|
||||
if(error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
});
|
||||
if (fs.lstatSync(argv.i).isDirectory()) {
|
||||
opts = nexe.package(path.join(argv.i, "package.json"), argv);
|
||||
nexe.compile(opts, function(error) {
|
||||
if (error) {
|
||||
return console.log(error.message);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
/**
|
||||
* Call the core
|
||||
**/
|
||||
nexe.compile({
|
||||
input : require.resolve(toAbsolute(argv.i)),
|
||||
output : toAbsolute(argv.o),
|
||||
flags : argv.f,
|
||||
nodeVersion : argv.r,
|
||||
python : argv.python,
|
||||
nodeTempDir : toAbsolute(argv.t),
|
||||
framework : argv.F
|
||||
},
|
||||
function(error) {
|
||||
if(error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
/**
|
||||
* Call the core
|
||||
**/
|
||||
nexe.compile({
|
||||
input: require.resolve(toAbsolute(argv.i)),
|
||||
output: toAbsolute(argv.o),
|
||||
flags: argv.f,
|
||||
nodeVersion: argv.r,
|
||||
python: argv.python,
|
||||
nodeTempDir: toAbsolute(argv.t),
|
||||
framework: argv.F
|
||||
},
|
||||
function(error) {
|
||||
if (error) {
|
||||
return console.log(error.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
machine:
|
||||
node:
|
||||
version: 5.7.0
|
||||
|
||||
test:
|
||||
override:
|
||||
- npm test:
|
||||
timeout: 5400
|
||||
@@ -1 +0,0 @@
|
||||
console.log("hello browser!");
|
||||
@@ -1,19 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1 +0,0 @@
|
||||
Hello World!!!
|
||||
@@ -1,23 +0,0 @@
|
||||
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);
|
||||
@@ -1 +0,0 @@
|
||||
hello world!
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"main": "./index.js",
|
||||
"browser": "./index.js"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
console.log("hello browser!");
|
||||
@@ -1,18 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1,23 +0,0 @@
|
||||
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);
|
||||
@@ -1 +0,0 @@
|
||||
hello world!
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"main": "./index.js",
|
||||
"browser": "./index.js"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
This is a
|
||||
- [ ] Bug Report
|
||||
- [ ] Feature Request
|
||||
- [ ] Other
|
||||
|
||||
<br/>
|
||||
If this is a bug report, What are the steps to reproduce?
|
||||
|
||||
```
|
||||
//provide configuration here
|
||||
```
|
||||
|
||||
<br/><br/>
|
||||
Please also provide:
|
||||
|
||||
- Platform(OS/Version):
|
||||
- Host Node Version:
|
||||
- Target Node Version:
|
||||
- Nexe version:
|
||||
- Python Version:
|
||||
|
||||
|
||||
+93
-141
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -21,165 +22,116 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
var mdeps = require("module-deps"),
|
||||
through = require("through"),
|
||||
async = require("async"),
|
||||
builtins = require("builtins");
|
||||
|
||||
var _log = require("./log");
|
||||
'use strict';
|
||||
|
||||
function bundle (input, complete) {
|
||||
let browserify = require('browserify'),
|
||||
path = require("path"),
|
||||
spawn = require('child_process').spawn,
|
||||
insertGlobals = require('insert-module-globals'),
|
||||
fs = require("fs"),
|
||||
async = require("async"),
|
||||
_log = require("./log");
|
||||
|
||||
async.waterfall([
|
||||
/**
|
||||
* User browserify to create a "packed" file.
|
||||
*
|
||||
* @param {string} input - input file
|
||||
* @param {string} nc - node compiler dir
|
||||
* @param {array} options - nexe options
|
||||
* @param {function} complete - next function to call (async)
|
||||
**/
|
||||
function bundle(input, nc, options, complete) {
|
||||
const bundlePath = path.join(nc, "lib", "nexe.js");
|
||||
const mapfile = options.output+'.map';
|
||||
let ws = fs.createWriteStream(bundlePath);
|
||||
|
||||
/**
|
||||
* first we resolve all of the deps
|
||||
*/
|
||||
const igv = '__filename,__dirname,_process';
|
||||
let insertGlobalVars = { isNexe: true },
|
||||
wantedGlobalVars = igv.split(',');
|
||||
|
||||
function resolveDeps (next) {
|
||||
// parse insertGlobalVars.
|
||||
Object.keys(insertGlobals.vars).forEach(function (x) {
|
||||
if (wantedGlobalVars.indexOf(x) === -1) {
|
||||
insertGlobalVars[x] = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
let paths = [path.join(nc, 'lib')];
|
||||
|
||||
if(options.browserifyPaths) {
|
||||
paths = paths.concat(options.browserifyPaths);
|
||||
}
|
||||
|
||||
|
||||
var deps = [];
|
||||
_log('executing browserify via API');
|
||||
let bproc = browserify([input], {
|
||||
debug: options.debug,
|
||||
commondir: false,
|
||||
paths: paths,
|
||||
builtins: false,
|
||||
insertGlobalVars: insertGlobalVars,
|
||||
detectGlobals: true,
|
||||
browserField: false
|
||||
});
|
||||
|
||||
if (options.browserifyExcludes && Array.isArray(options.browserifyExcludes)) {
|
||||
for (let i = 0; i < options.browserifyExcludes.length; i++) {
|
||||
let lib = options.browserifyExcludes[i];
|
||||
_log('Excluding \'%s\' from browserify bundle', lib);
|
||||
bproc.exclude(lib);
|
||||
}
|
||||
}
|
||||
|
||||
var md = mdeps({
|
||||
xtransform: function (tr, file) {
|
||||
// copy the excludes code for requires for now.
|
||||
if (options.browserifyRequires && Array.isArray(options.browserifyRequires)) {
|
||||
for (let i = 0; i < options.browserifyRequires.length; i++) {
|
||||
let lib = options.browserifyRequires[i];
|
||||
let name = lib.file || lib; // for object format.
|
||||
// if `lib` is object then fetch all params without `file`
|
||||
// otherwise returns empty object
|
||||
let opts = (lib instanceof Object) && Object.keys(lib)
|
||||
.filter((key) => key !== 'file')
|
||||
.reduce((acc, key) => { return acc[key] = lib[key], acc }, {})
|
||||
|| {};
|
||||
|
||||
var buffer = [];
|
||||
console.log(tr);
|
||||
_log('Force including \'%s\' in browserify bundle', name);
|
||||
bproc.require(lib, opts);
|
||||
}
|
||||
}
|
||||
|
||||
if(options.debug) {
|
||||
bproc.require(require.resolve('source-map-support'))
|
||||
}
|
||||
|
||||
return through(write, end);
|
||||
let bprocbun = bproc.bundle() // bundle
|
||||
.pipe(ws) // pipe to file
|
||||
|
||||
var self = this;
|
||||
// error on require errors, still can't contionue. ffs browserify
|
||||
bprocbun.on('error', function(err) {
|
||||
_log('error', '[browserify] '+err);
|
||||
});
|
||||
|
||||
ws.on('error', function(err) {
|
||||
console.log(err);
|
||||
_log('error', 'Failed to save stdout to disk');
|
||||
process.exit(1);
|
||||
})
|
||||
|
||||
function write (chunk) {
|
||||
buffer.push(chunk.toString());
|
||||
// console.log(chunk.toString(""))
|
||||
console.log(tr);
|
||||
}
|
||||
ws.on('close', function() {
|
||||
var source = fs.readFileSync(bundlePath, 'utf8');
|
||||
source = source.replace(/[^\x00-\x7F]/g, "");
|
||||
|
||||
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)+"]")
|
||||
// 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);
|
||||
}
|
||||
|
||||
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();
|
||||
complete();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = bundle;
|
||||
|
||||
+27
-18
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* 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
|
||||
@@ -21,15 +22,33 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
'use strict';
|
||||
|
||||
let path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
/**
|
||||
* TODO: Optimize this code. (more like document it so I understand it better.)
|
||||
* Accessort for embed
|
||||
**/
|
||||
function embed(resourceFiles, resourceRoot, complete) {
|
||||
function encode(filePath) {
|
||||
const accessor = function(key) {
|
||||
if (embeddedFiles.hasOwnProperty(key)) {
|
||||
return new Buffer(embeddedFiles[key], 'base64');
|
||||
} else {
|
||||
//file was not embedded, throw err.
|
||||
throw new Error('Embedded file not found');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Embed files.
|
||||
*
|
||||
* @param {array} resourceFiles - array of files to embed.
|
||||
* @param {string} resourceRoot - root of resources.
|
||||
* @param {function} compelte - callback
|
||||
**/
|
||||
function embed(resourceFiles, resourceRoot, options, complete) {
|
||||
const encode = function(filePath) {
|
||||
return fs.readFileSync(filePath).toString('base64');
|
||||
}
|
||||
|
||||
@@ -40,8 +59,8 @@ function embed(resourceFiles, resourceRoot, complete) {
|
||||
throw new Error("Bad Argument: resourceFiles is not an array");
|
||||
}
|
||||
|
||||
var buffer = "var embeddedFiles = {\n";
|
||||
for (var i = 0; i < resourceFiles.length; ++i) {
|
||||
let buffer = "var embeddedFiles = {\n";
|
||||
for (let i = 0; i < resourceFiles.length; ++i) {
|
||||
buffer += JSON.stringify(path.relative(resourceRoot, resourceFiles[i])) + ': "';
|
||||
buffer += encode(resourceFiles[i]) + '",\n';
|
||||
}
|
||||
@@ -51,14 +70,4 @@ function embed(resourceFiles, resourceRoot, complete) {
|
||||
complete(null, buffer);
|
||||
}
|
||||
|
||||
var accessor = function (key) {
|
||||
if (embeddedFiles.hasOwnProperty(key)) {
|
||||
return new Buffer(embeddedFiles[key], 'base64');
|
||||
}
|
||||
else {
|
||||
//file was not embedded, throw err.
|
||||
throw new Error('Embedded file not found');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = embed;
|
||||
|
||||
+869
-491
File diff suppressed because it is too large
Load Diff
+3
-2
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* 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,6 +23,8 @@
|
||||
*
|
||||
**/
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
/**
|
||||
* standard output, takes 3 different types.
|
||||
* log, error, and warn
|
||||
@@ -31,8 +34,6 @@
|
||||
**/
|
||||
function _log () {
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
level = args.shift();
|
||||
|
||||
|
||||
+23
-18
@@ -3,7 +3,7 @@
|
||||
"name": "nexe",
|
||||
"description": "create single executables out of your [node/io].js applications",
|
||||
"license": "MIT",
|
||||
"version": "0.4.1",
|
||||
"version": "1.1.3",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Criag Condon",
|
||||
@@ -11,40 +11,45 @@
|
||||
"url": "http://crcn.io/"
|
||||
}
|
||||
],
|
||||
"scripts": {
|
||||
"test": "echo node: $(node -v) && node_modules/.bin/mocha --reporter mocha-circleci-reporter test/test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jaredallard/nexe.git"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"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",
|
||||
"async": "^1.5.2",
|
||||
"browserify": "^13.0.0",
|
||||
"colors": "^1.1.2",
|
||||
"glob": "^7.0.0",
|
||||
"gunzip-maybe": "^1.3.1",
|
||||
"insert-module-globals": "^7.0.1",
|
||||
"mkdirp": "^0.5.1",
|
||||
"module-deps": "^4.0.5",
|
||||
"ncp": "^2.0.0",
|
||||
"outcome": "0.0.18",
|
||||
"progress": "^1.1.8",
|
||||
"request": "^2.53.0",
|
||||
"sprintf": "~0.1.5",
|
||||
"step": "0.0.x",
|
||||
"tar.gz": "0.1.1",
|
||||
"through": "^2.3.6",
|
||||
"yargs": "^3.2.1"
|
||||
"request": "^2.67.0",
|
||||
"tar-stream": "^1.3.1",
|
||||
"yargs": "^4.2.0"
|
||||
},
|
||||
"nexe": {
|
||||
"input": "./bin/nexe",
|
||||
"output": "nexe^$",
|
||||
"temp": "src",
|
||||
"runtime": {
|
||||
"framework": "iojs",
|
||||
"version": "2.3.1",
|
||||
"framework": "nodejs",
|
||||
"version": "5.5.0",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
},
|
||||
"preferGlobal": "true",
|
||||
"preferGlobal": true,
|
||||
"bin": {
|
||||
"nexe": "./bin/nexe"
|
||||
"nexe": "bin/nexe"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^2.4.5",
|
||||
"mocha-circleci-reporter": "0.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
true
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Embedded Files Test
|
||||
*
|
||||
* @author Jared Allard <jaredallard@outlook.com>
|
||||
* @version 0.0.1
|
||||
* @license MIT
|
||||
**/
|
||||
|
||||
const nexeres = require('nexeres');
|
||||
|
||||
process.stdout.write(nexeres.get('hw.txt').toString('ascii'));
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "embededfiles-test",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
},
|
||||
"nexe": {
|
||||
"input": "index.js",
|
||||
"output": "test.nex",
|
||||
"resourceFiles": [
|
||||
"hw.txt"
|
||||
],
|
||||
"browserify": {
|
||||
"excludes": [],
|
||||
"requires": []
|
||||
},
|
||||
"temp": "../src",
|
||||
"debug": false,
|
||||
"runtime": {
|
||||
"nodeConfigureOpts": ["--fully-static"],
|
||||
"framework": "node",
|
||||
"version": "5.7.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
var express = require('express');
|
||||
var path = require('path');
|
||||
var favicon = require('serve-favicon');
|
||||
var logger = require('morgan');
|
||||
var cookieParser = require('cookie-parser');
|
||||
var bodyParser = require('body-parser');
|
||||
var jade = require('jade');
|
||||
|
||||
var routes = require('./routes/index');
|
||||
var users = require('./routes/users');
|
||||
|
||||
var app = express();
|
||||
|
||||
// view engine setup
|
||||
app.set('views', path.join(__dirname, 'views'));
|
||||
app.set('view engine', 'jade');
|
||||
|
||||
// uncomment after placing your favicon in /public
|
||||
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
|
||||
app.use(logger('dev'));
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: false }));
|
||||
app.use(cookieParser());
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
app.use('/', routes);
|
||||
app.use('/users', users);
|
||||
|
||||
// catch 404 and forward to error handler
|
||||
app.use(function(req, res, next) {
|
||||
var err = new Error('Not Found');
|
||||
err.status = 404;
|
||||
next(err);
|
||||
});
|
||||
|
||||
// error handlers
|
||||
|
||||
// development error handler
|
||||
// will print stacktrace
|
||||
if (app.get('env') === 'development') {
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: err
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// production error handler
|
||||
// no stacktraces leaked to user
|
||||
app.use(function(err, req, res, next) {
|
||||
res.status(err.status || 500);
|
||||
res.render('error', {
|
||||
message: err.message,
|
||||
error: {}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
module.exports = app;
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var app = require('../app');
|
||||
var debug = require('debug')('express-test:server');
|
||||
var http = require('http');
|
||||
|
||||
/**
|
||||
* Get port from environment and store in Express.
|
||||
*/
|
||||
|
||||
var port = normalizePort(process.env.PORT || '3000');
|
||||
app.set('port', port);
|
||||
|
||||
/**
|
||||
* Create HTTP server.
|
||||
*/
|
||||
|
||||
var server = http.createServer(app);
|
||||
|
||||
/**
|
||||
* Listen on provided port, on all network interfaces.
|
||||
*/
|
||||
|
||||
server.listen(port);
|
||||
server.on('error', onError);
|
||||
server.on('listening', onListening);
|
||||
|
||||
/**
|
||||
* Normalize a port into a number, string, or false.
|
||||
*/
|
||||
|
||||
function normalizePort(val) {
|
||||
var port = parseInt(val, 10);
|
||||
|
||||
if (isNaN(port)) {
|
||||
// named pipe
|
||||
return val;
|
||||
}
|
||||
|
||||
if (port >= 0) {
|
||||
// port number
|
||||
return port;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "error" event.
|
||||
*/
|
||||
|
||||
function onError(error) {
|
||||
if (error.syscall !== 'listen') {
|
||||
throw error;
|
||||
}
|
||||
|
||||
var bind = typeof port === 'string'
|
||||
? 'Pipe ' + port
|
||||
: 'Port ' + port;
|
||||
|
||||
// handle specific listen errors with friendly messages
|
||||
switch (error.code) {
|
||||
case 'EACCES':
|
||||
console.error(bind + ' requires elevated privileges');
|
||||
process.exit(1);
|
||||
break;
|
||||
case 'EADDRINUSE':
|
||||
console.error(bind + ' is already in use');
|
||||
process.exit(1);
|
||||
break;
|
||||
default:
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for HTTP server "listening" event.
|
||||
*/
|
||||
|
||||
function onListening() {
|
||||
var addr = server.address();
|
||||
var bind = typeof addr === 'string'
|
||||
? 'pipe ' + addr
|
||||
: 'port ' + addr.port;
|
||||
debug('Listening on ' + bind);
|
||||
}
|
||||
|
||||
process.stdout.write('true');
|
||||
process.exit(0);
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "express-test",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node ./bin/www"
|
||||
},
|
||||
"dependencies": {
|
||||
"body-parser": "~1.13.2",
|
||||
"cookie-parser": "~1.3.5",
|
||||
"debug": "~2.2.0",
|
||||
"express": "~4.13.1",
|
||||
"jade": "~1.11.0",
|
||||
"morgan": "~1.6.1",
|
||||
"serve-favicon": "~2.3.0"
|
||||
},
|
||||
"nexe": {
|
||||
"input": "bin/www",
|
||||
"output": "test.nex",
|
||||
"temp": "../src",
|
||||
"debug": false,
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "5.10.0",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
body {
|
||||
padding: 50px;
|
||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #00B7FF;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET home page. */
|
||||
router.get('/', function(req, res, next) {
|
||||
res.render('index', { title: 'Express' });
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,9 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
|
||||
/* GET users listing. */
|
||||
router.get('/', function(req, res, next) {
|
||||
res.send('respond with a resource');
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,6 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
h1= message
|
||||
h2= error.status
|
||||
pre #{error.stack}
|
||||
@@ -0,0 +1,5 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
h1= title
|
||||
p Welcome to #{title}
|
||||
@@ -0,0 +1,7 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title= title
|
||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||
body
|
||||
block content
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Test to verify if we support strict mode (flags)
|
||||
*
|
||||
* @author Jared Allard <jaredallard@outlook.com>
|
||||
* @version 0.0.1
|
||||
* @license MIT
|
||||
**/
|
||||
|
||||
// "use strict"; w/o --use_strict
|
||||
|
||||
let isStrict = (function() { return !this; })();
|
||||
|
||||
console.log(isStrict);
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "flags-test",
|
||||
"nexe": {
|
||||
"input": "./index.js",
|
||||
"output": "test.nex",
|
||||
"temp": "../src",
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "5.7.0",
|
||||
"ignoreFlags": false,
|
||||
"js-flags": "--use_strict",
|
||||
"node-args": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
let gulp = require('gulp');
|
||||
let nexe = require('nexe');
|
||||
|
||||
gulp.task( "compile", ( callback ) => {
|
||||
let options = {
|
||||
input: "index.js",
|
||||
output: "test.nex",
|
||||
python: "python",
|
||||
nodeTempDir: "./tmp",
|
||||
nodeVersion: "latest",
|
||||
flags: false,
|
||||
framework: "nodejs"
|
||||
};
|
||||
|
||||
nexe.compile( options, ( err ) => {
|
||||
console.log( err );
|
||||
callback( err );
|
||||
} );
|
||||
} );
|
||||
|
||||
gulp.task('default', ['compile']);
|
||||
@@ -0,0 +1,2 @@
|
||||
// it probably executed.
|
||||
console.log(true);
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "gulp-test-170",
|
||||
"version": "0.0.1",
|
||||
"description": "gulpfile.js issue #170",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Jared Allard <jaredallard@outlook.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"gulp": "^3.9.0",
|
||||
"nexe": "^1.0.5"
|
||||
},
|
||||
"nexe": {
|
||||
"input": "./index.js",
|
||||
"output": "test.nex",
|
||||
"temp": "../src",
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "5.7.0",
|
||||
"ignoreFlags": true,
|
||||
"node-args": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Test to verify if we support strict mode (flags)
|
||||
*
|
||||
* @author Jared Allard <jaredallard@outlook.com>
|
||||
* @version 0.0.1
|
||||
* @license MIT
|
||||
**/
|
||||
|
||||
// test.nex --help
|
||||
|
||||
let status = false;
|
||||
|
||||
// console.log(process.argv);
|
||||
|
||||
if(process.argv[2]) {
|
||||
status = true;
|
||||
}
|
||||
|
||||
console.log(status);
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "flags-test",
|
||||
"nexe": {
|
||||
"input": "./index.js",
|
||||
"output": "test.nex",
|
||||
"temp": "../src",
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "5.7.0",
|
||||
"ignoreFlags": true,
|
||||
"node-args": ""
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
require('js-yaml');
|
||||
|
||||
console.log(true);
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "js-yaml-148",
|
||||
"version": "1.0.0",
|
||||
"description": "#148 js-yaml fails to work",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Jared Allard <jaredallard@outlook.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"js-yaml": "^3.5.2"
|
||||
},
|
||||
"nexe": {
|
||||
"input": "index.js",
|
||||
"output": "test.nex",
|
||||
"temp": "../src",
|
||||
"runtime": {
|
||||
"version": "5.7.0",
|
||||
"framework": "node"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
--timeout 100000000
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
/**
|
||||
* Test runner for nexe
|
||||
*
|
||||
* @author Jared Allard <jaredallard@outlook.com>
|
||||
* @license MIT
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const spawn = require('child_process').spawn;
|
||||
|
||||
// our vars
|
||||
const NEXE_VERSION = require('../package.json').version;
|
||||
const testBase = __dirname;
|
||||
const LOG_FILE = path.join(testBase, 'test.log');
|
||||
|
||||
if(fs.existsSync(LOG_FILE)) {
|
||||
fs.unlinkSync(LOG_FILE);
|
||||
}
|
||||
|
||||
let logfile = fs.createWriteStream(LOG_FILE, {
|
||||
autoClose: false
|
||||
});
|
||||
|
||||
const compileTest = function(test, cb) {
|
||||
let testDir = path.join(testBase, test);
|
||||
if(!fs.existsSync(testDir)) {
|
||||
throw new Error('Test not found');
|
||||
return cb(false);
|
||||
}
|
||||
|
||||
let npminst = spawn('npm', ['install'], {
|
||||
cwd: testDir
|
||||
});
|
||||
|
||||
npminst.on('error', function() {
|
||||
throw new Error('Failed to execute NPM');
|
||||
return cb(false);
|
||||
});
|
||||
|
||||
npminst.on('close', function(code) {
|
||||
if(code !== 0) {
|
||||
throw new Error('NPM exited with non-zero status');
|
||||
return cb(false);
|
||||
}
|
||||
|
||||
let testinst = spawn('../../bin/nexe', [], {
|
||||
cwd: testDir
|
||||
});
|
||||
|
||||
testinst.on('error', function() {
|
||||
throw new Error('Test failed to compile');
|
||||
return cb(false);
|
||||
});
|
||||
|
||||
testinst.on('close', function(code) {
|
||||
let err = null;
|
||||
if(code !== 0) {
|
||||
throw new Error('Test gave non-zero code');
|
||||
err = false;
|
||||
}
|
||||
|
||||
logfile = fs.createWriteStream(LOG_FILE);
|
||||
|
||||
return cb(err);
|
||||
});
|
||||
|
||||
testinst.stdout.on('data', function(d) {
|
||||
process.stdout.write(d.toString('ascii'));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Run a test-generated binary
|
||||
*
|
||||
* @param {string} test - test name (dir)
|
||||
* @param {array} optional args - array of args to pass to the binary
|
||||
* @param {function} cb - callback
|
||||
**/
|
||||
const runTest = function(test, args, cb) {
|
||||
let testDir = path.join(testBase, test);
|
||||
let testBin = path.join(testDir, 'test.nex')
|
||||
|
||||
// check params
|
||||
if(!Array.isArray(args)) {
|
||||
cb = args;
|
||||
args = [];
|
||||
}
|
||||
|
||||
if(!fs.existsSync(testDir)) {
|
||||
throw new Error('Test not found');
|
||||
return cb(false);
|
||||
}
|
||||
|
||||
if(!fs.existsSync(testBin)) {
|
||||
throw new Error('Test binary not found');
|
||||
return cb(false);
|
||||
}
|
||||
|
||||
let returned = false;
|
||||
let testinst = spawn(testBin, args, {
|
||||
cwd: testDir
|
||||
})
|
||||
|
||||
testinst.stdout.on('data', function(d) {
|
||||
let status = d.toString('ascii');
|
||||
|
||||
if(status === true || status === 'true' || status === 'true\n') {
|
||||
testinst.stdin.pause();
|
||||
testinst.kill();
|
||||
|
||||
// make it know we returned.
|
||||
returned = true;
|
||||
|
||||
return cb();
|
||||
}
|
||||
})
|
||||
|
||||
testinst.on('close', function(c) {
|
||||
if(returned !== true) {
|
||||
throw new Error('Test failed (stdout never contained true)');
|
||||
return cb(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
console.log('NOTICE: The first test may take awhile as it may compile Node.js');
|
||||
console.log(' Monitor the log file (test.log) for progress.');
|
||||
|
||||
|
||||
after(function() {
|
||||
console.log('notice: closing test.log file descriptor.')
|
||||
logfile.end();
|
||||
});
|
||||
|
||||
/**
|
||||
* Tests express compatability.
|
||||
**/
|
||||
describe('nexe can bundle express', function() {
|
||||
let testname = 'express-test';
|
||||
|
||||
describe('build', function () {
|
||||
it('compiles without errors', function (next) {
|
||||
compileTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs successfully', function(next) {
|
||||
runTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('nexe and embedding files', function() {
|
||||
let testname = 'embeded-files';
|
||||
|
||||
describe('build', function () {
|
||||
it('compiles without errors', function (next) {
|
||||
compileTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs successfully', function(next) {
|
||||
runTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('v8 flags test (strict mode)', function() {
|
||||
let testname = 'flags-test';
|
||||
|
||||
describe('build', function () {
|
||||
it('compiles without errors', function (next) {
|
||||
compileTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs successfully', function(next) {
|
||||
runTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('nexe can be utilized in gulp test', function() {
|
||||
let testname = 'gulp-test-170';
|
||||
|
||||
describe('build', function () {
|
||||
it('compiles without errors', function (next) {
|
||||
compileTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs successfully', function(next) {
|
||||
runTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('nexe can ignore node.js flags test', function() {
|
||||
let testname = 'ignoreFlags-test';
|
||||
|
||||
describe('build', function () {
|
||||
it('compiles without errors', function (next) {
|
||||
compileTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs successfully', function(next) {
|
||||
runTest(testname, ['--help'], function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('nexe supports js-yaml test', function() {
|
||||
let testname = 'js-yaml-148';
|
||||
|
||||
describe('build', function () {
|
||||
it('compiles without errors', function (next) {
|
||||
compileTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
|
||||
it('runs successfully', function(next) {
|
||||
runTest(testname, function(err) {
|
||||
return next(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user