{"id":15010341,"url":"https://github.com/eval/bubble-config","last_synced_at":"2025-04-09T22:41:20.337Z","repository":{"id":227500486,"uuid":"771605743","full_name":"eval/bubble-config","owner":"eval","description":"An aero powered config with environments aimed at Babashka tasks.","archived":false,"fork":false,"pushed_at":"2024-03-18T18:32:34.000Z","size":32,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T00:38:18.566Z","etag":null,"topics":["babashka","cli","clojure","configuration"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eval.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-13T15:54:57.000Z","updated_at":"2024-03-15T19:44:32.000Z","dependencies_parsed_at":"2024-03-18T20:02:48.186Z","dependency_job_id":null,"html_url":"https://github.com/eval/bubble-config","commit_stats":null,"previous_names":["eval/bubble-config"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Fbubble-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Fbubble-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Fbubble-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eval%2Fbubble-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eval","download_url":"https://codeload.github.com/eval/bubble-config/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248124848,"owners_count":21051757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babashka","cli","clojure","configuration"],"created_at":"2024-09-24T19:33:39.158Z","updated_at":"2025-04-09T22:41:20.317Z","avatar_url":"https://github.com/eval.png","language":"Clojure","readme":"# 🫧 Bubble C🫧nfig\n\nAn [aero](https://github.com/juxt/aero)-powered config with environments aimed at Babashka tasks.\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://polar.sh/eval\"\u003e\u003cpicture\u003e\u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://polar.sh/embed/subscribe.svg?org=eval\u0026label=Subscribe\u0026darkmode\"\u003e\u003cimg alt=\"Subscribe on Polar\" src=\"https://polar.sh/embed/subscribe.svg?org=eval\u0026label=Subscribe\"\u003e\u003c/picture\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Rationale\n\nI wanted to make my Babashka tasks simpler. Instead of doing variations of `bb some-task --flag1 val1 --flag2 val2` in development/test/production etc., this library allows you to do `bb some-task -e dev` and the right flags for the environment will be read from a config-file and passed to the task (while allowing overrides).\n\n## Usage\n\n### Babashka tasks\n\nThis library is ideal for Babashka tasks as it allows you to call tasks with predefined flags from a config-file.\n\nSay we have a CLI, clojore.core/prn, and create a task from it:\n\n```clojure\n;; bb.edn\n:tasks {\n  prn (exec 'clojure.core/prn)\n}\n```\n\nWorks as expected:\n```shell\n$ bb prn -a 1 -b 2\n{:a 1, :b 2}\n```\n\nNow when you have a lot of flags that also differ between, say, local development, CI and production, then it's convenient to have those environment-specific 'sets' of flags in one config.  \nThis is what Bubble Config allows you to do:\n\n```clojure\n;; config.edn\n:deps  {io.github.eval/bubble-config {:git/sha \"ac45fc05f889e3acfeaeb12e919908e6e42a1c66\"}}\n:tasks {:init\n         (defn config []\n           (exec 'bubble-config.core/config))\n\n  prn (exec 'clojure.core/prn {:exec-args (config)})\n}\n```\n\nInstall a sample config:\n```bash\n$ bb -x bubble-config.core/sample \u003e config.edn\n```\n\nNow we get:\n\n```shell\n# dev environment\n$ bb prn\n{:a 0, :b 1}\n\n# test environment via flag\n$ bb prn -e test\n{:a 0, :b 2, :e \"test\"}\n\n# test environment via env-var\n$ env BBL_ENV=test bb prn\n{:a 0, :b 2}\n\n# config overrides\n$ bb prn -e test -a 2\n{:a 2, :b 2, :e \"test\"}\n```\n\nSo instead of having long commands that differ in every environment, `bb some-task` suffices everywhere. Switching between envs is easy, as is inspecting what the flags per environment look like.\n\n### config\n\nThe config will be read by [aero](https://github.com/juxt/aero) with the following additions/conventions:\n- the `#env` tag-literal\n  which is like `#profile`:  \n  ```clojure\n  #env{:dev  {:database-url \"postgres://localhost:5432/app_dev\"}\n       :test {:database-url \"postgres://localhost:5432/app_test\"}}\n  ```\n  Differences with `#profile`:\n  - In case no env is provided, the first env found in the config-file is assumed (aero uses `:default` as fallback).\n  - Providing an unknown `env` triggers an exception (aero's result would be `nil`).\n- if the config contains a key `:bubble-config/root`, then that will be the result  \n  This to allow for scratchpad keys, e.g.\n  ```clojure\n  {:defaults {:a 1}\n   :bubble-config/root #merge [#ref [:defaults] ,,,]}\n  ```\n  See also [the sample.edn](./resources/sample.edn).\n\n### CLI\n\nUse the `bubble-config.core/print` CLI to see the config for an environment:\n\n![Screenshot 2024-03-15 at 12 58 30](https://github.com/eval/bubble-config/assets/290596/ae7af76b-1ae1-4fb5-8bc0-cc9c1279bedb)\n\n\n``` bash\n# Use this env-var in case you want to test it without a deps.edn file\n$ export BBL_DEPS='{:deps {io.github.eval/bubble-config {:git/sha \"ac45fc05f889e3acfeaeb12e919908e6e42a1c66\"}}}'\n\n# Babashka/Clojure commands side by side\n# a sample config\n$ bb -Sdeps \"${BBL_DEPS}\" -x bubble-config.core/sample | tee config.edn\n$ clojure -Sdeps \"${BBL_DEPS}\" -X bubble-config.core/sample | tee config.edn\n\n# print config\n# the default environment is the first of the detected environments in config.edn\n# meta-data shows, among other things, what envs were detected (left out in following examples).\n$ bb -Sdeps \"${BBL_DEPS}\" -x bubble-config.core/print\n$ clojure -Sdeps \"${BBL_DEPS}\" -X bubble-config.core/print\n^{:bubble-config/available-envs (:dev :test :prod),\n  :bubble-config/config-file \"config.edn\",\n  :bubble-config/current-env :dev}\n{:a 0, :b 1}\n\n# different environment via env-var\n$ env BBL_ENV=prod bb -Sdeps \"${BBL_DEPS}\" -x bubble-config.core/print\n$ env BBL_ENV=prod clojure -Sdeps \"${BBL_DEPS}\" -X bubble-config.core/print\n{:a 0, :b 3}\n\n# different environment via the env-flag (overrides env-var)\n$ bb -Sdeps \"${BBL_DEPS}\" -x bubble-config.core/print -e test\n$ clojure -Sdeps \"${BBL_DEPS}\" -X bubble-config.core/print :env test\n{:a 0, :b 2}\n\n# full help\n$ bb -Sdeps \"${BBL_DEPS}\" -x bubble-config.core/print -h\n$ clojure -Sdeps \"${BBL_DEPS}\" -X bubble-config.core/print :help true\n\n# unknown env raises assert-exception\n$ bb -Sdeps \"${BBL_DEPS}\" -x bubble-config.core/print -e foo\n```\n\n\n## LICENSE\n\nCopyright (c) 2024 Gert Goet, ThinkCreate.\nDistributed under the MIT license. See [LICENSE](LICENSE).\n","funding_links":["https://polar.sh/eval"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feval%2Fbubble-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feval%2Fbubble-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feval%2Fbubble-config/lists"}