Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 09d7093295 | |||
| 3a091f45bd | |||
| 9575c0811b | |||
| ab6b540e23 | |||
| dcea374922 | |||
| b3b6c6b936 | |||
| 058c34ee8a | |||
| 9750c70873 |
+1
-1
@@ -5,4 +5,4 @@ export NVS_HOME="$HOME/.nvs"
|
||||
|
||||
set -e -x
|
||||
|
||||
yarn run asset-compile
|
||||
npm run asset-compile
|
||||
|
||||
@@ -8,13 +8,13 @@ jobs:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- package-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
||||
- package-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
|
||||
- package- # Fallback for the latest package.json cache
|
||||
- run:
|
||||
name: setup
|
||||
command: .circleci/setup.sh
|
||||
- save_cache:
|
||||
key: package-{{ checksum "package.json" }}-{{ checksum "yarn.lock" }}
|
||||
key: package-{{ checksum "package.json" }}-{{ checksum "package-lock.json" }}
|
||||
paths:
|
||||
- node_modules
|
||||
- run:
|
||||
|
||||
+3
-4
@@ -1,11 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
echo "setting up node to use latest lts"
|
||||
|
||||
export NVS_HOME="$HOME/.nvs"
|
||||
git clone --depth=1 https://github.com/jasongin/nvs "$NVS_HOME"
|
||||
. "$NVS_HOME/nvs.sh" install
|
||||
nvs add lts && nvs link lts nvs use default
|
||||
npm install -g yarn
|
||||
yarn
|
||||
node -v
|
||||
npm -v
|
||||
npm i
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<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>
|
||||
<a href="https://gitter.im/nexe/nexe?utm_source=badge&utm_medium=badge"><img src="https://badges.gitter.im/nexe/nexe.svg"></a>
|
||||
</p>
|
||||
|
||||
<p align="center"><code>npm i nexe -g</code></p>
|
||||
@@ -43,7 +42,6 @@ For more CLI options see: `nexe --help`
|
||||
### Examples
|
||||
|
||||
- `nexe server.js -r "public/**/*.html"`
|
||||
- `nexe my-bundle.js --no-bundle -o app.exe`
|
||||
- `nexe --build`
|
||||
- `nexe -t x86-8.0.0`
|
||||
|
||||
@@ -90,14 +88,14 @@ compile({
|
||||
- Output executable file path
|
||||
- default: same as `name` with an OS specific extension.
|
||||
- #### `target: string | object`
|
||||
- An object or string describing platform-arch-version. e.g. `'windows-ia32-6.10.3'`
|
||||
- An object or string describing platform-arch-version. e.g. `'windows-ia32-10.13.0'`
|
||||
- each segment is optional, and will be merged with the current environment
|
||||
- Examples: ([full list](https://github.com/nexe/nexe/releases))
|
||||
- `'win32-x86-8.6.0`
|
||||
- `'win32-x86-10.13.0`
|
||||
- `{ platform: 'alpine' }`
|
||||
- `darwin-8.6.0`
|
||||
- `darwin-10.13.0`
|
||||
- `linux-x64`
|
||||
- `macos-8.4.0`
|
||||
- `macos-10.13.0`
|
||||
|
||||
See [test/target.spec.ts](test/target.spec.ts)
|
||||
- If the [`build`](#build-boolean) flag is set, the platform portion of the target is ignored.
|
||||
@@ -145,12 +143,12 @@ compile({
|
||||
- #### `temp: string`
|
||||
- Path to use for storing nexe's build files
|
||||
- Override in the env with `NEXE_TEMP`
|
||||
- default: `./.nexe` in the cwd
|
||||
- default: `~/.nexe`
|
||||
- #### `ico: string`
|
||||
- Path to a user provided icon to be used (Windows only). Requires `--build` to be set.
|
||||
- #### `rc: object`
|
||||
- Settings for patching the [node.rc](https://github.com/nodejs/node/blob/master/src/res/node.rc) configuration file (Windows only).
|
||||
- Example:
|
||||
- Example (keys may vary depending ont the version. Reference the file linked above):
|
||||
```javascript
|
||||
{
|
||||
CompanyName: "ACME Corp",
|
||||
|
||||
Generated
+30
-38
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nexe",
|
||||
"version": "3.0.0-beta.9",
|
||||
"version": "3.0.0-beta.12",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -79,9 +79,9 @@
|
||||
}
|
||||
},
|
||||
"@types/got": {
|
||||
"version": "9.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/got/-/got-9.2.0.tgz",
|
||||
"integrity": "sha512-6aWDCt7AO0rhQSjnk+aLFIPfStFH1tMNQ9KLLfOT9SctmjOEndrqoo5Bw/YEIFYY2QRy744D/qUc2F3a3+mLsw==",
|
||||
"version": "9.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/got/-/got-9.2.2.tgz",
|
||||
"integrity": "sha512-6G2FdsJxcaUP0/08di2A5kHEfSbXd2npcB/9gsvFNR5kdlKWkJ4RpYdJLQRifwktHqsq/NfSnkoZYws/E009og==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
@@ -1336,11 +1336,11 @@
|
||||
}
|
||||
},
|
||||
"got": {
|
||||
"version": "9.3.2",
|
||||
"resolved": "https://registry.npmjs.org/got/-/got-9.3.2.tgz",
|
||||
"integrity": "sha512-OyKOUg71IKvwb8Uj0KP6EN3+qVVvXmYsFznU1fnwUnKtDbZnwSlAi7muNlu4HhBfN9dImtlgg9e7H0g5qVdaeQ==",
|
||||
"version": "9.5.0",
|
||||
"resolved": "https://registry.npmjs.org/got/-/got-9.5.0.tgz",
|
||||
"integrity": "sha512-N+4kb6i9t1lauJ4NwLVVoFVLxZNa6i+iivtNzCSVw7+bVbTXoq0qXctdd8i9rj3lrI0zDk5NGzcO4bfpEP6Uuw==",
|
||||
"requires": {
|
||||
"@sindresorhus/is": "^0.12.0",
|
||||
"@sindresorhus/is": "^0.14.0",
|
||||
"@szmarczak/http-timer": "^1.1.0",
|
||||
"cacheable-request": "^5.1.0",
|
||||
"decompress-response": "^3.3.0",
|
||||
@@ -1354,12 +1354,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@sindresorhus/is": {
|
||||
"version": "0.12.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.12.0.tgz",
|
||||
"integrity": "sha512-9ve22cGrAKlSRvi8Vb2JIjzcaaQg79531yQHnF+hi/kOpsSj3Om8AyR1wcHrgl0u7U3vYQ7gmF5erZzOp4+51Q==",
|
||||
"requires": {
|
||||
"symbol-observable": "^1.2.0"
|
||||
}
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-0.14.0.tgz",
|
||||
"integrity": "sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ=="
|
||||
},
|
||||
"cacheable-request": {
|
||||
"version": "5.2.0",
|
||||
@@ -1384,9 +1381,9 @@
|
||||
}
|
||||
},
|
||||
"http-cache-semantics": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz",
|
||||
"integrity": "sha512-NtexGRtaV5z3ZUX78W9UDTOJPBdpqms6RmwQXmOhHws7CuQK3cqIoQtnmeqi1VvVD6u6eMMRL0sKE9BCZXTDWQ=="
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz",
|
||||
"integrity": "sha512-OO/9K7uFN30qwAKvslzmCTbimZ/uRjtdN5S50vvWLwUKqFuZj0n96XyCzF5tHRHEO/Q4JYC01hv41gkX06gmHA=="
|
||||
},
|
||||
"normalize-url": {
|
||||
"version": "3.3.0",
|
||||
@@ -2185,9 +2182,9 @@
|
||||
"integrity": "sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc="
|
||||
},
|
||||
"prettier": {
|
||||
"version": "1.15.2",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.2.tgz",
|
||||
"integrity": "sha512-YgPLFFA0CdKL4Eg2IHtUSjzj/BWgszDHiNQAe0VAIBse34148whfdzLagRL+QiKS+YfK5ftB6X4v/MBw8yCoug==",
|
||||
"version": "1.15.3",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.15.3.tgz",
|
||||
"integrity": "sha512-gAU9AGAPMaKb3NNSUUuhhFAS7SCO4ALTN4nRIn6PJ075Qd28Yn2Ig2ahEJWdJwJmlEBTUfC7mMUSFy8MwsOCfg==",
|
||||
"dev": true
|
||||
},
|
||||
"process-nextick-args": {
|
||||
@@ -2258,12 +2255,12 @@
|
||||
"integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc="
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
|
||||
"integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==",
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.9.0.tgz",
|
||||
"integrity": "sha512-TZNye00tI67lwYvzxCxHGjwTNlUV70io54/Ed4j6PscB8xVfuBJpRenI/o6dVk0cY0PYTY27AgCoGGxRnYuItQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"path-parse": "^1.0.5"
|
||||
"path-parse": "^1.0.6"
|
||||
}
|
||||
},
|
||||
"resolve-dependencies": {
|
||||
@@ -2638,11 +2635,6 @@
|
||||
"has-flag": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"symbol-observable": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz",
|
||||
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
|
||||
},
|
||||
"tapable": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz",
|
||||
@@ -2751,9 +2743,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"tslint": {
|
||||
"version": "5.11.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz",
|
||||
"integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=",
|
||||
"version": "5.12.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint/-/tslint-5.12.0.tgz",
|
||||
"integrity": "sha512-CKEcH1MHUBhoV43SA/Jmy1l24HJJgI0eyLbBNSRyFlsQvb9v6Zdq+Nz2vEOH00nC5SUx4SneJ59PZUS/ARcokQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"babel-code-frame": "^6.22.0",
|
||||
@@ -2771,9 +2763,9 @@
|
||||
}
|
||||
},
|
||||
"tslint-config-prettier": {
|
||||
"version": "1.16.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.16.0.tgz",
|
||||
"integrity": "sha512-zu6RAcpBtqdvhT6KpBh9kRPYATjOf9BnRi718kNqVKFjEgSE4rFrPprFju1YJrkOa3RbtbWI1ZSuLd2NBX1MDw==",
|
||||
"version": "1.17.0",
|
||||
"resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.17.0.tgz",
|
||||
"integrity": "sha512-NKWNkThwqE4Snn4Cm6SZB7lV5RMDDFsBwz6fWUkTxOKGjMx8ycOHnjIbhn7dZd5XmssW3CwqUjlANR6EhP9YQw==",
|
||||
"dev": true
|
||||
},
|
||||
"tslint-plugin-prettier": {
|
||||
@@ -2811,9 +2803,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.1.6",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.1.6.tgz",
|
||||
"integrity": "sha512-tDMYfVtvpb96msS1lDX9MEdHrW4yOuZ4Kdc4Him9oU796XldPYF/t2+uKoX0BBa0hXXwDlqYQbXY5Rzjzc5hBA==",
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz",
|
||||
"integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==",
|
||||
"dev": true
|
||||
},
|
||||
"uglify-es": {
|
||||
|
||||
+8
-8
@@ -2,7 +2,7 @@
|
||||
"name": "nexe",
|
||||
"description": "Create a single executable out of your Node.js application",
|
||||
"license": "MIT",
|
||||
"version": "3.0.0-beta.9",
|
||||
"version": "3.0.0-beta.12",
|
||||
"contributors": [
|
||||
"Craig Condon <craig.j.condon@gmail.com> (http://crcn.io)",
|
||||
"Jared Allard <jaredallard@outlook.com>",
|
||||
@@ -37,10 +37,10 @@
|
||||
"app-builder": "^5.2.0",
|
||||
"caw": "^2.0.1",
|
||||
"chalk": "^2.4.1",
|
||||
"cherow": "^1.6.8",
|
||||
"download": "^7.1.0",
|
||||
"globby": "^8.0.1",
|
||||
"got": "^9.3.2",
|
||||
"cherow": "1.6.8",
|
||||
"got": "^9.5.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"multistream": "^2.1.1",
|
||||
@@ -53,7 +53,7 @@
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/execa": "^0.9.0",
|
||||
"@types/globby": "^8.0.0",
|
||||
"@types/got": "^9.2.0",
|
||||
"@types/got": "^9.2.2",
|
||||
"@types/minimist": "^1.2.0",
|
||||
"@types/mkdirp": "^0.5.2",
|
||||
"@types/mocha": "^5.2.5",
|
||||
@@ -65,11 +65,11 @@
|
||||
"chai": "^4.2.0",
|
||||
"execa": "^1.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"prettier": "^1.15.2",
|
||||
"prettier": "^1.15.3",
|
||||
"ts-node": "^7.0.1",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.16.0",
|
||||
"tslint": "^5.12.0",
|
||||
"tslint-config-prettier": "^1.17.0",
|
||||
"tslint-plugin-prettier": "^2.0.1",
|
||||
"typescript": "^3.1.6"
|
||||
"typescript": "^3.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
+10
-5
@@ -1,7 +1,6 @@
|
||||
import { delimiter, dirname, normalize, join } from 'path'
|
||||
import { Buffer } from 'buffer'
|
||||
import { createReadStream } from 'fs'
|
||||
import { Readable, Stream } from 'stream'
|
||||
import { spawn } from 'child_process'
|
||||
import { Logger, LogStep } from './logger'
|
||||
import {
|
||||
@@ -26,6 +25,8 @@ const isBsd = Boolean(~process.platform.indexOf('bsd'))
|
||||
const make = isWindows ? 'vcbuild.bat' : isBsd ? 'gmake' : 'make'
|
||||
const configure = isWindows ? 'configure' : './configure'
|
||||
|
||||
type StringReplacer = (match: string) => string
|
||||
|
||||
export interface NexeFile {
|
||||
filename: string
|
||||
absPath: string
|
||||
@@ -82,6 +83,10 @@ export class NexeCompiler {
|
||||
* Output filename (-o myapp.exe)
|
||||
*/
|
||||
public output = this.options.output
|
||||
/**
|
||||
* Flag to indicate whether or notstdin was used for input
|
||||
*/
|
||||
public stdinUsed = false
|
||||
/**
|
||||
* Path to the configure script
|
||||
*/
|
||||
@@ -155,9 +160,9 @@ export class NexeCompiler {
|
||||
}
|
||||
|
||||
@bound
|
||||
async replaceInFileAsync(file: string, replace: string | RegExp, value: string) {
|
||||
async replaceInFileAsync(file: string, replace: string | RegExp, value: string | StringReplacer) {
|
||||
const entry = await this.readFileAsync(file)
|
||||
entry.contents = entry.contents.replace(replace, value)
|
||||
entry.contents = entry.contents.replace(replace, value as any)
|
||||
}
|
||||
|
||||
@bound
|
||||
@@ -166,9 +171,9 @@ export class NexeCompiler {
|
||||
entry.contents = contents
|
||||
}
|
||||
|
||||
quit() {
|
||||
quit(error?: any) {
|
||||
const time = Date.now() - this.start
|
||||
this.log.write(`Finished in ${time / 1000}s`)
|
||||
this.log.write(`Finished in ${time / 1000}s`, error ? 'red' : 'green')
|
||||
return this.log.flush()
|
||||
}
|
||||
|
||||
|
||||
+36
-37
@@ -34,6 +34,8 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
const { blobPath, resources: manifest } = binary
|
||||
const { resourceStart, stat } = binary.layout
|
||||
const directories: { [key: string]: { [key: string]: boolean } } = {},
|
||||
notAFile = '!@#$%^&*',
|
||||
isWin = process.platform.startsWith('win'),
|
||||
isString = (x: any): x is string => typeof x === 'string' || x instanceof String,
|
||||
isNotFile = () => false,
|
||||
isNotDirectory = isNotFile,
|
||||
@@ -42,23 +44,25 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
isDirectory = isFile,
|
||||
path = require('path')
|
||||
|
||||
let log = (text: string) => {
|
||||
if ((process.env.DEBUG || '').toLowerCase().includes('nexe:require')) {
|
||||
process.stderr.write('[nexe] - ' + text + '\n')
|
||||
} else {
|
||||
log = noop
|
||||
}
|
||||
let log = (text: string) => true
|
||||
if ((process.env.DEBUG || '').toLowerCase().includes('nexe:require')) {
|
||||
log = (text: string) => process.stderr.write('[nexe] - ' + text + '\n')
|
||||
}
|
||||
|
||||
const getKey = process.platform.startsWith('win')
|
||||
? function getKey(filepath: string): string {
|
||||
let key = path.resolve(filepath)
|
||||
if (key.substr(1, 2) === ':\\') {
|
||||
key = key[0].toUpperCase() + key.substr(1)
|
||||
}
|
||||
return key
|
||||
}
|
||||
: path.resolve
|
||||
const getKey = function getKey(filepath: string | Buffer | null): string {
|
||||
if (Buffer.isBuffer(filepath)) {
|
||||
filepath = filepath.toString()
|
||||
}
|
||||
if (!isString(filepath)) {
|
||||
return notAFile
|
||||
}
|
||||
let key = path.resolve(filepath)
|
||||
|
||||
if (isWin && key.substr(1, 2) === ':\\') {
|
||||
key = key[0].toUpperCase() + key.substr(1)
|
||||
}
|
||||
return key
|
||||
}
|
||||
|
||||
const statTime = function() {
|
||||
return {
|
||||
@@ -89,7 +93,7 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
return Object.assign({}, binary.layout.stat, fileExtensions, { size }, statTime())
|
||||
}
|
||||
|
||||
const ownStat = function(filepath: string) {
|
||||
const ownStat = function(filepath: any) {
|
||||
setupManifest()
|
||||
const key = getKey(filepath)
|
||||
if (directories[key]) {
|
||||
@@ -139,6 +143,8 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
currentDir = path.dirname(currentDir)
|
||||
}
|
||||
})
|
||||
;(manifest[notAFile] as any) = false
|
||||
;(directories[notAFile] as any) = false
|
||||
setupManifest = noop
|
||||
}
|
||||
|
||||
@@ -163,32 +169,26 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
realpathSync: function realpathSync(filepath: any, options: any) {
|
||||
setupManifest()
|
||||
const key = getKey(filepath)
|
||||
if (isString(filepath) && (manifest[filepath] || manifest[key])) {
|
||||
if (manifest[key]) {
|
||||
return filepath
|
||||
}
|
||||
return originalFsMethods.realpathSync.call(fs, filepath, options)
|
||||
},
|
||||
readdir: function readdir(filepath: string | Buffer, options: any, callback: any) {
|
||||
setupManifest()
|
||||
filepath = filepath.toString()
|
||||
if ('function' === typeof options) {
|
||||
callback = options
|
||||
options = { encoding: 'utf8' }
|
||||
}
|
||||
const dir = directories[getKey(filepath)]
|
||||
if (dir) {
|
||||
process.nextTick(() => {
|
||||
//todo merge with original?
|
||||
callback(null, Object.keys(dir))
|
||||
})
|
||||
if ('function' === typeof options) {
|
||||
callback = options
|
||||
options = { encoding: 'utf8' }
|
||||
}
|
||||
process.nextTick(() => callback(null, Object.keys(dir)))
|
||||
} else {
|
||||
return originalFsMethods.readdir.apply(fs, arguments)
|
||||
}
|
||||
},
|
||||
|
||||
readdirSync: function readdirSync(filepath: string | Buffer, options: any) {
|
||||
setupManifest()
|
||||
filepath = filepath.toString()
|
||||
const dir = directories[getKey(filepath)]
|
||||
if (dir) {
|
||||
return Object.keys(dir)
|
||||
@@ -198,8 +198,8 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
|
||||
readFile: function readFile(filepath: any, options: any, callback: any) {
|
||||
setupManifest()
|
||||
const entry = manifest[filepath] || manifest[getKey(filepath)]
|
||||
if (!entry || !isString(filepath)) {
|
||||
const entry = manifest[getKey(filepath)]
|
||||
if (!entry) {
|
||||
return originalFsMethods.readFile.apply(fs, arguments)
|
||||
}
|
||||
const [offset, length] = entry
|
||||
@@ -230,8 +230,8 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
},
|
||||
createReadStream: function createReadStream(filepath: any, options: any) {
|
||||
setupManifest()
|
||||
const entry = manifest[filepath] || manifest[getKey(filepath)]
|
||||
if (!entry || !isString(filepath)) {
|
||||
const entry = manifest[getKey(filepath)]
|
||||
if (!entry) {
|
||||
return originalFsMethods.createReadStream.apply(fs, arguments)
|
||||
}
|
||||
const [offset, length] = entry
|
||||
@@ -248,9 +248,8 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
},
|
||||
readFileSync: function readFileSync(filepath: any, options: any) {
|
||||
setupManifest()
|
||||
|
||||
const entry = manifest[filepath] || manifest[getKey(filepath)]
|
||||
if (!entry || !isString(filepath)) {
|
||||
const entry = manifest[getKey(filepath)]
|
||||
if (!entry) {
|
||||
return originalFsMethods.readFileSync.apply(fs, arguments)
|
||||
}
|
||||
const [offset, length] = entry
|
||||
@@ -263,14 +262,14 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
|
||||
return encoding ? result.toString(encoding) : result
|
||||
},
|
||||
statSync: function statSync(filepath: string | Buffer) {
|
||||
const stat = isString(filepath) && ownStat(filepath)
|
||||
const stat = ownStat(filepath)
|
||||
if (stat) {
|
||||
return stat
|
||||
}
|
||||
return originalFsMethods.statSync.apply(fs, arguments)
|
||||
},
|
||||
stat: function stat(filepath: string | Buffer, callback: any) {
|
||||
const stat = isString(filepath) && ownStat(filepath)
|
||||
const stat = ownStat(filepath)
|
||||
if (stat) {
|
||||
process.nextTick(() => {
|
||||
callback(null, stat)
|
||||
|
||||
+1
-1
@@ -36,10 +36,10 @@ async function compile(
|
||||
}
|
||||
|
||||
if (error) {
|
||||
compiler.quit(error)
|
||||
if (compiler.options.loglevel !== 'silent' && error) {
|
||||
process.stderr.write(EOL + error.message + EOL)
|
||||
}
|
||||
compiler.quit()
|
||||
if (callback) return callback(error)
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
||||
+17
-12
@@ -1,6 +1,6 @@
|
||||
import * as parseArgv from 'minimist'
|
||||
import { NexeCompiler } from './compiler'
|
||||
import { isWindows } from './util'
|
||||
import { isWindows, STDIN_FLAG } from './util'
|
||||
import { basename, extname, join, isAbsolute, resolve } from 'path'
|
||||
import { getTarget, NexeTarget } from './target'
|
||||
import { EOL, homedir } from 'os'
|
||||
@@ -194,11 +194,16 @@ function isEntryFile(filename?: string): filename is string {
|
||||
return Boolean(filename && !isAbsolute(filename))
|
||||
}
|
||||
|
||||
export function resolveEntry(input: string, cwd: string, maybeEntry?: string) {
|
||||
if (input === '-' || maybeEntry === '-') {
|
||||
return ''
|
||||
}
|
||||
export function resolveEntry(
|
||||
input: string,
|
||||
cwd: string,
|
||||
maybeEntry: string | undefined,
|
||||
bundle: boolean | string
|
||||
) {
|
||||
let result = null
|
||||
if (input === '-' || maybeEntry === '-') {
|
||||
return STDIN_FLAG
|
||||
}
|
||||
if (input && isAbsolute(input)) {
|
||||
return input
|
||||
}
|
||||
@@ -206,19 +211,19 @@ export function resolveEntry(input: string, cwd: string, maybeEntry?: string) {
|
||||
const inputPath = padRelative(input)
|
||||
result = resolveFileNameSync(cwd, inputPath)
|
||||
}
|
||||
|
||||
if (isEntryFile(maybeEntry) && (!result || !result.absPath)) {
|
||||
const inputPath = padRelative(maybeEntry)
|
||||
result = resolveFileNameSync(cwd, inputPath)
|
||||
}
|
||||
if (!process.stdin.isTTY) {
|
||||
return ''
|
||||
if (!process.stdin.isTTY && (!result || !result.absPath) && bundle === defaults.bundle) {
|
||||
return STDIN_FLAG
|
||||
}
|
||||
if (!result || !result.absPath) {
|
||||
result = resolveFileNameSync(cwd, '.')
|
||||
}
|
||||
if (!result.absPath) throw new Error(`Entry file "${input}" not found!`)
|
||||
|
||||
if (!result.absPath) {
|
||||
throw new Error(`Entry file "${input}" not found!`)
|
||||
}
|
||||
return result.absPath
|
||||
}
|
||||
|
||||
@@ -234,8 +239,8 @@ function normalizeOptions(input?: Partial<NexeOptions>): NexeOptions {
|
||||
? resolve(cwd, options.temp)
|
||||
: process.env.NEXE_TEMP || join(homedir(), '.nexe')
|
||||
const maybeEntry = isCli(input) ? argv._[argv._.length - 1] : undefined
|
||||
options.input = resolveEntry(options.input, cwd, maybeEntry)
|
||||
options.enableStdIn = isCli(input) && options.input === ''
|
||||
options.input = resolveEntry(options.input, cwd, maybeEntry, options.bundle)
|
||||
options.enableStdIn = isCli(input) && options.input === STDIN_FLAG
|
||||
options.name = extractName(options)
|
||||
options.loglevel = extractLogLevel(options)
|
||||
options.flags = flatten(opts.flag, options.flags)
|
||||
|
||||
@@ -6,8 +6,21 @@ export default async function disableNodeCli(compiler: NexeCompiler, next: () =>
|
||||
return next()
|
||||
}
|
||||
|
||||
if (semverGt(compiler.target.version, '9.99')) {
|
||||
if (semverGt(compiler.target.version, '10.9')) {
|
||||
await compiler.replaceInFileAsync('src/node.cc', /(?<!void )ProcessArgv\(/g, '//ProcessArgv(')
|
||||
} else if (semverGt(compiler.target.version, '9.999')) {
|
||||
await compiler.replaceInFileAsync(
|
||||
'src/node.cc',
|
||||
'int i = 1; i < v8_argc; i++',
|
||||
'int i = v8_argc; i < v8_argc; i++'
|
||||
)
|
||||
let matches = 0
|
||||
await compiler.replaceInFileAsync('src/node.cc', /v8_argc > 1/g, match => {
|
||||
if (matches++) {
|
||||
return 'false'
|
||||
}
|
||||
return match
|
||||
})
|
||||
} else {
|
||||
const nodeccMarker = 'argv[index][0] =='
|
||||
|
||||
|
||||
+39
-3
@@ -1,20 +1,56 @@
|
||||
import { NexeCompiler } from '../compiler'
|
||||
import { resolve } from 'path'
|
||||
import { resolve, relative } from 'path'
|
||||
import { each } from '@calebboyd/semaphore'
|
||||
import resolveFiles from 'resolve-dependencies'
|
||||
import { dequote, STDIN_FLAG } from '../util'
|
||||
import { Readable } from 'stream'
|
||||
|
||||
function getStdIn(stdin: Readable): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
let out = ''
|
||||
stdin
|
||||
.setEncoding('utf8')
|
||||
.on('readable', () => {
|
||||
let current
|
||||
while ((current = stdin.read())) {
|
||||
out += current
|
||||
}
|
||||
})
|
||||
.on('end', () => resolve(out))
|
||||
})
|
||||
}
|
||||
|
||||
export default async function bundle(compiler: NexeCompiler, next: any) {
|
||||
const { bundle, cwd, input } = compiler.options
|
||||
compiler.entrypoint = './' + relative(cwd, input)
|
||||
compiler.startup = ';require("module").runMain();'
|
||||
|
||||
if (!bundle) {
|
||||
await compiler.addResource(resolve(cwd, input))
|
||||
return next()
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
let code = ''
|
||||
if (typeof bundle === 'string') {
|
||||
code = await require(bundle).createBundle(compiler.options)
|
||||
}
|
||||
|
||||
if (input === STDIN_FLAG) {
|
||||
compiler.stdinUsed = true
|
||||
compiler.entrypoint = './__nexe_stdin.js'
|
||||
code = code || dequote(await getStdIn(process.stdin))
|
||||
await compiler.addResource(resolve(cwd, compiler.entrypoint), code)
|
||||
return next()
|
||||
}
|
||||
|
||||
const { files } = await resolveFiles(input, { cwd, expand: true, loadContent: false })
|
||||
const { files, warnings } = await resolveFiles(input, { cwd, expand: true, loadContent: false })
|
||||
|
||||
if (
|
||||
warnings.filter(x => x.startsWith('Error parsing file') && !x.includes('node_modules')).length
|
||||
) {
|
||||
throw new Error('Parsing Error:\n' + warnings.join('\n'))
|
||||
}
|
||||
|
||||
await each(Object.keys(files), (filename: string) => compiler.addResource(filename), {
|
||||
concurrency: 10
|
||||
})
|
||||
|
||||
+4
-35
@@ -1,24 +1,8 @@
|
||||
import { normalize, relative, resolve } from 'path'
|
||||
import { normalize, relative } from 'path'
|
||||
import { createWriteStream, chmodSync, statSync } from 'fs'
|
||||
import { dequote } from '../util'
|
||||
import { Readable } from 'stream'
|
||||
import { NexeCompiler } from '../compiler'
|
||||
import { NexeTarget } from '../target'
|
||||
|
||||
function getStdIn(stdin: Readable): Promise<string> {
|
||||
return new Promise(resolve => {
|
||||
let out = ''
|
||||
stdin
|
||||
.setEncoding('utf8')
|
||||
.on('readable', () => {
|
||||
let current
|
||||
while ((current = stdin.read())) {
|
||||
out += current
|
||||
}
|
||||
})
|
||||
.on('end', () => resolve(out))
|
||||
})
|
||||
}
|
||||
import { STDIN_FLAG } from '../util'
|
||||
|
||||
/**
|
||||
* The "cli" step detects the appropriate input. If no input options are passed,
|
||||
@@ -26,28 +10,13 @@ function getStdIn(stdin: Readable): Promise<string> {
|
||||
* After all the build steps have run, the output (the executable) is written to a file or piped to stdout.
|
||||
*
|
||||
* Configuration:
|
||||
* - compiler.options.input - file path to the input bundle.
|
||||
* - fallbacks: stdin, package.json#main
|
||||
* - compiler.options.output - file path to the output executable.
|
||||
* - fallbacks: stdout, nexe_ + epoch + ext
|
||||
*
|
||||
* @param {*} compiler
|
||||
* @param {*} next
|
||||
*/
|
||||
export default async function cli(compiler: NexeCompiler, next: () => Promise<void>) {
|
||||
const { log } = compiler
|
||||
let stdInUsed = false
|
||||
if (!process.stdin.isTTY && compiler.options.enableStdIn) {
|
||||
stdInUsed = true
|
||||
compiler.entrypoint = './__nexe_stdin.js'
|
||||
const code = dequote(await getStdIn(process.stdin))
|
||||
await compiler.addResource(resolve(compiler.options.cwd, compiler.entrypoint), code)
|
||||
} else {
|
||||
compiler.entrypoint = './' + relative(compiler.options.cwd, compiler.options.input)
|
||||
}
|
||||
compiler.startup = ';require("module").runMain();'
|
||||
await next()
|
||||
|
||||
const { log } = compiler
|
||||
const target = compiler.options.targets.shift() as NexeTarget
|
||||
const deliverable = await compiler.compileAsync(target)
|
||||
|
||||
@@ -67,7 +36,7 @@ export default async function cli(compiler: NexeCompiler, next: () => Promise<vo
|
||||
const outputFile = relative(process.cwd(), output)
|
||||
step.log(
|
||||
`Entry: '${
|
||||
stdInUsed ? (compiler.options.mangle ? '[stdin]' : '[none]') : inputFile
|
||||
compiler.stdinUsed ? (compiler.options.mangle ? STDIN_FLAG : '[none]') : inputFile
|
||||
}' written to: ${outputFile}`
|
||||
)
|
||||
resolve(compiler.quit())
|
||||
|
||||
@@ -4,6 +4,7 @@ import pify = require('pify')
|
||||
import rimraf = require('rimraf')
|
||||
|
||||
const rimrafAsync = pify(rimraf)
|
||||
export const STDIN_FLAG = '[stdin]'
|
||||
|
||||
export async function each<T>(
|
||||
list: T[] | Promise<T[]>,
|
||||
|
||||
Reference in New Issue
Block a user