Code Monkey home page Code Monkey logo

elm-json's Introduction

CI Workflow npm version

Deal with your elm.json

NOTE: This is very much a work in progress. May mess up your files completely. Use with care.

elm-json provides a bunch of tools to make common tasks involving your elm.json files a little easier: upgrading your dependencies, installing specific versions of packages, removing dependencies or initializing new packages, to name a few.

elm-json never writes to files used by the official toolchain, except elm.json itself. It may, however, read some files from your ELM_HOME when possible, to prevent downloading things you may already have on your filesystem.

Installation

Binaries are attached to the github releases and distributed for Windows, OS X and Linux (statically linked with musl).

For ease of installation, an npm installer also exists:

npm install --global elm-json

Usage

elm-json offers a bunch of subcommands to make life a little easier.

elm-json help

USAGE:
    elm-json [FLAGS] <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
        --offline    Enable offline mode, which means no HTTP traffic will
                     happen
    -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
    tree         List entire dependency graph as a tree
    uninstall    Uninstall a package
    upgrade      Bring your dependencies up to date

Gives a quick overview of the more common subcommands. This can also be used for finding documentation about specific subcommands.

Adding dependencies: elm-json install

USAGE:
    elm-json install [FLAGS] <PACKAGE>... [-- <INPUT>]

FLAGS:
    -h, --help       Prints help information
        --test       Install as a test-dependency
    -V, --version    Prints version information
        --yes        Answer "yes" to all questions

ARGS:
    <PACKAGE>...    Package to install, e.g. elm/core or elm/[email protected]
    <INPUT>         The elm.json file to upgrade [default: elm.json]

elm-json install allows installing dependencies, at the latest version that works given your existing dependencies, or a particular version if you so choose. By adding the --test flag, the chosen package(s) will be added to your test-dependencies rather than your regular dependencies.

Example: Installing the latest available version of a package

elm-json install elm/http

Adds the latest version of elm/http to your dependencies.

For packages, it will use the latest possible version as the lowerbound, and the next major as the exclusive upper bound. This mirrors the behaviour of elm install.

For applications, this will pick the latest available version, adding all indirect dependencies as well.

Example: Installing the latest available 2.x.x version of a package

elm-json install elm/http@2

Adds the latest version of elm/http with 2 as its major version number to your dependencies.

Example: Installing as a test-dependency

elm-json install --test elm/[email protected]

Adds version 2.0.0 of elm/http to your test-dependencies.

For packages, the provided version is used as the lower bound, with the next major being used as the exclusive upper bound.

For applications, this will install exactly the specified version.

Example: Installing multiple dependencies to a specified elm.json file

elm-json install elm/http elm/json -- elm/elm.json

Add the latest possible versions of elm/http and elm/json to ./elm/elm.json.

Removing dependencies: elm-json uninstall

USAGE:
    elm-json uninstall [FLAGS] <PACKAGE>... [-- <INPUT>]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
        --yes        Answer "yes" to all questions

ARGS:
    <PACKAGE>...    Package to uninstall, e.g. elm/html
    <INPUT>         The elm.json file to upgrade [default: elm.json]

Uninstall dependencies. This is the inverse of elm-json install and its API is similar but slightly simpler.

Version bounds may not be specified and --test is not an allowed flag for this command.

Example: Uninstalling a package

elm-json uninstall elm/html

Removes the elm/html package from your dependencies.

Upgrading dependencies: elm-json upgrade

USAGE:
    elm-json upgrade [FLAGS] [INPUT]

FLAGS:
    -h, --help       Prints help information
        --unsafe     Allow major versions bumps
    -V, --version    Prints version information
        --yes        Answer "yes" to all questions

ARGS:
    <INPUT>    The elm.json file to upgrade [default: elm.json]

By default, this will only allow patch and minor changes for direct (test) dependencies.

When the --unsafe flag is provided, major version bumps are also allowed. Note that this may very well break your application. Use with care!

NOTE: This subcommand does not yet support elm.json files with type package.

Example: Safely updating all dependencies

elm-json upgrade

This command will check if any updates can safely be applied. In practice this means that for your direct dependencies and direct test-dependencies, we'll look for newer versions with the same major version number. Your indirect dependencies and indirect test-dependencies may be modified in more ways, depending on the constraints set by your direct dependencies.

Example: Major version upgrades for your dependencies

elm-json upgrade --unsafe

If major version changes are available, this will attempt to apply them. Note that this may still not update all dependencies to their latest release, if you have another dependency preventing to do so.

If you want to upgrade a specific package to a specific version, try running elm-json install author/project@version, which will tell you what package(s) are preventing this from happening.

Initializing applications/packages: elm-json new

USAGE:
    elm-json new

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

Create a new elm.json file, for applications or packages.

This is very rudimentary right now.

Deeply listing all dependencies: elm-json tree

USAGE:
    elm-json tree [FLAGS] [PACKAGE] [-- <INPUT>]

FLAGS:
    -h, --help       Prints help information
        --test       Promote test-dependencies to top-level dependencies
    -V, --version    Prints version information

ARGS:
    <PACKAGE>    Limit output to show path to some (indirect) dependency
    <INPUT>      The elm.json file to solve [default: elm.json]

Lists the entire dependency graph (with test-dependencies included when --test is passed) as a tree.

Example output:

