Skip to main content

moon v1.39 - Improved task inputs, better proto integration, and project layers

· 5 min read
Miles Johnson
Founder, developer

This is a rather small release, but it does include some important changes to task inputs, and proto's integration.

Improved task inputs

A few months ago we introduced an RFC for improving task inputs that introduces new syntax, functionality, and input types. In this release, we have implemented a portion of the RFC for testing before we implement the rest. Continue reading for more details!

New formats

To start, we are introducing 2 new formats for configuring task inputs, a URI format and an object format, both of which support custom parameters.

URIs

URIs should be rather familiar, as they are a string prefixed with a scheme (://), followed by a value, and an optional list of query parameters (?). Currently files can be specified using the file:// scheme, and globs with the glob:// scheme. Environment variables do not support URIs.

moon.yml
tasks:
build:
# ...
inputs:
- 'file:///*.config.js?optional'
- 'glob://src/**/*.ts'
info

Files and globs can still be configured using literal strings. The URI format can be used when customizing parameters!

Objects

Objects provide an alternative to strings, allowing you to customize parameters in a standard and familiar format. Files can be specified using the file key, and globs with the glob key. Environment variables do not support objects.

moon.yml
tasks:
build:
# ...
inputs:
- file: '/*.config.js'
optional: true
- glob: 'src/**/*.ts'

New parameters

As mentioned above, file and glob inputs now support parameters, which can be customized using URI and object formats. The following parameters are available:

Files

  • content (string) - When determining affected state, will match against the file's content using the defined regex pattern, instead of relying on file existence.
  • optional (boolean) - When hashing and set to true and the file is missing, will not log a warning. When set to false and the file is missing, will fail with an error. Defaults to logging a warning.

Globs

  • cache (boolean) - When gathering inputs for hashing, defines whether the glob results should be cached for the duration of the moon process. Defaults to true.

Better proto integration

In previous versions of moon, we would automatically install proto for you based on certain conditions. This logic was applied to all moon sub-commands, which was not necessary, as it was only required for task running related commands.

To improve this, we have integrated proto into the action pipeline through a new action, SetupProto, which runs before any SetupToolchain action. With this, proto is only installed when required by that specific toolchain, and not for every command.

New proto setting

Additionally, we are introducing a proto setting in .moon/toolchain.yml, which can be used to control the integration of proto in moon. To start, you can now customize the proto version! This is extremely useful if you want to test new proto features, or need to rollback to an older version.

.moon/toolchain.yml
proto:
version: '0.51.4'

Other changes

Lastly, proto has been upgrade to v0.51, which includes 2 major features: lockfiles and custom registries. However, we have yet to test these features thoroughly in moon, so they are not "officially" supported yet, but you can still use them if you wish. We will be adding support for these features in the future.

Project layers

Project layers may sound like a new feature, but they are simply a rename of the project type. Going forward, the type setting in moon.yml has been renamed to layer, but backwards compatibility will be maintained until v2. Why the rename?

The term "layer" better reflects the purpose and functionality of this concept, as it defines a layer (the layer setting) within the development stack (the stack setting), and helps to enforce proper relationships. This change aims to improve clarity and consistency in our configuration.

For example, the following layers are available, from highest to lowest. Layers can then depend on lower layers, but not higher layers. Except for automations and applications, they can also depend on themself.

LayerDescription
automationAn automated testing suite, like E2E, integration, or visual tests.
applicationAn application of any kind.
toolAn internal tool, CLI, one-off script, etc.
libraryA self-contained, shareable, and publishable set of code.
scaffoldingTemplates or generators for scaffolding.
configurationConfiguration files or infrastructure.
unknownWhen not configured.

Because of this rename, the following changes have been made:

  • type --> layer in moon.yml
  • --type --> --layer in moon query projects
  • projectType --> projectLayer for MQL
  • $projectType --> $projectLayer for task tokens
  • enforceProjectTypeRelationships --> enforceLayerRelationships in .moon/workspace.yml

Other changes

View the official release for a full list of changes.

  • Added unstable support for bubbling up logs from WASM plugins.
  • Updated the @moonrepo/cli npm package to no longer rely on postinstall scripts.
  • Improved argument quoting for commands and scripts.

What's next?

With toolchains plugins being stabilized more, we'd like to focus on some other areas.

  • Better command line argument parsing/joining (especially for task args)
  • Pkl configuration improvements
  • WASM toolchain documentation