With this enhacenment, template designers are able to choose a different default path for the `.copier-answers.yml` file, and users are still able to alter it via their API/CLI calls.
The main purpose for this is to let users use several templates to fill the same destination directory, and still be able to autoupdate all of them by just providing the answers file path to use.
@Tecnativa TT20357
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
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
This commit fixes#119. Summary:
- Depend on packaging to get a good implementation of PEP 440.
- Document new behaviors.
- Add support for migrations.
- Checkout by default the most modern git tag available in the template.
- Reuse `run_tasks` to run migrations too.
- Use `git describe --tags --always` to obtain template commit, to get a version parseable by PEP 440.
- Update `test_updatediff` to with new behaviors.
@Tecnativa TT20357
Fix#88 the easiest way possible. Changes summary:
- A new `--vcs-ref` flag that indicates which commit/ref you want to copy, and only applies when the source directory is git-versioned.
- A new `--no-diff` flag to `copier update` skips the smartypants diff behavior.
What it does?
- Checks you are updating a git-versioned destination from a git-versioned source.
- Clones the destination into temp dir.
- Does a `copier copy -f tmp_src tmp_dst` (yes, a temp dir also).
- Gets the git diff between `tmp_dst` and `dst_path`.
- Performs a normal `copier update dst_path`.
- Applies the git diff at the end, to try to respect downstream project evolution.
@Tecnativa TT20357
The `.tmpl` suffix doesn't seem to be a very widely adopted standard on the Jinja world. Others like `.jinja` or `.j2` usually have better IDE integration.
It's not like `.tmpl` is a wrong default, so here I'm leaving it as a default but letting template developers to change it to another one that fits better their environment.
Apart from this, if you really had to produce any `.tmpl` files in your copies, having files that ended with `.tmpl.tmpl` seemed a bit weird, while now you can change that suffix to whatever fits better your project.
@Tecnativa TT20357
The initial implementation in https://github.com/pykong/copier/pull/103 was calling the file logfile, but it was renamed to copier-answers later.
However I discovered there are still a few remainders of the old implementation.
Here I remove them.
@Tecnativa TT20357
Fix#89 and fix#89 by adding a new extended syntax to make prompts way more usable.
Leverages plumbum's helpers, so prompt code is removed from Copier codebase, making it smaller BTW.
See README and the new test to understand the new features.
@Tecnativa TT20357
Continues the job started in #104:
- Configure more languages for VSCode to format on save.
- Recommend extensions for VSCode.
- Remove settings from `.prettierrc.yml` that are duplicated in `.editorconfig` (which prettier uses by default).
OK, now this diff is very big, but it's actually modifying only style, not code functions themselves. From now on, this won't have to happen again.
Basically I just ran `pre-commit run --all-files` and committed that. I hope you like how it looks now!
- If the copy destination exists and has a `.copier-answers.yml`, all questions asked in the template `copier.yml` file will get the answer found in `.copier-answers.yml` by default.
- For now, there are no `_private` variables in the copier-answers, but in the future there might be, so I'm documenting that now.
- Add docs for some of Copier's hidden features.
- Add `to_nice_yaml` filter, to be able to dump beautiful YAML. [This name matches that on Ansible](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#filters-for-formatting-data) just in case somebody wants to share templates among both engines, although do not take that as an official support statement.
- Add a test that copies a folder with default data, then copies with altered data, and then copies again with default data and still the altered values have been used.
- This is a partial improvement towards completion of #88.
@Tecnativa TT20357
- Alter comments syntax to match project templating syntax: `[# This is a comment now #]`.
- Document and test the way to restore Jinja2 default syntax. This is not obvious otherwise.
- Update Jinja docs location.
@Tecnativa TT20357