Compare commits

...

80 Commits

Author SHA1 Message Date
calebboyd 1e57f3268b fix: handle relative paths for input 2017-09-27 16:21:45 -05:00
James M. Greene dc76aea5c8 Prepend the Python path for Windows for overriding 2017-07-05 16:57:58 -05:00
calebboyd 72afbe68a4 chore: add issue template 2017-04-10 23:29:42 -05:00
Jared Allard ad83cf769f fix: center text below badges 2017-03-06 12:43:33 -08:00
Jared Allard 8395f588a3 readme: add build status, support. 2017-03-05 22:07:23 -08:00
Jared Allard df3d667e4e update: A few new readme tweaks. 2017-03-05 21:57:40 -08:00
Jared Allard f928f3e758 fix: .gitignore ignore .DS_Store, add yarn.lock 2017-03-05 21:09:09 -08:00
Jared Allard 2f4356d6d2 Merge pull request #269 from anmonteiro/pythonpaths
startupSnapshot: need to generate python raw strings because of windows paths
2016-11-29 12:21:50 -08:00
Jared Allard 5cd8b5f177 Merge pull request #278 from kevgo/patch-1
Match CircleCI badge style to other badges
2016-11-29 12:21:26 -08:00
Kevin Goslar de58ad2593 Match CircleCI badge style to other badges 2016-11-29 07:20:14 -08:00
Christopher Karper b822f58973 Merge pull request #275 from control-freak-ide/master
=fixed toAbsolute for exists check instead of joining blindly
2016-11-21 10:11:30 -05:00
Christopher Karper de23c5e4c8 Merge pull request #236 from varatep/master
fix typo
2016-11-21 10:08:51 -05:00
mc007 8f96b2bca9 =fixed toAbsolute for exists check instead of joining blindly 2016-11-05 16:44:54 +01:00
António Nuno Monteiro 968d68b218 startupSnapshot: need to generate python raw strings because of windows
paths
2016-10-27 13:24:24 +02:00
Jared Allard 5136d3ebe9 Merge pull request #263 from anmonteiro/snapshotv1
allow custom V8 startup snapshot
2016-10-18 17:25:34 -07:00
António Nuno Monteiro 6a52ab861d allow custom V8 startup snapshot 2016-10-17 13:06:21 +02:00
Jared Allard 9b2b340f6d Merge pull request #244 from thekiba/issue-243
#243 - hotfix call browserify.require(file, opts)
2016-08-23 14:33:15 -07:00
TheKiba 03374f9f47 Added global variable isNexe 2016-08-11 21:08:12 +02:00
TheKiba 5d56a05531 This commit fixes #243 - hotfix call browserify.require(file, opts) 2016-08-06 02:20:44 +02:00
Jared Allard c113fbc731 Merge pull request #239 from ProfessorEugene/issue-238
#238 - attempting to have nodeConfigureArgs picked up
2016-07-24 23:24:00 -07:00
erachitskiy 1e2522852f This commit fixes #238 - attempting to get nodeConfigureArgs picked up regardless of python binary being used 2016-07-13 18:19:18 -04:00
Varatep Buranintu f6b8affdbf fix typo
var2.js --> ver2.js
2016-06-22 06:52:31 -07:00
Jared Allard 2b027229f1 Merge pull request #230 from jpheur/master
Fixes "Native module not found" problem
2016-05-30 09:47:41 -07:00
jpheur 970817e0f4 Fixes "Native module not found" problem 2016-05-30 12:05:43 +03:00
Jared Allard 23947c6d80 Merge pull request #214 from silviom/master
makeVCBuildArgs option added
2016-05-05 14:42:35 -07:00
Silvio Massari 88e5e05d49 makeVCBuildArgs option added 2016-05-05 14:38:28 -03:00
Jared Allard 541765e1d1 Merge pull request #211 from Apercu/patch-1
fix(exe): remove assignation on undefined variable
2016-04-16 18:50:08 -07:00
Balthazar Gronon 0c401f3c1e fix(exe): remove assignation on undefined variable 2016-04-16 18:04:41 +02:00
Jared Allard f6a18e18db npm/exe: check for lib/internal/boostrap_node.js, npm 1.1.2 fixes #207 2016-04-08 09:49:28 -07:00
Jared Allard da7b6af0fa Merge pull request #190 from ruffrey/patch-1
Document resourceRoot option
2016-02-28 22:23:02 -08:00
Jeff H. Parrish 694602fa22 Document resourceRoot option 2016-02-28 21:30:11 -08:00
Jared Allard 7994dc56c4 readme: remove yet another trace of the merge 2016-02-25 10:55:54 -08:00
Jared Allard f8b9de750f tests: actually output from the right command 2016-02-24 22:03:12 -08:00
Jared Allard cfd01c60c6 tests: output output for debug for now 2016-02-24 21:57:28 -08:00
Jared Allard 4899c1983b test: timeout for compile 2016-02-24 21:34:42 -08:00
Jared Allard 040e3c39a6 test: circle.yml 2016-02-24 21:28:14 -08:00
Jared Allard ebdd8055bd npm: update yargs to 4.2.0 2016-02-24 18:58:49 -08:00
Jared Allard 220836ea2f test: add cicircle, testing compilier toolchain. 2016-02-24 18:38:29 -08:00
Jared Allard 599858f799 test: run npm install on each test before trying to compile 2016-02-24 16:21:30 -08:00
Jared Allard b526d16298 test: log node version to stdout for circleci issues 2016-02-24 15:56:06 -08:00
Jared Allard d9d43332c6 test: ignore ci files 2016-02-24 15:47:48 -08:00
Jared Allard 42314a7083 test: setup mocha-circlci-reporter 2016-02-24 15:47:24 -08:00
Jared Allard f690b81a97 tests: finalize test system for now, be ready for a ci someday 2016-02-24 15:39:59 -08:00
Jared Allard 6faed1838f test: track tets/{mocha.opts, test.js} 2016-02-24 14:28:55 -08:00
Jared Allard 841f22f0bb tests: fix incorrect write type for express-test, exit process 2016-02-24 13:22:21 -08:00
Jared Allard ab1d92cf68 exe: fix an issue where finalContents isnt initialized, more test work 2016-02-24 12:58:13 -08:00
Jared Allard 208c2b2b56 bundle: add _process instead of process to igv, start test system work 2016-02-24 00:00:46 -08:00
Jared Allard 3b25e7409b bundle: add process to global vars, may fix some issues 2016-02-23 23:34:08 -08:00
Jared Allard aa6988c85f npm: vbump to 1.1.1 for when its released 2016-02-23 23:15:41 -08:00
Jared Allard a8c13a436b bundle: browserify.paths for controling require paths from nexe 2016-02-23 23:14:57 -08:00
Jared Allard f50e94a781 bundle/exe: more ES6, browserify.excludes, browserify.requires in package.json. 2016-02-23 23:00:19 -08:00
Jared Allard 71f39e5a11 Merge pull request #188 from jeff-blaisdell/issue-184
ISSUE-184: Allow browserify configuration to be passed through to bundler.
2016-02-22 09:08:58 -08:00
Jeff Blaisdell ae4baad4f3 ISSUE-184: Allow browserify configuration to be passed through to bundler. 2016-02-21 09:58:44 -06:00
Jared Allard 0ffbb5be66 Merge pull request #181 from mt-sergio/patch-1
Missing dot
2016-02-08 06:03:07 -08:00
Sergio Arcos 97f6f71788 Missing dot 2016-02-08 17:03:27 +09:00
Jared Allard 6a07ea62ea exe: support --jsFlag, use browserify API, try to get work started on source maps 2016-02-07 00:45:16 -08:00
Jared Allard ce2db38b92 npm: 1.1.0 release 2016-02-01 12:57:14 -08:00
Jared Allard f75948b7e8 exe: use custom tar+gz extraction method, should fix #175 2016-02-01 12:56:48 -08:00
Jared Allard 36a31b1048 git/npm: dont try to include src directory. 2016-01-30 15:13:42 -08:00
Jared Allard b25643483e npm: dont track test 2016-01-29 11:40:00 -08:00
Jared Allard 3f997ca93a npm: lets go npm! 2016-01-29 11:39:10 -08:00
Jared Allard 6273bd2e9a npm: continue the attempts to figure out why bin isnt included 2016-01-29 11:38:38 -08:00
Jared Allard 4d8a1849e8 npm: try to fix bin/nexe not being included in npm 2016-01-29 11:21:14 -08:00
Jared Allard df246cd2fc exe: support 0.10.x for js-flags 2016-01-28 20:21:26 -08:00
Jared Allard ea38821fd4 test: include js-yaml senario, which fixes #148 2016-01-28 17:51:56 -08:00
Jared Allard bbe26640df npm: prepare version 1.0.7, release 1.0.6 2016-01-28 15:38:43 -08:00
Jared Allard 54675f0e23 bundle: search top-level directories for browserify as well. Fixes #170. Implement support for js-flags in 0.12.x 2016-01-28 15:32:33 -08:00
Jared Allard 3ac02efd18 readme: document opts for nexe.compile and package.json 2016-01-28 14:50:37 -08:00
Jared Allard b100922d91 test: dont append os ext to test file. 2016-01-28 14:29:21 -08:00
Jared Allard 87660c3682 exe: fixes #168. Implements package.json nexe.runtime.js-flags for v8 flags. 2016-01-28 14:25:31 -08:00
Jared Allard 635cd62196 exe: handle tar extraction & download failures better 2016-01-24 21:08:38 -08:00
Jared Allard 336a5ea2e3 misc: remove .cupboard 2016-01-24 21:01:58 -08:00
Jared Allard 7fe0d207de exe: better configure error, logs, fix a bug in handling spawn args for certain node versions 2016-01-24 20:59:58 -08:00
Jared Allard 3e708ca916 npm: prepare 1.0.5 2016-01-24 17:30:40 -08:00
Jared Allard de84339c80 exe: dont check for options, yet. fixes #163 2016-01-24 17:28:04 -08:00
Jared Allard fb81a9c75e npm: prepare 1.0.4 2016-01-22 15:00:23 -08:00
Jared Allard 0e34905ddc npm/bundle: remove through depend that wasnt even used 2016-01-22 14:58:31 -08:00
Jared Allard c1e7416644 npm: fix version issue, and don't bundle src in builds 2016-01-22 14:51:16 -08:00
Jared Allard 53daa903ea readme: remove 5.x.x notice 2016-01-22 14:42:40 -08:00
Jared Allard 9e2a5f1c78 exe/bundle: fix bugs intoduced in 1.0.0. v1.0.1. Fixes #162 2016-01-22 14:37:27 -08:00
38 changed files with 3439 additions and 707 deletions
-4
View File
@@ -1,4 +0,0 @@
[commands]
proj = subl .
.DS_Store
+12 -6
View File
@@ -1,9 +1,15 @@
node_modules
.DS_Store
*.nex
src
nexe.exe
nexe
temp/
node_modules
npm-debug.log
# test/**/src
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
+3
View File
@@ -0,0 +1,3 @@
node_modules
test
src
+88 -18
View File
@@ -1,14 +1,19 @@
### Nexe
<p align="center"><img src="https://cloud.githubusercontent.com/assets/2391349/23598327/a17bb68a-01ee-11e7-8f55-88a5fc96e997.png" /></p>
[![Join the chat at https://gitter.im/crcn/nexe](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jaredallard/nexe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Dependency Status](https://david-dm.org/jaredallard/nexe.svg)](https://david-dm.org/crcn/nexe)
[![Stories in Ready](https://badge.waffle.io/jaredallard/nexe.svg?label=ready&title=Ready)](http://waffle.io/jaredallard/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>
# NOTICE: Node 5.x.x is broken right now.
<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.
![screenshot](https://cloud.githubusercontent.com/assets/2391349/23597575/e333884c-01e8-11e7-9fbf-3a83088bc748.png)
![screen shot 2014-02-28 at 10 32 54 am](https://f.cloud.github.com/assets/757408/2296993/c276f7b6-a0a6-11e3-86d3-e6c5feba2a85.png)
## 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
@@ -45,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");
}
```
@@ -107,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
@@ -136,16 +141,33 @@ Options:
var nexe = require('nexe');
nexe.compile({
input: 'input.js',
output: 'path/to/bin',
nodeVersion: '5.5.0',
nodeTempDir: 'src',
python: 'path/to/python',
resourceFiles: [ 'path/to/a/file' ],
flags: true,
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
});
```
@@ -155,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": "node",
"version": "5.5.0",
"version": "5.6.0",
"js-flags": "--use_strict",
"ignoreFlags": true
}
}
@@ -171,6 +199,48 @@ 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
+71 -66
View File
@@ -1,96 +1,101 @@
#!/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);
if (path.isAbsolute(pt)) {
return pt
}
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);
}
}
);
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);
}
}
);
}
+8
View File
@@ -0,0 +1,8 @@
machine:
node:
version: 5.7.0
test:
override:
- npm test:
timeout: 5400
+22
View File
@@ -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:
+84 -34
View File
@@ -22,48 +22,95 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**/
var mdeps = require("module-deps"),
path = require("path"),
spawn = require('child_process').spawn,
fs = require("fs"),
through = require("through2"),
async = require("async"),
browserify = require('browserify'),
builtins = require("builtins"),
_log = require("./log");
'use strict';
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");
/**
* User browserify to create a "packed" file.
*
* @param {String} input - input file
* @param {String} nc - node compiler dir
* @param {Function} complete - next function to call (async)
* @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, complete) {
var bundlePath = path.join(nc, "lib", "nexe.js");
var ws = fs.createWriteStream(bundlePath);
var proc = spawn('node', [path.join(__dirname, '../', 'node_modules/browserify/bin/cmd.js'), '--node', input ]);
function bundle(input, nc, options, complete) {
const bundlePath = path.join(nc, "lib", "nexe.js");
const mapfile = options.output+'.map';
let ws = fs.createWriteStream(bundlePath);
// TODO: Get path of nexe directory, and refer to it.
const igv = '__filename,__dirname,_process';
let insertGlobalVars = { isNexe: true },
wantedGlobalVars = igv.split(',');
proc.stdout.pipe(ws);
proc.on('error', function(err) {
console.error(err.toString('ascii'));
_log('error', 'Failed to invoke browserify');
process.exit(1);
})
proc.stderr.on('data', function(data) {
console.error(data.toString('ascii'));
_log('error', 'Browserify failed to launch');
process.exit(1);
// parse insertGlobalVars.
Object.keys(insertGlobals.vars).forEach(function (x) {
if (wantedGlobalVars.indexOf(x) === -1) {
insertGlobalVars[x] = undefined;
}
});
proc.on('close', function(code) {
_log("Browserify finished");
})
let paths = [path.join(nc, 'lib')];
if(options.browserifyPaths) {
paths = paths.concat(options.browserifyPaths);
}
_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);
}
}
// 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 }, {})
|| {};
_log('Force including \'%s\' in browserify bundle', name);
bproc.require(lib, opts);
}
}
if(options.debug) {
bproc.require(require.resolve('source-map-support'))
}
let bprocbun = bproc.bundle() // bundle
.pipe(ws) // pipe to file
// 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);
@@ -77,7 +124,7 @@ function bundle (input, nc, complete) {
// write the source modified to nexe.js
fs.writeFile(bundlePath, source, 'utf8', function(err) {
if(err) {
if (err) {
_log('error', 'failed to save source');
process.exit(1);
}
@@ -85,3 +132,6 @@ function bundle (input, nc, complete) {
complete();
});
});
}
module.exports = bundle;
+25 -17
View File
@@ -23,14 +23,32 @@
*
**/
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');
}
@@ -41,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';
}
@@ -52,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;
+853 -514
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -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();
+12 -12
View File
@@ -3,7 +3,7 @@
"name": "nexe",
"description": "create single executables out of your [node/io].js applications",
"license": "MIT",
"version": "1.0.0",
"version": "1.1.6",
"contributors": [
{
"name": "Criag Condon",
@@ -11,29 +11,28 @@
"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",
"async": "^1.5.2",
"browserify": "^13.0.0",
"builtins": "1.0.3",
"colors": "^1.1.2",
"glob": "^6.0.4",
"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.67.0",
"sprintf": "~0.1.5",
"step": "0.0.x",
"tar.gz": "1.0.2",
"through": "^2.3.8",
"yargs": "^3.32.0"
"tar-stream": "^1.3.1",
"yargs": "^4.2.0"
},
"nexe": {
"input": "./bin/nexe",
@@ -47,9 +46,10 @@
},
"preferGlobal": true,
"bin": {
"nexe": "./bin/nexe"
"nexe": "bin/nexe"
},
"devDependencies": {
"nodeunit": "^0.9.1"
"mocha": "^2.4.5",
"mocha-circleci-reporter": "0.0.1"
}
}
+1
View File
@@ -0,0 +1 @@
true
+11
View File
@@ -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'));
+28
View File
@@ -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"
}
}
}
+61
View File
@@ -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;
+93
View File
@@ -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);
Binary file not shown.
-17
View File
@@ -1,17 +0,0 @@
/**
* Test Express with nexe
**/
console.log('express init');
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.send('It works!');
});
app.listen(8000, function() {
console.log('Listening on port 8000');
});
+21 -17
View File
@@ -1,24 +1,28 @@
{
"name": "express-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"version": "0.0.0",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"nexe": {
"input": "./index.js",
"output": "express-test^$",
"temp": "src",
"runtime": {
"framework": "nodejs",
"version": "5.5.0",
"ignoreFlags": true
}
"start": "node ./bin/www"
},
"dependencies": {
"express": "^4.13.4"
"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;
}
+9
View File
@@ -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;
+9
View File
@@ -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;
+6
View File
@@ -0,0 +1,6 @@
extends layout
block content
h1= message
h2= error.status
pre #{error.stack}
+5
View File
@@ -0,0 +1,5 @@
extends layout
block content
h1= title
p Welcome to #{title}
+7
View File
@@ -0,0 +1,7 @@
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
+13
View File
@@ -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);
+15
View File
@@ -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": ""
}
}
}
+23
View File
@@ -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']);
+2
View File
@@ -0,0 +1,2 @@
// it probably executed.
console.log(true);
+26
View File
@@ -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": ""
}
}
}
+19
View File
@@ -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);
+15
View File
@@ -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": {}
}
+3
View File
@@ -0,0 +1,3 @@
require('js-yaml');
console.log(true);
+23
View File
@@ -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"
}
}
}
+1
View File
@@ -0,0 +1 @@
--timeout 100000000
+249
View File
@@ -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);
});
});
});
});
+1610
View File
File diff suppressed because it is too large Load Diff