Update TemplatesΒΆ
One of the big advantages of Flexlate is the ease of bringing updates to the template back to your project. Flexlate creates real Git merge conflicts, so you can use your preferred merge tool to resolve them. Flexlate saves the resolved conflicts in Git branches, so you wonβt have to resolve the same conflicts again on the next update.
Updating TemplatesΒΆ
The fxt update
command updates the template(s)
to the latest version allowed. It can also be used to update the data
with or without updating the version.
$ cat answer1.txt 2.7 $ fxt update Syncing changes in flexlate configs to output question1? Format: yaml The second question question2? Format: float 50 create answer1.txt create temp.txt β Successfully updated template output $ cat answer1.txt 50.0 some new footer
By default, it will prompt for all the questions, using the saved answers as defaults. You can change any data that you want during the update process.
Updating without PromptsΒΆ
If you want to use the existing data and skip all prompts, you can
pass the --no-input
flag or -n
for short:
fxt update -n
Updating specific TemplatesΒΆ
You can update specific templates by passing the names of the template sources you want to update, for example:
fxt update copier-simple-example
Checking for UpdatesΒΆ
The fxt check
command
checks for updates to the template(s). It displays
them in a tabular format if there are updates available.
$ fxt check β All templates up to date $ fxt config target copier-simple-example $ fxt check π Some templates are not up to date. Run fxt update to update βββββββββββββββββββββββββ³βββββββββββββββββββββββββββ³ββββββββββββββββββββββββββββ β Template Name β Current Version β Latest Version β β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ© β copier-simple-example β c7e1ba1bfb141e9c577e7c2β¦ β f3fa2c9526c12b3011e0a261β¦ β βββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ
For scripting purposes, it returns code 0
if there are no updates available,
and 1
if there are:
if ! fxt check; then
echo "Need to update template";
else
echo "No updates to template needed";
fi;
Change Target VersionΒΆ
Normally, the target version in a template source will be set to null
,
meaning fxt update
will always update to the newest version. If a template
source was added with the --version
flag, then it will have that version
set as the target version. When the target version is specified for a template
source, fxt update
will not update beyond that version.
To remove the target version, use the
fxt config target
command to remove
the target version.
$ fxt init-from https://github.com/nickderobertis/copier-simple-example --version c7e1ba1bfb141e9c577e7c21ee4a5d3ae5dde04d Initializing flexlate project with default add mode local and user=False in /tmp/tmp9u8snrur β Initializing... β Initializing... β Initializing... β Finished initializing flexlate project Adding template source... Adding template source copier-simple-example from https://github.com/nickderobertis/copier-simple-example β β Sucessfully added template source copier-simple-example β Ή β Ή Applying template copier-simple-example to /tmp/tmp9u8snrur Updating 1 applied templates question1? Format: yaml my answer The second question question2? Format: float 10 create my answer.txt create temp.txt β Successfully updated template output β Successfully applied template copier-simple-example to /tmp/tmp9u8snrur $ cd project $ cat flexlate.json | grep target "target_version": "c7e1ba1bfb141e9c577e7c21ee4a5d3ae5dde04d", $ fxt config target copier-simple-example $ cat flexlate.json | grep target "target_version": null, $ cat 'my answer.txt' 10.0 $ fxt update --no-input Syncing changes in flexlate configs to output create my answer.txt create temp.txt β Successfully updated template output $ cat 'my answer.txt' 10.0 some new footer
Get Automated PRs with Template UpdatesΒΆ
Flexlate has official companion Github Actions that can automate using Flexlate. The Flexlate Update Action can be used to help automatically get PRs for template updates.
If there is a merge conflict in the changes, it will open a separate PR to resolve the conflicts, allowing you to resolve them in Githubβs web editor.
Follow the user guide on CI automation to hook up this workflow and other supporting workflows.
Next StepsΒΆ
In order to keep updating and not have to resolve the same merge conflicts repeatedly, we need to save the Flexlate history.