hammer_cli/lib.rs
1//! # Hammer
2//!
3//! Hammer is a no-config cli tool for running concurrent tasks with monorepo support.
4//! Monorepo tooling *should* be as simple as it can. Unfortunately, the current tooling is overly
5//! complex and can lead to a lot of time spent configuring and debugging, when you should be
6//! worried about writing your code.
7//!
8//! You can think of Hammer as a lightweight alternative for turborepo. Currently, it only
9//! supports JS/TS projects. In the future it could expand and have a larger number of languages
10//! supported.
11//!
12//! ### The `hammer` bin
13//!
14//! The `hammer` binary is hammer's CLI. It aims to be as simple as it can get.
15//!
16//! Syntax:
17//! ```bash
18//! hammer <SCRIPT> [OPTS]
19//! ```
20//!
21//! Example:
22//!
23//! ```bash
24//! hammer dev
25//! ```
26//! *Runs all the workspaces projects "hammer:dev" scripts.*
27//!
28//! #### Disabling the prefix
29//!
30//! By default, hammer will look up for all the scripts containing the prefix `hammer:` in package.json,
31//! thus making it easy to gradually adopt the tool and run only the scripts you want using it.
32//! If you don't want this, just use the `--no-prefix` flag and hammer will look for the `dev` script directly:
33//!
34//! ```bash
35//! hammer dev --no-prefix
36//! ```
37//! *Runs all workspace projects "dev" scripts.*
38//!
39//! **alias**: -n
40//!
41//! #### Filtering
42//!
43//! You can filter which projects should be targeted by hammer:
44//!
45//! ```bash
46//! hammer dev --filter web
47//! ```
48//! *Will only run the dev script of the project that contains a package.json with the "name" being "web"*
49//!
50//! **alias**: -f
51//!
52//! #### Environment variables
53//!
54//! By default, hammer will load the root .env file and inject all of its variables in every child
55//! process that it starts. You can also pass variables via the command line, and they will override system
56//! variables or root .env variables. This is really useful for changing some environment in a testing script,
57//! for example:
58//!
59//! ```bash
60//! hammer test --env NODE_ENV:TESTING
61//! ```
62//!
63//! *Will run all workspaces "hammer:test" scripts and inject a environment variable NODE_ENV=TESTING*
64//!
65//! **alias**: -e
66//!
67//! I recommend setting up some scripts in the root package.json so it becomes easy to have these separate
68//! environments:
69//!
70//! ```json
71//! {
72//! ...
73//! "scripts": {
74//! "dev": "hammer dev",
75//! "test": "hammer test -e NODE_ENV:TESTING"
76//! },
77//! ...
78//! }
79//! ```
80//! *Easy to run with `pnpm dev`, `pnpm test`*
81//!
82//! #### Directory Depth
83
84pub mod fs_checks;
85pub mod npm_process;
86pub mod package_json;
87pub mod tasks;
88pub mod errors;
89pub mod args;