Mani sync does not remove projects removed from configuration
Is your feature request related to a problem? Please describe
When I use mani sync, and later archive/remove a project from my mani configuration file, running mani sync again does not remove that project directory from my workspace. This leads to outdated project folders remaining in the workspace, even though they are no longer managed in my mani configuration. The workspace becomes cluttered with old projects that no longer match the current state defined in mani.yaml.
Describe the solution you'd like
I would like mani sync to automatically detect and remove project directories from the workspace when those projects have been deleted or archived from the mani configuration file. This would ensure that my workspace always reflects the current state defined in my mani configuration, containing only the projects that are currently active and managed.
Possible implementation approaches:
1. Add a `--cleanup` or `--remove-orphaned` flag to `mani sync` command
2. Make this the default behavior with an opt-out flag like `--no-cleanup`
3. Add a separate command like `mani clean` or `mani workspace cleanup`
Additional context
I regularly update my mani configuration, archiving or removing projects as they become inactive. Currently, I have to manually delete old project directories from my workspace, which:
• Adds unnecessary manual steps to my workflow
• Increases the risk of mistakes (accidentally deleting active projects)
• Results in workspace drift where the actual directories don’t match the configuration
• Makes workspace maintenance more cumbersome over time
This feature would be especially valuable for teams working with dynamic project sets where projects are frequently added, archived, or removed from the mani configuration.
That'd be a nice feature, but it needs to be implemented thoroughly since we'd be deleting files and folders from users filesystem which poses a risk. Would probably need a confirm (Y/N) with a preview of what will be deleted. I don't have time right now to implement this feature but feel free to open up a PR.
I can do that and I can add the confirmation option.
What do you prefer for the implementation approaches:
1. Add a `--cleanup` or `--remove-orphaned` flag to `mani sync` command
2. Make this the default behavior with an opt-out flag like `--no-cleanup`
3. Add a separate command like `mani clean` or `mani workspace cleanup`
Personally I prefer it as a default behavior, I had a case where the repo was duplicated because the path changed.
- I like
--remove-orphanedas it's clear what it does. - Not default behavior since someone might download a mani.yaml file and put it in a directory that already has other folders/files, and then when they run
mani syncit would remove everything (even with the confirm button sometimes people don't read and just press Y). However, we can add an option likeremove_orphaned: truethat you put in your mani.yaml file, then it would be default. We already have these options forsync_gitignore,sync_remotes, etc. - Not sure if we need a new sub-command for this since
mani synckinda implies we are syncing stuff. But if u think there is a case when u sometimes want to only remove orphaned and not clone repos, then I thinkmani cleansounds good.
ok I will create a PR to add --remove-orphaned option, thanks for your feedback!