When composing templates, it's often needed to be able to load answers from other templates that you know are usually combined with yours. Or any other kind of external data.
@moduon MT-8282
This new command allows to reapply a template, keeping old answers but discarding subproject evolution.
It is useful when there are bugs replaying an old version of the template, or when the subproject has drifted too much from the template and you need to reset it.
BREAKING CHANGE: All CLI calls to Copier must now include the subcommand as the 1st argument. For example, `copier` must become now `copier update`; also `copier ./tpl ./dst` must become `copier copy ./tpl ./dst`.
BREAKING CHANGE: All flags must go after the subcommand now. For example, `copier -r HEAD update ./dst` must now become `copier update -r HEAD ./dst` or `copier update ./dst -r HEAD`.
BREAKING CHANGE: Automatic mode removed. Since now subcommands are required, the automatic mode is removed.
BREAKING CHANGE: Deprecated `copier.copy` function is removed. Use `copier.run_copy`, `copier.run_update` or `copier.run_recopy` explicitly as needed.
Fix https://github.com/copier-org/copier/issues/1081
Close https://github.com/copier-org/copier/issues/1082
When questions didn't have a default answer, the interactive behavior was confusing.
Fixes https://github.com/copier-org/copier/issues/355.
BREAKING CHANGE: All default answers must be explicit now.
* refactor(tests): add type hints and clean up
* fix: import `Protocol` from `typing-extensions` when using Python 3.7
* fix: import `Literal` from `typing-extensions` when using Python 3.7
* refactor(tests): create template and subproject directory using `tmp_path_factory` fixture
* refactor(tests): use OS-agnostic file path separator
* refactor(tests): use `/` separator for `skip_if_exists` paths
* style: fix formatting error
* refactor(tests): expect POSIX path for local repo URL
* Refactor
* Fix#110.
* Rewrite test_config_exclude, test_config_exclude_overridden and test_config_include. These tests were badly designed, using a monkeypatch that would never happen in the real world, and actually producing false positives. I moved them to test_exclude.py and rewritten to test the what and not the how.
* Fix#214 by removing skip option. Relevant tests use the better skip_if_exists=["**"].
* Remove subdirectory flag from API/CLI. It was confusing and could lead to bad maintenance situations. Fixes#315.
* Remove extra_paths and fix#321
* Remember that you cannot use _copier_conf.src_path as a path now
* use dataclasses
* Create errors module, simplify some tests, fix many others
* Fix some tests, complete EnvOps removal
* Fix#214 and some tests related to it
* Reorder code
* Update docs and imports
* Modularize test_complex_questions
* Interlink worker and questionary a bit better
* Removal of Questionary class, which only had 1 meaningful method that is now merged into Worker to avoid circular dependencies.
* Fix#280 in a simple way: only user answers are type-casted inside API, and CLI transforms all `--data` using YAML always. Predictable.
* Use prereleases correctly.
* Reorder AnswersMap to have a more significative repr.
* Simpler cache for old `Question.get_choices()` method (renamed now).
* fix wrong test
* Fix test_subdirectory
* Fix test_tasks (and remove tests/demo_tasks)
* Fix path filter tests, and move it to test_exclude, where it belongs
* Make test_config pass
* Fix more wrongly designed tests
* Use cached_property backport if needed
* xfail test known to fail on mac
* force posix paths on windows
* Add typing_extensions for python < 3.8
* Sort dependencies in pyproject.toml
* Support python 3.6 str-to-datetime conversion
* Workaround https://bugs.python.org/issue43095
* xfail test_path_filter on windows
* Upgrade mkdocs and other dependencies to fix https://github.com/pawamoy/mkdocstrings/issues/222
* Add missing reference docs.
* Add workaround for https://github.com/pawamoy/mkdocstrings/pull/209
* Docs.
* Remove validators module
* Add workaround for https://github.com/pawamoy/mkdocstrings/issues/225
* Restore docs autorefs as explained in https://github.com/pawamoy/mkdocstrings/issues/226#issuecomment-775413562.
* Workaround https://github.com/pawamoy/pytkdocs/issues/86
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
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
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