-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install elm-json using elm-tooling #480
Conversation
Also install the dev dependencies elm and elm-format using elm-tooling.
I might not get to my laptop to look at this before Christmas so bare with me. I have already gone from skeptical to keen though so nice work 👍 |
No worries! No rush to do anything before Christmas. Or this year. We’ll get back to it in 2021! 🎅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, raised a couple of points for discussion:
Before: ``` ❯ ../bin/elm-test -- UNFINISHED DEFINITION - /Users/lydell/forks/node-test-runner/example-application/tests/TestsPassing.elm I got stuck while parsing the `x` definition: 3| x ^ I was expecting to see an argument or an equals sign next. Here is a valid definition (with a type annotation) for reference: greet : String -> String greet name = "Hello " ++ name ++ "!" The top line (called a "type annotation") is optional. You can leave it off if you want. As you get more comfortable with Elm and as your project grows, it becomes more and more valuable to add them though! They work great as compiler-verified documentation, and they often improve error messages! Compiling > `elm make` failed with exit code 1. ``` After: ``` ❯ ../bin/elm-test -- UNFINISHED DEFINITION - /Users/lydell/forks/node-test-runner/example-application/tests/TestsPassing.elm I got stuck while parsing the `x` definition: 3| x ^ I was expecting to see an argument or an equals sign next. Here is a valid definition (with a type annotation) for reference: greet : String -> String greet name = "Hello " ++ name ++ "!" The top line (called a "type annotation") is optional. You can leave it off if you want. As you get more comfortable with Elm and as your project grows, it becomes more and more valuable to add them though! They work great as compiler-verified documentation, and they often improve error messages! `elm make` failed with exit code 1. ``` Notice the `Compile >` line near the bottom in the “Before” output. That’s not supposed to be there. I fixed this by reverting the change here: #480 (comment) This is pretty tricky. I’ll try to explain. So we print this `Thing > Other thing > Last thing` progress line, where each segment appears over time. For this reason, the terminal cursor never moves to the next line, so we can overwrite the line over and over. Once done, we move to the next line so the test output can print below the (finished) progress line. But what happens if there’s an error? We don’t want to end up with something like: ``` Thing > Other thingError: Can’t do this and that for: more lines of error Maybe try this and that? ``` So we want to move to the next line when printing an error as well. `progressLogger.logLine('')` worked for this case most of the time: It would reprint `Thing > Other` (which technically was unnecessary but couldn’t be seen) and then moved to the new line. Another thing I noticed while writing this: The empty string would actually result in `This > Other > ` (an unwanted trailing `>` separator). But the thing is that we can’t actually know that the cursor is still on the cursor line. Why? Because `elm make` might have printed to stderr (in case of compilation errors in the user’s code). We don’t know if it has either – we can’t capture its stderr because then we would lose colors. So a solution that works in both cases is to _not_ reprint the progress line and instead only move to the next line. (That results in an extra blank line for the compiler errors but I don’t think it matters.)
This PR uses elm-tooling to install elm-json instead of the elm-json npm package.
Look at this size improvement:
Size was measured by running
du -sh node_modules
after installing node-test-runner (and nothing else) on MacOS.The elm-json binary itself around 2 MB on MacOS.
The huge space drop comes from not depending on
binwrap
anymore. It has some pretty have dependencies.Benefits of using elm-tooling:
npm install
. And if the user uses elm-tooling to install elm and elm-format as well, all three tools are downloaded in parallel. Similar PR for elm-review.The only noticeable difference is when the elm-json executable is transferred from the Internet to the user’s machine.
Previously, it happened during
npm install
. Unless you use ignore-scripts – then it happened the first timeelm-json
was executed. Now, it happens right beforeelm-json
is about to be executed. Unless the user already downloaded elm-json to~/.elm/elm-tooling/
before.Given that node-test-runner executes both elm and elm-json, which both can make network requests, I think it’s fine to also execute elm-tooling’s
getExectuable
function which also can make network requests. node-test-runner continues to work offline once all needed things exist on the user’s machine.binwrap uses the request module, while elm-tooling uses curl if available, otherwise wget and finally Node.js’ https module. If the user used request’s environment variables for proxies, that should probably just work since curl seems to use the same environment variables. But there might be some little difference. Either way, both curl and wget also support config files that lets the user alter how they work as needed, which is a good thing.
Previously, the elm-json binary was downloaded to
./node_modules/elm-json/unpacked-bin/
. Now it’s downloaded to~/.elm/elm-tooling/elm-json/0.2.8/
. Elm and elm-json write to~/.elm
too, so it should be fine. (elm-tooling supportsELM_HOME
and Windows.)The plan now is to:
elm-tooling
to the @elm-tooling org so I don’t become a single point of failure.elm-tooling
in Slack and Discourse. So far I haven’t talked much about it, waiting for these two PRs to be made.