How it works¶
The Platform CLI is largely a wrapper around
Copier, with a few tweaks to support
easier-to-reason-about file exclusions and answers files in the
.<TEMPLATE_NAME>/ subdirectories.
Review Copier's basic concepts and how updates work.
But in brief, when you install a template template-foo for app bar a few
things happen:
- The repository for
template-foois cloned to a local temporary directory. - Note, the latest tagged version in the repository is checked out by
default. Overridable with the
--versionarg. - The
copier.ymlfile is read from the localtemplate-fooclone, which provides the configuration and parameters of the template (e.g., what questions to ask the user). - If there are template parameters that need answered (and they have not been
provided explicitly via
--dataargs), the user is prompted for them. - A
.template-foodirectory is created at the top-level of the project with abar.ymlinside it, containing the version of the template used and the answers to the parameters for thebarinstance of the template. - The files in the local clone of
template-fooare iterated over and copied to the project, with templates being populated with the provided answers.
On update:
- The repository for
template-foois cloned to a local temporary directory. - The version of
template-foocurrently used by the project is used to create a create a fresh instance of the template with the current project parameters, effectively a clean copy of the existing project as if it had just been created from the template. - This clean copy of the project is then compared to the actual current project, and the diff recorded. Effectively capturing any changes that have be made to the project outside of the template process itself, to re-apply later.
- The latest tagged version (or value specified by
--version) oftemplate-foois then applied to the project, prompting for any new parameters that need answers. Similar to the install process, though with some special logic around deleted files, etc. .template-foo/bar.ymlfile at the top-level of the project is updated for the answers to any new parameters and the updated template version.- The diff of manual changes from before is applied.