Skip to content

Commit dd30e72

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix-create-basis-package-resolution
2 parents 543648a + 5adc17f commit dd30e72

File tree

18 files changed

+283
-141
lines changed

18 files changed

+283
-141
lines changed

.cljfmt.edn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
{:remove-multiple-non-indenting-spaces? true
2-
:sort-ns-references? true}
2+
:sort-ns-references? true
3+
4+
:extra-indents {k16.kmono.build/for-each-package [[:inner 0] [:inner 1]]}}

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Lint
2+
3+
on: [push]
4+
5+
jobs:
6+
check-formatting:
7+
runs-on: ubuntu-latest
8+
9+
permissions:
10+
contents: read
11+
12+
steps:
13+
- name: Checkout git repo
14+
uses: actions/checkout@v4
15+
16+
- uses: extractions/setup-just@v3
17+
- uses: DeLaGuardo/setup-clojure@13.2
18+
with:
19+
cljfmt: 0.16.1
20+
21+
- name: Install prettier
22+
run: |
23+
npm i -g prettier
24+
25+
- name: Install Pruner
26+
run: |
27+
set -euo pipefail
28+
29+
mkdir -p $HOME/.local/bin
30+
curl -fL https://github.com/julienvincent/pruner/releases/download/v1.0.0-alpha.10/pruner-linux-amd64 \
31+
-o "$HOME/.local/bin/pruner"
32+
33+
chmod +x "$HOME/.local/bin/pruner"
34+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
35+
36+
pruner --version
37+
38+
- name: Check Formatting
39+
run: just lint
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
((list_lit
2+
((sym_lit) @def-type
3+
(sym_lit) @def-name
4+
(str_lit) @docstring @injection.content)
5+
(map_lit)?
6+
7+
(_)+)
8+
9+
(#match? @def-type "^(def|defprotocol)$")
10+
(#offset! @injection.content 0 1 0 -1)
11+
(#escape! @injection.content "\"")
12+
(#set! injection.language "markdown"))
13+
14+
((list_lit
15+
((sym_lit) @def-type
16+
(sym_lit) @def-name
17+
(str_lit)? @docstring @injection.content)
18+
(map_lit)?
19+
20+
[
21+
(vec_lit)
22+
(list_lit (vec_lit))+
23+
])
24+
25+
(#match? @def-type "^(defn-?|defmacro)$")
26+
(#offset! @injection.content 0 1 0 -1)
27+
(#escape! @injection.content "\"")
28+
(#set! injection.language "markdown"))
29+
30+
;; Match ns
31+
((list_lit
32+
((sym_lit) @fn-type
33+
(sym_lit) @ns-name
34+
(#eq? @fn-type "ns")
35+
36+
(str_lit)? @docstring @injection.content)
37+
(map_lit)?)
38+
39+
(_)*
40+
41+
(#offset! @injection.content 0 1 0 -1)
42+
(#escape! @injection.content "\"")
43+
(#set! injection.language "markdown"))
44+
45+
(list_lit
46+
((sym_lit) @fn-name
47+
(#eq? @fn-name "defprotocol")
48+
(sym_lit) @protocol-name
49+
50+
(str_lit)?)
51+
52+
(list_lit
53+
(sym_lit)
54+
(vec_lit)+
55+
(str_lit) @docstring @injection.content)
56+
57+
(#offset! @injection.content 0 1 0 -1)
58+
(#escape! @injection.content "\"")
59+
(#set! injection.language "markdown"))
60+
61+
((str_lit) @injection.content
62+
(#match? @injection.content "^\"(SET|TRUNCATE|SELECT|CREATE|DELETE|ALTER|UPDATE|DROP|INSERT|WITH)")
63+
(#offset! @injection.content 0 1 0 -1)
64+
(#escape! @injection.content "\"")
65+
(#set! injection.language "sql"))

justfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ cli *args:
3131

3232
test *args:
3333
just cli {{ args }} run -M :test
34+
35+
format dry='false':
36+
pruner format '**/*.clj' \
37+
--config pruner.toml \
38+
--lang clojure \
39+
--check={{ dry }}
40+
41+
lint:
42+
just format true

packages/kmono-build/src/k16/kmono/build.clj

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
(defn published?
1717
"A `predicate-fn` designed to be used with [[k16.kmono.core.graph/filter-by]].
1818
19-
Checks whether a given `package` has been published to it's maven repository.
20-
The repositories from the packages `:mvn/deps` map will be used to run this
21-
check.
19+
Checks whether a given `package` has been published to it's maven repository.
20+
The repositories from the packages `:mvn/deps` map will be used to run this
21+
check.
2222
23-
Requires that the package has a `:version` set in order to perform a maven
24-
query.
23+
Requires that the package has a `:version` set in order to perform a maven
24+
query.
2525
26-
This fn will just return `false` if the package `:version` is not set."
26+
This fn will just return `false` if the package `:version` is not set."
2727
[package]
2828
(let [local-repo-override (str (fs/create-temp-dir))]
2929
(try
@@ -49,22 +49,22 @@
4949
(defn join
5050
"Attempt to join together a given a series of paths.
5151
52-
For example - given `(join \"/a/b/c\" \"../d\")` return `\"/a/b/d\"`"
52+
For example - given `(join \"/a/b/c\" \"../d\")` return `\"/a/b/d\"`"
5353
[& paths]
5454
(->> (apply fs/file paths)
5555
fs/normalize
5656
str))
5757

5858
(defn create-basis
5959
"Constructs a basis using [[clojure.tools.build.api/create-basis]] with a
60-
modified set of `:libs`.
60+
modified set of `:libs`.
6161
6262
Any `:local/root` kmono dependencies within the resolved basis `:libs` are
6363
replaced with their respective `:mvn/version` coordinate by looking up the
6464
lib's symbol in the given `packages` map.
6565
66-
These `:libs` are then used to generate a correctly referenced `pom.xml` when
67-
using [[clojure.tools.build.api/write-pom]].
66+
These `:libs` are then used to generate a correctly referenced `pom.xml` when
67+
using [[clojure.tools.build.api/write-pom]].
6868
6969
The `packages` map should contain all workspace packages required for version
7070
lookup (typically the full unfiltered package map).
@@ -99,26 +99,26 @@
9999
(defn for-each-package
100100
"Execute a given `build-fn` for each package in the given `packages` map.
101101
102-
Accepts an optional `opts` map containing:
102+
Accepts an optional `opts` map containing:
103103
104-
- **`:concurrency`** :int (default 4) - The maximum number of packages that
105-
can be executing at a time.
106-
- **`:run-in-order`** :boolean (default `true`) - Set this to false to run
107-
all packages concurrently ignoring their dependency order.
108-
- **`silent`** :boolean (default `false`) - Set this to true to disable
109-
logging the package name and version.
104+
- **`:concurrency`** :int (default 4) - The maximum number of packages that
105+
can be executing at a time.
106+
- **`:run-in-order`** :boolean (default `true`) - Set this to false to run
107+
all packages concurrently ignoring their dependency order.
108+
- **`silent`** :boolean (default `false`) - Set this to true to disable
109+
logging the package name and version.
110110
111-
The `build-fn` will be called with the `*project-root*` var (from
112-
`clojure.tools.build.api`) bound to the subdirectory of the relevant package.
113-
This allows using the various API's from `tools.build` under the assumption
114-
that all specified paths will be relative to the package subdirectory.
111+
The `build-fn` will be called with the `*project-root*` var (from
112+
`clojure.tools.build.api`) bound to the subdirectory of the relevant package.
113+
This allows using the various API's from `tools.build` under the assumption
114+
that all specified paths will be relative to the package subdirectory.
115115
116-
TIP: Use the [[clojure.tools.build.api/resolve-path]] API to resolve a path
117-
relative to the current package dir.
116+
TIP: Use the [[clojure.tools.build.api/resolve-path]] API to resolve a path
117+
relative to the current package dir.
118118
119-
The `build-fn` will be called concurrently (up to max of `:concurrency` or
120-
`4`) but packages with dependencies will only be executed after each of their
121-
respective dependencies have run unless `:run-in-order` is `false`."
119+
The `build-fn` will be called concurrently (up to max of `:concurrency` or
120+
`4`) but packages with dependencies will only be executed after each of their
121+
respective dependencies have run unless `:run-in-order` is `false`."
122122
{:style/indent :defn
123123
:malli/schema
124124
[:function

packages/kmono-core/src/k16/kmono/core/config.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
(defn resolve-workspace-config
3232
"Read in and validate kmono workspace config at a given `root` dir.
3333
34-
This will attempt to load the key `:kmono/workspace` from both a `deps.edn`
35-
file and a `deps.local.edn` file at the given `root`. These will be merged
36-
together with the `deps.local.edn` taking precedence."
34+
This will attempt to load the key `:kmono/workspace` from both a `deps.edn`
35+
file and a `deps.local.edn` file at the given `root`. These will be merged
36+
together with the `deps.local.edn` taking precedence."
3737
[root]
3838
(let [root-workspace-config (read-kmono-config (fs/file root "deps.edn") :kmono/workspace)
3939
local-workspace-config (read-kmono-config (fs/file root "deps.local.edn") :kmono/workspace)
@@ -49,7 +49,7 @@
4949

5050
(defn resolve-package-config
5151
"Read in and validate kmono package config from a package at the given
52-
`package-path`."
52+
`package-path`."
5353
[package-path]
5454
(let [deps-file-path (fs/file package-path "deps.edn")
5555

packages/kmono-core/src/k16/kmono/core/deps.clj

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@
7979

8080
(defn filter-package-aliases
8181
"Filter the given `packages` map by those that contain aliases described by at
82-
least one of the given given `globs`.
82+
least one of the given given `globs`.
8383
84-
Returns a map with pkg-name as the key and the set of aliases from that
85-
package that matched the globs.
84+
Returns a map with pkg-name as the key and the set of aliases from that
85+
package that matched the globs.
8686
87-
```clojure
88-
(filter-package-aliases {:package-a {}} [:*/test])
89-
;; => {:package-a #{:test}}
90-
```"
87+
```clojure
88+
(filter-package-aliases {:package-a {}} [:*/test])
89+
;; => {:package-a #{:test}}
90+
```"
9191
[globs packages]
9292
(reduce
9393
(fn [packages [pkg-name pkg]]
@@ -113,17 +113,17 @@
113113

114114
(defn generate-sdeps-aliases
115115
"Generate an `-Sdeps` compatible map containing aliases generated from various
116-
workspace sources.
116+
workspace sources.
117117
118-
This is the primary way of augmenting clojure with new classpath information.
118+
This is the primary way of augmenting clojure with new classpath information.
119119
120-
Aliases are generated from:
120+
Aliases are generated from:
121121
122-
1. The set of packages in the workspace. These are added into an alias called
123-
`:kmono/packages` containing `:extra-deps`.
124-
2. All the aliases from all packages in the workspace are raised up and
125-
combined, scoping their alias names to the package name.
126-
3. The aliases from `deps.local.edn` in the project root."
122+
1. The set of packages in the workspace. These are added into an alias called
123+
`:kmono/packages` containing `:extra-deps`.
124+
2. All the aliases from all packages in the workspace are raised up and
125+
combined, scoping their alias names to the package name.
126+
3. The aliases from `deps.local.edn` in the project root."
127127
[project-root packages]
128128
(let [local-deps
129129
(fs/file project-root "deps.local.edn")

packages/kmono-core/src/k16/kmono/core/fs.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
(find-project-root parent current-root)))))
5757

5858
(defn find-project-root!
59-
"This is the same as [[k16.kmono.core.fs/find-project-root]] but will throw
60-
an exception if no project root can be found."
59+
"This is the same as [[k16.kmono.core.fs/find-project-root]] but will throw an
60+
exception if no project root can be found."
6161
([] (find-project-root! nil))
6262
([dir]
6363
(let [root (find-project-root dir)]

packages/kmono-core/src/k16/kmono/core/graph.clj

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
(defn find-cycle
4747
"Find a dependency cycle in `packages` and returns it as a closed path.
4848
49-
Returns a vector like `[a b c a]` for a cycle `a -> b -> c -> a`, or nil if
50-
no cycle is found."
49+
Returns a vector like `[a b c a]` for a cycle `a -> b -> c -> a`, or nil if
50+
no cycle is found."
5151
[packages]
5252
(loop [nodes (sort (keys packages))
5353
visited #{}
@@ -73,19 +73,19 @@
7373

7474
(defn parallel-topo-sort
7575
"Sort a given `packages` map by the order in which the packages therein depend
76-
on each other.
76+
on each other.
7777
78-
As an example, if I have 3 packages `a`, `b`, `c` and `b` depends on `a`
79-
then:
78+
As an example, if I have 3 packages `a`, `b`, `c` and `b` depends on `a`
79+
then:
8080
81-
```clojure
82-
(parallel-topo-sort {a {} b {} c {}})
83-
;; => [[a c] [b]]
84-
```
81+
```clojure
82+
(parallel-topo-sort {a {} b {} c {}})
83+
;; => [[a c] [b]]
84+
```
8585
86-
This is generally used to calculate the execution order of packages when
87-
trying to run commands in subpackages or build/release packages in the
88-
correct order."
86+
This is generally used to calculate the execution order of packages when
87+
trying to run commands in subpackages or build/release packages in the
88+
correct order."
8989
{:malli/schema [:=> [:cat core.schema/?PackageMap] [:maybe ?ExecOrder]]}
9090
[packages]
9191
(let [stage
@@ -113,7 +113,7 @@
113113
(defn query-dependents
114114
"Find all dependent packages of `pkg-name` within the give `packages` map.
115115
116-
This includes all transitive dependencies."
116+
This includes all transitive dependencies."
117117
{:malli/schema [:=> [:cat core.schema/?PackageMap :symbol] [:set :symbol]]}
118118
[packages pkg-name]
119119

@@ -156,15 +156,15 @@
156156
(defn filter-by
157157
"Filter a given `packages` map by those that match the given `predicate-fn`.
158158
159-
If the `:include-dependents` property is `true` then all dependent packages
160-
of the retained packages will also be kept.
159+
If the `:include-dependents` property is `true` then all dependent packages
160+
of the retained packages will also be kept.
161161
162-
This function will update the `:depends-on` and `:dependent` keys of each
163-
retained package to include only other packages that still remain in the map.
162+
This function will update the `:depends-on` and `:dependent` keys of each
163+
retained package to include only other packages that still remain in the map.
164164
165-
It's generally recommended to use this function instead of writing your own
166-
package filtering. If you need to write your own then you should also make
167-
sure to keep the `:depends-on` and `:dependents` updated."
165+
It's generally recommended to use this function instead of writing your own
166+
package filtering. If you need to write your own then you should also make
167+
sure to keep the `:depends-on` and `:dependents` updated."
168168
([predicate-fn packages] (filter-by predicate-fn {} packages))
169169
([predicate-fn {:keys [include-dependents]} packages]
170170
(let [filtered

0 commit comments

Comments
 (0)