From f98e8a1f8de7ccb008577a9a1a8a373ca30cbe09 Mon Sep 17 00:00:00 2001 From: Avi Vahl Date: Fri, 7 Jul 2023 04:35:11 +0300 Subject: [PATCH] ci: add Node 20 to test matrix (#484) and strip colors from Node output during test --- .github/workflows/tests.yml | 2 +- package-lock.json | 103 +++++++----------- package.json | 1 + packages/esm/src/test/esm-loader.test.ts | 7 +- ...ension.test.ts => node-extension.test.mts} | 9 +- 5 files changed, 49 insertions(+), 73 deletions(-) rename packages/node/src/test/{node-extension.test.ts => node-extension.test.mts} (92%) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4cd5851f..46a6fb05 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [18, 16] + node-version: [20, 18, 16] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - uses: actions/checkout@v3 diff --git a/package-lock.json b/package-lock.json index 9b432e14..e63a451d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rimraf": "^5.0.1", + "strip-ansi": "^7.1.0", "typescript": "~5.1.6", "webpack": "^5.88.1" }, @@ -147,33 +148,6 @@ "node": ">=12" } }, - "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", - "dev": true, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/@isaacs/cliui/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -1199,6 +1173,18 @@ "node": ">=4.0" } }, + "node_modules/eslint/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/espree": { "version": "9.6.0", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.0.tgz", @@ -2472,19 +2458,19 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "node_modules/string-width/node_modules/ansi-regex": { + "node_modules/string-width-cjs/node_modules/strip-ansi": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, - "engines": { - "node": ">=12" + "dependencies": { + "ansi-regex": "^5.0.1" }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" + "engines": { + "node": ">=8" } }, - "node_modules/string-width/node_modules/strip-ansi": { + "node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", @@ -2499,7 +2485,8 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "node_modules/strip-ansi": { + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", @@ -2511,17 +2498,16 @@ "node": ">=8" } }, - "node_modules/strip-ansi-cjs": { - "name": "strip-ansi", + "node_modules/strip-ansi/node_modules/ansi-regex": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, "engines": { - "node": ">=8" + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, "node_modules/strip-json-comments": { @@ -2873,16 +2859,16 @@ "node": ">=8" } }, - "node_modules/wrap-ansi/node_modules/ansi-regex": { + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, - "engines": { - "node": ">=12" + "dependencies": { + "ansi-regex": "^5.0.1" }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" + "engines": { + "node": ">=8" } }, "node_modules/wrap-ansi/node_modules/ansi-styles": { @@ -2897,21 +2883,6 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/wrap-ansi/node_modules/strip-ansi": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", - "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", - "dev": true, - "dependencies": { - "ansi-regex": "^6.0.1" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/strip-ansi?sponsor=1" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index acca9706..b8701ca1 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "rimraf": "^5.0.1", + "strip-ansi": "^7.1.0", "typescript": "~5.1.6", "webpack": "^5.88.1" }, diff --git a/packages/esm/src/test/esm-loader.test.ts b/packages/esm/src/test/esm-loader.test.ts index ae342347..bf005ee0 100644 --- a/packages/esm/src/test/esm-loader.test.ts +++ b/packages/esm/src/test/esm-loader.test.ts @@ -1,9 +1,10 @@ import { describe, it } from 'node:test'; import { equal, notEqual, ok } from 'node:assert/strict'; -import { dirname, join, sep } from 'node:path'; -import { platform } from 'node:os'; import { spawnSync } from 'node:child_process'; import { createRequire } from 'node:module'; +import { platform } from 'node:os'; +import { dirname, join, sep } from 'node:path'; +import stripAnsi from 'strip-ansi'; const require = createRequire(import.meta.url); const fixturesRoot = dirname(require.resolve('@ts-tools/fixtures/package.json')); @@ -11,7 +12,7 @@ const fixturesRoot = dirname(require.resolve('@ts-tools/fixtures/package.json')) export function runCommand(command: string): { output: string; exitCode: number } { const [execName, ...args] = command.split(' '); const { output, status: exitCode } = spawnSync(execName!, args); - return { output: output.join('\n'), exitCode: exitCode || 0 }; + return { output: stripAnsi(output.join('\n')), exitCode: exitCode || 0 }; } describe('using node --loader @ts-tools/esm ', { timeout: 5_000 }, () => { diff --git a/packages/node/src/test/node-extension.test.ts b/packages/node/src/test/node-extension.test.mts similarity index 92% rename from packages/node/src/test/node-extension.test.ts rename to packages/node/src/test/node-extension.test.mts index 2b121868..77527fa2 100644 --- a/packages/node/src/test/node-extension.test.ts +++ b/packages/node/src/test/node-extension.test.mts @@ -1,15 +1,18 @@ import { describe, it } from 'node:test'; import { equal, notEqual, ok } from 'node:assert/strict'; -import { join, sep, dirname } from 'node:path'; -import { platform } from 'node:os'; import { spawnSync } from 'node:child_process'; +import { createRequire } from 'node:module'; +import { platform } from 'node:os'; +import { dirname, join, sep } from 'node:path'; +import stripAnsi from 'strip-ansi'; +const require = createRequire(import.meta.url); const fixturesRoot = dirname(require.resolve('@ts-tools/fixtures/package.json')); export function runCommand(command: string): { output: string; exitCode: number } { const [execName, ...args] = command.split(' '); const { output, status: exitCode } = spawnSync(execName!, args); - return { output: output.join('\n'), exitCode: exitCode || 0 }; + return { output: stripAnsi(output.join('\n')), exitCode: exitCode || 0 }; } describe('using node -r @ts-tools/node/r ', { timeout: 5_000 }, () => {