From 02ff87dc0ec7437f94b1538c096f3912817d9c4d Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Thu, 17 Aug 2023 12:39:15 -0300 Subject: [PATCH] Ignore yarn 2.4.3 (#627) After [#617](https://github.com/heroku/buildpacks-nodejs/pull/617) was merged our inventory automation ran and the PR to update the `yarn` inventory with `2.4.3` ([#620](https://github.com/heroku/buildpacks-nodejs/pull/620)) had failing tests that showed that the layout for this version did not match our other distributions. This PR modifies the automation to ignore this version of `yarn` so that our mirroring jobs no longer report as failing and we will not get this distribution added to our inventory since it requires special handling in the buildpack to be usable. --- common/bin/download-verify-npm-package | 4 ++-- common/nodejs-utils/src/distribution.rs | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/common/bin/download-verify-npm-package b/common/bin/download-verify-npm-package index 8ad8b236..090718fa 100755 --- a/common/bin/download-verify-npm-package +++ b/common/bin/download-verify-npm-package @@ -20,9 +20,9 @@ if [ -z "$package_version" ]; then fi if [ "yarn" = "${package_name}" ]; then - # Yarn 2+ (aka: "berry") is hosted under a different npm package (except for version 2.4.3). + # Yarn 2+ (aka: "berry") is hosted under a different npm package. major_version=$(echo "$package_version" | cut -d "." -f 1) - package_name=$([ "$major_version" -ge 2 ] && [ "$package_version" != "2.4.3" ] && echo "@yarnpkg/cli-dist" || echo "yarn") + package_name=$([ "$major_version" -ge 2 ] && echo "@yarnpkg/cli-dist" || echo "yarn") fi npm_url="https://registry.npmjs.com/${package_name}/${package_version}" diff --git a/common/nodejs-utils/src/distribution.rs b/common/nodejs-utils/src/distribution.rs index 570d9a02..6a7b4322 100644 --- a/common/nodejs-utils/src/distribution.rs +++ b/common/nodejs-utils/src/distribution.rs @@ -123,11 +123,28 @@ fn list_upstream_node_versions() -> anyhow::Result { .collect() } +const IGNORE_YARN_VERSIONS: [&str; 1] = [ + // This version is ignored because all of the current 2.x versions are published by the `@yarnpkg/cli-dist` + // module except for this one which is published by the `yarn` module. The layout of this package + // differs from what we expect so instead of coding in some edge case handling when we install this + // yarn version in the buildpack, we've decided to ignore it. + // + // There should be little user impact here because our Yarn inventory only controls the "global" binary + // that is installed which acts as a wrapper to the actual version of Yarn used when building. + // For Yarn 2+ projects, the actual Yarn version used is meant to be committed to the folder + // `.yarn/release` and the global binary delegates all operations to the committed version. + "2.4.3", +]; + fn list_upstream_yarn_versions() -> anyhow::Result { let mut vset = VersionSet::new(); for pkg in ["yarn", "@yarnpkg/cli-dist"] { for release in npmjs_org::list_releases(pkg)? { - vset.insert(release.version); + let ignore_release = pkg == "yarn" + && IGNORE_YARN_VERSIONS.contains(&release.version.to_string().as_str()); + if !ignore_release { + vset.insert(release.version); + } } } Ok(vset)