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

**URL:** <https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537>\
**Category:** Show and Tell\
**Created:** [April 23, 2019, 2:41pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537 "2019-04-23T14:41:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ilias](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ilias/32/6_2.png) [@ilias](https://discourse.elm-lang.org/u/ilias)\
**Post date:** [April 23, 2019, 2:41pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/1 "2019-04-23T14:41:36Z")

</div>

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`](https://github.com/zwilias/elm-json/blob/master/README.md), 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

```auto
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!

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/2/22ee160efa30657e522b04e3cdc688b599f55f95.png)

Cool! How about major upgrades?

![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/b/bfcfbaaf9044a5d8e8768834ebc7bee216b4cacc.png)

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](https://github.com/zwilias/elm-json)

---

<div class="post-metadata">

**Author:** ![harrysarson](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/harrysarson/32/1305_2.png) [@harrysarson](https://discourse.elm-lang.org/u/harrysarson)\
**Post date:** [April 23, 2019, 4:50pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/2 "2019-04-23T16:50:10Z")

</div>

Oooh it is written in rust - very nice 🙂

---

<div class="post-metadata">

**Author:** ![alexkorban](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/alexkorban/32/3242_2.png) [@alexkorban](https://discourse.elm-lang.org/u/alexkorban)\
**Post date:** [April 23, 2019, 11:23pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/3 "2019-04-23T23:23:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jxxcarlson](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jxxcarlson/32/866_2.png) [@jxxcarlson](https://discourse.elm-lang.org/u/jxxcarlson)\
**Post date:** [April 24, 2019, 11:15am UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/4 "2019-04-24T11:15:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mattpiz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mattpiz/32/860_2.png) [@mattpiz](https://discourse.elm-lang.org/u/mattpiz)\
**Post date:** [April 24, 2019, 11:25am UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/5 "2019-04-24T11:25:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ilias](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ilias/32/6_2.png) [@ilias](https://discourse.elm-lang.org/u/ilias)\
**Post date:** [April 27, 2019, 2:10pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/6 "2019-04-27T14:10:53Z")

</div>

# 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!

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/f/f476740d83b645a60216dd2c423993b6f150755e.jpeg)

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

# 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](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!

---

<div class="post-metadata">

**Author:** ![Namek](https://avatars.discourse-cdn.com/v4/letter/n/6a8cbe/32.png) [@Namek](https://discourse.elm-lang.org/u/Namek)\
**Post date:** [April 28, 2019, 1:21am UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/7 "2019-04-28T01:21:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jxxcarlson](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jxxcarlson/32/866_2.png) [@jxxcarlson](https://discourse.elm-lang.org/u/jxxcarlson)\
**Post date:** [May 5, 2019, 12:54pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/8 "2019-05-05T12:54:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [May 15, 2019, 12:54pm UTC](https://discourse.elm-lang.org/t/elm-json-a-tool-for-managing-elm-json-files/3537/9 "2019-05-15T12:54:06Z")

</div>

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