mani icon indicating copy to clipboard operation
mani copied to clipboard

Mani sync does not remove projects removed from configuration

Open fazzabi opened this issue 4 months ago • 4 comments

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.

fazzabi avatar Aug 12 '25 10:08 fazzabi

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.

alajmo avatar Aug 12 '25 15:08 alajmo

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.

fazzabi avatar Aug 12 '25 15:08 fazzabi

  1. I like --remove-orphaned as it's clear what it does.
  2. 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 sync it would remove everything (even with the confirm button sometimes people don't read and just press Y). However, we can add an option like remove_orphaned: true that you put in your mani.yaml file, then it would be default. We already have these options for sync_gitignore, sync_remotes, etc.
  3. Not sure if we need a new sub-command for this since mani sync kinda 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 think mani clean sounds good.

alajmo avatar Aug 12 '25 15:08 alajmo

ok I will create a PR to add --remove-orphaned option, thanks for your feedback!

fazzabi avatar Aug 12 '25 15:08 fazzabi