-
-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add _updatable: true
to copier.yml
instead of having to create the answers file by hand
#983
Comments
Hi there! I understand the issue, thanks for posting it! To fix your current problem, you'll have to remove the broken answers file, commit and copy again. I won't reject the fix if you want to contribute it, but I don't plan to add it. After all, I think it's normal that, if you don't follow the docs regarding how to create the answers file, Copier crashes. 😅
Hey such a good idea! I'll close this issue and open a new discussion about this idea: #1011 |
I wonder whether we actually need to require a Copier template to contain a file So why not omit the WDYT, @yajo and @heavelock? /cc @pawamoy |
From my perspective of a first time user, it was a bit confusing that there was an answer file that I had to prefill with a required content. Of course, I admit this is my fault because it is written in the documentation and I should have followed it better. However, I completely agree with you @sisp that pre-existence of this file is not really necessary. |
The file is needed because it is a way to indicate that you support updates. Without it, your template becomes bootstrap-only, just like cookiecutter or yeoman. It also helps on advanced use cases like meta-templates. I agree it could be replaced by a |
_updatable: true
to copier.yml
instead of having to create the answers file by hand
I think neither The different ways of generating a project would look like this:
Project updates would look like this:
WDYT? |
I like the fact that updates support is opt-in. I myself have updatable and non-updatable templates. I wouldn't like to loose that. Supporting updates adds load on the template maintenance, so I think it's better to start from simple to complex. Reusing the answers file option is IMHO less explicit. That would make updates opt-out instead. I don't see many benefits TBH. 🤔 |
Opt-in vs. opt-out is a fair point. I'm not opinionated at all. The current behavior is fine for me. |
I still find the
This approach is backwards compatible as we would still support the To illustrate the compatibility and behavior of the different options, this table might help:
|
Don't you think |
Our current design is that each option has 3 possible sources: API, CLI and
Also, passing Also, what if So, to avoid ambiguities, I think a new, explicit, bool-only option is better.
It would make sense if you have a |
Thanks for your detailed reply. You're arguments are convincing, let's stick with |
I agree that it would be nice to get rid of the template, which is confusing. |
That's an interesting PoV. It'd be a breaking change if we default to true, but it makes sense indeed. |
Describe the problem
I created my first template with
{{_copier_conf.answers_file}}.jinja
file that was completely empty.I ran
copier package_template new_package
which created a new project.Then I re-ran the same command
copier package_template new_package
which lead copier to crash.File "/Users/qsbt/.local/pipx/venvs/copier/lib/python3.9/site-packages/copier/subproject.py", line 66, in last_answers for key, value in self._raw_answers.items() AttributeError: 'NoneType' object has no attribute 'items'
To Reproduce
\{\{_copier_conf.answers_file\}\}.jinja
. Have at least 1 questioncopier package_template new_package
. Answer anythingcopier package_template new_package
.If the template file for the answers contains jinja2 template, everything works properly.
Logs
Full exception stack.
Expected behavior
I would expect copier to check if it can render template for the
.copier-answer.yml
and complain if it cannot since it's a vital file for the template.Maybe even create a template for a template that would be shipped with copier?
copier new_template
that would create all expected files for a template?Environment
The text was updated successfully, but these errors were encountered: