monorepo-ez-script v0.0.8
monorepo-ez-script
CLI for running script of each workspace in monorepo more easily.
š
š»āāļø deno is not supported.
Why
There are numerous workspaces in the monorepo. And each workspace has its own scripts in package.json. If you want to run a script in a workspace, you must know the workspace and script name. Then, depending on the type of package manager, you need to type the command as follows.
yarn workspace <WORKSPACE> <SCRIPT>
npm run <SCRIPT> --workspace=<WORKSPACE>
pnpm --filter "<WORKSPACE>" <SCRIPT>I know we can also add an abbreviated script to root package.json. But, it would be quite cumbersome to add each time the number of workspaces and scripts increases. This project contains a command (i.e. mes run) that allows you to simply select a workspace and a script to run.
Install and Setup
Install:
npm install --save-dev monorepo-ez-scriptCreate configuration file:
mes init // generate configuration automaticallyUsage
$ mes help
Usage: mes [options] [command]
CLI for running workspace script easily in monorepo
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
init Create configuration file in root directory
run Select workspace and run script
help [command] display help for commandmes init
- Collect information like package manager, workspace's name, scripts.
- Then, create configuration file with above information in root directory.
$ mes init
> Creating configuration file...
> Collecting workspace information...
[====================] 2/2 100%mes run
- If there is not configuration, run
mes initfirst automatically. - If there is not
packageManagerin configuraion, applynpmby default. - First, choose which
workspaceto run. - Then, choose which
scriptto run.
$ mes run
ā Which workspace would you like to run script? āŗ monorepo-ez-script
? Which script would you like to run? āŗ - Use arrow-keys. Return to submit.
⯠build
lint
format
prepare
devConfiguration
Run command mes init, then configuration .mesrc.json would be generated in root directory automatically.
Currently, only .mesrc.json is supported.
(I will do my best to support in various ways asap.)
.mesrc.json example
{
"packageManager": "pnpm",
"workspaces": [
"monorepo-ez-script"
],
"scripts": {
"monorepo-ez-script": [
"build",
"lint",
"format",
"dev"
]
}
}- packageManager:
npm | pnpm | yarndenois not supported.- If there isn't packageManager, use
npmby default. - If packageManager is not one of
npm,pnpm,yarn, quit command.
- workspaces:
string[]- If there isn't workspaces, quit command.
- If there isn't any workspace in workspaces (empty array), quit command.
scripts:
Record<string, string[]>- Each key is workspace name and value is array including scripts key.
- It there isn't workspace name that selected as key, quit command.
- If workspace name that selected has empty array, quit command.
License
MIT