Elm-json: A tool for managing elm.json files

Hi all!

I’ve mentioned this in a few places already, and now it’s time for a more official announcement!

I’ve been working on elm-json, a tool for making elm.json management a little easier. Most of the current features are based on having a good version constraint solver, so it can offer somewhat helpful information when things go wrong.

Quick overview

USAGE:
    elm-json [FLAGS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
    -v, --verbose    Sets the level of verbosity

SUBCOMMANDS:
    help         Prints this message or the help of the given subcommand(s)
    install      Install a package
    new          Create a new elm.json file
    uninstall    Uninstall a package
    upgrade      Bring your dependencies up to date

Installation

npm i -g elm-json

What does it do?

It aims to make it easier to do fairly common things:

  • installing a specific version of a dependency (e.g. elm-json install elm/http@2.0.0)
  • removing dependencies and their indirect dependencies (e.g. elm-json uninstall foo/bar)
  • upgrading all your dependencies to their latest version with the same major version number (elm-json upgrade)
  • or upgrading while crossing major version boundaries (elm-json upgrade --unsafe)

Additionally, it also exposes some of the version solver for reuse in other tools. Specifically node-test-runner could benefit from this, to create a complete dependency graph given an elm.json for either a package or application, and ending up with a concrete set of direct and indirect dependencies with the test-dependencies in there as well.

It can also choose versions to be minimal rather than the default “newest versions that satisfy the constraints”, which could enable elm-test to test packages with both version at the lower end of the bounds as well as the higher end!

Show me the goods!

Okay, demoing a CLI isn’t that exciting. But hey, let’s see what happens when I try to upgrade the elm.json for an app!

Cool! How about major upgrades?

image

That seems to work, too!

Disclaimer

It’s still pretty new, and I’m still pretty new to Rust. It should not write to your files (except its own cache file) without permission, so it should be relatively safe to use, but if it ends up breaking in to your freezer and eating all your ice cream, please don’t scream at me. However, do log issues when things go wrong! -> https://github.com/zwilias/elm-json

64 Likes

Oooh it is written in rust - very nice :slightly_smiling_face:

2 Likes

Great work. It’s an extremely useful and necessary tool, thank you!

1 Like

3 Cheers!! A great addition to the Elm toolchain.

1 Like

<3 <3 <3
There is a <3 button but it didn’t seem enough ^^

1 Like

Minor update #1: elm-json tree

I’ve added a elm-json tree subcommand to list your entire dependency graph as a tree. If you’ve ever wondered where an indirect dependency actually comes from, this can help answer that question!

This is included in the v0.2.0 release - npm i -g elm-json to get your hands on it :wink:

Minor update #2: node-test-runner PR

In the first post, I mentioned how node-test-runner could benefit from the solve subcommand. So, to actually show how, I made a PR integrating elm-json solve into the node-test-runner, which should definitely help prevent issues with the dependencies generated by elm-test being incomplete or incorrect! https://github.com/rtfeldman/node-test-runner/pull/356

If people have come across more cases where elm-test gave a weird error about dependencies, please send me your elm.json so I can validate whether this PR actually fixes the issue for your situation as well!

15 Likes

Should be found on https://github.com/isRuslan/awesome-elm/blob/master/README.md#tools

Just used elm-json uninstall – it removed not only the package that I no longer needed, but also the dependencies of that package (minus dependencies used elsewhere). A VERRRY useful feature.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.