Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9906df8d55 | |||
| d685ec21e5 | |||
| a2c4f3e9f1 | |||
| 79bcb753b4 | |||
| bc2a637cc4 | |||
| ad279e6daf | |||
| 2b9a8b1f0e | |||
| 7a7aaefa23 | |||
| 04fdd165a4 | |||
| 455d6893fd | |||
| ee529ce9b5 | |||
| 280b93b0a8 | |||
| 9ecd84ff8f |
@@ -7,7 +7,7 @@
|
||||
<a href="https://www.npmjs.com/package/nexe"><img src="https://img.shields.io/npm/l/nexe.svg" alt="License"></a>
|
||||
</p>
|
||||
|
||||
<p align="center"><code>npm i nexe@beta -g</code></p>
|
||||
<p align="center"><code>npm i nexe -g</code></p>
|
||||
<p align="center">Nexe is a command-line utility that compiles your Node.js application into a single executable file.</p>
|
||||
|
||||
<p align="center">
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
## Motivation and Features
|
||||
|
||||
- Supports production ready builds
|
||||
- Self contained applications
|
||||
- Ability to run multiple applications with *different* node.js runtimes.
|
||||
- Distribute binaries without needing node / npm.
|
||||
@@ -28,40 +27,37 @@
|
||||
|
||||
## Usage
|
||||
|
||||
- Existing application bundle:
|
||||
- Application entrypoint:
|
||||
|
||||
`nexe my-app-bundle.js -o my-app`
|
||||
`nexe my-app.js`
|
||||
|
||||
- stdin interface
|
||||
|
||||
`rollup -c | nexe --resource ./public/**/* -o my-app.exe`
|
||||
`rollup -c | nexe --resource "./public/**/*" -o my-app.exe`
|
||||
|
||||
For more CLI options see: `nexe --help`
|
||||
|
||||
## Including Additional Resources
|
||||
# Advanced
|
||||
|
||||
Additional resources can be added to the binary by passing `-r glob/pattern/**/*`. These included files can be read in the application by using `fs.readFile` or `fs.readFileSync`
|
||||
## Resources
|
||||
|
||||
Additional files or resources can be added to the binary by passing `-r "glob/pattern/**/*"`. These included files can be read in the application by using `fs.readFile` or `fs.readFileSync`
|
||||
|
||||
## Compiling Node
|
||||
|
||||
By default `nexe` will attempt to download a pre-built executable. However, some users may want to customize the way node is built, either by changing the flags, providing a different icon, or different executable details. To build node, use the `build` option/flag
|
||||
|
||||
Nexe also exposes its patching pipeline to the user. This allows the application of simple patching of node sources prior to compilation.
|
||||
By default `nexe` will attempt to download a pre-built executable. However, It may be unavailable ([github releases](https://github.com/nexe/nexe/releases))
|
||||
or you may want to customize what is built. See `nexe --help` for a list of options available when passing the `--build` option. You will also need to ensure your environment is setup to [build node](https://github.com/nodejs/node/blob/master/BUILDING.md)
|
||||
|
||||
## Node.js API
|
||||
|
||||
Using Nexe Programatically
|
||||
|
||||
#### Example
|
||||
|
||||
|
||||
```javascript
|
||||
const { compile } = require('nexe')
|
||||
|
||||
compile({
|
||||
input: './my-app.js',
|
||||
output: './my-app.exe',
|
||||
build: true, //builds node
|
||||
build: true, //required to use patches
|
||||
patches: [
|
||||
async (compiler, next) => {
|
||||
await compiler.setFileContentsAsync(
|
||||
@@ -75,60 +71,56 @@ compile({
|
||||
console.log('success')
|
||||
})
|
||||
```
|
||||
## NexeOptions
|
||||
|
||||
### `options`
|
||||
### `options: object`
|
||||
|
||||
- #### `build: boolean`
|
||||
- Build node from source (required in beta)
|
||||
- #### `input: string`
|
||||
- Input bundle file path
|
||||
- default: stdin or the current directory's main file (package.json)
|
||||
- #### `output: string`
|
||||
- Output executable file path
|
||||
- default: same as `name` with an OS specific extension.
|
||||
- #### `target: string`
|
||||
- Dash seperated platform-architecture-version. e.g. `'win32-ia32-6.10.3'`
|
||||
- default: `[process.platform, process.arch, process.version.slice(1)].join('-')`
|
||||
- #### `target: string | object`
|
||||
- Combination of platform-arch-version. e.g. `'win32-ia32-6.10.3'`
|
||||
- each segment is optional, and will be merged with the current environment
|
||||
- default: `process`
|
||||
- #### `bundle: string | boolean`
|
||||
- If a string is provided it must be a valid relative module path
|
||||
and should provide an export with the following signature:
|
||||
```typescript
|
||||
export function createBundle (
|
||||
filename: string,
|
||||
options: { name: string, minify: any, cwd: string }
|
||||
): Promise<string>`
|
||||
export function createBundle (options: NexeOptions): Promise<string>
|
||||
```
|
||||
- default: true, uses the internal fuse-box configuration
|
||||
- default: true
|
||||
- #### `name: string`
|
||||
- Module friendly name of the application
|
||||
- default: basename of the input file, or `nexe_${Date.now()}`
|
||||
- #### `cwd: string`
|
||||
- Directory nexe will operate on as though it is the cwd
|
||||
- default: process.cwd()
|
||||
- #### `version: string`
|
||||
- The Node version you're building for
|
||||
- default: `process.version.slice(1)`
|
||||
- #### `build: boolean`
|
||||
- Build node from source
|
||||
- #### `python: string`
|
||||
- On Linux this is the path pointing to your python2 executable
|
||||
- On Windows this is the directory where `python` can be accessed
|
||||
- default: `null`
|
||||
- #### `flags: Array<string>`
|
||||
- #### `flags: string[]`
|
||||
- Array of node runtime flags to build node with.
|
||||
- Example: `['--expose-gc']`
|
||||
- default: `[]`
|
||||
- #### `configure: Array<string>`
|
||||
- #### `configure: string[]`
|
||||
- Array of arguments for the node build configure step
|
||||
- Example: `['--with-dtrace', '--dest-cpu=x64']`
|
||||
- default: `[]`
|
||||
- #### `make: Array<string>`
|
||||
- #### `make: string[]`
|
||||
- Array of arguments for the node build make step, on windows this step recieves options for vcBuild.bat
|
||||
- default: `[]` or `['nosign', 'release']` for non windows systems
|
||||
- #### `make: Array<string>`
|
||||
- #### `make: string[]`
|
||||
- Alias for `make` option
|
||||
- #### `snapshot: string`
|
||||
- path to a file to be used as the warmup snapshot for the build
|
||||
- default: `null`
|
||||
- #### `resources: Array<string>`
|
||||
- #### `resources: string[]`
|
||||
- Array of globs with files to include in the build
|
||||
- Example: `['./public/**/*']`
|
||||
- default: `[]`
|
||||
@@ -143,16 +135,19 @@ compile({
|
||||
- Example: `{ CompanyName: "ACME Corp" }`
|
||||
- default: `{}`
|
||||
- #### `clean: boolean`
|
||||
- If included, nexe will remove temporary files for accompanying configuration and exit
|
||||
- If included, nexe will remove temporary files for the accompanying configuration and exit
|
||||
- #### `enableNodeCli: boolean`
|
||||
- Enable the original Node CLI (will prevent application cli from working)
|
||||
- default: `false`
|
||||
- #### `fakeArgv: boolean`
|
||||
- fake the entry point file name (`process.argv[1]`). If nexe was used with stdin this will be `'[stdin]'`.
|
||||
- #### `sourceUrl: string`
|
||||
- Provide an alternate url for the node source. Should be a `.tar.gz`
|
||||
- Provide an alternate url for the node source code
|
||||
- Note: temporary files will still be created for this under the specified version
|
||||
- #### `loglevel: string`
|
||||
- Set the loglevel, info, silent, or verbose
|
||||
- default: `'info'`
|
||||
- #### `patches: Array<NexePatch>`
|
||||
- #### `patches: NexePatch[]`
|
||||
- Userland patches for patching or modifying node source
|
||||
- default: `[]`
|
||||
|
||||
@@ -170,7 +165,7 @@ For examples, see the built in patches: [src/patches](src/patches)
|
||||
- Quickly perform a replace in a file within the downloaded Node.js source. The rest arguments are passed along to `String.prototype.replace`
|
||||
- `readFileAsync(filename: string): Promise<NexeFile>`
|
||||
- Access (or create) a file within the downloaded Node.js source.
|
||||
- `files: Array<NexeFile>`
|
||||
- `files: NexeFile[]`
|
||||
- The cache of the currently read, modified, or created files within the downloaded Node.js source.
|
||||
|
||||
#### `NexeFile`
|
||||
@@ -180,10 +175,10 @@ For examples, see the built in patches: [src/patches](src/patches)
|
||||
|
||||
Any modifications made to `NexeFile#contents` will be maintained in the cache _without_ the need to explicitly write them back out, e.g. using `NexeCompiler#setFileContentsAsync`.
|
||||
|
||||
### Native Modules
|
||||
## Native Modules
|
||||
|
||||
Nexe has a plugin built for use with [fuse-box](http://fuse-box.org) > 2.2.1. This plugin currently supports modules that require `.node` files and those that use the `bindings` module.
|
||||
Take a look at the [example](examples/native-build/build.js)
|
||||
Take a look at the (windows) [example](examples/native-build/build.js)
|
||||
|
||||
- [ ] Implement support `node-pre-gyp#find`.
|
||||
|
||||
|
||||
@@ -1,22 +1,13 @@
|
||||
const { FuseBox } = require('fuse-box')
|
||||
const { NativeModulePlugin } = require('../../lib/bundling')
|
||||
const fuse = FuseBox.init({
|
||||
homeDir: './',
|
||||
cache: false,
|
||||
log: true,
|
||||
debug: true,
|
||||
output: '$name.js',
|
||||
plugins: [
|
||||
new NativeModulePlugin({
|
||||
zmq: {
|
||||
additionalFiles: [
|
||||
'../../windows/lib/x64/libzmq-v100-mt-4_0_4.dll'
|
||||
]
|
||||
}
|
||||
})
|
||||
]
|
||||
const nexe = require('../..')
|
||||
nexe.compile({
|
||||
output: 'native-build',
|
||||
silent: true,
|
||||
native: {
|
||||
zmq: {
|
||||
additionalFiles: [
|
||||
'../../windows/lib/x64/libzmq-v100-mt-4_0_4.dll'
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
fuse.bundle('app')
|
||||
.target('server')
|
||||
.instructions(`> index.js`)
|
||||
fuse.run()
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ setInterval(function(){
|
||||
console.log('sending a multipart message envelope')
|
||||
pub.send(['kitty cats', 'meow!'])
|
||||
}, 2500)
|
||||
console.log('global', global.require.main)
|
||||
var sub = zmq.socket('sub')
|
||||
sub.connect('tcp://127.0.0.1:3000')
|
||||
sub.subscribe('kitty cats')
|
||||
|
||||
@@ -4,15 +4,13 @@
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"bundle": "node build",
|
||||
"build-windows": "nexe -i app.js -o app.exe"
|
||||
"build": "node build"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"sqlite3": "^3.1.10",
|
||||
"zmq": "^2.15.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fuse-box": "^2.2.1-beta.7"
|
||||
}
|
||||
"devDependencies": {}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
const nexe = require('./lib/nexe')
|
||||
const eol = require('os').EOL
|
||||
|
||||
module.exports = nexe
|
||||
|
||||
if (require.main === module) {
|
||||
nexe.compile(nexe.argv).catch((e) => {
|
||||
process.stderr.write(e.stack, () => process.exit(1))
|
||||
process.stderr.write(eol + e.stack, () => process.exit(1))
|
||||
})
|
||||
}
|
||||
|
||||
Generated
+127
-170
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "nexe",
|
||||
"version": "2.0.0-rc.1",
|
||||
"version": "2.0.0-rc.5",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@types/bluebird": {
|
||||
"version": "3.5.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.8.tgz",
|
||||
"integrity": "sha512-rBfrD56OxaqVjghtVqp2EEX0ieHkRk6IefDVrQXIVGvlhDOEBTvZff4Q02uo84ukVkH4k5eB1cPKGDM2NlFL8A==",
|
||||
"@types/chai": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.4.tgz",
|
||||
"integrity": "sha512-cvU0HomQ7/aGDQJZsbtJXqBQ7w4J4TqLB0Z/h8mKrpRjfeZEvTbygkfJEb7fWdmwpIeDeFmIVwAEqS0OYuUv3Q==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chalk": {
|
||||
@@ -16,15 +16,6 @@
|
||||
"integrity": "sha1-ox10JBprHtu5c8822XooloNKUfk=",
|
||||
"dev": true
|
||||
},
|
||||
"@types/execa": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/execa/-/execa-0.7.0.tgz",
|
||||
"integrity": "sha512-jBDAaCXX9nDnucbfs5tVojSLMRlxa+Dqp1L9OERn9MyOTIEOILRq2ATsu2dvn9IXoJp2NZwK5SVUUuZsq1my2g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "8.0.25"
|
||||
}
|
||||
},
|
||||
"@types/glob": {
|
||||
"version": "5.0.32",
|
||||
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-5.0.32.tgz",
|
||||
@@ -62,6 +53,12 @@
|
||||
"integrity": "sha1-fyrX7FX5FEgvybHsS7GuYCjUYGY=",
|
||||
"dev": true
|
||||
},
|
||||
"@types/mocha": {
|
||||
"version": "2.2.42",
|
||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.42.tgz",
|
||||
"integrity": "sha512-b6gVDoxEbAQGwbV7gSzeFw/hy3/eEAokztktdzl4bHvGgb9K5zW4mVQDlVYch2w31m8t/J7L2iqhQvz3r5edCQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "8.0.25",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.25.tgz",
|
||||
@@ -94,14 +91,14 @@
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz",
|
||||
"integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=",
|
||||
"requires": {
|
||||
"mime-types": "2.1.16",
|
||||
"mime-types": "2.1.17",
|
||||
"negotiator": "0.6.1"
|
||||
}
|
||||
},
|
||||
"acorn": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.1.tgz",
|
||||
"integrity": "sha512-vOk6uEMctu0vQrvuSqFdJyqj1Q0S5VTDL79qtjo+DhRr+1mmaD+tluFSCZqhvi/JUhXSzoZN2BhtstaPEeE8cw=="
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.1.2.tgz",
|
||||
"integrity": "sha512-o96FZLJBPY1lvTuJylGA9Bk3t/GKPPJG8H0ydQQl01crzwJgspa4AEIq/pVTXigmK0PHVQhiAtn8WMBLL9D2WA=="
|
||||
},
|
||||
"acorn-es7": {
|
||||
"version": "0.1.0",
|
||||
@@ -128,7 +125,7 @@
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-4.0.1.tgz",
|
||||
"integrity": "sha1-raWgFXNyeiN3dM5iVWTQeeyd4So=",
|
||||
"requires": {
|
||||
"acorn": "5.1.1"
|
||||
"acorn": "5.1.2"
|
||||
}
|
||||
},
|
||||
"ajax-request": {
|
||||
@@ -246,6 +243,12 @@
|
||||
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz",
|
||||
"integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ="
|
||||
},
|
||||
"assertion-error": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz",
|
||||
"integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=",
|
||||
"dev": true
|
||||
},
|
||||
"async-each": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz",
|
||||
@@ -272,7 +275,7 @@
|
||||
"integrity": "sha1-g2TKYt+Or7gwSZ9pkXdGbDsDSZ0=",
|
||||
"requires": {
|
||||
"babel-runtime": "6.26.0",
|
||||
"core-js": "2.5.0",
|
||||
"core-js": "2.5.1",
|
||||
"regenerator-runtime": "0.10.5"
|
||||
}
|
||||
},
|
||||
@@ -281,7 +284,7 @@
|
||||
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
|
||||
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
|
||||
"requires": {
|
||||
"core-js": "2.5.0",
|
||||
"core-js": "2.5.1",
|
||||
"regenerator-runtime": "0.11.0"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -397,6 +400,20 @@
|
||||
"url-to-options": "1.0.1"
|
||||
}
|
||||
},
|
||||
"chai": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz",
|
||||
"integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"assertion-error": "1.0.2",
|
||||
"check-error": "1.0.2",
|
||||
"deep-eql": "3.0.1",
|
||||
"get-func-name": "2.0.0",
|
||||
"pathval": "1.1.0",
|
||||
"type-detect": "4.0.3"
|
||||
}
|
||||
},
|
||||
"chain-able": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/chain-able/-/chain-able-1.0.1.tgz",
|
||||
@@ -414,6 +431,12 @@
|
||||
"supports-color": "2.0.0"
|
||||
}
|
||||
},
|
||||
"check-error": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
||||
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
|
||||
"dev": true
|
||||
},
|
||||
"chokidar": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
|
||||
@@ -524,26 +547,15 @@
|
||||
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
|
||||
},
|
||||
"core-js": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.0.tgz",
|
||||
"integrity": "sha1-VpwFCRi+ZIazg3VSAorgRmtxcIY="
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.1.tgz",
|
||||
"integrity": "sha1-rmh03GaTd4m4B1T/VCjfZoGcpQs="
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
|
||||
"integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "4.1.1",
|
||||
"shebang-command": "1.2.0",
|
||||
"which": "1.3.0"
|
||||
}
|
||||
},
|
||||
"cryptiles": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz",
|
||||
@@ -676,6 +688,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"deep-eql": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
|
||||
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-detect": "4.0.3"
|
||||
}
|
||||
},
|
||||
"deep-is": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
|
||||
@@ -814,28 +835,13 @@
|
||||
"integrity": "sha1-b2Ma7zNtbEY2K1F2QETOIWvjwFE="
|
||||
},
|
||||
"exec-sh": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.2.0.tgz",
|
||||
"integrity": "sha1-FPdd4/INKG75MwmbLOUKkDWc7xA=",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/exec-sh/-/exec-sh-0.2.1.tgz",
|
||||
"integrity": "sha512-aLt95pexaugVtQerpmE51+4QfWrNc304uez7jvj6fWnN8GeEHpttB8F36n8N7uVhUMbH/1enbxQ9HImZ4w/9qg==",
|
||||
"requires": {
|
||||
"merge": "1.2.0"
|
||||
}
|
||||
},
|
||||
"execa": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/execa/-/execa-0.8.0.tgz",
|
||||
"integrity": "sha1-2NdrvBtVIX7RkP1t1J08d07PyNo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"cross-spawn": "5.1.0",
|
||||
"get-stream": "3.0.0",
|
||||
"is-stream": "1.1.0",
|
||||
"npm-run-path": "2.0.2",
|
||||
"p-finally": "1.0.0",
|
||||
"signal-exit": "3.0.2",
|
||||
"strip-eof": "1.0.0"
|
||||
}
|
||||
},
|
||||
"expand-brackets": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz",
|
||||
@@ -1047,6 +1053,16 @@
|
||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||
"integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE="
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
|
||||
"integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
|
||||
"requires": {
|
||||
"asynckit": "0.4.0",
|
||||
"combined-stream": "1.0.5",
|
||||
"mime-types": "2.1.17"
|
||||
}
|
||||
},
|
||||
"forwarded": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.0.tgz",
|
||||
@@ -1072,11 +1088,11 @@
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||
},
|
||||
"fuse-box": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/fuse-box/-/fuse-box-2.2.2.tgz",
|
||||
"integrity": "sha1-7sPExJSW2/ygjUMXmhifv7zmf9o=",
|
||||
"version": "2.2.31",
|
||||
"resolved": "https://registry.npmjs.org/fuse-box/-/fuse-box-2.2.31.tgz",
|
||||
"integrity": "sha1-NtJnpsanmVKpwft9FkPBlJptQvU=",
|
||||
"requires": {
|
||||
"acorn": "5.1.1",
|
||||
"acorn": "5.1.2",
|
||||
"acorn-es7": "0.1.0",
|
||||
"acorn-es7-plugin": "1.1.7",
|
||||
"acorn-jsx": "4.0.1",
|
||||
@@ -1093,11 +1109,11 @@
|
||||
"fuse-tools": "1.0.5",
|
||||
"glob": "7.1.2",
|
||||
"ieee754": "1.1.8",
|
||||
"inquirer": "3.2.2",
|
||||
"inquirer": "3.2.3",
|
||||
"lego-api": "1.0.8",
|
||||
"mustache": "2.3.0",
|
||||
"opencollective": "1.0.3",
|
||||
"postcss": "6.0.9",
|
||||
"postcss": "6.0.11",
|
||||
"pretty-time": "0.2.0",
|
||||
"prettysize": "0.0.3",
|
||||
"realm-utils": "1.0.8",
|
||||
@@ -1119,6 +1135,12 @@
|
||||
"resolved": "https://registry.npmjs.org/fuse-tools/-/fuse-tools-1.0.5.tgz",
|
||||
"integrity": "sha1-mMn1EzNIqakTV8v4v1cXH6bNYUo="
|
||||
},
|
||||
"get-func-name": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
|
||||
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
|
||||
"dev": true
|
||||
},
|
||||
"get-proxy": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/get-proxy/-/get-proxy-2.1.0.tgz",
|
||||
@@ -1340,9 +1362,9 @@
|
||||
"integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4="
|
||||
},
|
||||
"inquirer": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.2.2.tgz",
|
||||
"integrity": "sha512-bTKLzEHJVATimZO/YFdLrom0lRx1BHfRYskFHfIMVkGdp8+dIZaxuU+4yrsS1lcu6YWywVQVVsfvdwESzbeqHw==",
|
||||
"version": "3.2.3",
|
||||
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.2.3.tgz",
|
||||
"integrity": "sha512-Bc3KbimpDTOeQdDj18Ir/rlsGuhBSSNqdOnxaAuKhpkdnMMuKsEGbZD2v5KFF9oso2OU+BPh7+/u5obmFDRmWw==",
|
||||
"requires": {
|
||||
"ansi-escapes": "2.0.0",
|
||||
"chalk": "2.1.0",
|
||||
@@ -1380,7 +1402,7 @@
|
||||
"requires": {
|
||||
"ansi-styles": "3.2.0",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"supports-color": "4.2.1"
|
||||
"supports-color": "4.4.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
@@ -1392,9 +1414,9 @@
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz",
|
||||
"integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==",
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
|
||||
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
|
||||
"requires": {
|
||||
"has-flag": "2.0.0"
|
||||
}
|
||||
@@ -1513,12 +1535,6 @@
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
|
||||
},
|
||||
"isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
||||
"dev": true
|
||||
},
|
||||
"isobject": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz",
|
||||
@@ -1725,16 +1741,6 @@
|
||||
"resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.0.tgz",
|
||||
"integrity": "sha1-TjNms55/VFfjXxMkvfb4jQv8cwY="
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
|
||||
"integrity": "sha512-q4spe4KTfsAS1SUHLO0wz8Qiyf1+vMIAgpRYioFYDMNqKfHQbg+AVDH3i4fvpl71/P1L0dBl+fQi+P37UYf0ew==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pseudomap": "1.0.2",
|
||||
"yallist": "2.1.2"
|
||||
}
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz",
|
||||
@@ -1793,7 +1799,7 @@
|
||||
"normalize-path": "2.1.1",
|
||||
"object.omit": "2.0.1",
|
||||
"parse-glob": "3.0.4",
|
||||
"regex-cache": "0.4.3"
|
||||
"regex-cache": "0.4.4"
|
||||
}
|
||||
},
|
||||
"mime": {
|
||||
@@ -1807,11 +1813,18 @@
|
||||
"integrity": "sha1-SNJtI1WJZRcErFkWygYAGRQmaHg="
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.16",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.16.tgz",
|
||||
"integrity": "sha1-K4WKUuXs1RbbiXrCvodIeDBpjiM=",
|
||||
"version": "2.1.17",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz",
|
||||
"integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=",
|
||||
"requires": {
|
||||
"mime-db": "1.29.0"
|
||||
"mime-db": "1.30.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"mime-db": {
|
||||
"version": "1.30.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz",
|
||||
"integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE="
|
||||
}
|
||||
}
|
||||
},
|
||||
"mimic-fn": {
|
||||
@@ -1962,15 +1975,6 @@
|
||||
"pify": "3.0.0"
|
||||
}
|
||||
},
|
||||
"npm-run-path": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
|
||||
"integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-key": "2.0.1"
|
||||
}
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz",
|
||||
@@ -2144,17 +2148,17 @@
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18="
|
||||
},
|
||||
"path-key": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz",
|
||||
"integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=",
|
||||
"dev": true
|
||||
},
|
||||
"path-to-regexp": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
|
||||
"integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz",
|
||||
"integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=",
|
||||
"dev": true
|
||||
},
|
||||
"pend": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
|
||||
@@ -2189,13 +2193,13 @@
|
||||
}
|
||||
},
|
||||
"postcss": {
|
||||
"version": "6.0.9",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.9.tgz",
|
||||
"integrity": "sha512-bBE2AHNEBhF23TfET6AA/lFP8ah+qHOZoFJEflFG+HgvVLdTmMOrocx/4LVVDIn3w6jUssw1q2Exk1cc9UOI8w==",
|
||||
"version": "6.0.11",
|
||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-6.0.11.tgz",
|
||||
"integrity": "sha512-DsnIzznNRQprsGTALpkC0xjDygo+QcOd+qVjP9+RjyzrPiyYOXBGOwoJ4rAiiE4lu6JggQ/jW4niY24WLxuncg==",
|
||||
"requires": {
|
||||
"chalk": "2.1.0",
|
||||
"source-map": "0.5.7",
|
||||
"supports-color": "4.2.1"
|
||||
"supports-color": "4.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-styles": {
|
||||
@@ -2213,13 +2217,13 @@
|
||||
"requires": {
|
||||
"ansi-styles": "3.2.0",
|
||||
"escape-string-regexp": "1.0.5",
|
||||
"supports-color": "4.2.1"
|
||||
"supports-color": "4.4.0"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.2.1.tgz",
|
||||
"integrity": "sha512-qxzYsob3yv6U+xMzPrv170y8AwGP7i74g+pbixCfD6rgso8BscLT2qXIuz6TpOaiJZ3mFgT5O9lyT9nMU4LfaA==",
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz",
|
||||
"integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==",
|
||||
"requires": {
|
||||
"has-flag": "2.0.0"
|
||||
}
|
||||
@@ -2280,12 +2284,6 @@
|
||||
"ipaddr.js": "1.4.0"
|
||||
}
|
||||
},
|
||||
"pseudomap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
||||
"integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=",
|
||||
"dev": true
|
||||
},
|
||||
"punycode": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
|
||||
@@ -2385,12 +2383,11 @@
|
||||
"integrity": "sha1-M2w+/BIgrc7dosn6tntaeVWjNlg="
|
||||
},
|
||||
"regex-cache": {
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz",
|
||||
"integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=",
|
||||
"version": "0.4.4",
|
||||
"resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz",
|
||||
"integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==",
|
||||
"requires": {
|
||||
"is-equal-shallow": "0.1.3",
|
||||
"is-primitive": "2.0.0"
|
||||
"is-equal-shallow": "0.1.3"
|
||||
}
|
||||
},
|
||||
"remove-trailing-separator": {
|
||||
@@ -2426,7 +2423,7 @@
|
||||
"is-typedarray": "1.0.0",
|
||||
"isstream": "0.1.2",
|
||||
"json-stringify-safe": "5.0.1",
|
||||
"mime-types": "2.1.16",
|
||||
"mime-types": "2.1.17",
|
||||
"oauth-sign": "0.8.2",
|
||||
"performance-now": "0.2.0",
|
||||
"qs": "6.4.0",
|
||||
@@ -2437,16 +2434,6 @@
|
||||
"uuid": "3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"form-data": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz",
|
||||
"integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=",
|
||||
"requires": {
|
||||
"asynckit": "0.4.0",
|
||||
"combined-stream": "1.0.5",
|
||||
"mime-types": "2.1.16"
|
||||
}
|
||||
},
|
||||
"qs": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz",
|
||||
@@ -2551,21 +2538,6 @@
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz",
|
||||
"integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ="
|
||||
},
|
||||
"shebang-command": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz",
|
||||
"integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"shebang-regex": "1.0.0"
|
||||
}
|
||||
},
|
||||
"shebang-regex": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz",
|
||||
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
|
||||
"dev": true
|
||||
},
|
||||
"shorthash": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/shorthash/-/shorthash-0.0.2.tgz",
|
||||
@@ -2700,12 +2672,6 @@
|
||||
"is-natural-number": "4.0.1"
|
||||
}
|
||||
},
|
||||
"strip-eof": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
|
||||
"dev": true
|
||||
},
|
||||
"strip-json-comments": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
|
||||
@@ -2851,13 +2817,19 @@
|
||||
"prelude-ls": "1.1.2"
|
||||
}
|
||||
},
|
||||
"type-detect": {
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.3.tgz",
|
||||
"integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=",
|
||||
"dev": true
|
||||
},
|
||||
"type-is": {
|
||||
"version": "1.6.15",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz",
|
||||
"integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=",
|
||||
"requires": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "2.1.16"
|
||||
"mime-types": "2.1.17"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
@@ -2976,19 +2948,10 @@
|
||||
"resolved": "https://registry.npmjs.org/watch/-/watch-1.0.2.tgz",
|
||||
"integrity": "sha1-NApxe952Vyb6CqB9ch4BR6VR3ww=",
|
||||
"requires": {
|
||||
"exec-sh": "0.2.0",
|
||||
"exec-sh": "0.2.1",
|
||||
"minimist": "1.2.0"
|
||||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz",
|
||||
"integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isexe": "2.0.0"
|
||||
}
|
||||
},
|
||||
"wordwrap": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
||||
@@ -3013,12 +2976,6 @@
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz",
|
||||
"integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=",
|
||||
"dev": true
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.8.0.tgz",
|
||||
|
||||
+8
-7
@@ -2,7 +2,7 @@
|
||||
"name": "nexe",
|
||||
"description": "Create a single executable out of your Node.js application",
|
||||
"license": "MIT",
|
||||
"version": "2.0.0-rc.2",
|
||||
"version": "2.0.0-rc.6",
|
||||
"contributors": [
|
||||
"Craig Condon <craig.j.condon@gmail.com> (http://crcn.io)",
|
||||
"Jared Allard <jaredallard@outlook.com>",
|
||||
@@ -11,7 +11,8 @@
|
||||
"scripts": {
|
||||
"nexe-build": "ts-node tasks/build",
|
||||
"prebuild": "rimraf lib && npm run lint",
|
||||
"prepublish": "npm run build",
|
||||
"prepublish": "npm test && npm run build",
|
||||
"test": "mocha test/**/*.spec.ts",
|
||||
"lint": "prettier --parser typescript --no-semi --print-width 100 --single-quote --write \"src/**/*.ts\"",
|
||||
"build": "tsc --declaration"
|
||||
},
|
||||
@@ -34,7 +35,7 @@
|
||||
"app-builder": "^5.1.0",
|
||||
"chalk": "^1.1.3",
|
||||
"download": "^6.2.0",
|
||||
"fuse-box": "^2.2.1",
|
||||
"fuse-box": "2.2.31",
|
||||
"globby": "^6.1.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
@@ -44,18 +45,18 @@
|
||||
"uglify-js": "3.0.28"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bluebird": "^3.5.8",
|
||||
"@types/chai": "^4.0.4",
|
||||
"@types/chalk": "^0.4.31",
|
||||
"@types/execa": "0.7.0",
|
||||
"@types/globby": "^0.6.0",
|
||||
"@types/minimist": "^1.2.0",
|
||||
"@types/mkdirp": "^0.3.29",
|
||||
"@types/mocha": "^2.2.42",
|
||||
"@types/ora": "^0.3.31",
|
||||
"@types/pify": "0.0.28",
|
||||
"@types/rimraf": "0.0.28",
|
||||
"execa": "0.8.0",
|
||||
"chai": "^4.1.2",
|
||||
"got": "^7.1.0",
|
||||
"mocha": "^3.2.0",
|
||||
"mocha": "^3.5.0",
|
||||
"prettier": "^1.6.1",
|
||||
"ts-node": "3.3.0",
|
||||
"typescript": "^2.4.1"
|
||||
|
||||
@@ -20,9 +20,8 @@ export function embedDotNode(
|
||||
file: { contents: string; absPath: string }
|
||||
) {
|
||||
const contents = fs.readFileSync(file.absPath)
|
||||
const module = Object.keys(options).find(x =>
|
||||
Boolean(~file.absPath.indexOf(path.join('node_modules', x)))
|
||||
)!
|
||||
const modulePathParts = file.absPath.split(path.sep).reverse()
|
||||
const module = modulePathParts[modulePathParts.findIndex(x => x === 'node_modules') - 1]
|
||||
const bindingName = path.basename(file.absPath)
|
||||
const settings = options[module]
|
||||
const moduleDir = hashName(contents)
|
||||
@@ -31,7 +30,7 @@ export function embedDotNode(
|
||||
'base64'
|
||||
)}';function mkdirp(r,t){t=t||null,r=path.resolve(r);try{fs.mkdirSync(r),t=t||r}catch(c){if("ENOENT"===c.code)t=mkdirp(path.dirname(r),t),mkdirp(r,t);else{var i;try{i=fs.statSync(r)}catch(r){throw c}if(!i.isDirectory())throw c}}return t};`
|
||||
|
||||
if (settings === true) {
|
||||
if (!settings || settings === true) {
|
||||
file.contents += `
|
||||
mkdirp('${moduleDir}');
|
||||
var bindingPath = path.join(process.cwd(), '${moduleDir}', '${bindingName}')
|
||||
@@ -105,13 +104,13 @@ export class BindingsRewrite {
|
||||
public nativeModulePaths: string[] = []
|
||||
public rewrite = false
|
||||
|
||||
isRequireBindings(node: any) {
|
||||
return node.callee.name === 'require' && node.arguments[0].value === 'bindings'
|
||||
isRequire(node: any, moduleName: string) {
|
||||
return node.callee.name === 'require' && node.arguments[0].value === moduleName
|
||||
}
|
||||
|
||||
onNode(absolutePath: string, node: any, parent: any) {
|
||||
if (node.type === 'CallExpression') {
|
||||
if (this.isRequireBindings(node) && parent.type === 'VariableDeclarator') {
|
||||
if (this.isRequire(node, 'bindings') && parent.type === 'VariableDeclarator') {
|
||||
/**
|
||||
* const loadBindings = require('bindings');
|
||||
* -> const loadBindings = String('');
|
||||
@@ -123,7 +122,7 @@ export class BindingsRewrite {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.isRequireBindings(node) && parent.type === 'CallExpression') {
|
||||
if (this.isRequire(node, 'bindings') && parent.type === 'CallExpression') {
|
||||
/**
|
||||
*const bindings = require('bindings')('native-module')....
|
||||
* -> const bindings = require('./path/to/native/module.node').....
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface FuseBoxFile {
|
||||
dependencies: string[]
|
||||
requiresRegeneration: boolean
|
||||
}
|
||||
consume(): void
|
||||
loadContents(): void
|
||||
makeAnalysis(
|
||||
parsingOptions?: any,
|
||||
@@ -20,19 +21,16 @@ export interface FuseBoxFile {
|
||||
): void
|
||||
}
|
||||
|
||||
export default function(options: ExtractNodeModuleOptions) {
|
||||
export default function(options: ExtractNodeModuleOptions = {}) {
|
||||
return new NativeModulePlugin(options)
|
||||
}
|
||||
|
||||
export class NativeModulePlugin {
|
||||
public test: RegExp
|
||||
public test = /node_modules.*(\.js|\.node)$|\.node$/
|
||||
public limit2Project = false
|
||||
private modules: (keyof ExtractNodeModuleOptions)[]
|
||||
|
||||
constructor(public options: ExtractNodeModuleOptions) {
|
||||
this.options = options
|
||||
this.test = new RegExp(`node_modules\/(${Object.keys(options).join('|')}).*\.js|\.node$`)
|
||||
}
|
||||
constructor(public options = {}) {}
|
||||
|
||||
init(context: any) {
|
||||
context.allowExtension('.node')
|
||||
@@ -47,6 +45,7 @@ export class NativeModulePlugin {
|
||||
}
|
||||
|
||||
const bindingsRewrite = new BindingsRewrite()
|
||||
|
||||
file.makeAnalysis(null, {
|
||||
plugins: [
|
||||
{
|
||||
|
||||
+12
-8
@@ -32,12 +32,13 @@ export class NexeCompiler {
|
||||
private env = { ...process.env }
|
||||
private compileStep: { modify: Function; log: Function }
|
||||
public log = new Logger(this.options.loglevel)
|
||||
public src = join(this.options.temp, this.options.version)
|
||||
public src: string
|
||||
public files: NexeFile[] = []
|
||||
public input: string
|
||||
public bundledInput?: string
|
||||
public output: string | null
|
||||
|
||||
public targets: NexeTarget[]
|
||||
public target: NexeTarget
|
||||
public resources: { bundle: string; index: { [key: string]: number[] } } = {
|
||||
index: {},
|
||||
bundle: ''
|
||||
@@ -46,13 +47,16 @@ export class NexeCompiler {
|
||||
public writeFileAsync: (file: string, contents: Buffer | string) => Promise<void>
|
||||
public replaceInFileAsync: (file: string, replacer: any, replaceValue: string) => Promise<void>
|
||||
public setFileContentsAsync: (file: string, contents: string | Buffer) => Promise<void>
|
||||
|
||||
private nodeSrcBinPath = isWindows
|
||||
? join(this.src, 'Release', 'node.exe')
|
||||
: join(this.src, 'out', 'Release', 'node')
|
||||
private nodeSrcBinPath: string
|
||||
|
||||
constructor(public options: NexeOptions) {
|
||||
const { python } = (this.options = options)
|
||||
this.targets = options.targets as NexeTarget[]
|
||||
this.target = this.targets[0]
|
||||
this.src = join(this.options.temp, this.target.version)
|
||||
this.nodeSrcBinPath = isWindows
|
||||
? join(this.src, 'Release', 'node.exe')
|
||||
: join(this.src, 'out', 'Release', 'node')
|
||||
this.log.step('nexe ' + nexeVersion, 'info')
|
||||
if (python) {
|
||||
if (isWindows) {
|
||||
@@ -147,7 +151,7 @@ export class NexeCompiler {
|
||||
const asset = githubRelease.assets.find(x => x.name === assetName)
|
||||
|
||||
if (!asset) {
|
||||
throw new Error(`${assetName} not available, create one using --build --empty`)
|
||||
throw new Error(`${assetName} not available, create it using the --build flag`)
|
||||
}
|
||||
const filename = this.getNodeExecutableLocation(target)
|
||||
await download(
|
||||
@@ -190,7 +194,7 @@ export class NexeCompiler {
|
||||
async compileAsync(target: NexeTarget) {
|
||||
const step = (this.compileStep = this.log.step('Compiling result'))
|
||||
const build = this.options.build
|
||||
const location = this.getNodeExecutableLocation(target)
|
||||
const location = this.getNodeExecutableLocation(build ? undefined : target)
|
||||
let binary = (await pathExistsAsync(location)) ? createReadStream(location) : null
|
||||
const header = this._generateHeader()
|
||||
if (!build && !binary) {
|
||||
|
||||
+3
-2
@@ -9,8 +9,9 @@ import {
|
||||
NexePatch
|
||||
} from './options'
|
||||
import cli from './steps/cli'
|
||||
import bundle from './bundling/fuse'
|
||||
import bundle from './steps/bundle'
|
||||
import download from './steps/download'
|
||||
import shim from './steps/shim'
|
||||
import artifacts from './steps/artifacts'
|
||||
import patches from './patches'
|
||||
import { rimrafAsync } from './util'
|
||||
@@ -39,7 +40,7 @@ async function compile(
|
||||
const buildSteps = build
|
||||
? [download, artifacts, ...patches, ...(options.patches as NexePatch[])]
|
||||
: []
|
||||
const nexe = compose(resource, bundle, cli, buildSteps)
|
||||
const nexe = compose(resource, bundle, cli, buildSteps, shim)
|
||||
return callback
|
||||
? void nexe(compiler).then(
|
||||
() => callback && callback(null),
|
||||
|
||||
+67
-56
@@ -1,11 +1,12 @@
|
||||
import * as parseArgv from 'minimist'
|
||||
import { NexeCompiler } from './compiler'
|
||||
import { isWindows } from './util'
|
||||
import { basename, extname, join, isAbsolute, relative } from 'path'
|
||||
import { isWindows, padRight } from './util'
|
||||
import { basename, extname, join, isAbsolute, relative, dirname } from 'path'
|
||||
import { getTarget, NexeTarget } from './target'
|
||||
import { EOL } from 'os'
|
||||
import * as c from 'chalk'
|
||||
|
||||
export const nexeVersion = '2.0.0-rc.2'
|
||||
export const nexeVersion = '2.0.0-rc.6'
|
||||
|
||||
export interface NexePatch {
|
||||
(compiler: NexeCompiler, next: () => Promise<void>): Promise<void>
|
||||
@@ -18,7 +19,6 @@ export interface NexeOptions {
|
||||
targets: (string | NexeTarget)[]
|
||||
name: string
|
||||
cwd: string
|
||||
version: string
|
||||
flags: string[]
|
||||
configure: string[]
|
||||
vcBuild: string[]
|
||||
@@ -30,14 +30,17 @@ export interface NexeOptions {
|
||||
enableNodeCli: boolean
|
||||
bundle: boolean | string
|
||||
patches: (string | NexePatch)[]
|
||||
native: any
|
||||
empty: boolean
|
||||
sourceUrl?: string
|
||||
python?: string
|
||||
loglevel: 'info' | 'silent' | 'verbose'
|
||||
silent?: boolean
|
||||
fakeArgv?: boolean
|
||||
verbose?: boolean
|
||||
info?: boolean
|
||||
ico?: string
|
||||
debugBundle?: boolean
|
||||
warmup?: string
|
||||
compress?: boolean
|
||||
clean?: boolean
|
||||
@@ -47,12 +50,7 @@ export interface NexeOptions {
|
||||
downloadOptions: any
|
||||
}
|
||||
|
||||
function padRight(str: string, l: number) {
|
||||
return (str + ' '.repeat(l)).substr(0, l)
|
||||
}
|
||||
|
||||
const defaults = {
|
||||
version: process.version.slice(1),
|
||||
flags: [],
|
||||
cwd: process.cwd(),
|
||||
configure: [],
|
||||
@@ -68,51 +66,61 @@ const defaults = {
|
||||
const alias = {
|
||||
i: 'input',
|
||||
o: 'output',
|
||||
t: 'target',
|
||||
n: 'name',
|
||||
v: 'version',
|
||||
t: 'target',
|
||||
b: 'build',
|
||||
n: 'name',
|
||||
r: 'resource',
|
||||
a: 'resource',
|
||||
p: 'python',
|
||||
f: 'flag',
|
||||
c: 'configure',
|
||||
m: 'make',
|
||||
s: 'snapshot',
|
||||
h: 'help',
|
||||
l: 'loglevel'
|
||||
l: 'loglevel',
|
||||
'fake-argv': 'fakeArgv'
|
||||
}
|
||||
const argv = parseArgv(process.argv, { alias, default: defaults })
|
||||
const help =
|
||||
`
|
||||
nexe --help CLI OPTIONS
|
||||
const g = c.gray
|
||||
let help = `
|
||||
${c.bold('nexe <entry-file> [options]')}
|
||||
|
||||
-b --build -- build from source
|
||||
-i --input =index.js -- application entry point
|
||||
-o --output =my-app.exe -- path to output file
|
||||
-t --target =win32-x64-6.10.3 -- *target a prebuilt binary
|
||||
-n --name =my-app -- main app module name
|
||||
-v --version =${padRight(process.version.slice(1), 23)}-- node version
|
||||
-p --python =/path/to/python2 -- python executable
|
||||
-f --flag ="--expose-gc" -- *v8 flags to include during compilation
|
||||
-c --configure ="--with-dtrace" -- *pass arguments to the configure step
|
||||
-m --make ="--loglevel" -- *pass arguments to the make/build step
|
||||
-s --snapshot =/path/to/snapshot -- build with warmup snapshot
|
||||
-r --resource =./paths/**/* -- *embed file bytes within the binary
|
||||
--bundle =./path/to/config -- pass a module path that exports nexeBundle
|
||||
--temp =./path/to/temp -- nexe temp files (for downloads and source builds)
|
||||
--no-bundle -- set when input is already bundled
|
||||
--cwd -- set the current working directory for the command
|
||||
--ico -- file name for alternate icon file (windows)
|
||||
--rc-* -- populate rc file options (windows)
|
||||
--clean -- force download of sources
|
||||
--enableNodeCli -- enable node cli enforcement (blocks app cli)
|
||||
--sourceUrl -- pass an alternate source (node.tar.gz) url
|
||||
--silent -- disable logging
|
||||
--verbose -- set logging to verbose
|
||||
${c.underline.bold('Options:')}
|
||||
|
||||
-* variable key name * option can be used more than once`.trim() + EOL
|
||||
-i --input ${g('=index.js')} -- application entry point
|
||||
-o --output ${g('=my-app.exe')} -- path to output file
|
||||
-t --target ${g('=8.4.0-x64')} -- node version description
|
||||
-n --name ${g('=my-app')} -- main app module name
|
||||
|
||||
function flattenFilter(...args: any[]): string[] {
|
||||
-r --resource -- *embed files (glob) within the binary
|
||||
|
||||
${c.underline.bold('Building from source:')}
|
||||
|
||||
-b --build -- build from source
|
||||
-p --python -- python2 (as python) executable path
|
||||
-f --flag -- *v8 flags to include during compilation
|
||||
-c --configure -- *arguments to the configure step
|
||||
-m --make -- *arguments to the make/build step
|
||||
--snapshot -- path to a warmup snapshot
|
||||
--ico -- file name for alternate icon file (windows)
|
||||
--rc-* -- populate rc file options (windows)
|
||||
--sourceUrl -- pass an alternate source (node.tar.gz) url
|
||||
--enableNodeCli -- enable node cli enforcement (blocks app cli)
|
||||
|
||||
${c.underline.bold('Other options:')}
|
||||
|
||||
--bundle -- custom bundling module with 'createBundle' export
|
||||
--temp -- temp file storage default './nexe'
|
||||
--cwd -- set the current working directory for the command
|
||||
--fake-argv TODO -- fake argv[1] with entry file
|
||||
--clean -- force download of sources
|
||||
--silent -- disable logging
|
||||
--verbose -- set logging to verbose
|
||||
|
||||
-* variable key name * option can be used more than once`.trim()
|
||||
help = EOL + help + EOL
|
||||
|
||||
function flatten(...args: any[]): string[] {
|
||||
return ([] as string[]).concat(...args).filter(x => x)
|
||||
}
|
||||
|
||||
@@ -140,7 +148,11 @@ function tryResolveMainFileName(cwd: string) {
|
||||
filename = basename(file).replace(extname(file), '')
|
||||
} catch (_) {}
|
||||
|
||||
return !filename || filename === 'index' ? 'nexe_' + Date.now() : filename
|
||||
if (filename === 'index' && basename(cwd)) {
|
||||
return basename(cwd)
|
||||
}
|
||||
|
||||
return filename ? filename : 'nexe_' + Date.now()
|
||||
}
|
||||
|
||||
function extractLogLevel(options: NexeOptions) {
|
||||
@@ -155,7 +167,8 @@ function extractName(options: NexeOptions) {
|
||||
if (!name && typeof options.input === 'string') {
|
||||
name = basename(options.input).replace(extname(options.input), '')
|
||||
}
|
||||
name = name || tryResolveMainFileName(options.cwd)
|
||||
name = name === 'index' ? tryResolveMainFileName(options.cwd) : name
|
||||
|
||||
return name.replace(/\.exe$/, '')
|
||||
}
|
||||
|
||||
@@ -193,31 +206,29 @@ function normalizeOptionsAsync(input?: Partial<NexeOptions>): Promise<NexeOption
|
||||
const opts = options as any
|
||||
|
||||
options.temp = process.env.NEXE_TEMP || join(options.cwd, '.nexe')
|
||||
options.name = extractName(options)
|
||||
options.input = findInput(options.input, options.cwd)
|
||||
options.name = extractName(options)
|
||||
options.loglevel = extractLogLevel(options)
|
||||
options.flags = flattenFilter(opts.flag, options.flags)
|
||||
options.targets = flattenFilter(opts.target, options.targets)
|
||||
options.make = flattenFilter(options.vcBuild, options.make)
|
||||
options.configure = flattenFilter(options.configure)
|
||||
options.resources = flattenFilter(opts.resource, options.resources)
|
||||
options.flags = flatten(opts.flag, options.flags)
|
||||
options.targets = flatten(opts.target, options.targets).map(getTarget)
|
||||
options.make = flatten(options.vcBuild, options.make)
|
||||
options.configure = flatten(options.configure)
|
||||
options.resources = flatten(opts.resource, options.resources)
|
||||
options.rc = options.rc || extractCliMap(/^rc-.*/, options)
|
||||
|
||||
options.targets = options.targets.map(getTarget)
|
||||
if (!options.targets.length) {
|
||||
options.targets.push(getTarget())
|
||||
}
|
||||
|
||||
if (options.build && options.targets.length) {
|
||||
if (options.build) {
|
||||
const { arch } = options.targets[0] as NexeTarget
|
||||
if (isWindows) {
|
||||
options.make = Array.from(new Set(options.make.concat([arch])))
|
||||
options.make = Array.from(new Set(options.make.concat(arch)))
|
||||
} else {
|
||||
options.configure = Array.from(new Set(options.configure.concat([`--dest-cpu=${arch}`])))
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.targets.length) {
|
||||
options.targets = [getTarget(options.version)]
|
||||
}
|
||||
|
||||
options.patches = options.patches.map(x => {
|
||||
if (typeof x === 'string') {
|
||||
return require(x).default
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NexeCompiler } from '../compiler'
|
||||
|
||||
export default async function buildFixes(compiler: NexeCompiler, next: () => Promise<void>) {
|
||||
if (!compiler.options.version.startsWith('8.2')) {
|
||||
if (!compiler.target.version.startsWith('8.2')) {
|
||||
return next()
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,15 @@ export default async function nodeRc(compiler: NexeCompiler, next: () => Promise
|
||||
let value = options[key]
|
||||
const isVar = /^[A-Z_]+$/.test(value)
|
||||
value = isVar ? value : `"${value}"`
|
||||
file.contents.replace(new RegExp(`VALUE "${key}",*`), `VALUE "${key}", ${value}`)
|
||||
file.contents = file.contents.replace(
|
||||
new RegExp(`VALUE "${key}",*`),
|
||||
`VALUE "${key}", ${value}`
|
||||
)
|
||||
})
|
||||
;['PRODUCTVERSION', 'FILEVERSION'].forEach(x => {
|
||||
if (options[x]) {
|
||||
file.contents = file.contents.replace(new RegExp(x + ' .*$', 'm'), `${x} ${options[x]}`)
|
||||
}
|
||||
})
|
||||
|
||||
return next()
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { NexeCompiler } from '../compiler'
|
||||
import { FuseBox, JSONPlugin, CSSPlugin, HTMLPlugin, QuantumPlugin } from 'fuse-box'
|
||||
import { readFileAsync } from '../util'
|
||||
//import NativeModulePlugin from './fuse-native-module-plugin'
|
||||
import { readFileAsync, writeFileAsync } from '../util'
|
||||
import { resolve } from 'path'
|
||||
import NativeModulePlugin from '../bundling/fuse-native-module-plugin'
|
||||
import { NexeOptions } from '../options'
|
||||
|
||||
function createBundle(filename: string, options: { name: string; minify: any; cwd: string }) {
|
||||
const plugins: any = [JSONPlugin(), CSSPlugin(), HTMLPlugin()]
|
||||
if (options.minify) {
|
||||
function createBundle(options: NexeOptions) {
|
||||
const plugins: any = [JSONPlugin(), CSSPlugin(), HTMLPlugin(), NativeModulePlugin(options.native)]
|
||||
if (options.compress) {
|
||||
plugins.push(
|
||||
QuantumPlugin({
|
||||
target: 'server',
|
||||
@@ -16,7 +18,7 @@ function createBundle(filename: string, options: { name: string; minify: any; cw
|
||||
}
|
||||
const fuse = FuseBox.init({
|
||||
cache: false,
|
||||
log: Boolean(process.env.NEXE_BUNDLE_DEBUG) || false,
|
||||
log: Boolean(process.env.NEXE_BUNDLE_LOG) || false,
|
||||
homeDir: options.cwd,
|
||||
sourceMaps: false,
|
||||
writeBundles: false,
|
||||
@@ -24,7 +26,7 @@ function createBundle(filename: string, options: { name: string; minify: any; cw
|
||||
target: 'server',
|
||||
plugins
|
||||
})
|
||||
fuse.bundle(options.name).instructions(`> ${filename}`)
|
||||
fuse.bundle(options.name).instructions(`> ${options.input}`)
|
||||
return fuse.run().then(x => {
|
||||
let output = ''
|
||||
x.bundles.forEach(y => (output = y.context.output.lastPrimaryOutput.content!.toString()))
|
||||
@@ -45,13 +47,14 @@ export default async function bundle(compiler: NexeCompiler, next: any) {
|
||||
|
||||
let producer = createBundle
|
||||
if (typeof compiler.options.bundle === 'string') {
|
||||
producer = require(compiler.options.bundle).createBundle
|
||||
producer = require(resolve(compiler.options.cwd, compiler.options.bundle)).createBundle
|
||||
}
|
||||
|
||||
compiler.input = await producer(compiler.options)
|
||||
|
||||
if ('string' === typeof compiler.options.debugBundle) {
|
||||
await writeFileAsync(compiler.options.debugBundle, compiler.input)
|
||||
}
|
||||
|
||||
compiler.input = await producer(compiler.options.input, {
|
||||
cwd: compiler.options.cwd,
|
||||
name: compiler.options.name,
|
||||
minify: compiler.options.compress
|
||||
})
|
||||
return next()
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { pathExistsAsync } from '../util'
|
||||
import { LogStep } from '../logger'
|
||||
import { IncomingMessage } from 'http'
|
||||
import { NexeCompiler } from '../compiler'
|
||||
import { NexeTarget } from '../target'
|
||||
|
||||
function fetchNodeSourceAsync(dest: string, url: string, step: LogStep, options = {}) {
|
||||
const setText = (p: number) => step.modify(`Downloading Node: ${p.toFixed()}%...`)
|
||||
@@ -27,8 +28,8 @@ function fetchNodeSourceAsync(dest: string, url: string, step: LogStep, options
|
||||
* @param {*} next
|
||||
*/
|
||||
export default async function downloadNode(compiler: NexeCompiler, next: () => Promise<void>) {
|
||||
const { src, log } = compiler
|
||||
const { version, sourceUrl, downloadOptions } = compiler.options
|
||||
const { src, log, targets: [{ version }] } = compiler
|
||||
const { sourceUrl, downloadOptions } = compiler.options
|
||||
const url = sourceUrl || `https://nodejs.org/dist/v${version}/node-v${version}.tar.gz`
|
||||
const step = log.step(`Downloading Node.js source from: ${url}`)
|
||||
if (await pathExistsAsync(src)) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { NexeCompiler } from '../compiler'
|
||||
|
||||
export default function(compiler: NexeCompiler, next: () => Promise<void>) {
|
||||
if (!compiler.options.fakeArgv) {
|
||||
return next()
|
||||
}
|
||||
|
||||
const nty = !process.stdin.isTTY
|
||||
const input = nty ? '[stdin]' : compiler.options.input
|
||||
|
||||
compiler.input =
|
||||
`!(() => {
|
||||
var r = require('path').resolve;
|
||||
process.argv.splice(1,0, ${nty ? `'${input}'` : `r("${input}")`});
|
||||
})();` + compiler.input
|
||||
|
||||
return next()
|
||||
}
|
||||
+6
-5
@@ -8,14 +8,15 @@ export { platforms, architectures }
|
||||
|
||||
export interface NexeTarget {
|
||||
version: string
|
||||
platform: NodePlatform
|
||||
arch: NodeArch
|
||||
platform: NodePlatform | string
|
||||
arch: NodeArch | string
|
||||
}
|
||||
|
||||
//TODO bsd
|
||||
const prettyPlatform: { [key: string]: NodePlatform } = {
|
||||
win32: 'windows',
|
||||
windows: 'windows',
|
||||
win: 'windows',
|
||||
darwin: 'mac',
|
||||
macos: 'mac',
|
||||
mac: 'mac',
|
||||
@@ -36,7 +37,7 @@ function isVersion(x: string) {
|
||||
if (!x) {
|
||||
return false
|
||||
}
|
||||
return /\d/.test(x.replace(/v|\./g, ''))
|
||||
return /^[\d]+$/.test(x.replace(/v|\.|\s+/g, ''))
|
||||
}
|
||||
|
||||
function isPlatform(x: string): x is NodePlatform {
|
||||
@@ -61,7 +62,7 @@ export function targetsEqual(a: NexeTarget, b: NexeTarget) {
|
||||
return a.arch === b.arch && a.platform === b.platform && a.version === b.version
|
||||
}
|
||||
|
||||
export function getTarget(target: string | NexeTarget = ''): NexeTarget {
|
||||
export function getTarget(target: string | Partial<NexeTarget> = ''): NexeTarget {
|
||||
let arch = process.arch as NodeArch,
|
||||
platform = prettyPlatform[process.platform],
|
||||
version = process.version.slice(1)
|
||||
@@ -75,7 +76,7 @@ export function getTarget(target: string | NexeTarget = ''): NexeTarget {
|
||||
.split('-')
|
||||
.forEach(x => {
|
||||
if (isVersion(x)) {
|
||||
version = x
|
||||
version = x.replace(/v/g, '')
|
||||
}
|
||||
if (isPlatform(x)) {
|
||||
platform = prettyPlatform[x]
|
||||
|
||||
@@ -22,6 +22,10 @@ function falseOnEnoent(e: any) {
|
||||
throw e
|
||||
}
|
||||
|
||||
function padRight(str: string, l: number) {
|
||||
return (str + ' '.repeat(l)).substr(0, l)
|
||||
}
|
||||
|
||||
function dequote(input: string) {
|
||||
input = input.trim()
|
||||
const singleQuote = input.startsWith("'") && input.endsWith("'")
|
||||
@@ -57,6 +61,7 @@ function isDirectoryAsync(path: string) {
|
||||
|
||||
export {
|
||||
dequote,
|
||||
padRight,
|
||||
isWindows,
|
||||
rimrafAsync,
|
||||
statAsync,
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
--check-leaks
|
||||
--require ts-node/register
|
||||
--recursive
|
||||
@@ -0,0 +1,28 @@
|
||||
import { padRight, isWindows } from '../src/util'
|
||||
import { expect } from 'chai'
|
||||
import { blue as b } from 'chalk'
|
||||
import { getTarget, NexeTarget } from '../src/target'
|
||||
|
||||
const arch = process.arch === 'ia32' ? 'x86' : process.arch
|
||||
|
||||
describe('Targets', () => {
|
||||
[
|
||||
['win-ia32-6.11.2', 'windows-x86-6.11.2'],
|
||||
[{ version: '6.11.2', platform: 'win', arch: 'ia32' }, 'windows-x86-6.11.2'],
|
||||
['win32-x64-6.11.2', 'windows-x64-6.11.2'],
|
||||
['darwin-x64-v8.4.0', 'mac-x64-8.4.0'],
|
||||
['static-x86-6.10.3', 'alpine-x86-6.10.3'],
|
||||
['linux-x32', `linux-x86-${process.version.slice(1)}`],
|
||||
['alpine-notsupported-6.10.3', `alpine-${arch}-6.10.3`],
|
||||
['not-a-thing', getTarget(process).toString()]
|
||||
].forEach(([input, expected]) => {
|
||||
it(`should accept: ${padRight(JSON.stringify(input), 53)} ${b('->')} ${expected}`, () => {
|
||||
expect(getTarget(input).toString()).to.equal(expected)
|
||||
})
|
||||
})
|
||||
|
||||
it ('should stringify and toString', () => {
|
||||
expect(JSON.stringify(getTarget(process))).to.equal(`"${getTarget(process)}"`)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user