From e7cd275cd837aebf98fbbc89b037bda475de9e42 Mon Sep 17 00:00:00 2001 From: Lily Foster Date: Mon, 27 Mar 2023 14:10:32 -0400 Subject: [PATCH] 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://')) {