OpenZeppelin / openzeppelin-sdk

OpenZeppelin SDK repository for CLI and upgrades.js. No longer actively developed.
MIT License
431 stars 201 forks source link

Cannot link dependency using github path #542

Open spalladino opened 5 years ago

spalladino commented 5 years ago

Running zos link using a full path to github fails to link the dependency:

$ zos link  git+https://github.com/smartcontractkit/chainlink.git#features/integrate-zos
Installing git+https://github.com/smartcontractkit/chainlink.git#features/integrate-zos via npm...
Could not find a zos.json file for 'git+https://github.com/smartcontractkit/chainlink.git#features/integrate-zos'. Make sure it is provided by the npm package.

This happens because zos looks for the zos.json file in the node_modules folder derived from the package name, so it's trying to retrieve the file from ./node_modules/git+https://github.com/smartcontractkit/chainlink.git#features/integrate-zos/zos.json, which clearly fails.

We should fetch the package name from the installation, and use that to access the zos.json file.

spalladino commented 5 years ago

For reference, this issue can be worked around by separately installing the dependency and then linking it:

$ npm install git+https://github.com/smartcontractkit/chainlink.git#features/integrate-zos
$ zos link chainlink
jbcarpanelli commented 5 years ago

I find this bug very interesting. WDYT about adding a flag to the link command to specify which source should be used? for example:

foo@bar:~$ zos link chainlink --source https://github.com/smartcontractkit/chainlink.git#features/integrate-zos

If no source is specified, we can continue using npm as the default.

spalladino commented 5 years ago

Isn't there any way to get the package name from the installation source? A command from npm itself maybe? This would allow us to get the name automatically, without requiring the user to specify it.