project
├── elm/core @ 1.0.2
├── elm/http @ 1.0.0
│   ├── elm/core @ 1.0.2 *
│   └── elm/json @ 1.1.3
│       └── elm/core @ 1.0.2 *
├── elm-community/json-extra @ 4.0.0
│   ├── elm/core @ 1.0.2 *
│   ├── elm/json @ 1.1.3 *
│   ├── elm/time @ 1.0.0
│   │   └── elm/core @ 1.0.2 *
│   └── rtfeldman/elm-iso8601-date-strings @ 1.1.3
│       ├── elm/core @ 1.0.2 *
│       ├── elm/json @ 1.1.3 *
│       ├── elm/parser @ 1.1.0
│       │   └── elm/core @ 1.0.2 *
│       └── elm/time @ 1.0.0 *
└── lukewestby/elm-http-builder @ 6.0.0
    ├── elm/core @ 1.0.2 *
    ├── elm/http @ 1.0.0 *
    ├── elm/json @ 1.1.3 *
    ├── elm/time @ 1.0.0 *
    └── elm/url @ 1.0.0
        └── elm/core @ 1.0.2 *

Items marked with * have their dependencies ommitted since they've already
appeared in the output.

Specifying a package-name will filter the tree so only paths leading to the specified package, in direct and indirect dependencies, will be shown.

For tooling: elm-json solve

USAGE:
    elm-json solve [FLAGS] [OPTIONS] [--] [INPUT]

FLAGS:
    -h, --help        Prints help information
    -m, --minimize    Choose lowest available versions rather than highest
        --test        Promote test-dependencies to top-level dependencies
    -V, --version     Prints version information

OPTIONS:
    -e, --extra <PACKAGE>...    Specify extra dependencies, e.g. elm/core or
                                elm/[email protected]

ARGS:
    <INPUT>    The elm.json file to solve [default: elm.json]

Documentation TBD. Intended for other tooling to use, not meant for human consumption.

Generating shell completions: elm-json completions

USAGE:
    elm-json completions <SHELL>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <SHELL>    The shell to generate the script for [possible values: bash,
               fish, zsh]

Create completion scripts for elm-json for bash/fish/zsh.

elm-json's People

Contributors

dependabot[bot] avatar harrysarson avatar mikeastock avatar zwilias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elm-json's Issues

Terminal cursor disappears if ctrl+c during `elm-json upgrade`

  1. Run elm-json upgrade.
  2. When asked “Should I make these changes? [Y/n]”, press ctrl+c.

Result: The command is exited as expected, but the terminal cursor is now gone.
Expected: The command is exited and the cursor shows as usual.

Possible fix: Listen to kill signals and reset terminal ANSI stuff.

"MISSING ELM.JSON" error at root of project

I ran elm-json upgrade supermacro/elm-antd at the root of my project (see the below directory structure diagram) and got the following error:

-- MISSING ELM.JSON ------------------------------------------------------------

No such file or directory (os error 2)

But as you can see from the below diagram, the elm.json is there.

Directory Structure:

.
├── README.md
├── elm-analyse.json
├── elm-stuff
├── elm.json
├── node_modules
├── package-lock.json
├── package.json
├── postcss.config.js
├── renovate.json
├── src
└── webpack.config.js

Interestingly, elm-json tree does work.

elm-json upgrade copies elm-explorations/test from test-dependencies to dependencies

Initial elm.json:

