Merge pull request #223457 from lilyinstarlight/fix/fetch-yarn-deps-pulsar

fetchYarnDeps: account for more yarn.lock spec edge cases
This commit is contained in:
Lily Foster 2023-07-16 20:24:16 -04:00 committed by GitHub
commit 249efd2271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 5 deletions

View File

@ -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;
};
}

View File

@ -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://')) {

View File

@ -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=";
};
}

View File

@ -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"