cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Remove config files after a 'npm uninstall'

Open Jwaegebaert opened this issue 10 months ago • 5 comments

When a user uninstalls our package, config files like .cli-m365-all-connections.json are not automatically removed. These leftover files should be cleaned up to maintain a tidy environment and prevent potential issues. We need to explore a solution that ensures these files are properly deleted during the uninstallation process, avoiding unnecessary data persistence.

Ref: https://github.com/pnp/cli-microsoft365/issues/6601#issuecomment-2671158941

Jwaegebaert avatar Feb 28 '25 13:02 Jwaegebaert

Just had a quick look at the npm docs and it doesn't seem like we'll have an easy way to hook onto uninstall events:

Due to the lack of necessary context, uninstall lifecycle scripts are not implemented and will not function.

ref: https://docs.npmjs.com/cli/v11/using-npm/scripts#a-note-on-a-lack-of-npm-uninstall-scripts

Jwaegebaert avatar Feb 28 '25 13:02 Jwaegebaert

Good find. We might need to consider a separate command that does the cleanup such as m365 uninstall. After cleaning up, it would show a message to run npm uninstall.

waldekmastykarz avatar Feb 28 '25 13:02 waldekmastykarz

What if we just create some uninstallation guidance around that? A separate command to do that seems a bit if an overkill for me.

Adam-it avatar Mar 07 '25 08:03 Adam-it

What if we just create some uninstallation guidance around that? A separate command to do that seems a bit if an overkill for me.

That's low hanging fruit. If there's more feedback/demand, we can always look for ways to simplify it.

waldekmastykarz avatar Apr 03 '25 13:04 waldekmastykarz

Alright, then I'll spec out a m365 uninstall command.

Jwaegebaert avatar Apr 17 '25 10:04 Jwaegebaert