Skip to content

Commit eedb179

Browse files
committed
Improve project documentation
1 parent d01394d commit eedb179

18 files changed

Lines changed: 535 additions & 62 deletions

File tree

README.md

Lines changed: 256 additions & 34 deletions
Large diffs are not rendered by default.

examples/workspace/README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,23 @@ This is the overall structure of the project:
2323

2424
In this structure we have two packages - `a` and `b` where package `b` depends on package `a`.
2525

26-
This project demonstrates a workflow where:
26+
> [!NOTE]
27+
>
28+
> Run `kmono query` to inspect the workspace package graph and see how packages relate
2729
28-
1) Packages are built and released when PR's are merged to master.
29-
2) Only packages that have changed since their previous version are build and released.
30-
3) The project uses convensional-commits and package versions are derived from commits.
30+
This project demonstrates a workflow where:
31+
32+
1. Packages are built and released when PR's are merged to master.
33+
2. Only packages that have changed since their previous version are build and released.
34+
3. The project uses conventional-commits and package versions are derived from commits.
3135

3236
The above requirements aren't needed to make use of kmono - this just serves to demonstrate a particular workflow and
3337
how you might use kmono to achieve it.
3438

3539
## Building/Releasing
3640

3741
The build and release workflow described above is entirely encapsulated in the `build.clj` file using `tools.build` and
38-
kmono-* APIs.
42+
kmono-\* APIs.
3943

4044
Packages can be built by running:
4145

@@ -49,8 +53,8 @@ And the built packages can then be released by running
4953
clojure -T:build release
5054
```
5155

52-
For both building and releasing you can add the `:skip-unchanged true` argument to build and release only packages that
53-
have changed. The idea being that you would pass this by default during CI.
56+
For both building and releasing you can add the `:skip-unchanged true` argument to only build and release packages that
57+
have changed since their last release. The idea being that you would pass this by default during CI.
5458

5559
```bash
5660
clojure -T:build build :skip-unchanged true
@@ -61,16 +65,16 @@ development to build all packages.
6165

6266
---
6367

64-
Take a look at the [example GitHub workflow file](./.github/workflows/release.yaml) for how you might set up your CI
68+
Have a look at the [example GitHub workflow file](./.github/workflows/release.yaml) for how you might set up your CI
6569
pipeline for release.
6670

6771
## Testing
6872

6973
To run the tests for each package you can run the command
7074

7175
```bash
76+
# Run `clojure -M` in each package (indicated by the `*`) that has a `:test` alias.
7277
kmono run -M ':*/test'
7378
```
7479

75-
This means run `clojure -M` in each package (indicated by the `*`) that has a `:test` alias. Each respective packages'
76-
`:test` alias will then be appended to the command when it is run, like so: `clojure -M:test`.
80+
Each respective packages' `:test` alias will then be appended to the command when it is run, like so: `clojure -M:test`.

examples/workspace/build.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
:repository "clojars"})
6969

