Archived
3
0

extract config to external files
Some checks failed
Check indentation / build (push) Has been cancelled
Continuous testing / build (push) Has been cancelled

This commit is contained in:
2025-03-12 23:08:40 +01:00
parent 975ebedace
commit 5513042b1b
10 changed files with 193 additions and 46 deletions

11
lib/config.mk Normal file
View File

@@ -0,0 +1,11 @@
JQ_INTO_TOML := '.prod|to_entries.[]|if (.value | type == "object") then "\n[" + .key + "]\n" + (.value|to_entries.[] | if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end) + "\n" else if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end end'
define to_toml
jq -r '.$(1)|to_entries.[]|if (.value | type == "object") then "\n[" + .key + "]\n" + (.value|to_entries.[] | if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end) + "\n" else if (.value | type == "string") then .key + " = \"" + (.value|tostring) + "\"" else .key + " = " + (.value|tostring) end end' $(2) > $(3)
endef
dst/dev_config.toml: config.json dst
$(call to_toml,dev,$<,$@)
dst/prod_config.toml: config.json dst
$(call to_toml,prod,$<,$@)