{
    "type": "application",
    "source-directories": [
        ".",
        "../ca-three-sixty-common",
        "../../../../lib/client/modules/ca-ui",
        "../../../../lib/client/modules/ca-utils",
        "../../../../node_modules/elm-upgrade-shims/lib-0.19",
        "../../../../node_modules/@kaizen/component-library/components"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "CurrySoftware/elm-datepicker": "4.0.0",
            "NoRedInk/elm-json-decode-pipeline": "1.0.0",
            "cultureamp/elm-css-modules-loader": "2.0.10",
            "danyx23/elm-uuid": "2.1.2",
            "elm/browser": "1.0.2",
            "elm/core": "1.0.5",
            "elm/html": "1.0.0",
            "elm/http": "1.0.0",
            "elm/json": "1.1.3",
            "elm/random": "1.0.0",
            "elm/svg": "1.0.1",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm-community/dict-extra": "2.4.0",
            "elm-community/easing-functions": "2.0.0",
            "elm-community/html-extra": "3.4.0",
            "elm-community/json-extra": "4.2.0",
            "elm-community/list-extra": "8.2.4",
            "elm-community/maybe-extra": "5.2.0",
            "elm-community/string-extra": "4.0.1",
            "elm-community/typed-svg": "6.0.0",
            "fapian/elm-html-aria": "1.4.0",
            "jamesmacaulay/elm-graphql": "2.0.0",
            "justinmimbs/date": "3.2.0",
            "justinmimbs/time-extra": "1.1.0",
            "krisajenkins/remotedata": "5.0.0",
            "mdgriffith/elm-style-animation": "4.0.0",
            "rtfeldman/elm-iso8601-date-strings": "1.1.3",
            "truqu/elm-dictset": "2.1.0",
            "y0hy0h/ordered-containers": "1.0.0"
        },
        "indirect": {
            "avh4/elm-color": "1.0.0",
            "elm/parser": "1.1.0",
            "elm/regex": "1.0.0",
            "elm/virtual-dom": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}

Ran yarn elm-json upgrade --yes ./path/to/elm.json.

Console output:

-- PACKAGE UPGRADES FOUND ------------------------------------------------------

I want to make some changes to your direct dependencies

- [CHG] justinmimbs/date 3.2.0 -> 3.2.1

I want to make some changes to your indirect dependencies

- [ADD] elm-explorations/test 1.2.2

Saved updated elm.json!

Resulting elm.json:

{
    "type": "application",
    "source-directories": [
        ".",
        "../ca-three-sixty-common",
        "../../../../lib/client/modules/ca-ui",
        "../../../../lib/client/modules/ca-utils",
        "../../../../node_modules/elm-upgrade-shims/lib-0.19",
        "../../../../node_modules/@kaizen/component-library/components"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "CurrySoftware/elm-datepicker": "4.0.0",
            "NoRedInk/elm-json-decode-pipeline": "1.0.0",
            "cultureamp/elm-css-modules-loader": "2.0.10",
            "danyx23/elm-uuid": "2.1.2",
            "elm/browser": "1.0.2",
            "elm/core": "1.0.5",
            "elm/html": "1.0.0",
            "elm/http": "1.0.0",
            "elm/json": "1.1.3",
            "elm/random": "1.0.0",
            "elm/svg": "1.0.1",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm-community/dict-extra": "2.4.0",
            "elm-community/easing-functions": "2.0.0",
            "elm-community/html-extra": "3.4.0",
            "elm-community/json-extra": "4.2.0",
            "elm-community/list-extra": "8.2.4",
            "elm-community/maybe-extra": "5.2.0",
            "elm-community/string-extra": "4.0.1",
            "elm-community/typed-svg": "6.0.0",
            "fapian/elm-html-aria": "1.4.0",
            "jamesmacaulay/elm-graphql": "2.0.0",
            "justinmimbs/date": "3.2.1",
            "justinmimbs/time-extra": "1.1.0",
            "krisajenkins/remotedata": "5.0.0",
            "mdgriffith/elm-style-animation": "4.0.0",
            "rtfeldman/elm-iso8601-date-strings": "1.1.3",
            "truqu/elm-dictset": "2.1.0",
            "y0hy0h/ordered-containers": "1.0.0"
        },
        "indirect": {
            "avh4/elm-color": "1.0.0",
            "elm/parser": "1.1.0",
            "elm/regex": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "elm-explorations/test": "1.2.2"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}

We've been seeing this consistently with elm-json 0.2.6, and we're still seeing it with 0.2.7.

Confusing message if offline and elm-json can’t find stuff locally?

Steps to reproduce:

  1. Go to any folder with a valid elm.json where elm-json solve elm.json usually succeeds. The one created by elm init is fine for testing.

  2. Either:

    • Run ELM_HOME=does/not/exist elm-json --offline solve elm.json
    • Disconnect from the Internet and run ELM_HOME=does/not/exist elm-json solve elm.json

Example result:

-- NO VALID PACKAGE VERSION ----------------------------------------------------

Because elm/core does not appear to exist and this project depends on
elm/core 1.0.2 <= v < 2.0.0, no valid set of package versions could be
found.

When the --offline flag isn’t used this is also printed before the above:

phase: retrieve
 Oct 17 11:10:47.817 WARN Failed to fetch versions from package.elm-lang.org

So in that case there’s at least a clue that the failure might be due to connectivity issues.

At least for this --offline case, would it be possible to have the error say something like this?

There’s not enough information locally to solve the dependencies. I need to look at package.elm-lang.org to get more information, but I can’t do that when --offline is used.

That message could work for connectivity issues as well, with some tweaks:

There’s not enough information locally to solve the dependencies. I tried to look at package.elm-lang.org to get more information, but doing so failed with the following message: ...

elm-json version: 0.2.8

Maybe related note: elm-json --offline solve elm.json consistently failed for me at work, even though I had just run elm-json solve elm.json successfully right before. Removing ~/.elm/elm-json and running elm-json solve elm.json once more solved the problem – now --offline succeeds. I still have a backup of the old ~/.elm/elm-json if you feel like taking a look at it.

Point is, I was playing around with elm-json --offline to learn more about how it works and was confused by the output I got. You might have better ideas around this.

Edit: Or maybe this is the expected output, it just takes a little learning to understand why.

thread 'main' panicked at 'IndexMap: key not found with `elm-json upgrade --unsafe`

I get the following error when running elm-json upgrade --unsafe with my elm.json:

$ elm-json upgrade --unsafe
thread 'main' panicked at 'IndexMap: key not found', /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/indexmap-1.0.2/src/map.rs:1654:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

This is with version 0.2.6:

$ elm-json --version
elm-json 0.2.6

This can be reproduced with the following elm.json, note that it works correctly without the --unsafe:

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "Chadtech/elm-bool-extra": "2.4.0",
            "Garados007/elm-svg-parser": "1.0.0",
            "NoRedInk/elm-compare": "2.0.0",
            "NoRedInk/elm-random-pcg-extended": "1.0.0",
            "NoRedInk/elm-uuid": "2.0.0",
            "Skinney/murmur3": "2.0.8",
            "avh4/elm-color": "1.0.0",
            "cuducos/elm-format-number": "7.0.0",
            "dillonkearns/elm-graphql": "4.5.0",
            "dmy/elm-pratt-parser": "2.0.0",
            "elm/browser": "1.0.2",
            "elm/bytes": "1.0.8",
            "elm/core": "1.0.4",
            "elm/file": "1.0.5",
            "elm/html": "1.0.0",
            "elm/http": "2.0.0",
            "elm/json": "1.1.3",
            "elm/parser": "1.1.0",
            "elm/svg": "1.0.1",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm-community/basics-extra": "4.0.0",
            "elm-community/dict-extra": "2.4.0",
            "elm-community/json-extra": "4.2.0",
            "elm-community/list-extra": "8.2.2",
            "elm-community/maybe-extra": "5.1.0",
            "elm-community/string-extra": "4.0.1",
            "folkertdev/one-true-path-experiment": "4.0.3",
            "gampleman/elm-visualization": "2.0.1",
            "justinmimbs/date": "3.2.0",
            "justinmimbs/time-extra": "1.1.0",
            "justinmimbs/timezone-data": "2.1.4",
            "mdgriffith/elm-ui": "1.1.0",
            "newmana/chroma-elm": "16.0.3",
            "rtfeldman/elm-hex": "1.0.0",
            "rtfeldman/elm-iso8601-date-strings": "1.1.3",
            "ryannhg/date-format": "2.3.0"
        },
        "indirect": {
            "NoRedInk/elm-random-general": "1.0.0",
            "andre-dietrich/parser-combinators": "3.2.0",
            "elm/random": "1.0.0",
            "elm/regex": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "folkertdev/elm-deque": "3.0.1",
            "folkertdev/svg-path-lowlevel": "3.0.0",
            "ianmackenzie/elm-float-extra": "1.1.0",
            "ianmackenzie/elm-geometry": "1.2.1",
            "ianmackenzie/elm-interval": "1.0.1",
            "ianmackenzie/elm-triangular-mesh": "1.0.3",
            "lukewestby/elm-string-interpolate": "1.0.4",
            "mgold/elm-nonempty-list": "4.0.2",
            "myrho/elm-round": "1.0.4",
            "pilatch/flip": "1.0.0"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}

Running with RUST_BACKTRACE does not give much more information:

$ RUST_BACKTRACE=1 elm-json upgrade --unsafe
thread 'main' panicked at 'IndexMap: key not found', /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/indexmap-1.0.2/src/map.rs:1654:13
stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
$ RUST_BACKTRACE=full elm-json upgrade --unsafe
thread 'main' panicked at 'IndexMap: key not found', /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/indexmap-1.0.2/src/map.rs:1654:13
stack backtrace:
   0:           0x578dee - <unknown>
   1:           0x49f49c - <unknown>
   2:           0x578476 - <unknown>
   3:           0x578157 - <unknown>
   4:           0x577a90 - <unknown>
   5:           0x4e6764 - <unknown>
   6:           0x52ae42 - <unknown>
   7:           0x51ffd6 - <unknown>
   8:           0x4b6d21 - <unknown>
   9:           0x4bcab3 - <unknown>
  10:           0x4a9a3a - <unknown>

Won't run on Elm 0.19.1

 $ pwd
/Users/carlson/dev/elm/mylibraries/elm-text-editor2/demo
 $ elm-json upgrade

-- NO VALID PACKAGE VERSION ----------------------------------------------------

Because Elm 0.19.1 is unavailable and this project depends on Elm
0.19.1, no valid set of package versions could be found.

Support modifying source-directories

In certain build setups, modifying the source-directories to swap out configuration of i18n modules is a pretty common occurrence. Some way to make this nice and accessible while allowing for e.g. ENV variables to be used would be pretty neat!

Perhaps this can tie into a "template" idea?

Dependency Update

Hey JIm,

Would it be difficult to upgrade the elm-geometry dependency? I'm hoping it's a dependency spec update, but maybe there have been API changes.

I'm getting this dependency conflict when trying to use the latest Stat module:

-- NO VALID PACKAGE VERSION ----------------------------------------------------

Because gampleman/elm-visualization 2.3.0 depends on ianmackenzie/elm-geometry
3.6.0 <= v < 4.0.0 and jxxcarlson/elm-stat 5.0.0 depends on ianmackenzie/elm-
geometry 1.2.1 <= v < 2.0.0, gampleman/elm-visualization 2.3.0 is incompatible with
jxxcarlson/elm-stat 5.0.0.

And because gampleman/elm-visualization 2.3.0 is incompatible with
jxxcarlson/elm-stat 5.0.0 and this project depends on gampleman/elm-
visualization 2.3.0, no valid set of package versions could be found.

Thanks!

Installing devDependencies does not remove them from indirect dependencies

Summary

When you install things using elm-json --test you do not get the same results as elm-test install or elm-test init when the dependency to be installed is already in the indirect dependencies.

Explanation

In elm-review, when you run elm-review init we generate the following empty JSON

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.2",
            "elm/json": "1.1.3"
        },
        "indirect": {}
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

