fix github dependency for yarn v1

This commit is contained in:
DavHau 2021-10-08 00:43:46 +07:00
parent 74bff7571b
commit 35f9cec8d0
2 changed files with 21 additions and 15 deletions

View File

@ -201,6 +201,7 @@ class PackageCommand(Command):
)
# dump translator arguments to json file and execute translator
print("Translating upstream metadata")
with tempfile.NamedTemporaryFile("w") as input_json_file:
json.dump(translator_input, input_json_file, indent=2)
input_json_file.seek(0) # flushes write cache

View File

@ -42,20 +42,8 @@
name = nameFromLockName dependencyName;
in
lib.nameValuePair ("${name}#${dependencyAttrs.version}") (
if ! lib.hasInfix "@github:" dependencyName then
{
version = dependencyAttrs.version;
hash = dependencyAttrs.integrity;
url = lib.head (lib.splitString "#" dependencyAttrs.resolved);
type = "fetchurl";
}
else if lib.hasInfix "@link:" dependencyName then
{
version = dependencyAttrs.version;
path = lib.last (lib.splitString "@link:" dependencyName);
type = "path";
}
else
if lib.hasInfix "@github:" dependencyName
|| lib.hasInfix "codeload.github.com/" dependencyAttrs.resolved then
let
gitUrlInfos = lib.splitString "/" dependencyAttrs.resolved;
in
@ -65,6 +53,23 @@
owner = lib.elemAt gitUrlInfos 3;
repo = lib.elemAt gitUrlInfos 4;
}
else if lib.hasInfix "@link:" dependencyName then
{
version = dependencyAttrs.version;
path = lib.last (lib.splitString "@link:" dependencyName);
type = "path";
}
else
{
version = dependencyAttrs.version;
hash =
if dependencyAttrs ? integrity then
dependencyAttrs.integrity
else
throw "Missing integrity for ${dependencyName}";
url = lib.head (lib.splitString "#" dependencyAttrs.resolved);
type = "fetchurl";
}
)) parsedLock;
dependencyGraph =
(lib.mapAttrs'
@ -105,7 +110,7 @@
in
"${depName}#${dependencyAttrs.version}"
)
packageJSON.dependencies;
(packageJSON.dependencies or {} // packageJSON.devDependencies or {});
};