diff options
author | Lily Foster <lily@lily.flowers> | 2023-07-16 20:24:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-16 20:24:16 -0400 |
commit | 249efd22716684611054f84e96f7f2633bc09d2b (patch) | |
tree | a0ef7062635feb41430517102a2a0e436c4d5411 /pkgs/build-support | |
parent | d8b8bf09f94ed705ad01d4058503b50acd2a04d4 (diff) | |
parent | 86f94c3e45e0ea38ecd2aebfecc1680530fd3a34 (diff) |
Merge pull request #223457 from lilyinstarlight/fix/fetch-yarn-deps-pulsar
fetchYarnDeps: account for more yarn.lock spec edge cases
Diffstat (limited to 'pkgs/build-support')
4 files changed, 33 insertions, 5 deletions
diff --git a/pkgs/build-support/node/fetch-yarn-deps/default.nix b/pkgs/build-support/node/fetch-yarn-deps/default.nix index f3b5a6bd163b7..d95b1078c162e 100644 --- a/pkgs/build-support/node/fetch-yarn-deps/default.nix +++ b/pkgs/build-support/node/fetch-yarn-deps/default.nix @@ -6,6 +6,8 @@ let sha512 = "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ=="; }; + tests = callPackage ./tests {}; + in { prefetch-yarn-deps = stdenv.mkDerivation { name = "prefetch-yarn-deps"; @@ -38,6 +40,8 @@ in { runHook postInstall ''; + + passthru = { inherit tests; }; }; fetchYarnDeps = let @@ -75,6 +79,6 @@ in { } // hash_ // (removeAttrs args ["src" "name" "hash" "sha256"])); in lib.setFunctionArgs f (lib.functionArgs f) // { - tests = callPackage ./tests {}; + inherit tests; }; } diff --git a/pkgs/build-support/node/fetch-yarn-deps/index.js b/pkgs/build-support/node/fetch-yarn-deps/index.js index 9f95e16970306..3cae1c16a2e7f 100755 --- a/pkgs/build-support/node/fetch-yarn-deps/index.js +++ b/pkgs/build-support/node/fetch-yarn-deps/index.js @@ -78,12 +78,21 @@ const isGitUrl = pattern => { } const downloadPkg = (pkg, verbose) => { + const [ name, spec ] = pkg.key.split('@', 2); + if (spec.startsWith('file:')) { + console.info(`ignoring relative file:path dependency "${spec}"`) + return + } + const [ url, hash ] = pkg.resolved.split('#') if (verbose) console.log('downloading ' + url) const fileName = urlToName(url) if (url.startsWith('https://codeload.github.com/') && url.includes('/tar.gz/')) { const s = url.split('/') - downloadGit(fileName, `https://github.com/${s[3]}/${s[4]}.git`, s[6]) + return downloadGit(fileName, `https://github.com/${s[3]}/${s[4]}.git`, s[s.length-1]) + } else if (url.startsWith('https://github.com/') && url.endsWith('.tar.gz')) { + const s = url.split('/') + return downloadGit(fileName, `https://github.com/${s[3]}/${s[4]}.git`, s[s.length-1].replace(/.tar.gz$/, '')) } else if (isGitUrl(url)) { return downloadGit(fileName, url.replace(/^git\+/, ''), hash) } else if (url.startsWith('https://')) { diff --git a/pkgs/build-support/node/fetch-yarn-deps/tests/default.nix b/pkgs/build-support/node/fetch-yarn-deps/tests/default.nix index 19451466f24fd..8ffe103a9548a 100644 --- a/pkgs/build-support/node/fetch-yarn-deps/tests/default.nix +++ b/pkgs/build-support/node/fetch-yarn-deps/tests/default.nix @@ -3,14 +3,18 @@ { simple = testers.invalidateFetcherByDrvHash fetchYarnDeps { yarnLock = ./simple.lock; - sha256 = "sha256-Erdkw2E8wWT09jFNLXGkrdwKl0HuSZWnUDJUrV95vSE="; + sha256 = "sha256-FRrt8BixleILmFB2ZV8RgPNLqgS+dlH5nWoPgeaaNQ8="; }; gitDep = testers.invalidateFetcherByDrvHash fetchYarnDeps { yarnLock = ./git.lock; - sha256 = "sha256-lAqN4LpoE+jgsQO1nDtuORwcVEO7ogEV53jCu2jFJUI="; + sha256 = "sha256-f90IiEzHDiBdswWewRBHcJfqqpPipaMg8N0DVLq2e8Q="; }; githubDep = testers.invalidateFetcherByDrvHash fetchYarnDeps { yarnLock = ./github.lock; - sha256 = "sha256-Tsfgyjxz8x6gNmfN0xR7G/NQNoEs4svxRN/N+26vfJU="; + sha256 = "sha256-DIKrhDKoqm7tHZmcuh9eK9VTqp6BxeW0zqDUpY4F57A="; + }; + gitUrlDep = testers.invalidateFetcherByDrvHash fetchYarnDeps { + yarnLock = ./giturl.lock; + sha256 = "sha256-VPnyqN6lePQZGXwR7VhbFnP7/0/LB621RZwT1F+KzVQ="; }; } diff --git a/pkgs/build-support/node/fetch-yarn-deps/tests/giturl.lock b/pkgs/build-support/node/fetch-yarn-deps/tests/giturl.lock new file mode 100644 index 0000000000000..154030a7e358c --- /dev/null +++ b/pkgs/build-support/node/fetch-yarn-deps/tests/giturl.lock @@ -0,0 +1,11 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"autocomplete-atom-api@https://codeload.github.com/atom/autocomplete-atom-api/legacy.tar.gz/refs/tags/v0.10.7": + version "0.10.7" + resolved "https://codeload.github.com/atom/autocomplete-atom-api/legacy.tar.gz/refs/tags/v0.10.7#c9d51fa721d543ccfc1b2189101155e81db6b97d" + +"find-and-replace@https://github.com/atom-community/find-and-replace/archive/refs/tags/v0.220.1.tar.gz": + version "0.220.1" + resolved "https://github.com/atom-community/find-and-replace/archive/refs/tags/v0.220.1.tar.gz#d7a0f56511e38ee72a89895a795bbbcab4a1a405" |