Skip to content

Commit

Permalink
refactor: kmono/config -> kmono/package
Browse files Browse the repository at this point in the history
better naming, keep supporting legacy name
  • Loading branch information
armed committed May 22, 2024
1 parent e4d153d commit 4ffbd5a
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 42 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,24 @@ One can pass this CLI args to `-T:kmono` command

### Package configuration

Package-specific configurations are done within each `deps.edn` file under the `:kmono/config` key:
Package-specific configurations are done within each `deps.edn` file under the `:kmono/package` key:

```clj
:kmono/config {;; maven artifact's group
:group com.example
;; maven's artifactId
;; this is optional and inferred from a package's dir name
:artifact my-lib
;; below are two builtin commands, each package must provide this commands
;; run :exec :build
:build-cmd "just build"
;; run :exec :release
:release-cmd "just release"}
:kmono/package {;; maven artifact's group
:group com.example
;; maven's artifactId
;; this is optional and inferred from a package's dir name
:artifact my-lib
;; below are two builtin commands, each package must provide this commands
;; run :exec :build
:build-cmd "just build"
;; run :exec :release
:release-cmd "just release"}
```

## Quick start (kmono.edn) - experimental

If a package directory has `kmono.edn` file it will be preferred. Configuration schema is the same, but without `:kmono/config` top level key:
If a package directory has `kmono.edn` file it will be preferred. Configuration schema is the same, but without `:kmono/package` top level key:

```clj
{;; maven artifact's group
Expand Down
2 changes: 1 addition & 1 deletion build/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(-> (io/file "deps.edn")
slurp
edn/read-string
:kmono/config))
:kmono/package))

(def lib (symbol (or (System/getenv "KMONO_PKG_NAME")
(str (:group kmono-config) "/" (:artifact kmono-config)))))
Expand Down
8 changes: 4 additions & 4 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:kmono/config {:group com.kepler16
:artifact kmono
:build-cmd "clojure -T:build build"
:release-cmd "clojure -T:build release"}
{:kmono/package {:group com.kepler16
:artifact kmono
:build-cmd "clojure -T:build build"
:release-cmd "clojure -T:build release"}
:paths ["src" "resources"]
:deps {babashka/process {:mvn/version "0.5.21"}
babashka/fs {:mvn/version "0.4.19"}
Expand Down
2 changes: 1 addition & 1 deletion src/k16/kmono/adapters/clojure_deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
(->adapter package-path 10000))
([package-path timeout-ms]
(when-let [deps-edn (read-pkg-deps! package-path)]
(when-let [kmono-config (some-> deps-edn :kmono/config)]
(when-let [kmono-config (some-> deps-edn :kmono/package)]
(let [{:keys [group artifact] :as config}
(-> kmono-config
(adapter/ensure-artifact package-path))
Expand Down
6 changes: 3 additions & 3 deletions src/k16/kmono/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(let [wp-deps-file (fs/file repo-root deps-file)]
(some-> (when (fs/exists? wp-deps-file)
(util/read-deps-edn! wp-deps-file))
(select-keys [:kmono/workspace :kmono/config]))))
(select-keys [:kmono/workspace :kmono/package]))))

(defn get-workspace-config
[repo-root]
Expand All @@ -30,8 +30,8 @@
workspace-config (:kmono/workspace kmono-merged-props)]
(when (seq workspace-config)
(ansi/assert-err!
(not (seq (:kmono/config kmono-merged-props)))
"Both `:kmono/config` and `:kmono/workspace can't be set")
(not (seq (:kmono/package kmono-merged-props)))
"Both `:kmono/package` and `:kmono/workspace can't be set")
(schema/assert-schema!
schema/?KmonoWorkspaceConfig "Workspace config error" workspace-config))
(m/encode schema/?KmonoWorkspaceConfig (or workspace-config {})
Expand Down
7 changes: 6 additions & 1 deletion src/k16/kmono/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
(try
(-> (fs/file file-path)
(slurp)
(edn/read-string))
(edn/read-string)
;; support for legacy name :kmono/config
(update-keys (fn [k]
(if (= k :kmono/config)
:kmono/package
k))))
(catch Throwable e
(throw (ex-info "Could not read deps.edn file"
{:file-path file-path
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/example_repo/packages/bar/deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:kmono/config {:group kepler16
:artifact bar-lib
:build-cmd "just build-and-install"
:release-cmd "just release"}
{:kmono/package {:group kepler16
:artifact bar-lib
:build-cmd "just build-and-install"
:release-cmd "just release"}
:paths ["src"]
:aliases {:test {:extra-paths ["test"]
:extra-deps {some/dependency {:mvn/version "1.0.0"}}}
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/example_repo/packages/foo/deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:kmono/config {:group kepler16
:artifact foo-lib
:build-cmd "just build-and-install"
:release-cmd "just release"}
{:kmono/package {:group kepler16
:artifact foo-lib
:build-cmd "just build-and-install"
:release-cmd "just release"}
:paths ["src"]
:aliases {:test {:extra-paths ["test"]
:extra-deps {kepler16/bar {:local/root "../bar"}}}}}
4 changes: 2 additions & 2 deletions test/k16/kmono/config_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
:deps {}
:paths ["src"]}))
(spit (fs/file repo-root p1-dir "deps.edn")
(str {:kmono/config {:build-cmd "echo 'build p1'"
(str {:kmono/package {:build-cmd "echo 'build p1'"
:release-cmd "echo 'release p1'"}
:deps {}
:paths ["src"]}))

(spit (fs/file repo-root p2-dir "deps.edn")
(str {:kmono/config {:group "my-own-group"
(str {:kmono/package {:group "my-own-group"
:build-cmd "echo 'build p2'"
:release-cmd "echo 'release p2'"}
:deps {}
Expand Down
20 changes: 10 additions & 10 deletions test/k16/kmono/test_utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@
(fs/create-dirs (fs/path repo-root d)))

(spit (fs/file repo-root "deps.edn")
(str {:kmono/config {:group "kmono-test"
:artifact "root-module"
:build-cmd "echo 'build root'"
:release-cmd "echo 'release root'"}
(str {:kmono/package {:group "kmono-test"
:artifact "root-module"
:build-cmd "echo 'build root'"
:release-cmd "echo 'release root'"}
:deps {}
:paths ["src"]}))

(spit (fs/file repo-root p1-dir "deps.edn")
(str {:kmono/config {:group "kmono-test"
:build-cmd "echo 'build p1'"
:release-cmd "echo 'release p1'"}
(str {:kmono/package {:group "kmono-test"
:build-cmd "echo 'build p1'"
:release-cmd "echo 'release p1'"}
:deps {}
:paths ["src"]}))

(spit (fs/file repo-root p2-dir "deps.edn")
(str {:kmono/config {:group "kmono-test"
:build-cmd "echo 'build p2'"
:release-cmd "echo 'release p2'"}
(str {:kmono/package {:group "kmono-test"
:build-cmd "echo 'build p2'"
:release-cmd "echo 'release p2'"}
:deps {}
:paths ["src"]}))))

Expand Down

0 comments on commit 4ffbd5a

Please sign in to comment.