As I havn’t yet seen any solution for solving elm.json dependency conflicts, I decided to try creating a small app for this, while waiting for someone else to come up with a proper solution. This is my first Elm app of over 1000 lines, so probably full of bugs.
The app parses given elm.json, then loads information about related packages and their versions, and shows a table of the versions of elm.json and all newer versions, including all indirect packages.
There is no automatic conflict resolution, but user can select versions from table and any dependency conflicts will be listed below. There is also some color coding to help select versions.
Online version: https://www.markuslaire.com/github/elm-dependencies-analyzer/
Source code: https://github.com/malaire/elm-dependencies-analyzer
I havn’t written any manual/help yet, so here are few notes about how this (currently) works:
- Open/paste your elm.json or click “Load Example” to see an example with some conflicts
- Press Analyze to parse JSON and load package information (this can take a moment)
- selected versions have blue background
- versions which are incompatible with selected versions have red background
- when hovering cursor over any version, all versions incompatible with that one have red border
- selected versions can be changed by clicking another version
- checkboxes change which packages are considered direct packages
- when removing direct packages, any indirect packages which aren’t needed anymore will be marked with strikethrough
- if selected versions have conflicts, those are listed below the table
- the selected versions (blue background) don’t have any conflicts here
- three newer versions are incompatible with selected versions
elm/http 2.0.0 ;
krisajenkins/remotedata 6.0.0 and
- mouse pointer is over
krisajenkins/remotedata 6.0.1 which is incompatible with 7 versions, shown with red border
ps. All HTTP requests go to my php backend which enforces 24 hour caching. So while this app does make quite many requests, they should be cached quite nicely, and don’t cause much load to package.elm-lang.org
FYI there is an official Elm package for parsing
elm.json files: https://package.elm-lang.org/packages/elm/project-metadata-utils/1.0.0/.
Cool indeed! Seems to me it would be useful to have an export/download feature as well - you could play around with choosing different versions and then once you’re happy with it, download an updated
Yes, I’ve been thinking adding export/download.
First I need to decide how to handle test-dependencies which I don’t include yet. I’m thinking adding another yes/no selector for each package so packages can be moved between direct/indirect/direct-test/indirect-test.
After that I just need to add ability to add new packages and this could be used to generate elm.json from scratch.
Nice, I only searched if there was anything for determining package compatibility which is the hardest part (doesn’t seem to be), so I missed that.
Especially when adding download/export it’ll be good to use official decoder/encoder to make sure nothing is lost in conversion.
Constraint types there are opaque which doesn’t work well with compatibility-calculations, so I’ll probably still use my own instead of those. Also
Constraint doesn’t seem to have any way of getting min/max version, so I’m not sure if I can actually use that at all.
(EDIT: I just created an issue about this.)
Yeah, I saw that it was only a small part of your code.
If you have the time, it would be helpful if you created a github issue for the limitations on getting data out of the version constraints.
Very awesome project and very handy to figure out problems! Thank you.
Still I would love to see an elm implementation in https://github.com/vscode-contrib/vscode-versionlens
Which might be easy, I only looked at doing an implementation for elixir, which unfortunately isn’t very nice to parse, and thus I did stop working on it.
This is really useful, just wanted to say thanks for making it.
Awesome indeed. @malaire pointed me to this today when I was haviing weird dependency problems – got an instant diagnosis. A really valuable contribution to the ecosystem.
I agree, thanks for making it. The versioning in 0.19 got more difficult I think, because of locked down dependencies for applications. Your tools at least tells me what possible upgrade paths could look like. Thanks. I’ll be using it much.
There is download option now.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.