Goal
Enable safe cleanup of leftover template files when switching between templates by introducing a manifest that tracks template-owned files.
Scope
- Define a
TemplateFiles property (or similar) in the template's sync metadata to store a list of relative paths for template-owned files
- Templates are responsible for declaring their own manifest; the CLI reads it but does not generate it
- Implement manifest comparison logic during
SwitchTemplateAsync to identify files that exist in the old template but not in the new one
- Add an opt-in flag (e.g.,
--clean-leftovers or --clean) to the switch template command to enable deletion of orphaned template files
- Respect existing
EntryModelPolicies to ensure user content directories are never deleted
- Gracefully handle templates without a manifest (older versions): cleanup is not possible, warn the user
Outcome
Users who switch templates will have the option to get a clean result without manually hunting down and removing obsolete files from the previous template. The default behavior remains safe (no deletion), preserving backward compatibility.
Notes
- The manifest is template-owned: each template declares which files belong to it
- If either the old or new template lacks a manifest, cleanup cannot be performed safely and the CLI should inform the user
- Consider whether the manifest should track file hashes to detect user modifications to template files (future enhancement)
- Related code:
ProjectService.SwitchTemplateAsync, KeystoneSyncModel, EntryModelPolicies.ExcludeUserContent
Goal
Enable safe cleanup of leftover template files when switching between templates by introducing a manifest that tracks template-owned files.
Scope
TemplateFilesproperty (or similar) in the template's sync metadata to store a list of relative paths for template-owned filesSwitchTemplateAsyncto identify files that exist in the old template but not in the new one--clean-leftoversor--clean) to the switch template command to enable deletion of orphaned template filesEntryModelPoliciesto ensure user content directories are never deletedOutcome
Users who switch templates will have the option to get a clean result without manually hunting down and removing obsolete files from the previous template. The default behavior remains safe (no deletion), preserving backward compatibility.
Notes
ProjectService.SwitchTemplateAsync,KeystoneSyncModel,EntryModelPolicies.ExcludeUserContent