#monorepo #tasks #hammer #cli #projects #command-line-tool

bin+lib hammer-cli

Hammer is a no-config cli tool for running concurrent tasks with monorepo support

7 releases

0.3.1 Mar 5, 2023
0.3.0 Feb 25, 2023
0.2.3 Feb 24, 2023
0.1.0 Feb 22, 2023

#556 in Concurrency

Download history 3/week @ 2024-07-21 5/week @ 2024-07-28 9/week @ 2024-09-22 1/week @ 2024-09-29

89 downloads per month
Used in 2 crates

MIT/Apache

14KB
238 lines

Hammer

Hammer is a no-config cli tool for running concurrent tasks with monorepo support. Monorepo tooling should be as simple as it can. Unfortunately, the current tooling is overly complex and can lead to a lot of time spent configuring and debugging, when you should be worried about writing your code.

You can think of Hammer as a lightweight alternative for turborepo. Currently, it only supports JS/TS projects. In the future it could expand and have a larger number of languages supported.

The hammer bin

The hammer binary is hammer's CLI. It aims to be as simple as it can get.

Syntax:

hammer <SCRIPT> [OPTS]

Example:

hammer dev

Runs all the workspaces projects "hammer:dev" scripts.

Disabling the prefix

By default, hammer will look up for all the scripts containing the prefix hammer: in package.json, thus making it easy to gradually adopt the tool and run only the scripts you want using it. If you don't want this, just use the --no-prefix flag and hammer will look for the dev script directly:

hammer dev --no-prefix

Runs all workspace projects "dev" scripts.

alias: -n

Filtering

You can filter which projects should be targeted by hammer:

hammer dev --filter web

Will only run the dev script of the project that contains a package.json with the "name" being "web"

alias: -f

Environment variables

By default, hammer will load the root .env file and inject all of its variables in every child process that it starts. You can also pass variables via the command line, and they will override system variables or root .env variables. This is really useful for changing some environment in a testing script, for example:

hammer test --env NODE_ENV:TESTING

Will run all workspaces "hammer:test" scripts and inject a environment variable NODE_ENV=TESTING

alias: -e

I recommend setting up some scripts in the root package.json so it becomes easy to have these separate environments:

{
    ...
    "scripts": {
        "dev": "hammer dev",
        "test": "hammer test -e NODE_ENV:TESTING"
    },
    ...
}

Easy to run with pnpm dev, pnpm test

Dependencies

~4–13MB
~147K SLoC