then run

elm-json install --yes jfmengels/elm-review@2 stil4m/elm-syntax@7 elm/project-metadata-utils@1 -- <pathToElmJson>

(thanks again for implementing the @major version a few months ago! ❤️ )

and that gives us

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.2",
            "elm/json": "1.1.3",
            "elm/project-metadata-utils": "1.0.1",
            "jfmengels/elm-review": "2.0.0",
            "stil4m/elm-syntax": "7.1.1"
        },
        "indirect": {
            "elm/html": "1.0.0",
            "elm/parser": "1.1.0",
            "elm/random": "1.0.0",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "elm-community/json-extra": "4.2.0",
            "elm-community/list-extra": "8.2.3",
            "elm-explorations/test": "1.2.2",
            "rtfeldman/elm-hex": "1.0.0",
            "rtfeldman/elm-iso8601-date-strings": "1.1.3",
            "stil4m/structured-writer": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

Notice ⬆️ that "elm-explorations/test": "1.2.2" has been added to indirect dependencies. That is because jfmengels/elm-review provides test helpers and as elm-explorations/test as a dependency.

Because I wanted to make it as easy as possible to get started writing tests for elm-review rules (things that you make with the library), I pre-add elm-explorations/test using

elm-json install --test --yes elm-explorations/test@1 -- <pathToElmJson>

and that gives the following elm.json

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.5",
            "elm/json": "1.1.3",
            "elm/project-metadata-utils": "1.0.1",
            "jfmengels/elm-review": "2.0.0",
            "stil4m/elm-syntax": "7.1.1"
        },
        "indirect": {
            "elm/html": "1.0.0",
            "elm/parser": "1.1.0",
            "elm/random": "1.0.0",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "elm-community/json-extra": "4.2.0",
            "elm-community/list-extra": "8.2.3",
            "elm-explorations/test": "1.2.2",
            "rtfeldman/elm-hex": "1.0.0",
            "rtfeldman/elm-iso8601-date-strings": "1.1.3",
            "stil4m/structured-writer": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}

