yarn-workspace-commands
Local Automator for yarn workspaces. Yarn-Workspace-Commands lets you to run a set of commands for local dev/ci build on all workspace packages folder.
Basic Usage
Install package on workspace root
yarn add yarn-workspace-commands -D -W
Define commands ywc.config.json
{
"[command_key]": {
/* Array of commands to execute */
"commands": "string[]",
/* Execute in parallel mode. Default : false */
"parallel": "boolean",
/* Execute only on root folder. Default : false */
"rootCommand": "boolean"
}
}
Execute
# command_key defined in ywc.config.json yarn ywc <command_key>
Detailed Setup Instructions
1. Setup Yarn Workspace
For further info on setting up yarn workspace : Setting Up Yarn Workspace
or
2. Install Package
yarn add yarn-workspace-commands -D -W
ywc.config.json
in workspace root
3. Create Set rootCommand : true
to make the commands run only on root folder.
package.json
in workspace root
4. Add script to
5. Run the commands
yarn test_ywc
Practical Example
If you have a yarn workspace and want to perform a clean build of all local packages after the installation of new modules.
-
Add the following to
ywc.config.json
-
Add the following script to
package.json
in workspace root
Environment Variables
Since the command execution is taking place under node environment, All environment variables available to process.env
can be used as inline arguments.
Example : Package versioning
-
ywc.config.json
-
Add the set version script to
package.json
-
Run the command to update version of all packages
yarn set-version