From 81e3aa4b32d066558209c31693c8dcfdec5efc73 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 22 Aug 2024 11:51:36 -0700 Subject: [PATCH 1/7] Support node --run --- src/analyzer.ts | 23 ++++++++++++----------- src/cli-options.ts | 22 ++++++++++++++-------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/analyzer.ts b/src/analyzer.ts index f44fbe82e..790ef0f66 100644 --- a/src/analyzer.ts +++ b/src/analyzer.ts @@ -5,31 +5,31 @@ */ import * as pathlib from 'path'; +import {Dependency, scriptReferenceToString, ServiceConfig} from './config.js'; +import {findNodeAtLocation, JsonFile} from './util/ast.js'; import * as fs from './util/fs.js'; import { CachingPackageJsonReader, FileSystem, } from './util/package-json-reader.js'; -import {Dependency, scriptReferenceToString, ServiceConfig} from './config.js'; -import {findNodeAtLocation, JsonFile} from './util/ast.js'; import {IS_WINDOWS} from './util/windows.js'; +import type {Agent} from './cli-options.js'; +import type { + ScriptConfig, + ScriptReference, + ScriptReferenceString, +} from './config.js'; +import type {Diagnostic, MessageLocation, Result} from './error.js'; +import type {Cycle, DependencyOnMissingPackageJson, Failure} from './event.js'; +import {Logger} from './logging/logger.js'; import type { ArrayNode, JsonAstNode, NamedAstNode, ValueTypes, } from './util/ast.js'; -import type {Diagnostic, MessageLocation, Result} from './error.js'; -import type {Cycle, DependencyOnMissingPackageJson, Failure} from './event.js'; import type {PackageJson, ScriptSyntaxInfo} from './util/package-json.js'; -import type { - ScriptConfig, - ScriptReference, - ScriptReferenceString, -} from './config.js'; -import type {Agent} from './cli-options.js'; -import {Logger} from './logging/logger.js'; export interface AnalyzeResult { config: Result; @@ -118,6 +118,7 @@ const DEFAULT_EXCLUDE_PATHS = [ const DEFAULT_LOCKFILES: Record = { npm: ['package-lock.json'], + nodeRun: ['package-lock.json'], yarnClassic: ['yarn.lock'], yarnBerry: ['yarn.lock'], pnpm: ['pnpm-lock.yaml'], diff --git a/src/cli-options.ts b/src/cli-options.ts index 9aa0bc178..bca889526 100644 --- a/src/cli-options.ts +++ b/src/cli-options.ts @@ -5,16 +5,16 @@ */ import * as os from 'os'; -import * as fs from './util/fs.js'; import * as pathlib from 'path'; -import {Result} from './error.js'; -import {MetricsLogger} from './logging/metrics-logger.js'; import {ScriptReference} from './config.js'; +import {Result} from './error.js'; import {FailureMode} from './executor.js'; -import {unreachable} from './util/unreachable.js'; +import {DefaultLogger} from './logging/default-logger.js'; import {Console, Logger} from './logging/logger.js'; +import {MetricsLogger} from './logging/metrics-logger.js'; import {QuietCiLogger, QuietLogger} from './logging/quiet-logger.js'; -import {DefaultLogger} from './logging/default-logger.js'; +import * as fs from './util/fs.js'; +import {unreachable} from './util/unreachable.js'; export const packageDir = await (async (): Promise => { // Recent versions of npm set this environment variable that tells us the @@ -45,7 +45,7 @@ export const packageDir = await (async (): Promise => { } })(); -export type Agent = 'npm' | 'pnpm' | 'yarnClassic' | 'yarnBerry'; +export type Agent = 'npm' | 'nodeRun' | 'pnpm' | 'yarnClassic' | 'yarnBerry'; export interface Options { script: ScriptReference; @@ -61,7 +61,8 @@ export interface Options { export const getOptions = async (): Promise> => { // This environment variable is set by npm, yarn, and pnpm, and tells us which // script is running. - const scriptName = process.env.npm_lifecycle_event; + const scriptName = + process.env.npm_lifecycle_event ?? process.env['NODE_RUN_SCRIPT_NAME']; // We need to handle "npx wireit" as a special case, because it sets // "npm_lifecycle_event" to "npx". The "npm_execpath" will be "npx-cli.js", // though, so we use that combination to detect this special case. @@ -279,6 +280,9 @@ function getArgvOptions( extraArgs: process.argv.slice(2), }; } + case 'nodeRun': { + return parseRemainingArgs(process.argv.slice(2)); + } case 'yarnClassic': { // yarn 1.22.18 // - If there is no "--", all arguments go to argv. @@ -313,6 +317,9 @@ function getArgvOptions( * Try to find the npm user agent being used. If we can't detect it, assume npm. */ function getNpmUserAgent(): Agent { + if (process.env['NODE_RUN_SCRIPT_NAME'] !== undefined) { + return 'nodeRun'; + } const userAgent = process.env['npm_config_user_agent']; if (userAgent !== undefined) { const match = userAgent.match(/^(npm|yarn|pnpm)\//); @@ -320,7 +327,6 @@ function getNpmUserAgent(): Agent { if (match[1] === 'yarn') { return /^yarn\/[01]\./.test(userAgent) ? 'yarnClassic' : 'yarnBerry'; } - return match[1] as 'npm' | 'pnpm'; } } From e537bbc3157dafd7311cfa3f77e49cd9bb7b9b49 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 22 Aug 2024 12:31:52 -0700 Subject: [PATCH 2/7] Refactor tests a bit --- src/test/cli-options.test.ts | 320 +++++++++++++++++++---------------- 1 file changed, 176 insertions(+), 144 deletions(-) diff --git a/src/test/cli-options.test.ts b/src/test/cli-options.test.ts index d271b501a..efd32b6c7 100644 --- a/src/test/cli-options.test.ts +++ b/src/test/cli-options.test.ts @@ -5,12 +5,14 @@ */ import * as pathlib from 'path'; -import * as assert from 'uvu/assert'; import {suite} from 'uvu'; +import * as assert from 'uvu/assert'; +import {Options, type Agent} from '../cli-options.js'; +import {Result} from '../error.js'; import {rigTest} from './util/rig-test.js'; import {WireitTestRig} from './util/test-rig.js'; -import {Options} from '../cli-options.js'; -import {Result} from '../error.js'; + +/* eslint-disable @typescript-eslint/unbound-method */ const test = suite(); @@ -35,6 +37,7 @@ async function getOptionsResult( main: TEST_BINARY_COMMAND, test: TEST_BINARY_COMMAND, start: TEST_BINARY_COMMAND, + other: TEST_BINARY_COMMAND, ...extraScripts, }, }, @@ -67,89 +70,59 @@ async function assertOptions( }); } -for (const command of ['npm', 'yarn', 'pnpm'] as const) { - const agent = command === 'yarn' ? 'yarnClassic' : command; - // eslint-disable-next-line @typescript-eslint/unbound-method - const skipIfYarn = command === 'yarn' ? test.skip : test; - // eslint-disable-next-line @typescript-eslint/unbound-method - const skipIfPnpm = command === 'pnpm' ? test.skip : test; +interface AgentCommands { + agent: Agent; + runCmd: string; + testCmd: string | undefined; + startCmd: string | undefined; +} - test( - `${command} run main`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} run main`, { - agent, - script: { - packageDir: rig.temp, - name: 'main', - }, - }); - }), - ); +const commands: AgentCommands[] = [ + { + agent: 'npm', + runCmd: 'npm run', + testCmd: 'npm test', + startCmd: 'npm start', + }, + { + agent: 'yarnClassic', + runCmd: 'yarn run', + testCmd: 'yarn test', + startCmd: 'yarn start', + }, + { + agent: 'pnpm', + runCmd: 'pnpm run', + testCmd: 'pnpm test', + startCmd: 'pnpm start', + }, +]; - test( - `${command} test`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} test`, { - agent, - script: { - packageDir: rig.temp, - name: 'test', - }, - }); - }), - ); - - test( - `${command} start`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} start`, { - agent, - script: { - packageDir: rig.temp, - name: 'start', - }, - }); - }), - ); +for (const {agent, runCmd, testCmd, startCmd} of commands) { + const isYarn = agent === 'yarnClassic'; + const isPnpm = agent === 'pnpm'; test( - `${command} run main -- --extra`, + `${agent} run`, rigTest(async ({rig}) => { - await assertOptions(rig, `${command} run main -- --extra`, { + await assertOptions(rig, `${runCmd} main`, { agent, script: { packageDir: rig.temp, name: 'main', }, - extraArgs: ['--extra'], - }); - }), - ); - - // Does not work in pnpm, see https://github.com/pnpm/pnpm/issues/4821. - skipIfPnpm( - `${command} test -- --extra`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} test -- --extra`, { - agent, - script: { - packageDir: rig.temp, - name: 'test', - }, - extraArgs: ['--extra'], }); }), ); test( - `${command} start -- --extra`, + `${agent} run --extra`, rigTest(async ({rig}) => { - await assertOptions(rig, `${command} start -- --extra`, { + await assertOptions(rig, `${runCmd} main -- --extra`, { agent, script: { packageDir: rig.temp, - name: 'start', + name: 'main', }, extraArgs: ['--extra'], }); @@ -157,9 +130,9 @@ for (const command of ['npm', 'yarn', 'pnpm'] as const) { ); test( - `${command} run main --watch`, + `${agent} run --watch`, rigTest(async ({rig}) => { - await assertOptions(rig, `${command} run main --watch`, { + await assertOptions(rig, `${runCmd} main --watch`, { agent, script: { packageDir: rig.temp, @@ -170,39 +143,10 @@ for (const command of ['npm', 'yarn', 'pnpm'] as const) { }), ); - // Does not work in pnpm, see https://github.com/pnpm/pnpm/issues/4821. - skipIfPnpm( - `${command} test --watch`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} test --watch`, { - agent, - script: { - packageDir: rig.temp, - name: 'test', - }, - watch: true, - }); - }), - ); - - test( - `${command} start --watch`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} start --watch`, { - agent, - script: { - packageDir: rig.temp, - name: 'start', - }, - watch: true, - }); - }), - ); - test( - `${command} run main --watch -- --extra`, + `${agent} run --watch --extra`, rigTest(async ({rig}) => { - await assertOptions(rig, `${command} run main --watch -- --extra`, { + await assertOptions(rig, `${runCmd} main --watch -- --extra`, { agent, script: { packageDir: rig.temp, @@ -214,66 +158,35 @@ for (const command of ['npm', 'yarn', 'pnpm'] as const) { }), ); - // Does not work in pnpm, see https://github.com/pnpm/pnpm/issues/4821. - skipIfPnpm( - `${command} test --watch -- --extra`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} test --watch -- --extra`, { - agent, - script: { - packageDir: rig.temp, - name: 'test', - }, - extraArgs: ['--extra'], - watch: true, - }); - }), - ); - - test( - `${command} start --watch -- --extra`, - rigTest(async ({rig}) => { - await assertOptions(rig, `${command} start --watch -- --extra`, { - agent, - script: { - packageDir: rig.temp, - name: 'start', - }, - extraArgs: ['--extra'], - watch: true, - }); - }), - ); - test( - `${command} run recurse -> ${command} run start --watch`, + `${agent} run recurse -> run other --watch`, rigTest(async ({rig}) => { await assertOptions( rig, - `${command} run recurse`, + `${runCmd} recurse`, { agent, script: { packageDir: rig.temp, - name: 'start', + name: 'other', }, extraArgs: [], watch: true, }, undefined, { - recurse: `${command} run start --watch`, + recurse: `${runCmd} other --watch`, }, ); }), ); test( - `WIREIT_LOGGER=simple ${command} run main`, + `${agent} WIREIT_LOGGER=simple run`, rigTest(async ({rig}) => { await assertOptions( rig, - `${command} run main`, + `${runCmd} main`, { agent, script: { @@ -290,11 +203,11 @@ for (const command of ['npm', 'yarn', 'pnpm'] as const) { ); test( - `WIREIT_LOGGER=quiet ${command} run main`, + `${agent} WIREIT_LOGGER=quiet run`, rigTest(async ({rig}) => { await assertOptions( rig, - `${command} run main`, + `${runCmd} main`, { agent, script: { @@ -315,28 +228,147 @@ for (const command of ['npm', 'yarn', 'pnpm'] as const) { // included on argv, and the npm_config_argv variable does not let us // reconstruct it, because it always reflects the first script in a chain, // instead of the current script. - skipIfYarn( - `${command} run recurse -> ${command} run start --watch -- --extra`, + (isYarn ? test.skip : test)( + `${agent} run recurse -> run other --watch --extra`, rigTest(async ({rig}) => { await assertOptions( rig, - `${command} run recurse`, + `${runCmd} recurse`, { agent, script: { packageDir: rig.temp, - name: 'start', + name: 'other', }, extraArgs: ['--extra'], watch: true, }, undefined, { - recurse: `${command} run start --watch -- --extra`, + recurse: `${runCmd} other --watch -- --extra`, }, ); }), ); + + if (testCmd !== undefined) { + test( + `${agent} test`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${testCmd}`, { + agent, + script: { + packageDir: rig.temp, + name: 'test', + }, + }); + }), + ); + + // Does not work in pnpm, see https://github.com/pnpm/pnpm/issues/4821. + (isPnpm ? test.skip : test)( + `${agent} test --extra`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${testCmd} -- --extra`, { + agent, + script: { + packageDir: rig.temp, + name: 'test', + }, + extraArgs: ['--extra'], + }); + }), + ); + + // Does not work in pnpm, see https://github.com/pnpm/pnpm/issues/4821. + (isPnpm ? test.skip : test)( + `${agent} test --watch`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${testCmd} --watch`, { + agent, + script: { + packageDir: rig.temp, + name: 'test', + }, + watch: true, + }); + }), + ); + + // Does not work in pnpm, see https://github.com/pnpm/pnpm/issues/4821. + (isPnpm ? test.skip : test)( + `${agent} test --watch --extra`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${testCmd} --watch -- --extra`, { + agent, + script: { + packageDir: rig.temp, + name: 'test', + }, + extraArgs: ['--extra'], + watch: true, + }); + }), + ); + } + + if (startCmd !== undefined) { + test( + `${agent} start`, + rigTest(async ({rig}) => { + await assertOptions(rig, startCmd, { + agent, + script: { + packageDir: rig.temp, + name: 'start', + }, + }); + }), + ); + + test( + `${agent} start --extra`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${startCmd} -- --extra`, { + agent, + script: { + packageDir: rig.temp, + name: 'start', + }, + extraArgs: ['--extra'], + }); + }), + ); + + test( + `${agent} start --watch`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${startCmd} --watch`, { + agent, + script: { + packageDir: rig.temp, + name: 'start', + }, + watch: true, + }); + }), + ); + + test( + `${agent} start --watch --extra`, + rigTest(async ({rig}) => { + await assertOptions(rig, `${startCmd} --watch -- --extra`, { + agent, + script: { + packageDir: rig.temp, + name: 'start', + }, + extraArgs: ['--extra'], + watch: true, + }); + }), + ); + } } test.run(); From ae285e7a32b4f1345ea90cb9d6dd92fda4cc2fac Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 22 Aug 2024 11:51:43 -0700 Subject: [PATCH 3/7] Test node --run support --- src/test/basic.test.ts | 60 +++++++++++++++++++++++++++++++----- src/test/cli-options.test.ts | 58 +++++++++++++++++++++++++--------- 2 files changed, 96 insertions(+), 22 deletions(-) diff --git a/src/test/basic.test.ts b/src/test/basic.test.ts index 21c5f69af..9d363ec43 100644 --- a/src/test/basic.test.ts +++ b/src/test/basic.test.ts @@ -6,10 +6,10 @@ import {suite} from 'uvu'; import * as assert from 'uvu/assert'; -import {rigTest} from './util/rig-test.js'; import {IS_WINDOWS} from '../util/windows.js'; -import {NODE_MAJOR_VERSION} from './util/node-version.js'; import {checkScriptOutput} from './util/check-script-output.js'; +import {NODE_MAJOR_VERSION} from './util/node-version.js'; +import {rigTest} from './util/rig-test.js'; const test = suite(); @@ -766,6 +766,34 @@ test( }), ); +if (NODE_MAJOR_VERSION >= 22) { + test( + 'runs a script with node --run', + rigTest(async ({rig}) => { + const cmdA = await rig.newCommand(); + await rig.write({ + 'package.json': { + scripts: { + a: 'wireit', + }, + wireit: { + a: { + command: cmdA.command, + }, + }, + }, + }); + const exec = rig.exec('node --run a'); + await exec.waitForLog(/0% \[0 \/ 1\] \[1 running\] a/); + (await cmdA.nextInvocation()).exit(0); + const res = await exec.exit; + assert.equal(res.code, 0); + assert.equal(cmdA.numInvocations, 1); + assert.match(res.stdout, /Ran 1 script and skipped 0/s); + }), + ); +} + test( 'runs a script with yarn', rigTest(async ({rig}) => { @@ -1062,9 +1090,21 @@ test( }), ); -for (const agent of ['npm', 'yarn', 'pnpm']) { +for (const command of [ + 'npm run', + 'node --run', + 'yarn run', + 'pnpm run', +] as const) { + if (command === 'node --run' && NODE_MAJOR_VERSION < 22) { + // node --run was added in Node 22. + continue; + } + // node --run needs an extra set of "--" before arguments will be passed down + // to Wireit. + const extraDashes = command === 'node --run' ? '--' : ''; test( - `can pass extra args with using "${agent} run --"`, + `can pass extra args with using "${command} run --"`, rigTest(async ({rig}) => { const cmdA = await rig.newCommand(); await rig.write({ @@ -1085,7 +1125,9 @@ for (const agent of ['npm', 'yarn', 'pnpm']) { // Initially stale. { - const wireit = rig.exec(`${agent} run a -- foo -bar --baz`); + const wireit = rig.exec( + `${command} a -- ${extraDashes} foo -bar --baz`, + ); const inv = await cmdA.nextInvocation(); assert.equal((await inv.environment()).argv.slice(3), [ 'foo', @@ -1099,7 +1141,9 @@ for (const agent of ['npm', 'yarn', 'pnpm']) { // Nothing changed, fresh. { - const wireit = rig.exec(`${agent} run a -- foo -bar --baz`); + const wireit = rig.exec( + `${command} a -- ${extraDashes} foo -bar --baz`, + ); assert.equal((await wireit.exit).code, 0); await wireit.waitForLog(/Ran 0 scripts and skipped 1/s); // } @@ -1107,7 +1151,9 @@ for (const agent of ['npm', 'yarn', 'pnpm']) { // Changing the extra args should change the fingerprint so that we're // stale. { - const wireit = rig.exec(`${agent} run a -- FOO -BAR --BAZ`); + const wireit = rig.exec( + `${command} a -- ${extraDashes} FOO -BAR --BAZ`, + ); const inv = await cmdA.nextInvocation(); assert.equal((await inv.environment()).argv.slice(3), [ 'FOO', diff --git a/src/test/cli-options.test.ts b/src/test/cli-options.test.ts index efd32b6c7..eb4e95451 100644 --- a/src/test/cli-options.test.ts +++ b/src/test/cli-options.test.ts @@ -9,6 +9,7 @@ import {suite} from 'uvu'; import * as assert from 'uvu/assert'; import {Options, type Agent} from '../cli-options.js'; import {Result} from '../error.js'; +import {NODE_MAJOR_VERSION} from './util/node-version.js'; import {rigTest} from './util/rig-test.js'; import {WireitTestRig} from './util/test-rig.js'; @@ -75,6 +76,11 @@ interface AgentCommands { runCmd: string; testCmd: string | undefined; startCmd: string | undefined; + /** + * Whether this agent needs an extra set of "--" before arguments will be + * passed down to Wireit. + */ + needsExtraDashes: boolean; } const commands: AgentCommands[] = [ @@ -83,24 +89,41 @@ const commands: AgentCommands[] = [ runCmd: 'npm run', testCmd: 'npm test', startCmd: 'npm start', + needsExtraDashes: false, + }, + { + agent: 'nodeRun', + runCmd: 'node --run', + testCmd: undefined, + startCmd: undefined, + needsExtraDashes: true, }, { agent: 'yarnClassic', runCmd: 'yarn run', testCmd: 'yarn test', startCmd: 'yarn start', + needsExtraDashes: false, }, { agent: 'pnpm', runCmd: 'pnpm run', testCmd: 'pnpm test', startCmd: 'pnpm start', + needsExtraDashes: false, }, ]; -for (const {agent, runCmd, testCmd, startCmd} of commands) { +for (const {agent, runCmd, testCmd, startCmd, needsExtraDashes} of commands) { + if (agent === 'nodeRun' && NODE_MAJOR_VERSION < 22) { + // node --run was added in Node 22. + continue; + } + const isYarn = agent === 'yarnClassic'; const isPnpm = agent === 'pnpm'; + const isWindows = process.platform === 'win32'; + const extraDashes = needsExtraDashes ? '--' : ''; test( `${agent} run`, @@ -118,7 +141,7 @@ for (const {agent, runCmd, testCmd, startCmd} of commands) { test( `${agent} run --extra`, rigTest(async ({rig}) => { - await assertOptions(rig, `${runCmd} main -- --extra`, { + await assertOptions(rig, `${runCmd} main -- ${extraDashes} --extra`, { agent, script: { packageDir: rig.temp, @@ -132,7 +155,7 @@ for (const {agent, runCmd, testCmd, startCmd} of commands) { test( `${agent} run --watch`, rigTest(async ({rig}) => { - await assertOptions(rig, `${runCmd} main --watch`, { + await assertOptions(rig, `${runCmd} main ${extraDashes} --watch`, { agent, script: { packageDir: rig.temp, @@ -146,19 +169,24 @@ for (const {agent, runCmd, testCmd, startCmd} of commands) { test( `${agent} run --watch --extra`, rigTest(async ({rig}) => { - await assertOptions(rig, `${runCmd} main --watch -- --extra`, { - agent, - script: { - packageDir: rig.temp, - name: 'main', + await assertOptions( + rig, + `${runCmd} main ${extraDashes} --watch -- --extra`, + { + agent, + script: { + packageDir: rig.temp, + name: 'main', + }, + extraArgs: ['--extra'], + watch: true, }, - extraArgs: ['--extra'], - watch: true, - }); + ); }), ); - test( + // https://github.com/google/wireit/issues/1168 + (isWindows ? test.skip : test)( `${agent} run recurse -> run other --watch`, rigTest(async ({rig}) => { await assertOptions( @@ -175,7 +203,7 @@ for (const {agent, runCmd, testCmd, startCmd} of commands) { }, undefined, { - recurse: `${runCmd} other --watch`, + recurse: `${runCmd} other ${extraDashes} --watch`, }, ); }), @@ -228,7 +256,7 @@ for (const {agent, runCmd, testCmd, startCmd} of commands) { // included on argv, and the npm_config_argv variable does not let us // reconstruct it, because it always reflects the first script in a chain, // instead of the current script. - (isYarn ? test.skip : test)( + (isYarn || isWindows ? test.skip : test)( `${agent} run recurse -> run other --watch --extra`, rigTest(async ({rig}) => { await assertOptions( @@ -245,7 +273,7 @@ for (const {agent, runCmd, testCmd, startCmd} of commands) { }, undefined, { - recurse: `${runCmd} other --watch -- --extra`, + recurse: `${runCmd} other ${extraDashes} --watch -- --extra`, }, ); }), From 9d6ca29f764dfd9ecf9717c5bff49b7ccb101a0d Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 22 Aug 2024 11:52:03 -0700 Subject: [PATCH 4/7] Add node 22 to tests --- .github/workflows/tests.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79c02e2f1..f7e983d9b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,26 +6,33 @@ jobs: tests: strategy: # We support Node Current, LTS, and Maintenance. See - # https://nodejs.org/en/about/releases/ for release schedule. + # https://github.com/nodejs/release#release-schedule for release schedule # # We test all supported Node versions on Linux, and the oldest and newest - # on macOS/Windows. + # on macOS/Windows. See + # https://github.com/actions/runner-images?tab=readme-ov-file#available-images + # for the latest available images. matrix: include: + # Maintenance - node: 18 os: ubuntu-22.04 - node: 18 os: macos-13 - node: 18 os: windows-2022 + + # LTS - node: 20 os: ubuntu-22.04 - - node: 20 + + # Current + - node: 22 + os: ubuntu-22.04 + - node: 22 os: macos-13 - - node: 20 + - node: 22 os: windows-2022 - - node: 21 - os: ubuntu-22.04 # Allow all matrix configurations to complete, instead of cancelling as # soon as one fails. Useful because we often have different kinds of From 3176b6e114bee28ce79af1cde03dc6815ae335e4 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 22 Aug 2024 11:53:25 -0700 Subject: [PATCH 5/7] Update README and CHANGELOG --- CHANGELOG.md | 7 +++++++ README.md | 29 ++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0903da50..9d4621d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Added support for `node --run`, available in Node 22 and above (see + https://nodejs.org/en/blog/announcements/v22-release-announce#running-packagejson-scripts). + ## [0.14.7] - 2024-08-05 - When GitHub caching fails to initialize, more information is now shown about diff --git a/README.md b/README.md index 6eea67cc9..e31eba49d 100644 --- a/README.md +++ b/README.md @@ -104,9 +104,7 @@ and replace the original script with the `wireit` command. Now when you run `npm run build`, Wireit upgrades the script to be smarter and -more efficient. Wireit works with [yarn](https://yarnpkg.com/) -(both 1.X "[Classic](https://classic.yarnpkg.com/)" and its successor "Berry") -and [pnpm](https://pnpm.io/), too. +more efficient. Wireit also works with [`node --run`](https://nodejs.org/en/blog/announcements/v22-release-announce#running-packagejson-scripts), [yarn](https://yarnpkg.com/), and [pnpm](https://pnpm.io/). You should also add `.wireit` to your `.gitignore` file. Wireit uses the `.wireit` directory to store caches and other data for your scripts. @@ -238,6 +236,13 @@ npm or Wireit: npm run build -- --verbose ``` +An additional `--` is required when using `node --run` in order to distinguish +between arguments intended for `node`, `wireit`, and the script itself: + +```sh +node --run build -- -- --verbose +``` + ## Input and output files The `files` and `output` properties of `wireit.