Skip to main content

moon v0.24 - Remote caching, interactive tasks, query improvements, and more

· 5 min read
Miles Johnson
James Pozdena

With this release, we've polished our CLI experience and improved task interoperability.

Remote caching now available

If you missed our announcement earlier this week, remote caching is now publicly available through our new service moonbase! If you're looking to speed up your CI pipelines and share build artifacts between runs, moonbase can help.

Project-level task platform

In our previous release, v0.23, we added support for project-level environment variables. This is great as it helps to reduce duplication for projects with many tasks. On that note, we wondered which configuration field we could apply similar treatment, and as such, we've added a project-level platform setting.

When this setting is defined, all task's within the current project that have not explicitly configured their platform, will inherit the project-level platform. If neither settings are defined, we'll attempt to detect the correct platform based on the state of the project.

<project>/moon.yml
# Will set non-explicit task's platform to node
platform: 'node'

tasks:
# Will be node
dev: # ...

# Will be node
build: # ...

# Will be system
serve:
# ...
platform: 'system'

This setting is extremely useful for projects that contain multiple languages. Even more so once we land Bun and Deno support, as we'll need a way to differentiate JavaScript/TypeScript projects!

Interactive tasks

When moon executes a task, it streams both stdout and stderr to the terminal and captures the output for later use. We do this for 2 reasons:

  • We store stdout.log and stderr.log files in a tarball archive.
  • We replay this captured output when executing a task that has been cached.

While this works, our approach is non-standard. Streams are either piped or inherited, not both! Because of our custom abstraction around streams and output capturing, it disrupts stdin, breaking all interactive commands. If you tried to run a task that prompted you with a question and were unable to answer it, this is why!

To remedy this shortcoming, we're approaching this from 2 angles. The first is that all tasks marked as local (or have caching disabled) will no longer capture streamed output, and will instead stream natively, allowing interactivity out of the box, but only when they're the only task being ran. This will cover the majority of use cases.

For the remaining use cases, we're introducing a new --interactive flag for moon run. When this flag is provided, it will force the target into an interactive mode.

$ moon run app:new --interactive

Improved moon query commands (breaking)

The moon query projects and moon query touched-files commands are useful for building custom solutions and integrations on top of moon, but they weren't developer friendly as they output large JSON blobs. To remedy this, we've updated both commands to output a simple human readable format by default, and moved the JSON output behind a --json flag.

For example, moon query touched-files now outputs a list of absolute file paths separated by new lines.

$ moon query touched-files
/moon/website/docs/commands/query/projects.mdx
/moon/crates/cli/tests/query_test.rs
/moon/crates/cli/src/commands/query.rs
/moon/website/blog/2023-02-13_v0.24.mdx

While moon query projects now outputs a list of project separated by new lines, where each line contains the project name, source, type, and language.

$ moon query projects
report | packages/report | library | typescript
runtime | packages/runtime | library | typescript
types | packages/types | library | typescript
visualizer | packages/visualizer | library | typescript
website | website | application | typescript

We had 2 goals in mind for this change, the first was to make it easily readable, and the second was for the default output to be easily parseable. We believe we've accomplished these goals!

New moon query tasks command

To expand on the query improvements above, we wanted to provide a way to also query for tasks, answering the question of "What tasks exists and for what projects?". And with this, we're introducing a new moon query tasks command!

$ moon query tasks
types
:build | packemon
:format | prettier
:lint | eslint
:test | jest
:typecheck | tsc
report
:build | packemon
:format | prettier
:lint | eslint
:test | jest
:typecheck | tsc
...

Shell completions

Auto-completion in your terminal increases productivity, which we're a massive fan of. To help support this, we're introducing the moon completions command, which generates the appropriate command completions for your current shell.

This command writes to stdout, which can then be redirected to a file of your choice. Be sure to configure your shell profile to load the completions!

$ moon completions > ~/.bash_completion.d/moon.sh

Other changes

View the official release for a full list of changes.

  • Added TypeScript v5 support.
  • Added a hasher.walkStrategy setting to .moon/workspace.yml.
  • Updated task outputs to support token functions (@group, @globs, etc).
  • Reworked our comparison/baseline estimations calcuations.

What's next?

Expect the following in the v0.25 release!

  • Deno tier 2 support.
  • CI insights and metrics within moonbase.
  • Project-level TypeScript settings.