Remove config files after a 'npm uninstall'
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
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,
uninstalllifecycle 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
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.
What if we just create some uninstallation guidance around that? A separate command to do that seems a bit if an overkill for me.
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.
Alright, then I'll spec out a m365 uninstall command.