diff --git a/README.md b/README.md index fd7e5de..571ab9c 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Unfortunately, cookiecutter does not allow us to show any description of the opt * `create_cli` (yes or no): if you plan to build an application with a command line interface (CLI), select *yes* here. This will integrate a template for the CLI into your project - minimal boilerplate guaranteed! (We're leveraging the awesome [typer](https://typer.tiangolo.com/) library for this.) * `config_file`: select your preferred config format. It is best practice to store your configuration separate from your code, even for small projects, but because there are a gazillion ways to do this, each project seems to reinvents the wheel. We want to provide a few options to set you up with a working configuration: - `yaml`: use [YAML](https://yaml.org/) as your configuration file format. Easy to read and write, widely adopted, relies on the [PyYAML](https://pyyaml.org/) package. - - `hocon`: use [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md) as your configuration file format. It is a superset of JSON, very resilient (it's really hard to make a breaking syntax error) and comes with powerful functions, e.g. for inheritance or variable substitution. Relies on the [pyhocon](https://github.com/chimpler/pyhocon/) package. + - `hocon`: use [HOCON](https://github.com/lightbend/config/blob/master/HOCON.md) as your configuration file format. It is a superset of JSON, very resilient (it's really hard to make a breaking syntax error) and comes with powerful functions, e.g. for inheritance or variable substitution. In this example you can find two environment configurations (`dev.conf`, `prod.conf`) that override parts of the default configuration. Relies on the [pyhocon](https://github.com/chimpler/pyhocon/) package. - `none`: don't need any configuration or want to do your own thing? choose this option. * `code_formatter`: a code formatter is a powerful tool that can help teams to stick to a common code style. However, a formatter cannot solve every code style problem for you and it may lead to issues for users that are not aware of how it works. Always talk to your team about [PEP 8](https://www.python.org/dev/peps/pep-0008/) and a common code style, then choose the right formatter for you (or none at all): - [`black`](https://github.com/psf/black): *the uncompromising Python code formatter*. diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 4c14940..e80176c 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -64,14 +64,15 @@ files_config_hocon = [ f'{module_dir}/util__hocon.py', f'{module_dir}/res/default.conf', - 'config/debug.conf', + 'config/dev.conf', + 'config/prod.conf', ] files_ci_gitlab = { ".gitlab-ci.yml", } -files_ci_all = files_ci_gitlab +files_ci_all = files_ci_gitlab folders_editor = [ '.idea__editor', @@ -165,7 +166,7 @@ def handle_editor_settings(): def handle_ci(): ci_pipeline = '{{ cookiecutter.ci_pipeline }}' - if ci_pipeline == "gitlab": + if ci_pipeline == "gitlab": _delete_files(files_ci_all - files_ci_gitlab) elif ci_pipeline == 'none': _delete_files(files_ci_all) diff --git a/tests/test_options.py b/tests/test_options.py index 83ed6cf..6783bc5 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -83,7 +83,7 @@ def test_config_hocon(): check_project( settings={'config_file': 'hocon', 'create_cli': 'yes'}, files_existent=['src/{module_name}/util.py', 'src/{module_name}/res/default.conf', - 'config/debug.conf'], + 'config/dev.conf', 'config/prod.conf'], files_non_existent=['config/config.yml'], test_cli=True, run_pytest=True) @@ -92,7 +92,7 @@ def test_config_yaml(): check_project( settings={'config_file': 'yaml'}, files_existent=['src/{module_name}/util.py', 'config/config.yml'], - files_non_existent=['config/debug.conf', 'src/{module_name}/res/default.conf'], + files_non_existent=['config/dev.conf', 'config/prod.conf', 'src/{module_name}/res/default.conf'], run_pytest=True) diff --git a/{{cookiecutter.project_slug}}/config/debug.conf b/{{cookiecutter.project_slug}}/config/debug.conf deleted file mode 100644 index 5d668c9..0000000 --- a/{{cookiecutter.project_slug}}/config/debug.conf +++ /dev/null @@ -1 +0,0 @@ -logging.level = DEBUG diff --git a/{{cookiecutter.project_slug}}/config/dev.conf b/{{cookiecutter.project_slug}}/config/dev.conf new file mode 100644 index 0000000..664f55e --- /dev/null +++ b/{{cookiecutter.project_slug}}/config/dev.conf @@ -0,0 +1,2 @@ +environment = "dev" +logging.level = DEBUG # overrides the log level that is specified in res/default.conf diff --git a/{{cookiecutter.project_slug}}/config/prod.conf b/{{cookiecutter.project_slug}}/config/prod.conf new file mode 100644 index 0000000..23a817b --- /dev/null +++ b/{{cookiecutter.project_slug}}/config/prod.conf @@ -0,0 +1 @@ +environment = "prod"