The rendering context now includes `_copier_conf`, which is a copy of the raw `ConfigData` object, but removing anything not JSON-serializable (a.k.a. `data.now` and `data.make_secret`).
This is useful for a number of purposes:
1. Imagine you have migration scripts but you want to store them on your template and NOT in your copies. Then you can use `_copier_conf.src_path` to find the local clone and call anything from there. This fixes#95 and fixes#157.
2. In the execution environment, it includes `$STAGE` (can be `task`, `after` or `before`), and in the case of migrations also `$VERSION_{FROM,TO,CURRENT}` to let migration scripts know where they are in the moment they're called, so we can reuse migration scripts and unleash their full power.
Now you can write your scripts in any language you want, and use any task execution system you want. Tests include a bash script and a python script, and docs include how to integrate with Invoke.
@Tecnativa TT20357
Due to copier not reloading the `copier.yml` file when doing the previous step to diff updates, it was trying to run tasks from let's say `v2` of the template after copying its `v1` version.
After this change, when copying `v1`, its `copier.yml` is reloaded, loading tasks for that version only (and executing them as usual).
The patch includes a git bundle that is a git repo with a couple of commits required to replicate the bug.
@Tecnativa TT20357
Secrets questions are available in the jinja render context, but are not logged into `.copier-answers.yml` by default.
To mark a question as secret, just set `secret: true` into its definition. You can also pass a list of question keys in `_secret_questions` if you prefer.
@Tecnativa TT20357
Any other method, if it gets casted from `None` it will return the answer default.
In the case of `str`, `None` would default to `"None"`, which is not desired.
@Tecnativa TT20357
When using the `--data` CLI option, all incoming data are strings. This is the expected behavior because at this point we still don't know the expected types of all answers (we don't even know the questions).
Now the type casting is done smartly when strings come in any form.
There are 2 special cases handled here:
1. When the expected type is bool and the incoming data is string. Handled by YAML because strings like "false", "0" and "no" would evaluate to `True` otherwise.
2. When the expected type is JSON or YAML but the incoming data is not a string. This can only happen when data comes in from API calls (not CLI) or is loaded from default answers in `copier.yml`. In these cases, we don't need to do any type casting, because the input is already a scalar.
@Tecnativa TT20357
Leverage pyyaml for a couple of jobs:
- Harden the possibility of dumping unsafe YAML, which was almost impossible already, but it's safer now.
- Do not sort twice; pyyaml already sorts.
@Tecnativa TT20357