7070
;; Create tags after successfully releasing the package.
71-
;;
71+
;;
7272
;; This will require calling `git push --tags` separately but you could
73-
;; just as easilly call it here too.
73+
;; just as easily call it here too.
7474
(git.tags/create-tags
7575
project-root {:tags [(kmono.version/create-package-version-tag pkg)]})))))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Run Clojure CLI commands with workspace packages and aliases automatically integrated.
2+
3+
Drop-in replacement for the standard `clojure` CLI enhanced with workspace awareness.
4+
Automatically includes workspace packages and their aliases, allowing you to work with
5+
your entire monorepo as a single project.
6+
7+
Examples:
8+
9+
```bash
10+
# Start a REPL with workspace packages available
11+
kmono clojure
12+
13+
# Run with specific aliases
14+
kmono clojure -A :dev
15+
16+
# Use package aliases (e.g., all :test aliases from packages)
17+
kmono clojure -P ':*/test' -M :test
18+
19+
# Run a main function with workspace awareness
20+
kmono clojure -M :my-main-alias
21+
22+
# Execute a tool
23+
kmono clojure -T :build
24+
25+
# Run with exec
26+
kmono clojure -X :my-exec-alias
27+
28+
# Pass through standard clojure arguments
29+
kmono clojure -M:test -- -m kaocha.runner
30+
31+
# Combine workspace and package aliases
32+
kmono clojure -A :dev -P ':*/dev,:*/test'
33+
```
34+
35+
The command automatically creates aliases for workspace packages and lifts
36+
package-specific aliases to the root level with namespaced names.
37+
38+
Use the global `-v` flag to see the actual `clojure` command being executed for debugging
39+
classpath issues.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Generate a classpath string from a Clojure project, augmented with workspace package
2+
information and aliases.
3+
4+
Similar to `clojure -Spath` but enhanced with kmono's workspace awareness. Particularly
5+
useful for editor integration (clojure-lsp), custom tooling, and debugging classpath
6+
issues.
7+
8+
Examples:
9+
10+
```bash
11+
# Basic classpath generation
12+
kmono cp
13+
14+
# Include specific root aliases
15+
kmono cp -A :dev,:test
16+
17+
# Include package aliases (e.g., all :test aliases from workspace packages)
18+
kmono cp -P ':*/test'
19+
20+
# Combine root and package aliases
21+
kmono cp -A :dev -P ':*/test,:*/dev'
22+
```
23+
24+
For clojure-lsp integration, use as a drop-in replacement for `clojure -Spath`:
25+
26+
```clojure
27+
;; .lsp/config.edn
28+
{:project-specs [{:project-path "deps.edn"
29+
:classpath-cmd ["kmono" "cp"]}]}
30+
```
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Execute external commands (non-Clojure) across multiple workspace packages.
2+
3+
Runs external commands in each workspace package directory, useful for shell scripts,
4+
build tools, tests, or any external commands across your monorepo.
5+
6+
Examples:
7+
8+
```bash
9+
# Run npm test in all packages
10+
kmono exec npm test
11+
12+
# Run a shell script in all packages
13+
kmono exec ./scripts/build.sh
14+
15+
# Run tests only in changed packages
16+
kmono exec --changed npm test
17+
18+
# Run commands in packages that changed since main branch
19+
kmono exec --changed-since origin/main pytest
20+
21+
# Run in specific packages only
22+
kmono exec -F :com.example/api,:com.example/web npm run build
23+
24+
# Run with limited concurrency
25+
kmono exec -c 2 ./slow-command.sh
26+
27+
# Run commands without dependency ordering (faster but potentially unsafe)
28+
kmono exec --run-in-order=false npm install
29+
```
30+
31+
Each command is executed with the package directory as the working directory. If any
32+
command fails, `kmono exec` continues running in other packages and reports failures at
33+
the end.
34+
35+
By default, commands run in dependency order to respect package relationships, but this
36+
can be disabled for independent operations like tests or linting.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Query and inspect information about the workspace package graph in various formats.
2+
3+
Provides information about workspace packages and their relationships. Outputs package
4+
metadata, version information, change tracking, and dependency relationships in JSON or
5+
EDN format.
6+
7+
Examples:
8+
9+
```bash
10+
# List all packages in JSON format
11+
kmono query
12+
13+
# List all packages in EDN format
14+
kmono query -o edn
15+
16+
# Query specific packages
17+
kmono query -F :com.example/api,:com.example/web
18+
19+
# Include version information from git tags
20+
kmono query --with-versions
21+
22+
# Only show packages that have changed since last version
23+
kmono query --with-changes --filter-unchanged
24+
25+
# Show packages changed since main branch
26+
kmono query --with-changes-since origin/main --filter-unchanged
27+
28+
# Only include specific fields
29+
kmono query --include-keys name,version,path
30+
```
31+
32+
Useful for debugging workspace configuration, building custom tooling, understanding
33+
package relationships, and identifying changed packages for CI/CD pipelines.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Start a Clojure REPL with workspace packages and aliases automatically configured.
2+
3+
Enhanced REPL with workspace awareness that automatically includes workspace packages in
4+
the classpath and applies configured aliases from both the root project and workspace
5+
packages.
6+
7+
Configuration example:
8+
9+
```clojure
10+
;; deps.local.edn
11+
{:kmono/workspace {;; Always include these aliases when running `kmono repl`
12+
:repl-aliases [:nrepl :cider]
13+
:aliases [:dev]
14+
:package-aliases [:*/dev]}}
15+
```
16+
17+
Examples:
18+
19+
```bash
20+
# Start basic REPL with workspace packages
21+
kmono repl
22+
23+
# Start REPL with additional root aliases
24+
kmono repl -A :dev,:test
25+
26+
# Start REPL with specific package aliases
27+
kmono repl -P ':*/test,:a/dev'
28+
29+
# Start REPL with both root and package aliases
30+
kmono repl -A :cider -P ':*/dev'
31+
```
32+
33+
Use `deps.local.edn` for personal REPL preferences without affecting the shared project
34+
configuration.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Execute Clojure commands with aliases across workspace packages that contain the specified
2+
aliases.
3+
4+
Automatically filters packages based on whether they have the requested alias defined in
5+
their `deps.edn` file. Useful for running tests, builds, or other Clojure-based tasks
6+
across multiple packages.
7+
8+
Examples:
9+
10+
```bash
11+
# Run tests in all packages that have a :test alias
12+
#
13+
# This will result in `clojure -M:test` being run in all workspace packages containing
14+
# a `:test` alias.
15+
kmono run -M :test
16+
17+
# Run build tools in packages with :build alias
18+
kmono run -T :build
19+
20+
# Run exec function in packages with :my-exec alias
21+
kmono run -X :my-exec :fn some-fn
22+
23+
# Run only in changed packages
24+
kmono run --changed -M :test
25+
26+
# Run in packages changed since main branch
27+
kmono run --changed-since origin/main -M :test
28+
29+
# Run with package filtering
30+
kmono run -F :com.example/api -M :test
31+
32+
# Run with limited concurrency
33+
kmono run -c 2 -M :test
34+
35+
# Pass additional arguments to the Clojure command
36+
kmono run -M :test --focus my-test-ns
37+
```
38+
39+
Only executes in packages that actually contain the specified alias, automatically
40+
skipping packages without the alias. Each command runs with the package directory as the
41+
working directory.
42+
43+
By default, commands run in dependency order to ensure proper build sequences, but this
44+
can be disabled for independent operations.

packages/kmono-cli/src/k16/kmono/cli/commands/clojure.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(ns k16.kmono.cli.commands.clojure
22
(:require
33
[babashka.process :as proc]
4+
[clojure.java.io :as io]
45
[clojure.string :as str]
56
[k16.kmono.cli.common.context :as common.context]
67
[k16.kmono.cli.common.opts :as opts]
@@ -77,7 +78,8 @@
7778

7879
(def command
7980
{:command "clojure"
80-
:desc "Run an augmented clojure command"
81+
:summary "Run an augmented clojure command"
82+
:desc (io/resource "k16/kmono/docs/clojure.md")
8183

8284
:options {:package-aliases opts/package-aliases-opt
8385

0 commit comments

Comments
 (0)