Handling of .plugged directories in unexpected locations
Referencing https://github.com/imjp94/gd-plug/pull/33#issuecomment-2254405250 where it's mentioned a proposal to move the default plugin directory causes bad behavior for the end user. I am in support of changing the default directory but I think the fix migration-wise is not any sort of automated migration but instead handling the general case of finding .plugged outside of where gd-plug thinks it should be.
There are a couple steps for this.
1. Move directory configuration into res://plug.gd, only falling back to default directory
eg
func _config():
plugged_dir = "addons/"
This ensures that the .plugged directory won't change for a user when updating via upgrade, it feels like something that should be user configurable. Thinking this should not be added with the default path when creating res://plug.gd, but should be added to documentation
2. Search for other .plugged directories if .plugged isn't found at plugged_dir path
If .plugged isn't where it's expected to be in _plug_start(), scan the project for .plugged directories.
If no .plugged directory is found elsewhere, create it.
If another .plugged directory is found:
- If ENV_FORCE is set, delete it
- Otherwise, warn the user and quit with an error message, something like
.plugged directory found at unexpected location
.plugged directory location: "res://wherever/.plugged"
expected location: "res://.plugged"
If this is unintentional, run command again with force
If this is an intended overridden .plugged folder path, add configuration to plug.gd:
func _config():
plugged_dir = "res://wherever/.plugged"
Handling the case of changing the default .plugged directory?
With these changes so far, I believe changing the default location of the .plugged folder requires only one forced upgrade by the end user and no manual file manipulation. I think this is probably ok and maybe even preferred since users may have to update their .gitignore or other files and should be aware of the change
Maybe add a more specific warning if the .plugged location is changing from res://.plugged to res://addons/gd-plug/.plugged.
gd-plug x.x.x has changed the default directory where it keeps plugin repos from "res://.plugged" to "res://addons/gd-plug/.plugged", you will have to force install once or remove the existing .plugged directory manually
Alternatively, more seamless for a casual user, would be that since upgrade uses force mode anyway, upgrade could just set force before _plug_start and then its handled automatically