npmlock2nix icon indicating copy to clipboard operation
npmlock2nix copied to clipboard

Git+https

Open Sohalt opened this issue 4 years ago • 10 comments

This should fix #89 There should probably be a test for this.

Sohalt avatar Aug 13 '21 15:08 Sohalt

Does this supersede #93?

andir avatar Aug 13 '21 18:08 andir

Does this supersede #93?

No, this is orthogonal to #93

Sohalt avatar Aug 13 '21 20:08 Sohalt

Though I just noticed, I messed up while untangling the commits and there's some stuff in here, that should be in #93

Sohalt avatar Aug 13 '21 20:08 Sohalt

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?

andir avatar Aug 14 '21 12:08 andir

Can you untangle these changes?

Yes, I'll try to do that tonight. I'm currently on a train.

Sohalt avatar Aug 14 '21 12:08 Sohalt

@andir is there anything still missing for this?

Sohalt avatar Oct 08 '21 08:10 Sohalt

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.

ursi avatar Oct 19 '21 23:10 ursi

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

dermetfan avatar Nov 13 '22 13:11 dermetfan

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

charukiewicz avatar May 03 '23 18:05 charukiewicz

It needs rewriting for the v2 API. I gave it a go but it's too dissimilar from v1 for me to work out.

YoshiRulz avatar Oct 22 '23 13:10 YoshiRulz