yarn2nix: handle codeload.github.com uris in IFD mode (#136922)

authored by

Yuka and committed by
GitHub
b27d18a4 839fb3f5

+15 -5
+5 -5
pkgs/development/tools/yarn2nix-moretea/yarn2nix/bin/yarn2nix.js
··· 53 53 54 54 // Check for missing hashes in the yarn.lock and patch if necessary 55 55 56 - const pkgs = R.pipe( 56 + let pkgs = R.pipe( 57 57 mapObjIndexedReturnArray((value, key) => ({ 58 58 ...value, 59 59 nameWithVersion: key, ··· 61 61 R.uniqBy(R.prop('resolved')), 62 62 )(json.object) 63 63 64 - const fixedPkgsPromises = R.map(fixPkgAddMissingSha1, pkgs) 65 - 66 64 ;(async () => { 67 - const fixedPkgs = await Promise.all(fixedPkgsPromises) 65 + if (!options['--no-patch']) { 66 + pkgs = await R.map(fixPkgAddMissingSha1, pkgs) 67 + } 68 68 69 69 const origJson = lockfile.parse(data) 70 70 ··· 81 81 82 82 if (!options['--no-nix']) { 83 83 // print to stdout 84 - console.log(generateNix(fixedPkgs, options['--builtin-fetchgit'])) 84 + console.log(generateNix(pkgs, options['--builtin-fetchgit'])) 85 85 } 86 86 })().catch(error => { 87 87 console.error(error)
+10
pkgs/development/tools/yarn2nix-moretea/yarn2nix/lib/generateNix.js
··· 80 80 81 81 const fileName = urlToName(url) 82 82 83 + if (resolved.startsWith('https://codeload.github.com/')) { 84 + const s = resolved.split('/') 85 + const githubUrl = `https://github.com/${s[3]}/${s[4]}.git` 86 + const githubRev = s[6] 87 + 88 + const [_, branch] = nameWithVersion.split('#') 89 + 90 + return fetchgit(fileName, githubUrl, rev, branch || 'master', builtinFetchGit) 91 + } 92 + 83 93 if (url.startsWith('git+') || url.startsWith("git:")) { 84 94 const rev = sha1OrRev 85 95