10 releases (6 breaking)
0.7.0 | Feb 4, 2023 |
---|---|
0.6.0 | Feb 3, 2023 |
0.5.0 | Feb 1, 2023 |
0.4.0 | Jan 31, 2023 |
0.1.1 | Jan 29, 2023 |
#2262 in Command line utilities
21 downloads per month
21KB
402 lines
onecfg
One config file to generate them all.
A program for managing config files across multiple repositories with the flexibility to extend and customize predefined configurations.
The idea is that a single config file can be used to control and generate all the necessary settings for a repository, reducing the need to manually manage multiple files.
Installation
cargo install onecfg
Usage
In short, a onecfg file (e.g. onecfg.json
) allows for the automatic generation
of config files as follows:
onecfg onecfg.json
Defining the format of the config files to be generated
{
"defines": {
".prettierrc.json": {"format": "json"}
}
}
Declaring patches specific to certain config files
{
"patches": {
".prettierrc.json": [
{"value": {"printWidth": 80}},
{"value": {"singleQuote": true}}
]
}
}
Extending onecfg files, including using predefined ones for convenience
{
"extends": [
"https://raw.githubusercontent.com/clebert/onecfg-lib/main/lib/onecfg-editorconfig.json",
"https://raw.githubusercontent.com/clebert/onecfg-lib/main/lib/onecfg-git.json",
"https://raw.githubusercontent.com/clebert/onecfg-lib/main/lib/onecfg-prettier.json",
"https://raw.githubusercontent.com/clebert/onecfg-lib/main/lib/onecfg-vscode.json"
]
}
Note: You can use JSON Schema to validate your onecfg file or enable autocompletion in the editor.
Config formats
text
{
"defines": {
"test.txt": {"format": "text"}
},
"patches": {
"test.txt": [{"value": "foo"}, {"value": "bar"}]
}
}
bar
json
{
"defines": {
"test.json": {"format": "json"}
},
"patches": {
"test.json": [{"value": {"foo": "bar"}}, {"value": {"baz": "qux"}}]
}
}
{
"baz": "qux",
"foo": "bar"
}
toml
{
"defines": {
"test.toml": {"format": "toml"}
},
"patches": {
"test.toml": [{"value": {"foo": "bar"}}, {"value": {"baz": "qux"}}]
}
}
baz = "qux"
foo = "bar"
yaml
{
"defines": {
"test.yml": {"format": "yaml"}
},
"patches": {
"test.yml": [{"value": {"foo": "bar"}}, {"value": {"baz": "qux"}}]
}
}
baz: qux
foo: bar
ignorefile
{
"defines": {
".testignore": {"format": "ignorefile"}
},
"patches": {
".testignore": [{"value": ["foo", "bar"]}, {"value": ["baz"]}]
}
}
foo
bar
baz
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Dependencies
~7–15MB
~322K SLoC