So everything looks good, except that elm-explorations/test is still in the indirect dependencies, and also in the direct dependencies, which elm-test doesn't like when it is running.

-- ERROR IN DEPENDENCIES ---------------------------------------------- elm.json

It looks like the dependencies elm.json in were edited by hand (or by a 3rd
party tool) leaving them in an invalid state.

Try to change them back to what they were before! It is much more reliable to
add dependencies with elm install or the dependency management tool in
elm reactor.

Please ask for help on the community forums if you try those paths and are still
having problems!

When you run elm-test init, elm-test removes elm-explorations/test from the indirect dependencies and adds it to the direct devDependencies. Then, running tests work.

You get the following elm.json:

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.2",
            "elm/json": "1.1.3",
            "elm/project-metadata-utils": "1.0.1",
            "jfmengels/elm-review": "2.0.0",
            "stil4m/elm-syntax": "7.1.1"
        },
        "indirect": {
            "elm/html": "1.0.0",
            "elm/parser": "1.1.0",
            "elm/random": "1.0.0",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2",
            "elm-community/json-extra": "4.2.0",
            "elm-community/list-extra": "8.2.3",
            "rtfeldman/elm-hex": "1.0.0",
            "rtfeldman/elm-iso8601-date-strings": "1.1.3",
            "stil4m/structured-writer": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {
            "elm-explorations/test": "1.2.2"
        },
        "indirect": {}
    }
}

Certificate Expired error when connecting to package.elm-lang.org via elm-json

I started to recieve "Failed to fetch versions from package.elm-lang.org" errors when running elm-json.

❯ /elm-json -vv solve
phase: retrieve
 Nov 22 16:41:31.931 DEBG Fetching versions since 0
 Nov 22 16:41:32.285 WARN Failed to fetch versions from package.elm-lang.org
phase: resolve
 Nov 22 16:41:32.287 INFO beginning dependency resolution
phase: retrieve
 Nov 22 16:41:32.287 DEBG Finding best version for package root with constraint 1.0.0
 Nov 22 16:41:32.293 DEBG Finding best version for package NoRedInk/elm-json-decode-pipeline with constraint 1.0.0
phase: resolve
 Nov 22 16:41:32.294 INFO Failed to add package NoRedInk/elm-json-decode-pipeline 1.0.0: Unknown package NoRedInk/elm-json-decode-pipeline
 Nov 22 16:41:32.294 INFO solve failed

-- NO VALID PACKAGE VERSION ----------------------------------------------------

Because NoRedInk/elm-json-decode-pipeline does not appear to exist and this
project depends on NoRedInk/elm-json-decode-pipeline 1.0.0, no valid set of
package versions could be found.
  • I can connect to package.elm-lang.org in my browsers and other command line clients well
  • I used Wireshark to understand what went wrong. I saw that the elm-json client got a Certificate Expired error.
  • All other client softwares and Keychain Access showed a valid certificate though. It's only elm-json somehow that fails.
  • I compiled elm-json on my computer to see if that makes any difference, but I still get the error.
  • I even wrote my first Rust program to see if there's anything Rust specific here. I simply fetched the JSON and printed out to the console, and it worked.

Screenshot 2021-11-22 at 16 12 00

Too-long `elm.json` `"summary"` is reported as invalid package name

I tried to install a package on a new project and got this error:

-- INVALID ELM.JSON ------------------------------------------------------------

A valid package name look like "author/project"

The "name" in my elm.json looked fine, so I wasn't sure what the problem was. I then tried to install the same package with the elm executable and got this error:

-- SUMMARY TOO LONG --------------------------------------------------- elm.json

I got stuck while reading your elm.json file. Your "summary" is too long:

...

I need it to be under 80 bytes so it renders nicely on the package website!

Note: I count the length in bytes, so using non-ASCII characters costs extra.
Please report your case at https://github.com/elm/compiler/issues if this seems
overly restrictive for your needs.

0.19.1 support

In order to support 0.19.1 when it is released, we need to take care of a few nits:

  • add 0.19.1 as a known elm version
  • figure out lookup paths for cached files (currently hardcoded to 0.19.0)

error with specific package

elm$ elm-json tree
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Json(Error("Invalid range: 0.19.0 <= v <= 0.20.0", line: 10, column: 43)), url: None }', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

