monomana (monorepo manager) is a command-line interface (CLI) tool designed to simplify command execution within monorepo workspaces. It automatically detects the package manager (like pnpm or yarn) and runs your commands in the specified workspace.
Since the tool is not published to crates.io yet, you can install it by cloning the repository and building it.
Beforehand, you need to install the Rust toolchain and the cargo package manager.
# clone the repository
git clone https://github.com/monomana/monomana.git
cd monomana
# build and install
cargo install --path .The primary command is run, which allows you to execute commands in a specific workspace.
monomana run <workspace_name> [package_manager] <command_to_run><workspace_name>: The name of the workspace where the command will be executed.[package_manager](Optional): You can explicitly specifypnpmoryarn. If omitted,monomanawill attempt to auto-detect the manager based on the lock files in the workspace.<command_to_run>: The actual command and its arguments you want to run (e.g.,build,test,dev).
Running a 'dev' script in a workspace named 'webapp'
The tool will auto-detect the package manager.
monomana run my-workspace devBuilding a project in a workspace named 'api' using pnpm
This example explicitly tells monomana to use pnpm.
monomana run my-pnpm-workspace pnpm buildPerforming a dry run
You can see what command would be executed without actually running it by using the --dry-run or -d flag.
monomana run webapp --dry-run buildcheck the workspace list
The tool reads the workspaces field in the package.json file or the pnpm-workspace.yaml file automatically, and lists the workspaces.
monomana list-workspacesmonomana provides workspace auto-completion for zsh(oh-my-zsh) environment.
Press tab key after monomana run to auto-complete the workspace name.
If you are using oh-my-zsh, the auto-completion should be enabled by default.
Error handling in this case is TBD.
In vanilla zsh environment, you need to add the following to your .zshrc file.
For shorthand, add the following to your .zshrc file.
# your .zshrc
# ...other rc configs
ZSH_COMPLETION_DIR=$HOME/.zsh/completions
fpath=($ZSH_COMPLETION_DIR $fpath)
typeset -U fpath
autoload -Uz compinit
compinitHere is the detailed explanation of the above code:
- run
compinit
# your .zshrc
# ...other rc configs
autoload -U compinit; compinit- add
fpathpath before runningcompinit
ZSH_COMPLETION_DIR=$HOME/.zsh/completions
fpath=($ZSH_COMPLETION_DIR $fpath)
typeset -U fpath
autoload -U compinit; compinit- (Optional) activate
GLOB_COMPLETEoption
setopt glob_complete