From 9c16891df93e2ece0a3b57c4e61b1227b2dd6f58 Mon Sep 17 00:00:00 2001 From: Paul Soporan Date: Thu, 27 Jan 2022 17:41:55 +0200 Subject: [PATCH 1/4] fix: use parseOptionalBoolean on YARN_IGNORE_NODE --- packages/yarnpkg-cli/sources/main.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/yarnpkg-cli/sources/main.ts b/packages/yarnpkg-cli/sources/main.ts index 1c58dc0b378e..b0bd8fd3ec52 100644 --- a/packages/yarnpkg-cli/sources/main.ts +++ b/packages/yarnpkg-cli/sources/main.ts @@ -1,11 +1,11 @@ -import {Configuration, CommandContext, PluginConfiguration, TelemetryManager, semverUtils} from '@yarnpkg/core'; -import {PortablePath, npath, xfs} from '@yarnpkg/fslib'; -import {execFileSync} from 'child_process'; -import {isCI} from 'ci-info'; -import {Cli, UsageError} from 'clipanion'; -import {realpathSync} from 'fs'; +import {Configuration, CommandContext, PluginConfiguration, TelemetryManager, semverUtils, miscUtils} from '@yarnpkg/core'; +import {PortablePath, npath, xfs} from '@yarnpkg/fslib'; +import {execFileSync} from 'child_process'; +import {isCI} from 'ci-info'; +import {Cli, UsageError} from 'clipanion'; +import {realpathSync} from 'fs'; -import {pluginCommands} from './pluginCommands'; +import {pluginCommands} from './pluginCommands'; function runBinary(path: PortablePath) { const physicalPath = npath.fromPortablePath(path); @@ -60,7 +60,8 @@ export async function main({binaryVersion, pluginConfiguration}: {binaryVersion: const version = process.versions.node; const range = `>=12 <14 || 14.2 - 14.9 || >14.10.0`; - if (process.env.YARN_IGNORE_NODE !== `1` && !semverUtils.satisfiesWithPrereleases(version, range)) + const ignoreNode = miscUtils.parseOptionalBoolean(process.env.YARN_IGNORE_NODE); + if (!ignoreNode && !semverUtils.satisfiesWithPrereleases(version, range)) throw new UsageError(`This tool requires a Node version compatible with ${range} (got ${version}). Upgrade Node, or set \`YARN_IGNORE_NODE=1\` in your environment.`); // Since we only care about a few very specific settings (yarn-path and ignore-path) we tolerate extra configuration key. From 4871d7b197e0955b0e9a80ca326cd98ba81631a2 Mon Sep 17 00:00:00 2001 From: Paul Soporan Date: Thu, 27 Jan 2022 17:43:47 +0200 Subject: [PATCH 2/4] chore: add comment --- packages/yarnpkg-cli/sources/main.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/yarnpkg-cli/sources/main.ts b/packages/yarnpkg-cli/sources/main.ts index b0bd8fd3ec52..bbab63f49fb6 100644 --- a/packages/yarnpkg-cli/sources/main.ts +++ b/packages/yarnpkg-cli/sources/main.ts @@ -60,6 +60,9 @@ export async function main({binaryVersion, pluginConfiguration}: {binaryVersion: const version = process.versions.node; const range = `>=12 <14 || 14.2 - 14.9 || >14.10.0`; + // YARN_IGNORE_NODE is special because this code needs to execute as early as possible. + // It's not a regular core setting because Configuration.find may use functions not available + // on older Node versions. const ignoreNode = miscUtils.parseOptionalBoolean(process.env.YARN_IGNORE_NODE); if (!ignoreNode && !semverUtils.satisfiesWithPrereleases(version, range)) throw new UsageError(`This tool requires a Node version compatible with ${range} (got ${version}). Upgrade Node, or set \`YARN_IGNORE_NODE=1\` in your environment.`); From 8a2abcbbd26dc0e0ece7af59acfc502c6f2d3ea2 Mon Sep 17 00:00:00 2001 From: Paul Soporan Date: Tue, 1 Feb 2022 17:08:09 +0200 Subject: [PATCH 3/4] chore: versions --- .yarn/versions/a1a4200d.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .yarn/versions/a1a4200d.yml diff --git a/.yarn/versions/a1a4200d.yml b/.yarn/versions/a1a4200d.yml new file mode 100644 index 000000000000..86b828aea491 --- /dev/null +++ b/.yarn/versions/a1a4200d.yml @@ -0,0 +1,23 @@ +releases: + "@yarnpkg/cli": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/core" + - "@yarnpkg/doctor" From 67e86407ae28c2671f1602cd2cd45d914bb423c3 Mon Sep 17 00:00:00 2001 From: Paul Soporan Date: Tue, 1 Feb 2022 17:11:33 +0200 Subject: [PATCH 4/4] chore: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ad23fd27593..cb70851a64f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ Various improvements have been made in the core to improve performance. Addition - Fixed a crash caused by a bad interaction between aliased packages and peer dependencies. - The ESBuild plugin will no longer allow access to Node.js builtins if the `platform` isn't set to Node. - SemVer ranges with build metadata can now be resolved. +- The `YARN_IGNORE_NODE` environment variable will now be parsed using the same mechanism as env variable configuration settings (i.e. both `1`/`0` and `true`/`false` will be accepted) ### ZipFS Extension