I tried stripping everything out except this one package that seems to be causing the error

elm$ cat elm.json
{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.0",
    "dependencies": {
        "direct": {
            "andre-dietrich/parser-combinators": "3.1.1"
        },
        "indirect": {
        }
    },
    "test-dependencies": {
        "direct": {
        },
        "indirect": {
        }
    }
}

Here is the output with RUST_BACKTRACE=1

elm$ RUST_BACKTRACE=1 elm-json tree
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { kind: Json(Error("Invalid range: 0.19.0 <= v <= 0.20.0", line: 10, column: 43)), url: None }

stack backtrace:
   0: <unknown> (0x10237b6a6)
   1: <unknown> (0x10237ba18)
   2: <unknown> (0x10237b409)
   3: <unknown> (0x102146913)
   4: <unknown> (0x102120893)
   5: <unknown> (0x102117ba5)
   6: <unknown> (0x1020ea79f)
   7: <unknown> (0x1024120f8)
   8: <unknown> (0x102409415)
   9: _main (0x10240ff38)', src/libcore/result.rs:997:5
stack backtrace:
   0: start
   1: start
   2: start
   3: start
   4: start
   5: start
   6: start
   7: start
   8: start
   9: start
  10: main
  11: start
  12: main

Support for upgrading code with packages

I'd like to establish a convention such that if a package contains an upgrade/Upgrade.elm file at the top level, than the package indicates that it can automatically update user code along with itself. This is at the moment best achieved via elm-review. Such an Upgrade.elm file would contain a dictionary of source versions to review configurations. The proposal would be that elm-json would detect when a user wishes to upgrade such a package and would offer the user to also modify their codebase. It would do this by dynamically generating an elm-review configuration based on the users current version of the dependency, then running elm-review --fix-all.

`elm-json install --yes ...` sporadically gets stuck on macOS 11 and 10.15

In Homebrew, we have seen commands like elm-json install elm/browser@1 --yes sporadically get stuck on macOS 11 (Big Sur) and 10.15 (Catalina). Haven't tried older macOS. So far, we haven't seen it fail on macOS 12 (Monterey) or 13 (Ventura)

