chore: refresh lint/dev deps (#1142)

This commit is contained in:
Caleb Boyd
2026-03-04 22:50:46 -06:00
committed by GitHub
parent 3ca0d81922
commit 6220bf0522
30 changed files with 3586 additions and 1888 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"semi": false,
"singleQuote": true
}
+1 -1
View File
@@ -1,3 +1,3 @@
{
"recommendations": [ "ms-vscode.vscode-typescript-tslint-plugin" ]
"recommendations": ["oxc.oxc-vscode"]
}
+5 -3
View File
@@ -1,7 +1,9 @@
{
"tslint.enable": true,
"tslint.run": "onType",
"tslint.autoFixOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "explicit"
},
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
+3394 -1695
View File
File diff suppressed because it is too large Load Diff
+41 -41
View File
@@ -1,13 +1,25 @@
{
"name": "nexe",
"version": "5.0.0-beta.4",
"description": "Create a single executable out of your Node.js application",
"license": "MIT",
"version": "5.0.0-beta.4",
"contributors": [
"Craig Condon <craig.j.condon@gmail.com> (http://crcn.io)",
"Jared Allard <jaredallard@outlook.com>",
"Caleb Boyd <caleb.boyd@hotmail.com>"
],
"repository": {
"type": "git",
"url": "git://github.com/nexe/nexe.git"
},
"bin": {
"nexe": "index.js"
},
"files": [
"lib"
],
"main": "index.js",
"typings": "lib/nexe.d.ts",
"scripts": {
"ci:build": "ts-node tasks/build",
"test": "mocha",
@@ -21,28 +33,6 @@
"build": "tsc --declaration && tsc -p tasks && webpack",
"postbuild": "ts-node tasks/post-build"
},
"repository": {
"type": "git",
"url": "git://github.com/nexe/nexe.git"
},
"files": [
"lib"
],
"typings": "lib/nexe.d.ts",
"main": "index.js",
"bin": {
"nexe": "index.js"
},
"engines": {
"node": ">=10"
},
"mocha": {
"spec": "./test/**/*.spec.ts",
"checkLeaks": true,
"require": [
"ts-node/register"
]
},
"dependencies": {
"@calebboyd/semaphore": "^1.3.1",
"@yarnpkg/fslib": "^3.0.0-rc.43",
@@ -65,28 +55,38 @@
"webpack-config-prefabs": "0.0.5"
},
"devDependencies": {
"@types/archiver": "^5.3.2",
"@types/chai": "^4",
"@types/archiver": "^7.0.0",
"@types/chai": "^5",
"@types/download": "^8",
"@types/globby": "^9",
"@types/lodash": "^4.14.192",
"@types/minimist": "^1.2.2",
"@types/mkdirp": "^1.0.2",
"@types/mocha": "^10.0.1",
"@types/multistream": "^4.1.0",
"@types/lodash": "^4.17.24",
"@types/minimist": "^1.2.5",
"@types/mkdirp": "^2.0.0",
"@types/mocha": "^10.0.10",
"@types/multistream": "^4.1.3",
"@types/ora": "^3.2.0",
"@types/rimraf": "3.0.2",
"@types/semver": "^7.3.13",
"chai": "^4.3.7",
"execa": "^5.1.1",
"lodash": "^4.17.21",
"mocha": "^10.2.0",
"prettier": "^2.8.7",
"ts-node": "^10.9.1",
"tslint": "^6.1.1",
"@types/rimraf": "4.0.5",
"@types/semver": "^7.7.1",
"chai": "^6.2.2",
"execa": "^9.6.1",
"lodash": "^4.17.23",
"mocha": "^11.7.5",
"prettier": "^3.8.1",
"ts-node": "^10.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.3.0",
"typescript": "^5.0.3",
"webpack-cli": "^5.0.1"
"typescript": "^5.9.3",
"webpack-cli": "^6.0.1"
},
"mocha": {
"checkLeaks": true,
"require": [
"ts-node/register"
],
"spec": "./test/**/*.spec.ts"
},
"engines": {
"node": ">=10"
}
}
+9 -11
View File
@@ -12,15 +12,13 @@ import {
isWindows,
bound,
semverGt,
wrap,
} from './util'
import { NexeOptions, version } from './options'
import { NexeTarget } from './target'
import { PassThrough, Readable, Stream, Transform } from 'stream'
import { Readable, Transform } from 'stream'
import MultiStream = require('multistream')
import { Bundle, toStream } from './fs/bundle'
import { File } from 'resolve-dependencies'
import { FactoryStream, LazyStream } from 'multistream'
const isBsd = Boolean(~process.platform.indexOf('bsd'))
const make = isWindows ? 'vcbuild.bat' : isBsd ? 'gmake' : 'make'
@@ -108,11 +106,11 @@ export class NexeCompiler {
public remoteAsset: string
constructor(public options: NexeOptions) {
const { python } = (this.options = options)
const { python } = this.options
//SOMEDAY iterate over multiple targets with `--outDir`
this.targets = options.targets as NexeTarget[]
this.target = this.targets[0]
if (!/https?\:\/\//.test(options.remote)) {
if (!/https?:\/\//.test(options.remote)) {
throw new NexeError(`Invalid remote URI scheme (must be http or https): ${options.remote}`)
}
this.remoteAsset = options.remote + this.target.toString()
@@ -133,7 +131,7 @@ export class NexeCompiler {
process.env.PATH = originalPath
} else {
this.env = { ...process.env }
python && (this.env.PYTHON = python)
if (python) this.env.PYTHON = python
}
}
@@ -245,12 +243,12 @@ export class NexeCompiler {
this.compileStep!.log(
`Configuring node build${
this.options.configure.length ? ': ' + this.options.configure : '...'
}`
}`,
)
await this._configureAsync()
const buildOptions = this.options.make
this.compileStep!.log(
`Compiling Node${buildOptions.length ? ' with arguments: ' + buildOptions : '...'}`
`Compiling Node${buildOptions.length ? ' with arguments: ' + buildOptions : '...'}`,
)
await this._runBuildCommandAsync(make, buildOptions)
return createReadStream(this.getNodeExecutableLocation())
@@ -305,11 +303,11 @@ export class NexeCompiler {
this.bundle.toStream().pipe(
new Transform({
transform: (chunk, _, cb) => {
vfsSize || this.bundle.finalize()
chunk && (vfsSize += chunk.length)
if (!vfsSize) this.bundle.finalize()
if (chunk) vfsSize += chunk.length
cb(null, chunk)
},
})
}),
),
]
+41 -36
View File
@@ -57,7 +57,7 @@ export class SnapshotZipFS extends BasePortableFakeFS {
p: FSPath<PortablePath>,
discard: () => Promise<T>,
accept: (zipFS: ZipFS, zipInfo: { subPath: PortablePath }) => Promise<T>,
{ requireSubpath = true }: { requireSubpath?: boolean } = {}
{ requireSubpath = true }: { requireSubpath?: boolean } = {},
): Promise<T> {
if (typeof p !== 'string') return await discard()
@@ -75,7 +75,7 @@ export class SnapshotZipFS extends BasePortableFakeFS {
p: FSPath<PortablePath>,
discard: () => T,
accept: (zipFS: ZipFS, zipInfo: { subPath: PortablePath; archivePath: string }) => T,
{ requireSubpath = true }: { requireSubpath?: boolean } = {}
{ requireSubpath = true }: { requireSubpath?: boolean } = {},
): T {
if (typeof p !== 'string') return discard()
@@ -104,7 +104,7 @@ export class SnapshotZipFS extends BasePortableFakeFS {
// return the original path in case it wasn't under /snapshot, e.g. if it was for a node module - otherwise the node module parent path is the wrong one (and other things resolve relative to that)
return p
}
}
},
)
}
@@ -118,34 +118,34 @@ export class SnapshotZipFS extends BasePortableFakeFS {
ppath.resolve(
snapshotPP,
npath.toPortablePath(
npath.relative(npath.fromPortablePath(this.root), npath.fromPortablePath(p))
)
npath.relative(npath.fromPortablePath(this.root), npath.fromPortablePath(p)),
),
),
ppath.resolve(
snapshotPP,
npath.toPortablePath(
npath.relative(
toNamespacedPath(npath.fromPortablePath(this.root)),
toNamespacedPath(npath.fromPortablePath(p))
)
)
toNamespacedPath(npath.fromPortablePath(p)),
),
),
),
ppath.resolve(
snapshotPP,
npath.toPortablePath(
npath.relative(npath.fromPortablePath(process.cwd()), npath.fromPortablePath(p))
)
npath.relative(npath.fromPortablePath(process.cwd()), npath.fromPortablePath(p)),
),
),
ppath.resolve(
snapshotPP,
npath.toPortablePath(
npath.relative(
toNamespacedPath(npath.fromPortablePath(process.cwd())),
toNamespacedPath(npath.fromPortablePath(p))
)
)
toNamespacedPath(npath.fromPortablePath(p)),
),
),
),
])
]),
)
for (const path of pathsToTry) {
const portablePath = npath.toPortablePath(path)
@@ -162,26 +162,26 @@ export class SnapshotZipFS extends BasePortableFakeFS {
sourceFs: FakeFS<PortablePath>,
sourceP: PortablePath,
destFs: FakeFS<PortablePath>,
destP: PortablePath
destP: PortablePath,
) => {
if ((flags & constants.COPYFILE_FICLONE_FORCE) !== 0)
throw Object.assign(
new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP}' -> ${destP}'`),
{ code: `EXDEV` }
{ code: `EXDEV` },
)
if (flags & constants.COPYFILE_EXCL && (await this.existsPromise(sourceP)))
throw Object.assign(
new Error(`EEXIST: file already exists, copyfile '${sourceP}' -> '${destP}'`),
{ code: `EEXIST` }
{ code: `EEXIST` },
)
let content
try {
content = await sourceFs.readFilePromise(sourceP)
} catch (error) {
} catch {
throw Object.assign(
new Error(`EINVAL: invalid argument, copyfile '${sourceP}' -> '${destP}'`),
{ code: `EINVAL` }
{ code: `EINVAL` },
)
}
@@ -194,8 +194,13 @@ export class SnapshotZipFS extends BasePortableFakeFS {
return await this.baseFs.copyFilePromise(sourceP, destP, flags)
},
async (zipFsS, { subPath: subPathS }) => {
return await fallback(zipFsS, subPathS, this.baseFs, destP)
}
return await fallback(
zipFsS as unknown as FakeFS<PortablePath>,
subPathS,
this.baseFs,
destP,
)
},
)
}
@@ -204,26 +209,26 @@ export class SnapshotZipFS extends BasePortableFakeFS {
sourceFs: FakeFS<PortablePath>,
sourceP: PortablePath,
destFs: FakeFS<PortablePath>,
destP: PortablePath
destP: PortablePath,
) => {
if ((flags & constants.COPYFILE_FICLONE_FORCE) !== 0)
throw Object.assign(
new Error(`EXDEV: cross-device clone not permitted, copyfile '${sourceP}' -> ${destP}'`),
{ code: `EXDEV` }
{ code: `EXDEV` },
)
if (flags & constants.COPYFILE_EXCL && this.existsSync(sourceP))
throw Object.assign(
new Error(`EEXIST: file already exists, copyfile '${sourceP}' -> '${destP}'`),
{ code: `EEXIST` }
{ code: `EEXIST` },
)
let content
try {
content = sourceFs.readFileSync(sourceP)
} catch (error) {
} catch {
throw Object.assign(
new Error(`EINVAL: invalid argument, copyfile '${sourceP}' -> '${destP}'`),
{ code: `EINVAL` }
{ code: `EINVAL` },
)
}
@@ -236,23 +241,23 @@ export class SnapshotZipFS extends BasePortableFakeFS {
return this.baseFs.copyFileSync(sourceP, destP, flags)
},
(zipFsS, { subPath: subPathS }) => {
return fallback(zipFsS, subPathS, this.baseFs, destP)
}
return fallback(zipFsS as unknown as FakeFS<PortablePath>, subPathS, this.baseFs, destP)
},
)
}
async readdirPromise(p: PortablePath): Promise<Array<Filename>>
async readdirPromise(
p: PortablePath,
opts: { withFileTypes: false } | null
opts: { withFileTypes: false } | null,
): Promise<Array<Filename>>
async readdirPromise(p: PortablePath, opts: { withFileTypes: true }): Promise<Array<Dirent>>
async readdirPromise(
p: PortablePath,
opts: { withFileTypes: boolean }
opts: { withFileTypes: boolean },
): Promise<Array<Filename> | Array<Dirent>>
async readdirPromise(
p: PortablePath,
opts?: { withFileTypes?: boolean } | null
opts?: { withFileTypes?: boolean } | null,
): Promise<Array<string | Dirent>> {
const fallback = async () => {
return await this.baseFs.readdirPromise(p, opts as any)
@@ -263,12 +268,12 @@ export class SnapshotZipFS extends BasePortableFakeFS {
async (zipFs, { subPath }) => {
const fallbackPaths: Array<string | Dirent> = await fallback().catch(() => [])
return Promise.resolve(
uniqReaddir(fallbackPaths.concat(await zipFs.readdirPromise(subPath, opts as any)))
uniqReaddir(fallbackPaths.concat(await zipFs.readdirPromise(subPath, opts as any))),
)
},
{
requireSubpath: false,
}
},
)
}
@@ -287,12 +292,12 @@ export class SnapshotZipFS extends BasePortableFakeFS {
let fallbackPaths: Array<string | Dirent> = []
try {
fallbackPaths = fallback()
} catch (e) {}
} catch {}
return fallbackPaths.concat(uniqReaddir(zipFs.readdirSync(subPath, opts as any)))
},
{
requireSubpath: false,
}
},
)
}
@@ -316,7 +321,7 @@ export class SnapshotZipFS extends BasePortableFakeFS {
return this.opendirSync(p, opts)
}
opendirSync(p: PortablePath, opts?: OpendirOptions) {
opendirSync(p: PortablePath, _opts?: OpendirOptions) {
const zipInfo = this.findZip(p)
let zipFsDir: Dir<PortablePath> | null = null
if (zipInfo) {
+25 -17
View File
@@ -1,20 +1,28 @@
if (true) {
const __nexe_patches = (process.nexe = { patches: {} }).patches
const slice = [].slice
{
const __nexe_patches = (process.nexe = { patches: {} }).patches;
const slice = [].slice;
const __nexe_noop_patch = function (original) {
const args = slice.call(arguments, 1)
return original.apply(this, args)
}
const args = slice.call(arguments, 1);
return original.apply(this, args);
};
const __nexe_patch = function (obj, method, patch) {
const original = obj[method]
if (!original) return
__nexe_patches[method] = patch
obj[method] = function() {
const args = [original].concat(slice.call(arguments))
return __nexe_patches[method].apply(this, args)
}
}
__nexe_patch((process).binding('fs'), 'internalModuleReadFile', __nexe_noop_patch)
__nexe_patch((process).binding('fs'), 'internalModuleReadJSON', __nexe_noop_patch)
__nexe_patch((process).binding('fs'), 'internalModuleStat', __nexe_noop_patch)
const original = obj[method];
if (!original) return;
__nexe_patches[method] = patch;
obj[method] = function () {
const args = [original].concat(slice.call(arguments));
return __nexe_patches[method].apply(this, args);
};
};
__nexe_patch(
process.binding("fs"),
"internalModuleReadFile",
__nexe_noop_patch,
);
__nexe_patch(
process.binding("fs"),
"internalModuleReadJSON",
__nexe_noop_patch,
);
__nexe_patch(process.binding("fs"), "internalModuleStat", __nexe_noop_patch);
}
+8 -8
View File
@@ -1,5 +1,5 @@
import { ZipFS, getLibzipSync } from '@yarnpkg/libzip'
import { patchFs, npath, PosixFS, NodeFS } from '@yarnpkg/fslib'
import { patchFs, PosixFS, NodeFS } from '@yarnpkg/fslib'
import { SnapshotZipFS } from './SnapshotZipFS'
import * as assert from 'assert'
import * as constants from 'constants'
@@ -38,7 +38,7 @@ function shimFs(binary: NexeHeader, fs: typeof import('fs') = require('fs')) {
blob,
0,
binary.layout.resourceSize,
binary.layout.resourceStart
binary.layout.resourceStart,
)
assert.equal(bytesRead, binary.layout.resourceSize)
@@ -56,21 +56,21 @@ function shimFs(binary: NexeHeader, fs: typeof import('fs') = require('fs')) {
if ((process.env.DEBUG || '').toLowerCase().includes('nexe:require')) {
process.stderr.write(
// @ts-ignore
`[nexe] - FILES ${JSON.stringify(Array.from(zipFs.entries.keys()), null, 4)}\n`
`[nexe] - FILES ${JSON.stringify(Array.from(zipFs.entries.keys()), null, 4)}\n`,
)
process.stderr.write(
// @ts-ignore
`[nexe] - DIRECTORIES ${JSON.stringify(Array.from(zipFs.listings.keys()), null, 4)}\n`
`[nexe] - DIRECTORIES ${JSON.stringify(Array.from(zipFs.listings.keys()), null, 4)}\n`,
)
log = (text: string) => {
return process.stderr.write(`[nexe] - ${text}\n`)
}
}
function internalModuleReadFile(this: any, original: any, ...args: any[]) {
function internalModuleReadFile(this: any, _original: any, ...args: any[]) {
log(`internalModuleReadFile ${args[0]}`)
try {
return posixSnapshotZipFs.readFileSync(args[0], 'utf-8')
} catch (e) {
} catch {
return ''
}
}
@@ -87,7 +87,7 @@ function shimFs(binary: NexeHeader, fs: typeof import('fs') = require('fs')) {
: [res, /"(main|name|type|exports|imports)"/.test(res)]
: res
}
patches.internalModuleStat = function (this: any, original: any, ...args: any[]) {
patches.internalModuleStat = function (this: any, _original: any, ...args: any[]) {
let statPath = args[0]
//in node 22, the path arg moved to arg[1]
if (typeof args[0] !== 'string') statPath = args[1]
@@ -96,7 +96,7 @@ function shimFs(binary: NexeHeader, fs: typeof import('fs') = require('fs')) {
const stat = posixSnapshotZipFs.statSync(statPath)
if (stat.isDirectory()) result = 1
else result = 0
} catch (e) {
} catch {
result = -constants.ENOENT
}
log(`internalModuleStat ${result} ${statPath}`)
+1 -1
View File
@@ -34,7 +34,7 @@ export class Logger {
}
flush() {
!this.silent && this.ora.succeed()
if (!this.silent) this.ora.succeed()
return new Promise((resolve) => setTimeout(resolve, frameLength))
}
+4 -5
View File
@@ -1,6 +1,5 @@
import { EOL } from 'os'
import { compose } from 'app-builder'
import { NexeCompiler, NexeError } from './compiler'
import { NexeCompiler } from './compiler'
import { normalizeOptions, NexeOptions, NexePatch } from './options'
import resource from './steps/resource'
import clean from './steps/clean'
@@ -13,7 +12,7 @@ import patches from './patches'
async function compile(
compilerOptions?: Partial<NexeOptions>,
callback?: (err: Error | null) => void
callback?: (err: Error | null) => void,
) {
let error: Error | null = null,
options: NexeOptions | null = null,
@@ -30,14 +29,14 @@ async function compile(
shim,
download,
options.build ? [artifacts, ...patches, ...(options.patches as NexePatch[])] : [],
options.plugins as NexePatch[]
options.plugins as NexePatch[],
)(compiler)
} catch (e: any) {
error = e
}
if (error) {
compiler && compiler.quit(error)
if (compiler) compiler.quit(error)
if (callback) return callback(error)
return Promise.reject(error)
}
+1 -1
View File
@@ -196,7 +196,7 @@ export function resolveEntry(
input: string,
cwd: string,
maybeEntry: string | undefined,
bundle: boolean | string
bundle: boolean | string,
) {
let result = null
if (input === '-' || maybeEntry === '-') {
+1 -1
View File
@@ -45,7 +45,7 @@ Object.defineProperty(
enumerable: false,
configurable: false,
}
})()
})(),
)
const contentBuffer = Buffer.from(Array(contentSize)),
+2 -2
View File
@@ -5,12 +5,12 @@ export default async function buildFixes(compiler: NexeCompiler, next: () => Pro
return next()
}
const file = await compiler.readFileAsync('./tools/msvs/find_python.cmd')
await compiler.readFileAsync('./tools/msvs/find_python.cmd')
await compiler.replaceInFileAsync(
'./tools/msvs/find_python.cmd',
'%p%python.exe -V 2>&1',
'"%p%python.exe" -V 2>&1'
'"%p%python.exe" -V 2>&1',
)
return next()
+4 -4
View File
@@ -10,13 +10,13 @@ export default async function disableNodeCli(compiler: NexeCompiler, next: () =>
await compiler.replaceInFileAsync(
'src/node.cc',
/(?<!static ExitCode )ProcessGlobalArgsInternal\(argv[^;]*;/gm,
'ExitCode::kNoFailure;/*$&*/'
'ExitCode::kNoFailure;/*$&*/',
)
} else if (semverGt(compiler.target.version, '11.6.0')) {
await compiler.replaceInFileAsync(
'src/node.cc',
/(?<!int )ProcessGlobalArgs\(argv[^;]*;/gm,
'0;/*$&*/'
'0;/*$&*/',
)
} else if (semverGt(compiler.target.version, '10.9')) {
await compiler.replaceInFileAsync('src/node.cc', /(?<!void )ProcessArgv\(argv/g, '//$&')
@@ -24,7 +24,7 @@ export default async function disableNodeCli(compiler: NexeCompiler, next: () =>
await compiler.replaceInFileAsync(
'src/node.cc',
'int i = 1; i < v8_argc; i++',
'int i = v8_argc; 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) => {
@@ -42,7 +42,7 @@ export default async function disableNodeCli(compiler: NexeCompiler, next: () =>
// allow NODE_OPTIONS, introduced in 8.0
semverGt(compiler.target.version, '7.99')
? `(${nodeccMarker} (is_env ? '-' : ']'))`
: `(${nodeccMarker} ']')`
: `(${nodeccMarker} ']')`,
)
}
+1 -1
View File
@@ -9,7 +9,7 @@ export default async function flags(compiler: NexeCompiler, next: () => Promise<
await compiler.replaceInFileAsync(
'node.gyp',
"'node_v8_options%': ''",
`'node_v8_options%': '${nodeflags.join(' ')}'`
`'node_v8_options%': '${nodeflags.join(' ')}'`,
)
return next()
+2 -2
View File
@@ -2,7 +2,7 @@ import { NexeCompiler } from '../compiler'
export default async function nodeGyp(
{ files, replaceInFileAsync }: NexeCompiler,
next: () => Promise<void>
next: () => Promise<void>,
) {
await next()
@@ -16,6 +16,6 @@ export default async function nodeGyp(
.filter((x) => x.filename.startsWith('lib'))
.map((x) => `'${x.filename}'`)
.toString()},
`.trim()
`.trim(),
)
}
+3 -3
View File
@@ -16,11 +16,11 @@ export default async function (compiler: NexeCompiler, next: () => Promise<void>
'def configure_v8(o):',
`def configure_v8(o):\n o['variables']['${variablePrefix}embed_script'] = r'${resolve(
cwd,
snapshot
snapshot,
)}'\n o['variables']['${variablePrefix}warmup_script'] = r'${resolve(
cwd,
warmup || snapshot
)}'`
warmup || snapshot,
)}'`,
)
return next()
+8 -8
View File
@@ -59,7 +59,7 @@ export default async function main(compiler: NexeCompiler, next: () => Promise<v
await compiler.replaceInFileAsync(
'lib/internal/modules/cjs/loader.js',
"'use strict';",
"'use strict';\n" + '{{ file("lib/fs/bootstrap.js") }}' + '\n'
"'use strict';\n" + '{{ file("lib/fs/bootstrap.js") }}' + '\n',
)
fileLines.splice(location.start.line, 0, 'expandArgv1 = false;')
} else {
@@ -68,7 +68,7 @@ export default async function main(compiler: NexeCompiler, next: () => Promise<v
0,
'{{ file("lib/fs/bootstrap.js") }}' +
'\n' +
(semverGt(version, '11.99') ? 'expandArgv1 = false;\n' : '')
(semverGt(version, '11.99') ? 'expandArgv1 = false;\n' : ''),
)
}
file.contents = fileLines.join('\n')
@@ -78,19 +78,19 @@ export default async function main(compiler: NexeCompiler, next: () => Promise<v
await compiler.replaceInFileAsync(
bootFile,
'initializeFrozenIntrinsics();',
'initializeFrozenIntrinsics();\n' + wrap('{{ file("lib/patches/boot-nexe.js") }}')
'initializeFrozenIntrinsics();\n' + wrap('{{ file("lib/patches/boot-nexe.js") }}'),
)
} else {
await compiler.replaceInFileAsync(
bootFile,
'initializePolicy();',
'initializePolicy();\n' + wrap('{{ file("lib/patches/boot-nexe.js") }}')
'initializePolicy();\n' + wrap('{{ file("lib/patches/boot-nexe.js") }}'),
)
}
await compiler.replaceInFileAsync(
bootFile,
'assert(!CJSLoader.hasLoadedAnyUserCJSModule)',
'/*assert(!CJSLoader.hasLoadedAnyUserCJSModule)*/'
'/*assert(!CJSLoader.hasLoadedAnyUserCJSModule)*/',
)
const { contents: nodeccContents } = await compiler.readFileAsync('src/node.cc')
if (nodeccContents.includes('if (env->worker_context() != nullptr) {')) {
@@ -98,20 +98,20 @@ export default async function main(compiler: NexeCompiler, next: () => Promise<v
'src/node.cc',
'if (env->worker_context() != nullptr) {',
'if (env->worker_context() == nullptr) {\n' +
' return StartExecution(env, "internal/main/run_main_module"); } else {\n'
' return StartExecution(env, "internal/main/run_main_module"); } else {\n',
)
} else {
await compiler.replaceInFileAsync(
'src/node.cc',
'MaybeLocal<Value> StartMainThreadExecution(Environment* env) {',
'MaybeLocal<Value> StartMainThreadExecution(Environment* env) {\n' +
' return StartExecution(env, "internal/main/run_main_module");\n'
' return StartExecution(env, "internal/main/run_main_module");\n',
)
}
} else {
await compiler.setFileContentsAsync(
'lib/_third_party_main.js',
'{{ file("lib/patches/boot-nexe.js") }}'
'{{ file("lib/patches/boot-nexe.js") }}',
)
}
return next()
+1 -1
View File
@@ -37,7 +37,7 @@ export function getLatestGitRelease(options?: any) {
export async function getUnBuiltReleases(options?: any) {
const nodeReleases = await getJson<NodeRelease[]>(
'https://nodejs.org/download/release/index.json'
'https://nodejs.org/download/release/index.json',
)
const existingVersions = (await getLatestGitRelease(options)).assets.map((x) => getTarget(x.name))
+3 -3
View File
@@ -14,7 +14,7 @@ function readDirAsync(dir: string): Promise<string[]> {
paths.map((file: string) => {
const path = join(dir, file)
return isDirectoryAsync(path).then((x) => (x ? readDirAsync(path) : (path as any)))
})
}),
).then((result) => {
return [].concat(...(result as any))
})
@@ -48,7 +48,7 @@ export default async function artifacts(compiler: NexeCompiler, next: () => Prom
await Promise.all(
tmpFiles.map(async (path) => {
return compiler.writeFileAsync(path.replace(temp, ''), await readFileAsync(path, 'utf-8'))
})
}),
)
await next()
@@ -63,6 +63,6 @@ export default async function artifacts(compiler: NexeCompiler, next: () => Prom
await mkdirpAsync(dirname(tempFile))
await writeFileAsync(tempFile, fileContents)
await compiler.writeFileAsync(file.filename, file.contents)
})
}),
)
}
+3 -3
View File
@@ -1,7 +1,7 @@
import { NexeCompiler, NexeError } from '../compiler'
import { resolve, relative } from 'path'
import resolveFiles, { resolveSync } from 'resolve-dependencies'
import { dequote, STDIN_FLAG, semverGt, each } from '../util'
import { dequote, STDIN_FLAG, semverGt } from '../util'
import { Readable } from 'stream'
function getStdIn(stdin: Readable): Promise<string> {
@@ -66,7 +66,7 @@ export default async function bundle(compiler: NexeCompiler, next: any) {
const { files, warnings } = await resolveFiles(
input,
...Object.keys(compiler.bundle.list).filter((x) => x.endsWith('.js') || x.endsWith('.mjs')),
{ cwd, expand: 'variable', loadContent: false }
{ cwd, expand: 'variable', loadContent: false },
)
if (
@@ -81,7 +81,7 @@ export default async function bundle(compiler: NexeCompiler, next: any) {
Object.entries(files).map(([key]) => {
step.log(`Including dependency: ${key}`)
return compiler.addResource(key)
})
}),
)
return next()
+4 -6
View File
@@ -29,15 +29,13 @@ export default async function cli(compiler: NexeCompiler, next: () => Promise<vo
deliverable
.pipe(createWriteStream(output))
.on('error', rej)
.once('close', (e: Error) => {
if (e) {
rej(e)
} else if (compiler.output) {
.once('close', () => {
if (compiler.output) {
const output = compiler.output,
mode = statSync(output).mode | 0o111,
inputFileLogOutput = relative(
process.cwd(),
resolve(compiler.options.cwd, compiler.entrypoint || compiler.options.input)
resolve(compiler.options.cwd, compiler.entrypoint || compiler.options.input),
),
outputFileLogOutput = relative(process.cwd(), output)
@@ -49,7 +47,7 @@ export default async function cli(compiler: NexeCompiler, next: () => Promise<vo
? STDIN_FLAG
: '[none]'
: inputFileLogOutput
}' written to: ${outputFileLogOutput}`
}' written to: ${outputFileLogOutput}`,
)
compiler.quit()
res(output)
+2 -2
View File
@@ -36,7 +36,7 @@ async function fetchPrebuiltBinary(compiler: NexeCompiler, step: any) {
current += data.length
step!.modify(`Downloading...${((current / total) * 100).toFixed()}%`)
})
}
},
)
} catch (e: any) {
if (e.statusCode === 404) {
@@ -58,7 +58,7 @@ export default async function downloadNode(compiler: NexeCompiler, next: () => P
{ sourceUrl, downloadOptions, build } = compiler.options,
url = sourceUrl || `https://nodejs.org/dist/v${version}/node-v${version}.tar.gz`,
step = log.step(
`Downloading ${build ? '' : 'pre-built '}Node.js${build ? ` source from: ${url}` : ''}`
`Downloading ${build ? '' : 'pre-built '}Node.js${build ? ` source from: ${url}` : ''}`,
),
exeLocation = compiler.getNodeExecutableLocation(build ? undefined : target),
downloadExists = await pathExistsAsync(build ? src : exeLocation)
+5 -5
View File
@@ -15,9 +15,9 @@ export default async function (compiler: NexeCompiler, next: () => Promise<void>
'})()',
'fsPatcher.shimFs(process.__nexe);',
compiler.options.fs ? '' : 'restoreFs();',
].join('\n')
].join('\n'),
//TODO support only restoring specific methods
)
),
)
compiler.shims.push(
wrap(`
@@ -26,7 +26,7 @@ export default async function (compiler: NexeCompiler, next: () => Promise<void>
cluster._setupWorker()
delete process.env.NODE_UNIQUE_ID
}
`)
`),
)
compiler.shims.push(
@@ -34,10 +34,10 @@ export default async function (compiler: NexeCompiler, next: () => Promise<void>
if (!process.send) {
const path = require('path')
const entry = path.resolve(path.dirname(process.execPath),${JSON.stringify(
compiler.entrypoint
compiler.entrypoint,
)})
process.argv.splice(1,0, entry)
}
`)
`),
)
}
+5 -1
View File
@@ -54,7 +54,11 @@ function isArch(x: string): x is NodeArch {
}
class Target implements NexeTarget {
constructor(public arch: NodeArch, public platform: NodePlatform, public version: string) {}
constructor(
public arch: NodeArch,
public platform: NodePlatform,
public version: string,
) {}
toJSON() {
return this.toString()
}
+1 -1
View File
@@ -17,7 +17,7 @@ declare module 'download' {
function download(
url: string,
destination?: string | DownloadOptions,
options?: DownloadOptions
options?: DownloadOptions,
): PromiseLike<Buffer> & Duplex
export = download
}
+5 -5
View File
@@ -8,7 +8,7 @@ export const STDIN_FLAG = '[stdin]'
export async function each<T>(
list: T[] | Promise<T[]>,
action: (item: T, index: number, list: T[]) => Promise<any>
action: (item: T, index: number, list: T[]) => Promise<any>,
) {
const l = await list
return Promise.all(l.map(action))
@@ -30,9 +30,9 @@ function padRight(str: string, l: number) {
}
const bound: MethodDecorator = function bound<T>(
target: Object,
propertyKey: string | Symbol,
descriptor: TypedPropertyDescriptor<T>
_target: object,
propertyKey: string | symbol,
descriptor: TypedPropertyDescriptor<T>,
) {
const configurable = true
return {
@@ -72,7 +72,7 @@ const isWindows = process.platform === 'win32'
function pathExistsAsync(path: string) {
return statAsync(path)
.then((x) => true)
.then(() => true)
.catch(falseOnEnoent)
}
+1 -12
View File
@@ -1,4 +1,4 @@
import { NexeTarget, architectures } from '../lib/target'
import { NexeTarget } from '../lib/target'
import { writeFileAsync, readFileAsync } from '../lib/util'
import got from 'got'
import execa = require('execa')
@@ -26,17 +26,6 @@ RUN echo "console.log('hello world')" >> index.js && \
`.trim()
}
function arm(target: NexeTarget) {
return `
FROM hypriot/rpi-node
ENV NEXE_VERSION=latest
WORKDIR /
RUN yarn global add nexe@\${NEXE_VERSION} && \
nexe --build --no-mangle -o out -t ${target.version}
`.trim()
}
export async function runDockerBuild(target: NexeTarget) {
//todo switch on alpine and arm
const dockerfile = alpine(target)
-9
View File
@@ -1,9 +0,0 @@
{
"rulesDirectory": ["tslint-plugin-prettier", "tslint-config-prettier"],
"linterOptions": {
"exclude": ["**/node_modules/**/*"]
},
"rules": {
"prettier": [true, { "semi": false, "printWidth": 100, "singleQuote": true }]
}
}