Skip to content

Commit

Permalink
perf: deps revision
Browse files Browse the repository at this point in the history
BREAKING CHANGE: following the deps, require Node.js v14
  • Loading branch information
antongolub committed Aug 5, 2023
1 parent ea3e501 commit 5ec15c0
Show file tree
Hide file tree
Showing 16 changed files with 1,867 additions and 1,832 deletions.
21 changes: 0 additions & 21 deletions .eslintrc.cjs

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Expand Up @@ -44,8 +44,6 @@ jobs:
path: |
docs
target
flow-typed
typings
buildstamp.json
# Fast unit tests flow
Expand Down Expand Up @@ -94,7 +92,7 @@ jobs:
strategy:
matrix:
os: [ windows-2019, ubuntu-22.04 ]
node-version: [ 18, 16, 14, 12 ]
node-version: [ 18, 16, 14 ]

name: Test (Node v${{ matrix.node-version }}, OS ${{ matrix.os }})
runs-on: ${{ matrix.os }}
Expand Down
108 changes: 56 additions & 52 deletions package.json
Expand Up @@ -2,39 +2,48 @@
"name": "yarn-audit-fix",
"version": "9.3.12",
"private": false,
"publishConfig": {
"access": "public"
},
"type": "module",
"description": "The missing `yarn audit fix`",
"bin": {
"yarn-audit-fix": "./target/es6/cli.js"
"yarn-audit-fix": "./target/esm/cli.mjs"
},
"source": "./src/main/ts/index.ts",
"main": "./target/es6/index.js",
"types": "./typings/index.d.ts",
"typescript": {
"definition": "./typings/index.d.ts"
"main": "./target/esm/index.mjs",
"exports": {
".": {
"types": "./target/dts/index.d.ts",
"import": "./target/esm/index.mjs",
"default": "./target/esm/index.mjs"
},
"./cli": {
"types": "./target/dts/cli.d.ts",
"import": "./target/esm/cli.mjs",
"default": "./target/esm/cli.mjs"
},
"./package.json": "./package.json"
},
"module": "target/esm/index.mjs",
"types": "target/dts/index.d.ts",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >= 16.0.0"
"node": "^14.13.1 || >= 16.0.0"
},
"scripts": {
"clean": "rimraf target typings flow-typed buildcache docs coverage",
"lint": "eslint 'src/**/*.+(js|ts)'",
"clean": "rimraf target buildcache docs coverage",
"lint:fix": "yarn lint --fix",
"format": "prettier --write \"src/**/*.ts\"",
"test": "concurrently 'npm:test:*'",
"test:unit": "NODE_OPTIONS=\"--experimental-vm-modules\" jest --config=jest.config.json --runInBand",
"test:integration": "node ./target/es6/cli.js --package-lock-only --audit-level=moderate --ignore-engines",
"test:integration-build": "yarn build:es5 && yarn test:integration",
"test:depcheck": "npm_config_yes=true npx depcheck@^0 --ignore-patterns='src/test/fixtures' --ignores='node:*,tslib,@types/*,tsc-esm-fix,eslint-config-*,typedoc,@jest/globals'",
"test": "npm-run-all -p -l lint test:unit test:integration test:depcheck",
"build": "yarn clean && npm-run-all -p -l build:esnext build:es6 build:ts build:libdef build:buildstamp docs && yarn build:esmfix",
"build:esnext": "mkdirp target/esnext && tsc -p tsconfig.esnext.json",
"build:es6": "mkdirp target/es6 && tsc -p tsconfig.es6.json",
"build:ts": "cpy src/main/ts/ target/ts/",
"build:buildstamp": "npm_config_yes=true npx buildstamp --git --out.path=buildstamp.json",
"build:libdef": "libdefkit --tsconfig=tsconfig.esnext.json --tsconfig=tsconfig.es6.json --entry=yarn-audit-fix/target/es6",
"build:esmfix": "yarn tsc-esm-fix --target=target/es6 --target=target/esnext --dirnameVar=false",
"docs": "typedoc",
"uglify": "for f in $(find target -name '*.js'); do short=${f%.js}; terser -c -m -o $short.js -- $f; done",
"test:integration": "node ./target/esm/cli.mjs --package-lock-only --audit-level=moderate --ignore-engines",
"test:depcheck": "npm_config_yes=true npx depcheck --ignore-patterns='src/test/fixtures' --ignores='node:*,@types/*,esbuild*,eslint-config-*,minimist,mkdirp,ts-node,typedoc,@jest/globals'",
"test:lint": "eslint -c src/test/lint/.eslintrc.json src",
"build": "concurrently 'npm:build:*'",
"build:buildstamp": "npm_config_yes=true npx buildstamp",
"build:ts": "cpy --cwd=src/main/ts . ../../../../../../target/ts/",
"build:esm": "node ./src/scripts/build.cjs --entry='./src/main/ts/index.ts:./src/main/ts/cli.ts'",
"build:dts": "tsc --emitDeclarationOnly --skipLibCheck --outDir target/dts",
"build:docs": "typedoc --options src/main/typedoc",
"postupdate": "yarn && yarn build && yarn test",
"publish:beta": "npm publish --no-git-tag-version --tag beta",
"publish:rc": "npm publish --no-git-tag-version --tag rc",
Expand All @@ -51,61 +60,56 @@
"files": [
"README.md",
"CHANGELOG.md",
"target",
"typings",
"flow-typed",
"target/esm",
"target/ts",
"target/dts",
"buildstamp.json"
],
"author": "Anton Golub <golub.anton@gmail.com>",
"license": "MIT",
"workspaces0": [
"packages/*"
],
"resolutions": {
"**/strip-ansi/ansi-regex": "^5.0.1",
"**/globby/fast-glob": "^3.2.7",
"**/json-schema": "^0.4.0"
},
"dependencies": {
"@types/find-cache-dir": "^3.2.1",
"@types/fs-extra": "^11.0.1",
"@types/lodash-es": "^4.17.7",
"@types/lodash-es": "^4.17.8",
"@types/semver": "^7.5.0",
"@types/yarnpkg__lockfile": "^1.1.6",
"@yarnpkg/lockfile": "^1.1.0",
"chalk": "^5.2.0",
"chalk": "^5.3.0",
"commander": "^10.0.1",
"find-cache-dir": "^4.0.0",
"find-up": "^6.3.0",
"fs-extra": "^11.1.1",
"globby": "^13.1.4",
"fast-glob": "^3.3.1",
"js-yaml": "^4.1.0",
"lodash-es": "^4.17.21",
"pkg-dir": "^7.0.0",
"semver": "^7.5.2",
"synp": "^1.9.10",
"tslib": "^2.5.3"
"semver": "^7.5.4",
"synp": "^1.9.10"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@qiwi/libdefkit": "^5.0.0",
"@qiwi/npm-run-all": "^4.1.7",
"@types/jest": "^29.5.2",
"@jest/globals": "^29.6.2",
"@types/jest": "^29.5.3",
"@types/js-yaml": "^4.0.5",
"@types/node": "^20.3.1",
"cpy-cli": "^4.2.0",
"eslint": "^8.42.0",
"eslint-config-prettier": "^8.8.0",
"@types/node": "^20.4.8",
"concurrently": "^8.2.0",
"cpy-cli": "^5.0.0",
"esbuild": "^0.18.17",
"esbuild-node-externals": "^1.8.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-config-qiwi": "^2.1.3",
"jest": "^29.5.0",
"mkdirp": "^1.0.4",
"npm": "^8.19.2",
"prettier": "^2.8.8",
"terser": "^5.18.0",
"ts-jest": "^29.1.0",
"tsc-esm-fix": "^2.20.14",
"jest": "^29.6.2",
"minimist": "^1.2.8",
"mkdirp": "^3.0.1",
"npm": "^9.8.1",
"prettier": "^3.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typedoc": "^0.24.8",
"typescript": "5.1.3"
"typescript": "5.1.6"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/main/ts/runner.ts
Expand Up @@ -59,7 +59,7 @@ export const runSync = (_flags: TFlags = {}, _flow?: TFlow): void => {
} catch (err: any) {
ctx.err = err

!flags.silent && console.error((err.stderr?.toString() || err.stdout?.toString() || err.error || err.status || err))
!flags.silent && console.error((err.stderr?.toString?.() || err.stdout?.toString?.() || err.error || err.status || err))
exec(flow.fallback, ctx)

throw err
Expand Down
5 changes: 3 additions & 2 deletions src/main/ts/util.ts
Expand Up @@ -8,13 +8,14 @@ import chalk from 'chalk'
import findCacheDir from 'find-cache-dir'
import { findUpSync, pathExistsSync } from 'find-up'
import fse, { SymlinkType } from 'fs-extra'
import { globbySync as glob, Options as GlobbyOptions } from 'globby'
import fg, { Options as GlobOptions } from 'fast-glob'
import yaml from 'js-yaml'
import { reduce } from 'lodash-es'
import { packageDirectorySync } from 'pkg-dir'

import { TFlags, TFlagsMapping } from './ifaces'

const glob = fg.sync
// FIXME Jest workaround: cannot properly mock `child_process` with import API
const cp = createRequire(import.meta.url)('child_process')
const { ensureDirSync, readFileSync } = fse
Expand Down Expand Up @@ -167,7 +168,7 @@ export const getWorkspaces = (
onlyFiles: true,
absolute: true,
gitignore: true,
} as GlobbyOptions,
} as GlobOptions,
)
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/typedoc/typedoc.json
@@ -0,0 +1,15 @@
{
"name": "yarn-audit-fix",
"out": "../../../target/docs",
"entryPoints": ["../../../src/main/ts/"],
"exclude": ["../../../src/test", "**/node_modules/**"],
"externalPattern": ["**/node_modules/**"],
"excludeExternals": true,
"excludePrivate": true,
"excludeProtected": true,
"includeVersion": true,
"hideGenerator": true,
"readme": "../../../README.md",
"tsconfig": "../../../tsconfig.json",
"theme": "default"
}
48 changes: 48 additions & 0 deletions src/scripts/build.cjs
@@ -0,0 +1,48 @@
#!/usr/bin/env node

const esbuild = require('esbuild')
const { nodeExternalsPlugin } = require('esbuild-node-externals')
const glob = require('fast-glob')
const minimist = require('minimist')

const {entry, external} = minimist(process.argv.slice(2), {
default: {
entry: './src/main/ts/index.ts'
}
})

const esmConfig = {
entryPoints: entry.split(':').map(e => e.includes('*') ? glob.sync(e, {absolute: false, onlyFiles: true}) : e).flat(1),
outdir: './target/esm',
bundle: true,
minify: true,
sourcemap: true,
sourcesContent: false,
platform: 'node',
target: 'ES2020',
format: 'esm',
outExtension: {
'.js': '.mjs'
},
external: ['node:*'], // https://github.com/evanw/esbuild/issues/1466
plugins: [nodeExternalsPlugin()], // https://github.com/evanw/esbuild/issues/619
tsconfig: './tsconfig.json'
}

const cjsConfig = {
...esmConfig,
outdir: './target/cjs',
target: 'es6',
format: 'cjs',
outExtension: {
'.js': '.cjs'
}
}

const config = process.argv.includes('--cjs')
? cjsConfig
: esmConfig

esbuild
.build(config)
.catch(() => process.exit(1))
8 changes: 8 additions & 0 deletions src/scripts/test.mjs
@@ -0,0 +1,8 @@
#!/usr/bin/env node

import glob from 'fast-glob'
import { pathToFileURL } from 'node:url'

const suites = await glob('src/test/**/*.test.{ts,cjs,mjs}', {cwd: process.cwd(), absolute: true, onlyFiles: true})

await Promise.all(suites.map(suite => import(pathToFileURL(suite))))
19 changes: 19 additions & 0 deletions src/test/lint/.eslintrc.json
@@ -0,0 +1,19 @@
{
"extends": ["eslint-config-qiwi"],
"rules": {},
"overrides": [
{
"files": ["src/test/ts/runner.ts", "src/main/ts/stages.ts"],
"rules": {
"sonarjs/no-duplicate-string": "off",
"@typescript-eslint/ban-ts-comment": "off"
}
},
{
"files": ["src/**/*.ts"],
"rules": {
"camelcase": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion src/test/ts/lockfile-v1.ts
@@ -1,4 +1,4 @@
import fs from 'node:fs'
import * as fs from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

Expand Down
2 changes: 1 addition & 1 deletion src/test/ts/lockfile-v2.ts
@@ -1,4 +1,4 @@
import fs from 'node:fs'
import * as fs from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

Expand Down
2 changes: 1 addition & 1 deletion src/test/ts/lockfile.ts
@@ -1,4 +1,4 @@
import fs from 'node:fs'
import * as fs from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'

Expand Down
8 changes: 0 additions & 8 deletions tsconfig.es6.json

This file was deleted.

9 changes: 0 additions & 9 deletions tsconfig.esnext.json

This file was deleted.

0 comments on commit 5ec15c0

Please sign in to comment.