Skip to content

Commit

Permalink
feat: add support for Node.js v20 (#541)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: decommission Node.js versions >=10 <16
  • Loading branch information
derevnjuk authored Apr 18, 2024
1 parent ead85f0 commit 653f9bf
Show file tree
Hide file tree
Showing 59 changed files with 178 additions and 207 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/auto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true

jobs:
Expand All @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [ 'lint', 'format', 'test:unit' ]
target: [ 'lint', 'format', 'test:unit', 'build' ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/composite/npm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
version:
description: 'Node.JS version'
required: false
default: "18.18.0"
default: "20"
cache:
description: 'Cache'
required: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ jobs:
include:
- os: windows-2019
target: win
node: 18
node: 20
- os: macos-11
target: macos
node: 18
node: 20
# Using the `centos7-devtoolset7` runner instead of latest (i.e. `ubuntu-20.04`)
# with gcc 7 but glibc 2.17, so binaries are compatible for Ubuntu 14.04 and Debian 8.
- os: ubuntu-20.04
target: linux
node: 14
node: 16
container:
image: centos/devtoolset-7-toolchain-centos7:7
options: "--user root"
Expand Down
39 changes: 19 additions & 20 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,30 @@ jobs:
- os: ubuntu-latest
container: ubuntu:16.04
executable: bright-cli-linux-x64
node: 14
node: 16
- os: ubuntu-latest
container: fedora:24
executable: bright-cli-linux-x64
node: 14
node: 16
- os: ubuntu-latest
container: fedora:latest
executable: bright-cli-linux-x64
node: 18
node: 20
- os: ubuntu-latest
executable: bright-cli-linux-x64
node: 18
node: 20
- os: macos-11
executable: bright-cli-macos-x64
node: 20
- os: macos-latest
executable: bright-cli-macos-x64
node: 18
node: 20
- os: windows-latest
executable: bright-cli-win-x64.exe
node: 18
node: 20
- os: windows-2019
executable: bright-cli-win-x64.exe
node: 20
steps:
- name: Install Packages (Fedora)
if: ${{ startsWith(matrix.container, 'fedora') }}
Expand Down Expand Up @@ -215,28 +221,21 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
node: [14, 16, 18]
os: [macos-latest, windows-latest, ubuntu-latest]
node: [16, 18, 20]
include:
- os: ubuntu-latest
node: 14
- os: ubuntu-latest
container: ubuntu:16.04
node: 16
- os: ubuntu-latest
node: 18
- os: ubuntu-latest
container: ubuntu:16.04
node: 14
container: fedora:24
node: 16
- os: ubuntu-latest
container: fedora:latest
node: 18
- os: ubuntu-latest
container: fedora:24
node: 14
exclude:
# TODO: Troubleshoot
- os: windows-latest
node: 14
container: fedora:latest
node: 20
steps:
- name: Install Packages (Fedora)
if: ${{ startsWith(matrix.container, 'fedora') }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18-alpine as base
FROM node:20-alpine as base

ARG VERSION

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]
},
"engines": {
"node": ">=10 <=18"
"node": ">=16 <=20"
},
"dependencies": {
"@neuralegion/os-service": "1.2.2",
Expand Down Expand Up @@ -66,7 +66,7 @@
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.2",
"@types/ms": "^0.7.31",
"@types/node": "^10.17.59",
"@types/node": "^16.18.96",
"@types/semver": "^7.5.8",
"@types/ws": "^7.4.7",
"@types/yargs": "~16.0.1",
Expand Down Expand Up @@ -129,15 +129,15 @@
"assets": [
"./node_modules/axios/**",
"./node_modules/win-ca/lib/crypt32-*.node",
"./node_modules/@neuralegion/os-service/prebuilds/win32-*/node.abi108.node",
"./node_modules/@neuralegion/raw-socket/prebuilds/win32-*/node.abi108.node",
"./node_modules/@neuralegion/raw-socket/prebuilds/linux-x64/node.abi83.glibc.node",
"./node_modules/@neuralegion/raw-socket/prebuilds/darwin-x64+arm64/node.abi108.node"
"./node_modules/@neuralegion/os-service/prebuilds/win32-*/node.abi115.node",
"./node_modules/@neuralegion/raw-socket/prebuilds/win32-*/node.abi115.node",
"./node_modules/@neuralegion/raw-socket/prebuilds/linux-x64/node.abi93.glibc.node",
"./node_modules/@neuralegion/raw-socket/prebuilds/darwin-x64+arm64/node.abi115.node"
],
"targets": [
"node14-linux-x64",
"node18-macos-x64",
"node18-windows-x64"
"node16-linux-x64",
"node20-macos-x64",
"node20-windows-x64"
],
"outputPath": "bin",
"compress": "Brotli"
Expand Down
9 changes: 2 additions & 7 deletions src/Archive/Parsers/BaseParser.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import { Validator } from '../Validators';
import { File, Parser } from './Parser';
import { promisify } from 'util';
import { access as exists, constants, readFile as read, stat } from 'fs';
import { access, constants, readFile, stat } from 'node:fs/promises';
import { ok } from 'assert';
import { basename, extname } from 'path';

const readFile = promisify(read);
const access = promisify(exists);
const statAsync = promisify(stat);

export class BaseParser<T> implements Parser {
private readonly FILE_SIZE_LIMIT = 500 * 1024 ** 2;

Expand All @@ -17,7 +12,7 @@ export class BaseParser<T> implements Parser {
public async parse(path: string): Promise<File> {
await this.access(path);

const fileStat = await statAsync(path);
const fileStat = await stat(path);

if (fileStat.size > this.FILE_SIZE_LIMIT) {
throw new Error('There is not enough storage space to save this file');
Expand Down
6 changes: 3 additions & 3 deletions src/Archive/RestArchives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ProxyFactory } from '../Utils';
import { inject, injectable } from 'tsyringe';
import axios, { Axios } from 'axios';
import FormData from 'form-data';
import { ok } from 'assert';
import https from 'https';
import http from 'http';
import { ok } from 'node:assert';
import https from 'node:https';
import http from 'node:http';

export interface RestArchivesOptions {
insecure?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/Archive/Validators/HarValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Entry, Har } from 'har-format';
import Ajv, { ValidateFunction } from 'ajv';
import betterAjvErrors from 'better-ajv-errors';
import { injectable } from 'tsyringe';
import { parse, Url } from 'url';

@injectable()
export class HarValidator implements Validator<Har> {
Expand Down Expand Up @@ -53,7 +52,7 @@ export class HarValidator implements Validator<Har> {
}

private parseEntry(entry: Entry): string | undefined {
const { host, protocol }: Url = parse(entry.request.url);
const { host, protocol } = new URL(entry.request.url);

if (!host || !protocol) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Archive/Validators/OasValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import betterAjvErrors from 'better-ajv-errors';
import ajvFormats from 'ajv/lib/compile/formats';
import draft4 from 'ajv/lib/refs/json-schema-draft-04.json';
import { injectable } from 'tsyringe';
import { ok } from 'assert';
import { ok } from 'node:assert';

@injectable()
export class OasValidator implements Validator<any> {
Expand Down
4 changes: 2 additions & 2 deletions src/Archive/Validators/PostmanValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import betterAjvErrors from 'better-ajv-errors';
import schemaDraft04 from 'ajv/lib/refs/json-schema-draft-04.json';
import schemaDraft07 from 'ajv/lib/refs/json-schema-draft-07.json';
import { injectable } from 'tsyringe';
import { ok } from 'assert';
import { parse } from 'path';
import { ok } from 'node:assert';
import { parse } from 'node:path';

@injectable()
export class PostmanValidator implements Validator<any> {
Expand Down
21 changes: 9 additions & 12 deletions src/Bus/Brokers/RabbitMQBus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { Backoff, logger, ProxyFactory } from '../../Utils';
import { Message } from '../Message';
import { ConfirmChannel, connect, Connection, ConsumeMessage } from 'amqplib';
import { DependencyContainer, inject, injectable } from 'tsyringe';
import { ok } from 'assert';
import { format, parse, UrlWithParsedQuery } from 'url';
import { EventEmitter, once } from 'events';
import { randomBytes } from 'crypto';
import { ok } from 'node:assert';
import { EventEmitter, once } from 'node:events';
import { randomBytes } from 'node:crypto';
import ErrnoException = NodeJS.ErrnoException;

export interface RabbitMQBusOptions {
Expand Down Expand Up @@ -326,21 +325,19 @@ export class RabbitMQBus implements Bus {
}

private prepareUrl(): string {
const url: UrlWithParsedQuery = parse(this.options.url, true);
const url = new URL(this.options.url);

if (this.options.credentials) {
const { username, password } = this.options.credentials;

url.auth = `${username}:${password}`;
url.username = username;
url.password = password;
}

url.query = {
...url.query,
frameMax: '0',
heartbeat: `${this.DEFAULT_HEARTBEAT_INTERVAL}`
};
url.searchParams.append('frameMax', '0');
url.searchParams.append('heartbeat', `${this.DEFAULT_HEARTBEAT_INTERVAL}`);

return format(url);
return url.toString();
}

private getEventName(event: Event): string {
Expand Down
1 change: 0 additions & 1 deletion src/Commands/Configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { logger } from '../Utils';
import { ConnectivityUrls, Platform, TestType, Options } from '../Wizard';
import { container } from '../Config';
import { Arguments, Argv, CommandModule } from 'yargs';
import { URL } from 'url';

export class Configure implements CommandModule {
public readonly command = 'configure [options]';
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/RunRepeater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { Arguments, Argv, CommandModule } from 'yargs';
import { Lifecycle } from 'tsyringe';
import { captureException } from '@sentry/node';
import { normalize } from 'path';
import { normalize } from 'node:path';

export class RunRepeater implements CommandModule {
public readonly command = 'repeater [options]';
Expand Down
1 change: 0 additions & 1 deletion src/Commands/RunScan.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ describe('RunScan', () => {

// assert
expect(act).toThrowError(SyntaxError);
expect(act).toThrowError(`Unexpected token ' in JSON at position 2`);
});
});
});
4 changes: 2 additions & 2 deletions src/Config/CliInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { sync } from 'find-up';
import path from 'path';
import { readFileSync } from 'fs';
import path from 'node:path';
import { readFileSync } from 'node:fs';

export class CliInfo {
public readonly cwd: string;
Expand Down
6 changes: 3 additions & 3 deletions src/Config/DefaultConfigReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { CliConfig, ConfigReader } from './ConfigReader';
import { Helpers } from '../Utils';
import { sync } from 'find-up';
import { load } from 'js-yaml';
import { extname } from 'path';
import { readFileSync } from 'fs';
import { Context, createContext, Script } from 'vm';
import { extname } from 'node:path';
import { readFileSync } from 'node:fs';
import { Context, createContext, Script } from 'node:vm';

export class DefaultConfigReader implements ConfigReader {
private readonly rcOptions: string[] = [
Expand Down
Loading

0 comments on commit 653f9bf

Please sign in to comment.