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 |
+7
-13
@@ -1,15 +1,9 @@
|
||||
.DS_Store
|
||||
temp/
|
||||
node_modules
|
||||
npm-debug.log
|
||||
test/**/src
|
||||
test/**/out.nex
|
||||
test/**/test.nex
|
||||
test/**/tmp
|
||||
test/**/node_modules
|
||||
test/**/*.map
|
||||
test/src
|
||||
test/test.log
|
||||
test-results.xml
|
||||
.DS_Store
|
||||
*.nex
|
||||
src
|
||||
.idea
|
||||
nexe.exe
|
||||
nexe
|
||||
npm-debug.log
|
||||
examples/**/src
|
||||
examples/**/out.nex
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
node_modules
|
||||
test
|
||||
src
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
<p align="center"><img src="https://cloud.githubusercontent.com/assets/2391349/23598327/a17bb68a-01ee-11e7-8f55-88a5fc96e997.png" /></p>
|
||||
### 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>
|
||||
[](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">Nexe is a command-line utility that compiles your Node.js application into a single executable file.</p>
|
||||
Nexe is a command-line utility that compiles your Node.js application into a single executable file.
|
||||
|
||||

|
||||

|
||||
|
||||
## 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
|
||||
|
||||
@@ -50,7 +43,7 @@ In this case nexe won't bundle the file
|
||||
if (someCheck) {
|
||||
x = require("./ver1.js");
|
||||
} else {
|
||||
x = require("./ver2.js");
|
||||
x = require("./var2.js");
|
||||
}
|
||||
```
|
||||
|
||||
@@ -112,7 +105,7 @@ Via NPM:
|
||||
Or git:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/jaredallard/nexe.git
|
||||
git clone https://github.com/crcn/nexe.git
|
||||
```
|
||||
|
||||
### CLI Usage
|
||||
@@ -141,33 +134,16 @@ Options:
|
||||
var nexe = require('nexe');
|
||||
|
||||
nexe.compile({
|
||||
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
|
||||
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"
|
||||
}, function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
|
||||
// do whatever
|
||||
console.log(err);
|
||||
});
|
||||
|
||||
```
|
||||
@@ -177,20 +153,14 @@ 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": "node",
|
||||
"version": "5.6.0",
|
||||
"js-flags": "--use_strict",
|
||||
"framework": "iojs",
|
||||
"version": "2.3.1",
|
||||
"ignoreFlags": true
|
||||
}
|
||||
}
|
||||
@@ -199,51 +169,9 @@ 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 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)
|
||||
|
||||
@@ -1,115 +1,96 @@
|
||||
#!/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
|
||||
}).
|
||||
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'
|
||||
alias: 'flags',
|
||||
description: 'Don\'t parse node and v8 flags, pass through app flags',
|
||||
default: false
|
||||
}).
|
||||
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) {
|
||||
//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(pt.substr(0, 1) == "/") return pt;
|
||||
if(pt.substr(1, 3) == ":/") return pt; // for windows "c:/"
|
||||
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) {
|
||||
return 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) {
|
||||
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) {
|
||||
return 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) {
|
||||
console.log(error.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
machine:
|
||||
node:
|
||||
version: 5.7.0
|
||||
|
||||
test:
|
||||
override:
|
||||
- npm test:
|
||||
timeout: 5400
|
||||
@@ -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"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
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:
|
||||
|
||||
|
||||
+141
-93
@@ -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,116 +21,165 @@
|
||||
* 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");
|
||||
|
||||
'use strict';
|
||||
var _log = require("./log");
|
||||
|
||||
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");
|
||||
function bundle (input, complete) {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
async.waterfall([
|
||||
|
||||
const igv = '__filename,__dirname,_process';
|
||||
let insertGlobalVars = { isNexe: true },
|
||||
wantedGlobalVars = igv.split(',');
|
||||
/**
|
||||
* first we resolve all of the deps
|
||||
*/
|
||||
|
||||
// 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);
|
||||
}
|
||||
function resolveDeps (next) {
|
||||
|
||||
|
||||
_log('executing browserify via API');
|
||||
let bproc = browserify([input], {
|
||||
debug: options.debug,
|
||||
commondir: false,
|
||||
paths: paths,
|
||||
builtins: false,
|
||||
insertGlobalVars: insertGlobalVars,
|
||||
detectGlobals: true,
|
||||
browserField: false
|
||||
});
|
||||
var deps = [];
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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 md = mdeps({
|
||||
xtransform: function (tr, file) {
|
||||
|
||||
_log('Force including \'%s\' in browserify bundle', name);
|
||||
bproc.require(lib, opts);
|
||||
}
|
||||
}
|
||||
var buffer = [];
|
||||
console.log(tr);
|
||||
|
||||
if(options.debug) {
|
||||
bproc.require(require.resolve('source-map-support'))
|
||||
}
|
||||
|
||||
let bprocbun = bproc.bundle() // bundle
|
||||
.pipe(ws) // pipe to file
|
||||
return through(write, end);
|
||||
|
||||
// error on require errors, still can't contionue. ffs browserify
|
||||
bprocbun.on('error', function(err) {
|
||||
_log('error', '[browserify] '+err);
|
||||
});
|
||||
var self = this;
|
||||
|
||||
ws.on('error', function(err) {
|
||||
console.log(err);
|
||||
_log('error', 'Failed to save stdout to disk');
|
||||
process.exit(1);
|
||||
})
|
||||
|
||||
ws.on('close', function() {
|
||||
var source = fs.readFileSync(bundlePath, 'utf8');
|
||||
source = source.replace(/[^\x00-\x7F]/g, "");
|
||||
function write (chunk) {
|
||||
buffer.push(chunk.toString());
|
||||
// console.log(chunk.toString(""))
|
||||
console.log(tr);
|
||||
}
|
||||
|
||||
// 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);
|
||||
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;
|
||||
|
||||
+18
-27
@@ -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,33 +21,15 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
'use strict';
|
||||
|
||||
let path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
/**
|
||||
* Accessort for embed
|
||||
* TODO: Optimize this code. (more like document it so I understand it better.)
|
||||
**/
|
||||
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) {
|
||||
function embed(resourceFiles, resourceRoot, complete) {
|
||||
function encode(filePath) {
|
||||
return fs.readFileSync(filePath).toString('base64');
|
||||
}
|
||||
|
||||
@@ -59,8 +40,8 @@ function embed(resourceFiles, resourceRoot, options, complete) {
|
||||
throw new Error("Bad Argument: resourceFiles is not an array");
|
||||
}
|
||||
|
||||
let buffer = "var embeddedFiles = {\n";
|
||||
for (let i = 0; i < resourceFiles.length; ++i) {
|
||||
var buffer = "var embeddedFiles = {\n";
|
||||
for (var i = 0; i < resourceFiles.length; ++i) {
|
||||
buffer += JSON.stringify(path.relative(resourceRoot, resourceFiles[i])) + ': "';
|
||||
buffer += encode(resourceFiles[i]) + '",\n';
|
||||
}
|
||||
@@ -70,4 +51,14 @@ function embed(resourceFiles, resourceRoot, options, 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;
|
||||
|
||||
+489
-867
File diff suppressed because it is too large
Load Diff
+2
-3
@@ -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
|
||||
@@ -23,8 +22,6 @@
|
||||
*
|
||||
**/
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
/**
|
||||
* standard output, takes 3 different types.
|
||||
* log, error, and warn
|
||||
@@ -34,6 +31,8 @@ var colors = require('colors');
|
||||
**/
|
||||
function _log () {
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
level = args.shift();
|
||||
|
||||
|
||||
+18
-23
@@ -3,7 +3,7 @@
|
||||
"name": "nexe",
|
||||
"description": "create single executables out of your [node/io].js applications",
|
||||
"license": "MIT",
|
||||
"version": "1.1.3",
|
||||
"version": "0.4.1",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Criag Condon",
|
||||
@@ -11,45 +11,40 @@
|
||||
"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.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",
|
||||
"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",
|
||||
"tar-stream": "^1.3.1",
|
||||
"yargs": "^4.2.0"
|
||||
"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"
|
||||
},
|
||||
"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": {
|
||||
"mocha": "^2.4.5",
|
||||
"mocha-circleci-reporter": "0.0.1"
|
||||
"nexe": "./bin/nexe"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
true
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* 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'));
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
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;
|
||||
@@ -1,93 +0,0 @@
|
||||
#!/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);
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
body {
|
||||
padding: 50px;
|
||||
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #00B7FF;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
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;
|
||||
@@ -1,9 +0,0 @@
|
||||
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;
|
||||
@@ -1,6 +0,0 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
h1= message
|
||||
h2= error.status
|
||||
pre #{error.stack}
|
||||
@@ -1,5 +0,0 @@
|
||||
extends layout
|
||||
|
||||
block content
|
||||
h1= title
|
||||
p Welcome to #{title}
|
||||
@@ -1,7 +0,0 @@
|
||||
doctype html
|
||||
html
|
||||
head
|
||||
title= title
|
||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||
body
|
||||
block content
|
||||
@@ -1,13 +0,0 @@
|
||||
/**
|
||||
* 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);
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
"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']);
|
||||
@@ -1,2 +0,0 @@
|
||||
// it probably executed.
|
||||
console.log(true);
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/**
|
||||
* 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);
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"name": "flags-test",
|
||||
"nexe": {
|
||||
"input": "./index.js",
|
||||
"output": "test.nex",
|
||||
"temp": "../src",
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "5.7.0",
|
||||
"ignoreFlags": true,
|
||||
"node-args": ""
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
require('js-yaml');
|
||||
|
||||
console.log(true);
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
--timeout 100000000
|
||||
-249
@@ -1,249 +0,0 @@
|
||||
/**
|
||||
* 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