nexdrew/rewrite-shrinkwrap-urls

Sync "from" urls to match "resolved"

casmith opened this issue · 5 comments

Many times when adding a new module, the "from" property is resolved as a range of versions instead of a URL. Later when shrinkwrapping again, they will then be resolved to the same url that is in the "resolved" field.

It would be nice to have an option to just sync the "from" property to match "resolved" so that VCS diffs are a little saner. I would like to use this tool to do this since we also use it for rewriting the urls for other reasons.

Would it make sense to include such a feature in this tool? If so, I will volunteer to implement it.

@casmith Sounds reasonable to me. You may be the only person using this package, so feel free to make it what you want ;) I'll do what I can to help test.

Raised here: #4. I think I incorrectly tagged the PR in the commit msg. Sorry for that.

@casmith Concerning this:

Many times when adding a new module, the "from" property is resolved as a range of versions instead of a URL. Later when shrinkwrapping again, they will then be resolved to the same url that is in the "resolved" field.

I'm interested in how you're achieving this. What's your process? Are you rewriting the shrinkwrap URLs in npm-shrinkwrap.json, committing that, and then running npm i against that shrinkwrap somewhere else? The only way I've been able to reproduce this is to install a dependency directly from a URL.

Regardless, I think the "from" property in npm-shrinkwrap.json is purely informational, so if fixing this in rewrite-shrinkwrap-urls makes your life easier, I'm all for it. Will get PR #4 tested, updated, merged, and released ASAP.

It's mostly when collaborating in a team. If one team member adds a new dependency, the "from" is resolve to a range of versions. I get the new shrinkwrap when I pull, npm install, and everything is fine. Then if I go add/update another dependency, when I shrinkwrap, I will have diffs unrelated to what I just changed because when I installed, it resolved from the URL instead of the range of versions.

Rewriting URLs is not part of our normal workflow, but there is another team using a different private NPM repo. They use this same package for rewriting URLs, so by happy accident we're now able to use it for both purposes.

Thanks btw, this is working beautifully!

@casmith Cool, thanks for sharing that, and thanks for the initial implementation! Let me know if you need anything else. 😎