Skip to content

Add template file manifest to enable cleanup of leftover files during template switch #85

@lex57ukr

Description

@lex57ukr

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions