chore: lint

This commit is contained in:
calebboyd
2022-07-07 18:08:57 -05:00
parent d361ed0c34
commit 0b0ac7109c
36 changed files with 1452 additions and 156 deletions
+6 -6
View File
@@ -1,16 +1,18 @@
name: Base Builds
on:
workflow_dispatch:
on:
push:
branches:
- refactor-old-node
jobs:
build:
strategy:
fail-fast: false
matrix:
version: ['14.19.1', '16.15.0', '18.1.0']
version: ['14.20.0', '16.16.0', '18.5.0']
arch: [x64, x86]
plat: [arm, macos, windows, linux, alpine]
exclude:
exclude:
- plat: arm
arch: x86
- plat: macos
@@ -40,7 +42,6 @@ jobs:
with:
node-version: ${{ matrix.version }}
- uses: actions/checkout@v3
with:
node-version: 18
- name: 'Install Dependencies'
@@ -49,4 +50,3 @@ jobs:
env:
NEXE_TARGET: ${{ matrix.plat }}-${{ matrix.arch }}-${{ matrix.version }}
run: npx ts-node tasks/build.ts
+1 -1
View File
@@ -1 +1 @@
16.15.0
16.15.1
+4 -3
View File
@@ -2,17 +2,18 @@
"module": {
"type": "commonjs",
"ignoreDynamic": true
},
"jsc": {
"parser": {
"syntax": "typescript",
"syntax": "typescript",
"dynamicImport": true,
"decorators": true
},
"transform": {
"legacyDecorator": true
},
"target": "es2019",
"target": "es2019",
"externalHelpers": false
}
}
}
+28 -4
View File
@@ -1,7 +1,4 @@
{
"tslint.enable": true,
"tslint.run": "onType",
"tslint.autoFixOnSave": true,
"files.exclude": {
"**/.git": true,
"**/.svn": true,
@@ -14,5 +11,32 @@
"**/node_modules": true,
"**/bower_components": true
},
"typescript.tsdk": "node_modules\\typescript\\lib"
"eslint.workingDirectories": [{ "mode": "auto" }],
"eslint.format.enable": true,
"editor.formatOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"[javascript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright (c) 2013-2018 Nexe Contributors
Copyright (c) 2013-2022 Nexe Contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
+13
View File
@@ -0,0 +1,13 @@
FROM centos:7
RUN yum install -y which centos-release-scl \
&& yum install -y devtoolset-9-gcc \
devtoolset-9-gcc-c++ \
make \
python3 \
curl \
&& curl -sL https://rpm.nodesource.com/setup_16.x | bash - \
&& yum install -y nodejs && npm install nexe -g \
&& echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc
SHELL ["/bin/bash", "--login", "-c"]
+4
View File
@@ -0,0 +1,4 @@
FROM node:16-alpine
RUN apk add --no-cache build-base linux-headers bash clang python3
SHELL ["/bin/bash", "--login", "-c"]
CMD ["bash"]
Executable → Regular
+4 -4
View File
@@ -5,12 +5,12 @@
const eol = require('os').EOL
async function main() {
const util = require('../lib/cjs/util')
const util = require('./lib/cjs/util.js')
await util.initEsm()
const color = util.color,
options = require('../lib/cjs/options'),
nexe = require('../lib/cjs/nexe'),
NexeError = require('../lib/cjs/compiler').NexeError,
options = require('./lib/cjs/options.js'),
nexe = require('./lib/cjs/nexe.js'),
NexeError = require('./lib/cjs/compiler.js').NexeError,
del = eol + eol,
argv = options.argv,
showHelp = argv.help || argv._.some((x) => x === 'help'),
+1267 -33
View File
File diff suppressed because it is too large Load Diff
+33 -17
View File
@@ -3,10 +3,12 @@
"description": "Create a single executable out of your Node.js application",
"license": "MIT",
"type": "commonjs",
"version": "4.0.0-rc.3",
"version": "4.0.0-rc.local",
"bin": {
"nexe": "./bin/index.js"
"nexe": "./index.js"
},
"types": "./lib/types/nexe.d.ts",
"main": "./lib/cjs/nexe.js",
"exports": {
"./package.json": "./package.json",
".": {
@@ -26,16 +28,17 @@
},
"files": [
"lib",
"bin"
"index.js"
],
"scripts": {
"lint": "tsc --noEmit && eslint \"{src,tasks,test}/**/*.ts\" --fix",
"test": "vitest run",
"test": "vitest run && node test/exports.mjs",
"prepublishOnly": "npm run lint && npm run build && npm test",
"build": "npm run cjs:build & npm run esm:build",
"prebuild": "rm -rf lib",
"cjs:build": "swc src -d lib/cjs --copy-files",
"esm:build": "swc src -d lib/esm --copy-files -C module.type=es6",
"postbuild": "node -p \"JSON.stringify({ type: 'module'})\" > lib/esm/package.json && tsc --emitDeclarationOnly && ts-node tasks/post-build"
"postbuild": "node -p \"JSON.stringify({type:'module'})\" > lib/esm/package.json && tsc --emitDeclarationOnly && ts-node tasks/post-build"
},
"contributors": [
"Craig Condon <craig.j.condon@gmail.com> (http://crcn.io)",
@@ -47,27 +50,28 @@
"chalk": "^5.0.1",
"download": "^8.0.0",
"fast-glob": "^3.2.11",
"got": "^12.0.4",
"got": "^12.1.0",
"meriyah": "^4.2.1",
"minimist": "^1.2.6",
"multistream": "^4.1.0",
"ora": "^6.1.0",
"resolve-dependencies": "^6.0.7"
"ora": "^6.1.2",
"resolve-dependencies": "^6.0.8"
},
"devDependencies": {
"@swc/cli": "^0.1.57",
"@swc/core": "^1.2.181",
"@swc/core": "^1.2.210",
"@types/minimist": "^1.2.2",
"@types/multistream": "^4.1.0",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"eslint": "^8.15.0",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"eslint": "^8.19.0",
"eslint-config-prettier": "~8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.6.2",
"ts-node": "^10.7.0",
"typescript": "^4.6.4",
"vitest": "^0.12.3"
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
"prettier": "^2.7.1",
"ts-node": "^10.8.2",
"typescript": "^4.7.4",
"vitest": "^0.17.0"
},
"prettier": {
"parser": "typescript",
@@ -78,6 +82,7 @@
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"plugins": [
"import",
"@typescript-eslint"
],
"extends": [
@@ -87,6 +92,17 @@
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/consistent-type-imports": [
2,
{
"prefer": "type-imports",
"disallowTypeAnnotations": false
}
],
"import/extensions": [
2,
"ignorePackages"
],
"@typescript-eslint/no-unused-vars": [
2,
{
+12 -9
View File
@@ -1,16 +1,19 @@
import { resolve, normalize, join } from 'node:path'
import { Buffer } from 'node:buffer'
import { createReadStream, ReadStream } from 'node:fs'
import type { ReadStream } from 'node:fs'
import { createReadStream } from 'node:fs'
import { spawn } from 'node:child_process'
import { File } from 'resolve-dependencies'
import type { File } from 'resolve-dependencies'
import MultiStream from 'multistream'
import { Logger, LogStep } from './logger'
import { readFile, writeFile, pathExists, isWindows, bound, wrap } from './util'
import { NexeOptions, version } from './options'
import { NexeTarget } from './target'
import { Bundle, toStream } from './fs/bundle'
import type { LogStep } from './logger.js'
import { Logger } from './logger.js'
import { readFile, writeFile, pathExists, isWindows, bound, wrap } from './util.js'
import { version } from './options.js'
import type { NexeOptions } from './options.js'
import type { NexeTarget } from './target.js'
import { Bundle, toStream } from './fs/bundle.js'
const isBsd = Boolean(~process.platform.indexOf('bsd')),
make = isWindows ? 'vcbuild.bat' : isBsd ? 'gmake' : 'make'
@@ -123,7 +126,7 @@ export class NexeCompiler {
async readFileAsync(file: string) {
this.assertBuild()
let cachedFile = this.files.find((x) => normalize(x.filename) === normalize(file))
if (cachedFile == null) {
if (!cachedFile) {
const absPath = join(this.src, file)
cachedFile = {
absPath,
@@ -249,7 +252,7 @@ export class NexeCompiler {
location = this.getNodeExecutableLocation(build ? undefined : target)
let binary = (await pathExists(location)) ? createReadStream(location) : null
if (binary == null) {
if (!binary) {
binary = await this.build()
step.log('Node binary compiled')
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { createReadStream } from 'node:fs'
import { relative } from 'node:path'
import { Readable } from 'node:stream'
import { File } from 'resolve-dependencies'
import type { File } from 'resolve-dependencies'
import MultiStream from 'multistream'
export type MultiStreams = Array<Readable | (() => Readable)>
-15
View File
@@ -1,15 +0,0 @@
{
"name": "nexe-fs",
"version": "1.0.1",
"description": "Virtual File System used by nexe",
"main": "bundle.js",
"files": [
"*.d.ts",
"*.js"
],
"author": "Caleb Boyd",
"dependencies": {
"multistream": "^2.1.1"
},
"license": "MIT"
}
+1 -1
View File
@@ -327,7 +327,7 @@ function shimFs(binary: NexeBinary, fs: any = require('fs')) {
}
let returningArray: boolean
patches.internalModuleReadJSON = function (this: any, original: any, ...args: any[]) {
if (returningArray == null) returningArray = Array.isArray(original.call(this, ''))
if (!returningArray) returningArray = Array.isArray(original.call(this, ''))
const res = patches.internalModuleReadFile.call(this, original, ...args)
return returningArray && !Array.isArray(res)
? [res, /"(main|name|type|exports|imports)"/.test(res)]
+2 -1
View File
@@ -1,4 +1,5 @@
import { Func, color, esm } from './util'
import type { Func } from './util.js'
import { color, esm } from './util.js'
const frameLength = 120
+14 -12
View File
@@ -1,15 +1,16 @@
import { NexeCompiler } from './compiler'
import { normalizeOptions, NexeOptions, NexePatch } from './options'
import { NexeCompiler } from './compiler.js'
import type { NexeOptions, NexePatch } from './options.js'
import { normalizeOptions } from './options.js'
import resource from './steps/resource'
import clean from './steps/clean'
import cli from './steps/cli'
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 { initEsm } from './util'
import resource from './steps/resource.js'
import clean from './steps/clean.js'
import cli from './steps/cli.js'
import bundle from './steps/bundle.js'
import download from './steps/download.js'
import shim from './steps/shim.js'
import artifacts from './steps/artifacts.js'
import patches from './patches/index.js'
import { initEsm } from './util.js'
async function compile(
compilerOptions?: Partial<NexeOptions>,
@@ -40,7 +41,8 @@ async function compile(
}
export { compile, NexeCompiler }
export { argv, version, NexeOptions, help } from './options'
export { argv, version, help } from './options.js'
export type { NexeOptions } from './options.js'
function exec<T>(mw: any[], ctx: T): Promise<void> | void {
let i = -1
+9 -7
View File
@@ -12,9 +12,11 @@ import parseArgv from 'minimist'
import caw from 'caw'
import { NexeCompiler, NexeError } from './compiler'
import { getTarget, NexeTarget } from './target'
import { isWindows, STDIN_FLAG, esm } from './util'
import type { NexeCompiler } from './compiler.js'
import { NexeError } from './compiler.js'
import type { NexeTarget } from './target.js'
import { getTarget } from './target.js'
import { isWindows, STDIN_FLAG, esm } from './util.js'
export const version = '{{replace:0}}'
@@ -197,18 +199,18 @@ export function resolveEntry(
const inputPath = padRelative(input)
result = resolveSync(cwd, inputPath)
}
if (isEntryFile(maybeEntry) && (result == null || !result.absPath)) {
if (isEntryFile(maybeEntry) && (!result || !result.absPath)) {
const inputPath = padRelative(maybeEntry)
result = resolveSync(cwd, inputPath)
}
if (!process.stdin.isTTY && (result == null || !result.absPath) && bundle === defaults.bundle) {
if (!process.stdin.isTTY && !result?.absPath && bundle === defaults.bundle) {
return STDIN_FLAG
}
if (result == null || !result.absPath) {
if (!result?.absPath) {
result = resolveSync(cwd, '.')
}
if (!result.absPath) {
throw new NexeError(`Entry file "${input || ''}" not found!`)
throw new NexeError(`Entry file "${input || maybeEntry}" not found!`)
}
return result.absPath
}
+2 -1
View File
@@ -1,4 +1,5 @@
import { NexeCompiler, NexeError } from '../compiler'
import type { NexeCompiler } from '../compiler.js'
import { NexeError } from '../compiler.js'
export default async function disableNodeCli(compiler: NexeCompiler, next: () => Promise<void>) {
if (compiler.options.enableNodeCli) {
+2 -1
View File
@@ -1,4 +1,5 @@
import { NexeCompiler, NexeError } from '../compiler'
import type { NexeCompiler } from '../compiler.js'
import { NexeError } from '../compiler.js'
export default async function flags(compiler: NexeCompiler, next: () => Promise<void>) {
const nodeflags = compiler.options.flags
+3 -3
View File
@@ -1,6 +1,6 @@
import bootNexe from './third-party-main'
import cli from './disable-node-cli'
import flags from './flags'
import bootNexe from './third-party-main.js'
import cli from './disable-node-cli.js'
import flags from './flags.js'
const patches = [bootNexe, cli, flags]
+3 -2
View File
@@ -1,6 +1,7 @@
import { parse } from 'meriyah'
import { NexeCompiler, NexeError } from '../compiler'
import { wrap, semverGt } from '../util'
import type { NexeCompiler } from '../compiler.js'
import { NexeError } from '../compiler.js'
import { wrap, semverGt } from '../util.js'
export default async function main(compiler: NexeCompiler, next: () => Promise<void>) {
let bootFile = 'lib/internal/bootstrap/pre_execution.js'
+1 -1
View File
@@ -1,4 +1,4 @@
import { platforms, architectures, NexeTarget, getTarget, targetsEqual } from './target'
import { platforms, architectures, NexeTarget, getTarget, targetsEqual } from './target.js'
export { NexeTarget }
const versionsToSkip = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13, 15, 17, 19, 21, 22]
+2 -2
View File
@@ -1,8 +1,8 @@
import { join, dirname } from 'node:path'
import { unlink, readdir, mkdir } from 'node:fs/promises'
import { readFile, writeFile, isDirectory } from '../util'
import { NexeCompiler } from '../compiler'
import { readFile, writeFile, isDirectory } from '../util.js'
import type { NexeCompiler } from '../compiler.js'
async function readDirAsync(dir: string): Promise<string[]> {
return await readdir(dir).then(async (paths) => {
+4 -3
View File
@@ -1,9 +1,10 @@
import { resolve, relative } from 'node:path'
import { Readable } from 'node:stream'
import type { Readable } from 'node:stream'
import resolveFiles, { resolveSync } from 'resolve-dependencies'
import { NexeCompiler, NexeError } from '../compiler'
import { dequote, STDIN_FLAG } from '../util'
import type { NexeCompiler } from '../compiler.js'
import { NexeError } from '../compiler.js'
import { dequote, STDIN_FLAG } from '../util.js'
async function getStdIn(stdin: Readable): Promise<string> {
let out = ''
+2 -2
View File
@@ -1,7 +1,7 @@
import { rm } from 'node:fs/promises'
import { NexeCompiler } from '../compiler'
import { NexeTarget } from '../target'
import type { NexeCompiler } from '../compiler.js'
import type { NexeTarget } from '../target.js'
export default async function clean(compiler: NexeCompiler, next: () => Promise<any>) {
const { options } = compiler
+3 -3
View File
@@ -1,8 +1,8 @@
import { dirname, normalize, relative, resolve } from 'node:path'
import { createWriteStream, chmodSync, statSync, mkdirSync } from 'node:fs'
import { NexeCompiler } from '../compiler'
import { NexeTarget } from '../target'
import { STDIN_FLAG } from '../util'
import type { NexeCompiler } from '../compiler.js'
import type { NexeTarget } from '../target.js'
import { STDIN_FLAG } from '../util.js'
/**
* The "cli" step detects the appropriate input. If no input options are passed,
+4 -3
View File
@@ -2,9 +2,10 @@ import { dirname } from 'node:path'
import download from 'download'
import { pathExists } from '../util'
import { LogStep } from '../logger'
import { NexeCompiler, NexeError } from '../compiler'
import { pathExists } from '../util.js'
import type { LogStep } from '../logger.js'
import type { NexeCompiler } from '../compiler.js'
import { NexeError } from '../compiler.js'
import type { IncomingMessage } from 'node:http'
+2 -2
View File
@@ -2,8 +2,8 @@ import { relative } from 'node:path'
import fg from 'fast-glob'
import { each } from '../util'
import { NexeCompiler } from '../compiler'
import { each } from '../util.js'
import type { NexeCompiler } from '../compiler.js'
export default async function resource(compiler: NexeCompiler, next: () => Promise<any>) {
const { cwd, resources } = compiler.options
+2 -2
View File
@@ -1,5 +1,5 @@
import { NexeCompiler } from '../compiler'
import { wrap } from '../util'
import type { NexeCompiler } from '../compiler.js'
import { wrap } from '../util.js'
export default async function (compiler: NexeCompiler, next: () => Promise<void>) {
await next()
+1 -1
View File
@@ -10,7 +10,7 @@ declare module 'got' {
declare module 'caw'
declare module 'download' {
import { Duplex } from 'stream'
import type { Duplex } from 'stream'
interface DownloadOptions {
extract?: boolean
strip?: number
-1
View File
@@ -1 +0,0 @@
export declare function build(target?: string | null): Promise<void>
-1
View File
@@ -1 +0,0 @@
export {}
+15
View File
@@ -0,0 +1,15 @@
import * as nexeEsm from '../lib/esm/nexe.js'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import { ok } from 'node:assert'
const cjs = createRequire(fileURLToPath(import.meta.url)),
nexeCjs = cjs('../lib/cjs/nexe.js'),
exports = ['NexeCompiler', 'argv', 'compile', 'help', 'version']
for (const exp of exports) {
ok(exp in nexeCjs)
ok(exp in nexeEsm)
}
console.log('esm and cjs modules match')
+2 -1
View File
@@ -1,7 +1,8 @@
import { describe, it, expect } from 'vitest'
import { normalizeOptions } from '../src/options'
import * as path from 'path'
import { normalizeOptions } from '../src/options.js'
const ext = process.platform === 'win32' ? '.exe' : ''
describe('options', () => {
+4 -3
View File
@@ -1,8 +1,9 @@
import { describe, it, expect } from 'vitest'
import { padRight } from '../src/util'
import chalk from 'chalk'
import { getTarget } from '../src/target'
import { padRight } from '../src/util.js'
import { getTarget } from '../src/target.js'
const b = chalk.blue,
arch = process.arch === 'ia32' ? 'x86' : process.arch
-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 }]
}
}