Unverified Commit 0f572ed3 authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

pnpm_{8,9,10}: add updateScript; pnpm_10: 10.6.3 -> 10.6.5 (#390687)

parents 6c57ac8b b171b549
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@ let
      hash = "sha256-z4anrXZEBjldQoam0J1zBxFyCsxtk+nc6ax6xNxKKKc=";
    };
    "10" = {
      version = "10.6.3";
      hash = "sha256-vB7+ku5NQLGnpkTlyp4YVcXF6vxrFRL5AXsxuSRUGds=";
      version = "10.6.5";
      hash = "sha256-R8i8pCtLSFNLWxso1XPFBnc5N7AvaOUpkvvYJpExxcg=";
    };
  };

+26 −1
Original line number Diff line number Diff line
{
  lib,
  stdenvNoCC,
  writeScript,
  callPackages,
  fetchurl,
  installShellFiles,
@@ -10,7 +11,9 @@
  version,
  hash,
}:

let
  majorVersion = lib.versions.major version;
in
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "pnpm";
  inherit version;
@@ -71,10 +74,32 @@ stdenvNoCC.mkDerivation (finalAttrs: {
    in
    {
      inherit (fetchDepsAttrs) fetchDeps configHook;
      inherit majorVersion;

      tests.version = lib.optionalAttrs withNode (
        testers.testVersion { package = finalAttrs.finalPackage; }
      );
      updateScript = writeScript "pnpm-update-script" ''
        #!/usr/bin/env nix-shell
        #!nix-shell -i bash -p curl jq common-updater-scripts
        set -eou pipefail

        curl_github() {
            curl -L ''${GITHUB_TOKEN:+" -u \":$GITHUB_TOKEN\""} "$@"
        }

        latestTag=$(curl_github https://api.github.com/repos/pnpm/pnpm/releases?per_page=100 | jq -r --arg major "v${majorVersion}" '[.[].tag_name | select(startswith($major))][0]')

        # Exit if there is no tag with this major version
        if [ "$latestTag" = "null" ]; then
          echo "No releases starting with v${majorVersion}"
          exit 0
        fi

        latestVersion="''${latestTag#v}"

        update-source-version pnpm_${majorVersion} "$latestVersion" --file=./pkgs/development/tools/pnpm/default.nix
      '';
    };

  meta = {