Originally this issue was seen while building unisonlang (Homebrew/homebrew-core#105842) which runs elm-json (https://github.com/unisonweb/unison-local-ui/blob/release/M4e/scripts/ui-core.js#L6). At that time, I was able to find the problematic command was elm-json but it stalled without any meaningful output.

I have tried debugging further in Homebrew/homebrew-core#117735 and was able to reproduce issue with TRACE logging (https://github.com/Homebrew/homebrew-core/actions/runs/3656429004/jobs/6190012945#step:6:5028)

Logs for elm-json -v -v -v install --yes elm/browser@1
  2022-12-10T00:05:01.927259Z DEBUG elm_json::package::retriever: Fetching versions since 0
  2022-12-10T00:05:01.928234Z DEBUG agent_thread{id=0}: isahc::agent: agent took 578.5µs to start up
  2022-12-10T00:05:01.928746Z TRACE agent_thread{id=0}:poll_messages:handle_message{Execute(Easy { handle: 0x15c00d600, handler: RequestHandler })}: isahc::agent: received message from agent handle
  2022-12-10T00:05:02.059321Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=false writable=true
  2022-12-10T00:05:02.090323Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.142090Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.192596Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.193501Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 8095 bytes of data
  2022-12-10T00:05:02.193731Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 8136 bytes of data
  2022-12-10T00:05:02.193884Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.212297Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.251924Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.252292Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 56 bytes of data
  2022-12-10T00:05:02.252418Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4096 bytes of data
  2022-12-10T00:05:02.252491Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 8192 bytes of data
  2022-12-10T00:05:02.252588Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4016 bytes of data
  2022-12-10T00:05:02.252706Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:02.252975Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4176 bytes of data
  2022-12-10T00:05:02.253048Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 8192 bytes of data
  2022-12-10T00:05:02.256888Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:02.256976Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12192 bytes of data
  2022-12-10T00:05:03.267341Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:03.267712Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4192 bytes of data
  2022-12-10T00:05:03.267822Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 8192 bytes of data
  2022-12-10T00:05:03.267900Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 3984 bytes of data
  2022-12-10T00:05:03.268203Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4208 bytes of data
  2022-12-10T00:05:03.268274Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 8192 bytes of data
  2022-12-10T00:05:03.273271Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:03.273376Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12160 bytes of data
  2022-12-10T00:05:04.283848Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:04.284273Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4224 bytes of data
  2022-12-10T00:05:04.284389Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12152 bytes of data
  2022-12-10T00:05:04.284705Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:04.284816Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:04.285081Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4232 bytes of data
  2022-12-10T00:05:04.285153Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12144 bytes of data
  2022-12-10T00:05:04.288938Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:04.289009Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12144 bytes of data
  2022-12-10T00:05:05.294020Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:05.294442Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:05.294799Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4240 bytes of data
  2022-12-10T00:05:05.294875Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12136 bytes of data
  2022-12-10T00:05:05.294983Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:05.295258Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:05.295358Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:05.295650Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4248 bytes of data
  2022-12-10T00:05:05.311961Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:05.312053Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16375 bytes of data
  2022-12-10T00:05:06.322475Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:06.322906Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:06.323259Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:06.323374Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:06.323654Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:06.323752Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:06.324025Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4257 bytes of data
  2022-12-10T00:05:06.324102Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12118 bytes of data
  2022-12-10T00:05:06.340603Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:06.340700Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12118 bytes of data
  2022-12-10T00:05:07.351131Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:07.351550Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:07.351899Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:07.352003Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:07.352275Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:07.352379Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:07.352650Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4266 bytes of data
  2022-12-10T00:05:07.352729Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12110 bytes of data
  2022-12-10T00:05:07.369231Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:07.369331Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12110 bytes of data
  2022-12-10T00:05:08.379818Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:08.380231Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:08.380582Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 4274 bytes of data
  2022-12-10T00:05:08.380657Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12102 bytes of data
  2022-12-10T00:05:08.380764Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:08.381042Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 12474 bytes of data
  2022-12-10T00:05:08.381115Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 3901 bytes of data
  2022-12-10T00:05:08.397752Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:08.397836Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 3901 bytes of data
  2022-12-10T00:05:09.398642Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:09.399109Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:09.399462Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:09.399577Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:09.399870Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:09.399967Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:09.400240Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 16384 bytes of data
  2022-12-10T00:05:09.400340Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false
  2022-12-10T00:05:09.400492Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 6278 bytes of data
  2022-12-10T00:05:09.416539Z TRACE agent_thread{id=0}:poll_messages:handle_message{UnpauseWrite(0)}: isahc::agent: received message from agent handle
  2022-12-10T00:05:09.416623Z TRACE send{method=GET uri=https://package.elm-lang.org/all-packages/since/0}:handler{id=0}:write: isahc::handler: received 6278 bytes of data

After the final line, it appears to be stuck and only stops when I force fail with a timeout. Otherwise, it appears to remain stuck indefinitely. This caused Homebrew CI to block for about 1 day until manually cancelled.

Had tried both pre-built binary fetched via npm and a locally built copy of elm-json.

Request ability to specify latest version of a major version of a package

Hi!

I'd like to request the ability to install the latest version of a major release of a dependency. In other words, I'd like to be able to do elm-json install author/name@2, or the equivalent of npm install something@^2 in npm.

Request context

I am the author elm-review, which is a library and CLI, and the CLI uses elm-json under the hood (thanks a lot for this tool, by the way ❤️).

elm-review works using a configuration written in Elm, where it defines the review rules to enable. Some of which are defined in local files, and the rest are found in Elm packages, such as this one.

To avoid polluting the project's elm.json (and potentially blocking the install of their dependencies), the configuration is in the review/ directory of their project, which has a Config.elm file and an elm.json file.

When running the actual review, it in essence copies the review/ folder somewhere in elm-stuff and compiles a new application by merging the user configuration and Elm code contained and specific to the CLI, using the source-directories and the dependencies found in review/elm.json.

To help onboard the user, the CLI provides an init command, where it will create the review/ directory with an empty configuration file and an elm.json, and will install the jfmengels/elm-review package using elm-json install jfmengels/elm-review.

That last section is where my problem resides. The code contained CLI application works for/with a specific version of this package (1.0.0 <= v < 2.0.0), but when running init, it will install the latest released version, potentially 2.0.0 or later. In effect, the day I release v2.0.0, all the existing init with the CLI that supports only v1.x.x will stop working correctly.

Proposed solution

The solutions I could think of with are:

  1. Specifying in the CLI the exact version of jfmengels/elm-review that will work (ex: 1.3.4), but that makes it necessary to release a new version of the CLI every time I release the package, which is not great.

  2. Have elm-json support a syntax like elm-json install author/name@1

  3. Have the CLI fetch the contents of the package registry, find out the latest version of the package of the major release I wish to support, and install that one (basically reimplement elm-json solve I think?)

I think I will go with solution 3, but maybe solution 2 is an easy and welcome (to you) addition to elm-json.

I don't know the exact reason for elm install not supporting this option in the first place. I am guessing it is because this is quite a rare edge-case.

Let met know what you think :)

Add `tree` command

This would work quite similar to solve in that it just solves the constraints, but rather than showing the flattened tree, it could show the entire DAG as a tree.

This can help in figuring out where an indirect dependency actually comes from.

Make solver errors more readable

Solver errors are manageable, but readability could be much improved:

  • some bold text for highlighting relevant parts
  • be smarter about which package is being added?
  • can we suggest ways to resolve issues?
  • some degenerate cases like elm-json install elm-lang/core on an 0.19 project are pretty bad

Add `elm-json outdated` command

It'd be useful for us to add a elm-json outdated command, which shows the same information as elm-json upgrade --unsafe (i.e. which packages are outdated), but doesn't prompt whether the upgrade should be performed.

This would be similar to npm outdated or pip list --outdated.

A simpler alternative would be to just add a --no command line argument to elm-json upgrade, which just answers "no" to all questions. (In addition to the already existing --yes argument.

Elm-json occasionally gets stuck, particularly when called from elm-review

While investigating an issue with elm-review getting stuck, I discovered that the underlying cause was elm-json becoming stuck when it was called in elm-review. Specifically, the issue occurs on isahc::get(url) in the fetch_remote_versions function. Once this happens, as terminating the elm-review process does not kill the elm-json process, it continues to fail on lock.exclusive() in the fetch_versions() function until all elm-json processes are manually terminated. And even if terminated, isahc::get usually continues to fail for some reason.

When it is stuck on isahc::get, the trace is like this.

> pkill elm
...
> ~/elm-json/target/debug/elm-json -v -v -v -v solve frontend/elm.json
2023-04-12T09:48:40.545177Z DEBUG elm_json::package::retriever: Fetching versions since 0
2023-04-12T09:48:40.546279Z DEBUG agent_thread{id=0}: isahc::agent: agent took 570.513µs to start up
2023-04-12T09:48:40.547415Z TRACE agent_thread{id=0}:poll_messages:handle_message{Execute(Easy { handle: 0x7f9d98811600, handler: RequestHandler })}: isahc::agent: received message from agent handle
2023-04-12T09:48:40.599818Z TRACE agent_thread{id=0}: isahc::agent: socket event socket=11 readable=true writable=false

I could successfully request https://package.elm-lang.org/all-packages/since/0 from my browser, so I'm unsure why elm-json is experiencing this problem.

Elm-review calls elm-json in this manner: /Users/tsukimizake/.elm/elm-tooling/elm-json/0.2.13/elm-json solve --extra elm/json@1 stil4m/elm-syntax@7 elm/project-metadata-utils@1 MartinSStewart/elm-serialize@1 -- /Users/tsukimizake/my-app/frontend/elm.json . The relevant code can be found here (spawnElmJsonAsync).

It appears that someone else has encountered a similar issue, as described in this post: https://elmlang.slack.com/archives/C010RT4D1PT/p1680266273643779.

Does anyone have any ideas about why this might be happening? Alternatively, could we consider implementing a timeout for the GET request to address the issue?

My environment is:
macOS 12.6.5 (Intel MacBook Pro 2019)
node v16.19.1

Provide mode to tighten version ranges on packages.

There is an issue on elm-test, where it fails to resolve versions when the declared version range in a package is wider than it should be:

rtfeldman/node-test-runner#277

The suggested fix there is simply for elm-test to provide a better error message to diagnose the issue, rather than for it to resolve the ranges itself and therefore mask an issue.

It is not incorrect for a package elm.json to declare a wider version range than its transitive dependencies really need, but it is good practice for it declare the correct range.

It would seem that an option could be added to elm-json to perform this automatically? For example:

elm-json tighten

Run the solver then update the declared versions in the dependencies to the actual correct ranges that the package will build against.

Improve CI/CD setup

Goals:

  • always run tests on osx, linux and windows
  • actually have tests 😅
  • only build when deployment is happening
  • leverage cargo caching to speed up tests (this likely won't help much)

No newline at end of file

hi! thanks for this project.

after uninstalling a couple dependencies, git diff reports my changes which include

Screen Shot 2020-04-28 at 12 19 40 PM

it seems like elm produces an elm.json which includes a trailing newline, but this project does not include the newline. maybe i'll dig in and send you a PR

Actually deal with errors

IO errors, for example, end up being dumped out, rather than being properly handled and showing an informative message

Feature proposition: `elm-json merge` when vendoring elm packages

I was just debugging a library and vendored it into my app to test the changes I made. For that I downloaded the library's source code and referenced it in my elm.json's src-directories. But I had to manually figure out which dependencies I needed to add to my app's elm.json.

With that use case in mind, I would propose an elm-json merge command which takes two elm.json and figures out which dependencies of the first need to be installed in the second. Usage could look like elm-json merge --from ../library/elm.json --into ./elm.json.

Is this a feature that would fit this utility?

Suggestion: Indicate why a package is not updated to the latest version

A problem that can be quite opaque to the user when using elm-json to upgrade dependencies, is when you don't get the latest version.

For instance, if you're using jfmengels/elm-review v2.9.0 and elm-explorations/test v1, then attempting to upgrade the latest will only yield the v2.9.1 version, because starting from v2.10.0, the package depends on elm-explorations/test v2.

I have seen a lot of confusion as to why people were not getting the most recent version, and I myself get confused in different situations, in which case I resort to this tool (https://www.markuslaire.com/github/elm-dependencies-analyzer/) to figure out the problem.

I think it could be interesting to explain — when upgrading to not the last version — why the upgrade was held back to a prior version.

I think that this could be challenging to explain in a clear way, but it could be worth it. A first stab could look like this:

npx elm-json install jfmengels/elm-review@2
-- PACKAGE CHANGES READY -------------------------------------------------------

I want to make some changes to your direct dependencies

  • [CHG] jfmengels/elm-review 2.6.2 -> 2.9.1

A newer version of jfmengels/elm-review (2.10.0) exists, but it depends on

  • elm-explorations/test 2.0.1 <= v < 3.0.0
    while you're depending on
  • elm-explorations/test v1.0.0

To upgrade to the latest version, you could upgrade all of these, by running

Should I make these changes anyway?

(cc @mpizenberg who might also be interested in this kind of issue)

Structure and flesh out readme

For each and every command, I'd like to include a few examples.

The risk of overwhelming with too much information is real, so it should be easy to navigate the readme:

  • a table of contents
  • a short overview of the flags for every command
  • titles for every example to illustrate the use-case

The goal is to balance "I know what I'm looking for but forgot the exact incantation" with "I know what I want to do but now how".

Consider a more distinct name

Hey there,

I'm not sure if elm-json is the ideal name for this. It's very hard to find it via duckduckgo and probably also via google. As there is elm/json and the elm.json files themselves.

A better name might hopefully help to distinguish and market this tool :)

Cheers

ARM builds

The following travis config gets fairly close:

addons:
  apt:
    packages:
      - musl-tools
      - gcc-arm-linux-gnueabihf

matrix:
  include:
    - name: RPI
      env: TARGET=armv7-unknown-linux-musleabihf CC_armv7_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc

but ultimately still result in build failure, however, that's probably because of something I did: https://travis-ci.org/zwilias/elm-json/jobs/621652061

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.