From e7cd275cd837aebf98fbbc89b037bda475de9e42 Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Mon, 27 Mar 2023 14:10:32 -0400 Subject: [PATCH 1/4] fetchYarnDeps: account for more yarn.lock spec edge cases * Ignore relative `file:` paths. * Support github codeload URLs with `refs/tags/tag` in addition to just `tag`. * Support https://github.com/owner/repo/archive/ref.tar.gz URLs for git download. --- pkgs/build-support/node/fetch-yarn-deps/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/node/fetch-yarn-deps/index.js b/pkgs/build-support/node/fetch-yarn-deps/index.js index b66e1220218d..e3b9b68fef2a 100755 --- a/pkgs/build-support/node/fetch-yarn-deps/index.js +++ b/pkgs/build-support/node/fetch-yarn-deps/index.js @@ -91,12 +91,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://')) { From 88375f1b74211487c0574033f958fdc06b783312 Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Mon, 27 Mar 2023 17:41:19 -0400 Subject: [PATCH 2/4] fetchYarnDeps: fix test hashes --- pkgs/build-support/node/fetch-yarn-deps/tests/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 19451466f24f..a3bd91defe67 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,14 @@ { 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="; }; } From a777753eb26c96144d58f899b5893509a87b6f5a Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Mon, 27 Mar 2023 17:41:32 -0400 Subject: [PATCH 3/4] fetchYarnDeps: add more git url tests --- .../node/fetch-yarn-deps/tests/default.nix | 4 ++++ .../node/fetch-yarn-deps/tests/giturl.lock | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 pkgs/build-support/node/fetch-yarn-deps/tests/giturl.lock 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 a3bd91defe67..8ffe103a9548 100644 --- a/pkgs/build-support/node/fetch-yarn-deps/tests/default.nix +++ b/pkgs/build-support/node/fetch-yarn-deps/tests/default.nix @@ -13,4 +13,8 @@ yarnLock = ./github.lock; 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 000000000000..154030a7e358 --- /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" From 86f94c3e45e0ea38ecd2aebfecc1680530fd3a34 Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Thu, 29 Jun 2023 11:11:41 -0400 Subject: [PATCH 4/4] prefetch-yarn-deps: add tests passthru --- pkgs/build-support/node/fetch-yarn-deps/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/build-support/node/fetch-yarn-deps/default.nix b/pkgs/build-support/node/fetch-yarn-deps/default.nix index 4cf2507706ae..6dc1ff44ca9e 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"; @@ -37,6 +39,8 @@ in { runHook postInstall ''; + + passthru = { inherit tests; }; }; fetchYarnDeps = let @@ -74,6 +78,6 @@ in { } // hash_ // (removeAttrs args ["src" "name" "hash" "sha256"])); in lib.setFunctionArgs f (lib.functionArgs f) // { - tests = callPackage ./tests {}; + inherit tests; }; }