Skip to content

Instantly share code, notes, and snippets.

@glefait
Created April 15, 2024 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glefait/0d81a99bc14051f3cee1b1cebb83c27d to your computer and use it in GitHub Desktop.
Save glefait/0d81a99bc14051f3cee1b1cebb83c27d to your computer and use it in GitHub Desktop.
Turn a cookiecutter replay JSON file into a configuration YAML file, easier to commit/reuse
# Requirements
- jq: https://github.com/jqlang/jq
- yq: https://github.com/mikefarah/yq
- CookieCutter: https://github.com/cookiecutter/cookiecutter
# In the following example, the project used is cookiecutter-django.json
# First time: run cookiecutter, chose options
cookiecutter https://github.com/cookiecutter/cookiecutter-django
# Extract parameters from the replay into a config-file
jq '.cookiecutter | with_entries(select(.key | startswith("_") | not))' ~/.cookiecutter_replay/cookiecutter-django.json \
| yq -P '{"default_context":.}' > cc-django-config-file.yml
# Usage
# Option 1: use the saved configuration interactively with saved options as default options
cookiecutter https://github.com/cookiecutter/cookiecutter-django --config-file cc-django-config-file.yml
# Option 2: apply the saved configuration without interaction
cookiecutter https://github.com/cookiecutter/cookiecutter-django --config-file cc-django-config-file.yml --no-input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment