122 Commits

Author SHA1 Message Date
Jairo Llopis
66ea5ee77a
Refresh copier update docs
Be more specific about what those `*.rej` files are and what to do with them.
2020-04-08 12:08:17 +01:00
Jairo Llopis
63842f5087
Add proseWrap: always to prettier configuration, and re-run pre-commit
This makes YAML and MD files to be automatically wrapped when possible and when it doesn't alter the content meaning. All looks better this way.
2020-04-08 12:01:06 +01:00
Jairo Llopis
d44ba2fbfb
Allow to choose custom answers file
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
2020-03-16 12:50:02 +00:00
Jairo Llopis
2d1f6f3857
Tasks and migrations env utilities
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
2020-03-13 13:33:58 +00:00
Jairo Llopis
9dbad43f6d
More space among questions
As questions can include now a more detailed help and types, it would be helpful to have them more spaced. It looks better.
2020-03-09 13:50:57 +00:00
Jairo Llopis
293d84f73d
Add secret questions support
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
2020-03-02 11:42:11 +00:00
Ben Felder
785db845b4
Add mypy badge 2020-02-28 20:20:48 +01:00
Ben Felder
024cbb0770
Improve grammar of readme 2020-02-28 20:07:23 +01:00
Ben Felder
c7052677d7
Capitalize copier 2020-02-28 19:53:48 +01:00
Ben Felder
34c920bc80
Merge pull request #143 from pykong/coverage_upload
Add coverage upload
2020-02-27 21:55:26 +01:00
Ben Felder
3aa1c4f3f7
Merge pull request #136 from pykong/yaml_include
Include other config files
2020-02-27 21:52:58 +01:00
Ben Felder
c3a4e3f848
Update coverage badge in readme 2020-02-27 21:45:08 +01:00
Ben Felder
7115f109ab
Add Credits section to readme 2020-02-27 21:07:00 +01:00
Ben Felder
3d9229f0e1
Make black happy 2020-02-27 12:36:54 +01:00
Ben Felder
127f467066
Update readme 2020-02-27 12:09:28 +01:00
Ben Felder
be9a6cfd7f
Add code style black basge 2020-02-27 09:47:19 +01:00
Ben Felder
251fe2b2fe
Remove unused imports in tools.py 2020-02-26 20:13:45 +01:00
Ben Felder
cfe81629d2
Update badges in readme 2020-02-26 20:05:31 +01:00
Ben Felder
5286396f14
Update README.md 2020-02-26 19:18:15 +01:00
Ben Felder
c451f4c949
Remove ignore option, adapt tests 2020-02-26 15:50:28 +01:00
Ben Felder
fb7f8ea249
Move image to img/ 2020-02-25 17:11:10 +01:00
Jairo Llopis
f2ae70a4a8
Exclude recursively
Excluding a folder and its contents didn't exclude its subfolders.

Now, excluding a folder excludes all its files and subfolders.

@Tecnativa TT20357
2020-02-24 14:03:03 +00:00
Jairo Llopis
6bf0cedd3a
Add migrations support
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
2020-02-21 13:52:35 +00:00
Jairo Llopis
e5f96ec1d0
Merge pull request #111 from Tecnativa/update-only-git-diff
Updates respecting evolved git history
2020-01-27 11:24:01 +00:00
Jairo Llopis
1f2ce1ed25
Updates respecting evolved git history
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
2020-01-23 12:38:57 +00:00
Jairo Llopis
6dd69a957f
Support custom templates suffix
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
2020-01-23 11:30:56 +00:00
Jairo Llopis
87104e36a5
Rename copierlog to copier-answers across the codebase
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
2020-01-14 09:27:33 +01:00
Jairo Llopis
2241d8fcb9
Add advanced questions format
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
2020-01-13 10:49:59 +01:00
Jairo Llopis
f8673465ba
Improve autoformatting
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).
2020-01-09 13:34:57 +00:00
Jairo Llopis
0a952b7680 Run pre-commit for the 1st time
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!
2019-12-10 11:47:30 +00:00
Ben Felder
82b1e22a3b
Merge pull request #103 from Tecnativa/copierlog
Add .copier-answers.yml to remember last answers
2019-12-03 16:14:44 +01:00
Jairo Llopis
a6643ffa58
Add .copier-answers.yml to remember last answers
- 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
2019-11-28 13:12:46 +00:00
Jairo Llopis
23f78419e8
New Jinja defaults, document how to restore them
- 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
2019-11-20 10:26:39 +00:00
Juan-Pablo Scaletti
c099dad20b Update the URLs in the README 2019-10-28 11:11:22 -05:00
Ben Felder
94b91857b2
Merge branch 'master' into more_cleanups 2019-10-02 20:16:55 +02:00
Juan-Pablo Scaletti
6cbd6c0fea Add coverage badge. Fix #75 2019-09-26 22:15:57 -05:00
Ben Felder
4e3a281585
Further work on README.md. 2019-09-20 20:29:30 +02:00
Ben Felder
21e6573cce
Formatted README.md via prettier.io. 2019-09-20 19:21:31 +02:00
Ben Felder
ad345bf5e3
Grammar and spelling fixes to README.md. 2019-09-20 18:59:53 +02:00
Ben Felder
0c6d586a4d
Removed support for JSON and TOML config files. 2019-09-16 21:03:15 +02:00
Juan-Pablo Scaletti
a13d7dc44f
Depersonalize call to action 2019-09-14 18:04:14 -05:00
Juan-Pablo Scaletti
266080547e Vote for me 2019-09-13 10:34:16 -05:00
Juan-Pablo Scaletti
dabf9cf09f Minor cleanup 2019-08-20 13:41:07 -05:00
Ben Felder
846ecfd7ba Removing python 3.5 support. 2019-07-07 15:40:24 +02:00
Juan-Pablo Scaletti
c715d24588
Update README.md 2019-06-13 23:38:57 -05:00
Juan-Pablo Scaletti
5e008493e8 Add a skip_if_exists option 2019-06-13 21:36:47 -05:00
Juan-Pablo Scaletti
830667c1ad Add a flag to disable the cleanup on error (cleanup enabled by default) 2019-06-13 17:38:48 -05:00
Juan-Pablo Scaletti
fc61a82cbd Explain some edge cases in the README 2019-06-13 17:15:20 -05:00
Juan-Pablo Scaletti
866dfd6a30 Include extra_paths in the README example 2019-06-13 10:17:53 -05:00
Ben Felder
ceca0b4654
Removed '---' from yaml block 2019-06-11 07:54:07 +02:00