Skip to main content

moon v0.26 - Deeper proto integration, Docker setup, and query commands

· 4 min read
Miles Johnson
Founder, developer

With this release, we're providing deeper integration with our new proto toolchain manager, better Docker support, and new query commands for debugging.

Full proto toolchain integration

Earlier this week we announced proto, our own toolchain manager, and an attempt at a next generation version manager for multiple languages. proto was originally moon's toolchain layer, but we felt it best to extract it out into a stand-alone tool for everyone to use, especially those not using moon!

Now that proto has been released, we've updated moon's Rust internals to utilize proto's latest Rust crates. For the most part, everything will continue to work the same. However, the biggest change is that the toolchain has moved from ~/.moon to ~/.proto, and will result in tools being re-downloaded and installed. Feel free to delete the old ~/.moon directory manually.

Furthermore, we've added first-class support for the new .prototools configuration file. If this file is found in the workspace root, we'll automatically enable the tools in our toolchain, and inject the versions (when not defined in .moon/toolchain.yml).

node = "18.0.0"
pnpm = "7.29.0"

New moon docker setup command

moon has provided built-in Dockerfile support since v0.15 (11 versions ago!) and we've always encouraged the use of the moon setup command to setup the toolchain and install project dependencies. Here's an example of a moon powered Dockerfile:

FROM node:latest

# Install moon binary
RUN npm install -g @moonrepo/cli

# Copy workspace skeleton
COPY ./.moon/docker/workspace .

# Install toolchain and dependencies
RUN moon setup

# Copy source files
COPY ./.moon/docker/sources .

# Build something
RUN moon run app:build

# Prune workspace
RUN moon docker prune

CMD ["moon", "run", "app:start"]

However, over the course of these 11 releases since v0.15, we refactored the moon setup command to only setup the toolchain, and no longer install project dependencies. We inadvertently broke our Docker integration. This was an oversight on our part.

To rectify this situation, we're introducing a new moon docker setup command that will efficiently install dependencies for projects focused/affected within the Dockerfile. This is a much better solution than before, and you should see improved Docker layer caching!

-RUN moon setup
+RUN moon docker setup

New moon query hash command

When moon runs a task, we generate a unique hash representing the state of that run. When something goes wrong however, and the hash is different than what you expect, debugging why is rather non-trivial and requires a lot of internal knowledge. We're looking to reduce this burden, by introducing the new moon query hash command.

$ moon query hash 0b55b234

This command will print the contents of the hash manifest, which is all inputs and sources used to generate the unique hash. From here you can use this output to investigate what's actually happening.

"command": "build",
"args": ["./build"]
// ...

New moon query hash-diff command

Expanding on the new command above, we're also introducing the moon query hash-diff command, which can be used to compute the difference between 2 hashes. Perfect in understanding what has changed between ran tasks.

$ moon query hash-diff 0b55b234 2388552f

When ran, the command will print out the differences as highlighted lines. If you use git diff, this will feel familiar to you.

"command": "build",
"args": [
+ "./dist"
- "./build"

Other changes

View the official release for a full list of changes.

  • A handful of critical bug fixes.
  • Targets that generate an empty hash are now considered a failure, as they may be an edge case not accounted for.

What's next?

Expect the following in the v1 release!

  • Officially release a v1!
  • Project tagging and constraints.