Koodimonni / Composer-Dropin-Installer

Use composer for installing dropin dependencies
Do What The F*ck You Want To Public License
45 stars 12 forks source link

When installed from git/vcs, original folder not deleted #22

Open Youdaman opened 3 years ago

Youdaman commented 3 years ago

Hi, I have a repo setup using SatisPress where I have a custom plugin that has the following file structure:

foo/

If I setup my website's composer.json with the following:

   "dropin-paths": {
      "wp-content/mu-plugins/": ["type:wordpress-muplugin", "package:repo/foo:foo.php"]
    },

Then it installs the plugin as an muplugin correctly, i.e. it ends up having only wp-content/mu-plugins/foo.php

However if I set it up using git instead:

"repositories": [
   {
      "type": "vcs",
      "url": "https://bar@bitbucket.org/baz/foo.git"
    }
]

and

   "dropin-paths": {
      "wp-content/mu-plugins/": ["type:wordpress-muplugin", "package:baz/foo:foo.php"]
    },

When it installs it leaves behind the original directory, i.e. wp-content/mu-plugins/foo.php along with wp-content/mu-plugins/foo/ (and in that directory is the composer.json, .git/ and .gitignore).

So in summary, pulling from a repo works as expected, moving the specified file and deleting the original directory, but pulling from vcs/git does not delete the original directory after the move.

Youdaman commented 3 years ago

Actually, I just noticed that if I do things using the repo method instead of vcs, it initially puts the plugin in wp-content/plugins/foo/foo.php and then just moves foo.php to wp-content/mu-plugins/foo.php and leaves behind the original directory in wp-content/plugins/foo/

The difference between the repo vs vcs methods then becomes that the repo method has an empty folder left behind while the vcs method has the composer.json and .git/ and .gitignore, so I guess that's just because the repo method doesn't fetch/install these files.

So it looks like the behaviour is probably working as expected and I need to work out whether I want to delete the original directories somehow.

I did spot the following in Dropin.php so I guess that was an idea you had already:

   #We could Remove original directories but don't do it
    #unlink($src);
onnimonni commented 3 years ago

If you add an opt-in option for the delete and document it in readme and add unit test for it I'm willing to merge it 👍