npmlock2nix
npmlock2nix copied to clipboard
Git+https
This should fix #89 There should probably be a test for this.
Does this supersede #93?
Does this supersede #93?
No, this is orthogonal to #93
Though I just noticed, I messed up while untangling the commits and there's some stuff in here, that should be in #93
Though I just noticed, I messed up while untangling the commits and there's some stuff in here, that should be in #93
Can you untangle these changes?
Can you untangle these changes?
Yes, I'll try to do that tonight. I'm currently on a train.
@andir is there anything still missing for this?
I tried to use this but got this error
error: [npmlock2nix] parseGitRef expects a string that matches `git\+(https://[^#]+)#(.+)` but was called with `git+https://github.com/ethereumjs/ethereumjs-abi.git`
looks like it's because you're requiring a #.
edit: well I patched the urls manually with mapAttrsRecursive and came to find out that this doesn't support github:org/repo without a revision. So I guess that makes sense.
Quick snippet for anyone running into the parseGitRef error due to unlocked git dependencies in package.json:
node_modules_attrs = let
transformJsonFile = file: f:
lib.pipe file [
lib.importJSON
f
builtins.toJSON
(pkgs.writeText (baseNameOf file))
(d: d.outPath)
];
in rec {
packageJson = transformJsonFile "${src}/package.json" (p: p // {
dependencies = builtins.mapAttrs (k: v:
if lib.hasPrefix "git+" v
then (lib.importJSON packageLockJson).dependencies.${k}.version
else v
) p.dependencies;
});
packageLockJson = transformJsonFile ./package-lock.json (p: p // {
dependencies = builtins.mapAttrs (k: v:
if v ? from
then v // { from = v.version; }
else v
) p.dependencies;
});
};
@Sohalt @andir we happen to be trying to use this tool for one of our projects and ran into this issue with git links. Is there any likelihood this PR will be merged in the near future? Is there anything that it still needs before merging?
It needs rewriting for the v2 API. I gave it a go but it's too dissimilar from v1 for me to work out.