JavaScript CLI wrapper for moon, a build system and repository management tool for the web ecosystem
npx @tessl/cli install tessl/npm-moonrepo--cli@1.40.0Moon CLI provides a JavaScript wrapper for moon, a repository management, organization, orchestration, and notification tool for the web ecosystem written in Rust. The CLI package enables developers to use moon through familiar package managers like npm, yarn, or pnpm, automatically handling platform-specific binary installation and execution.
npm install @moonrepo/cli or yarn add @moonrepo/climoon command globally after installationFor programmatic usage:
const { findMoonExe } = require("@moonrepo/cli/utils");After installation, use the moon command directly:
# Initialize moon in your repository
moon init
# Run a specific task in a project
moon run app:build
# Run a task across all projects
moon run :test
# Check project health
moon check
# View project information
moon project myappconst { findMoonExe } = require("@moonrepo/cli/utils");
const { spawn } = require("child_process");
// Get the path to the moon binary
const moonPath = findMoonExe();
console.log("Moon binary located at:", moonPath);
// Execute moon programmatically
const child = spawn(moonPath, ["run", "app:build"], {
stdio: "inherit"
});
child.on("close", (code) => {
console.log(`Moon process exited with code ${code}`);
});The package consists of three main components:
moon.js and moonx.js executable scripts that spawn the native Rust binaryutils.js module that detects platform/architecture and locates the correct binaryThe package automatically downloads and installs platform-specific binaries through optional dependencies, ensuring the correct native binary is available for Linux, macOS, and Windows systems.
Core utility functions for locating and executing the moon binary across different platforms.
function findMoonExe(): string;findMoonExe(): Locates and returns the absolute path to the platform-specific moon binary executable. Throws an Error if the executable is not found.
The package includes a post-install script (postinstall-old.js) that automatically configures the binary after installation.
// Internal post-install functionality (not exported)
function setupBinary(): void;setupBinary(): Internal function that runs during package installation to link or copy the platform-specific binary to the local package directory. This process:
The moon binary provides extensive command-line functionality accessible through the JavaScript wrapper. All commands support standard CLI patterns with arguments, flags, and subcommands.
moon init
moon completionsmoon bin <tool>
moon setup
moon teardown
moon toolchain <subcommand>
moon node <subcommand>moon project <id>
moon project-graph [id]
moon task <target>
moon task-graph [id]
moon action-graph [target]
moon sync [subcommand]moon generate
moon templatesmoon run [...targets]
moon check
moon cimoon extmoon clean
moon docker <subcommand>
moon mcp
moon migrate <subcommand>
moon query <subcommand>
moon upgradefile - Generate a default Dockerfile for a projectprune - Remove extraneous files and folders within a Dockerfilescaffold - Scaffold a repository skeleton for use within Dockerfile(s)setup - Setup a Dockerfile by installing dependencies for necessary projectsThe package also provides moonx, a simplified task runner interface:
moonx <task-target>moonx: Automatically prefixes provided arguments with run, so moonx app:build is equivalent to moon run app:build.
// Platform detection constants (internal use, not exported)
const isLinux: boolean;
const isMacos: boolean;
const isWindows: boolean;
const platform: string;
const arch: string;
const triple: string;Platform Detection Constants: Internal constants used by the utils module for determining the current system architecture and operating system. These are used internally by findMoonExe() but are not part of the public API.
The package throws errors in the following scenarios:
findMoonExe() cannot locate the platform-specific moon binarySupports multiple platforms through optional dependencies:
The correct binary is automatically selected during installation based on the detected platform and architecture.
The package includes a post-install script that:
This ensures the moon binary is immediately available after package installation without additional setup steps.