-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed global commands not being discovered where Composer installs th… #3615
Conversation
I'm really unsure about why we have both I'm ambivalent about all of the file searching here. Maybe we should call the finder twice, once at |
…em, or if symlinked by using a Composer path repository.
8eb7bd5
to
9b4b6fe
Compare
…s of Composer installer paths that exist.
I've got this issue as well and would love to see this (or some variation) merged in. What is left to do here - explicitly call the finder twice and update docs? |
The main requirements are 1) passing tests and 2) no excessive searching. If someone has created |
Actually, I'm just going to use the new namespaces recommended in the docs: http://docs.drush.org/en/master/commands/#global-drush-commands I think that works better anyway since autoloading classes in global Drush commands was problematic, for me at least. In other words, there is not much value for nesting commands under src/ or whatever. Thanks! |
Do those work though? The point of this issue is that commands aren't being discovered.
Can you confirm if the above works? |
Yes, that works for me with Drush 9.4.0. What didn't work for me was nesting further, like under a src/ directory:
⬆️ Doesn't work. |
Oh wait -- does 'dev_modules' in the filename need to match 'dev_modules' in the namespace? If that's the case, then that won't work for projects that have hyphens in the name. I've already filed an issue for that. |
No, hyphens will not work but you can get around that by specifying a custom install name for you package: https://github.com/composer/installers#custom-install-names |
A PR in consolidation/annotated-command to transliterate the dashes to underscore would be welcome. |
This is not working for me, because Annotated Command is deriving the namespace from the path in discoverCommandFilesInLocation()... see consolidation/annotated-command#155 |
Ok so consolidation/annotated-command#155 is by design, I am told over there. I don't understand how this problem is meant to be fixed. |
I'm not sure either. I'm open to suggestions. Above I said this PR would be fine if it avoided excessive searching should anyone drop a large folder in their DRUPAL/drush directory. I'm also in favor of deprecating commandfile searching and coming up with a more clear declarative API. @weitzman was just using some plugin mechanism that @Chi-teck extracted from one of his projects. Maybe that would be helpful here? I don't know anything about it, so I don't know. |
Can you change the installer name in your package's composer.json to match the namespace? Ex.
That's what I was referring to in #3615 (comment). Sorry if I'm missing something. |
Yup, I did that. Annotated Command assumes the namespace is something different, and so the command class is not picked up.
I'm burnt out on this. Drush 9 breaks my command package completely. I don't know what direction to take, as Drush/AC/Robo seem to have different and conflicting requirements. I just want ONE way of registering a command to work so my package works -- I don't care how. |
I'm -1 on Drush global commands and +1 on standalone commands (see https://github.com/g1a/starter) that AC does not have a plugin mechanism. Robo has a recommended plugin mechanism, but Drush does not use it. Drush focused on a plugin mechanism for modules, and stopped short of providing a clean mechanism for global commands. If you want to keep on the global command bandwagon, you're going to have to push through and make the darn thing work. There's not a lot of demand for this, though, and as I said above and before, we're de-emphasizing global commands because it really complicates the dependency hell problem, especially if you want to allow your global plugins to have dependencies. I'm sorry this has been rough on you; no one has had time to fix all of the hard problems yet. |
But correct me if I'm wrong -- you're one of the principal authors of all three packages! Why don't they agree on how to do things?
Sorry, I am done here. I am probably the only user of the Drupal Code Builder Drush command, since now Drush comes bundled with code generator of its own, people will be using that, even if it is very limited compared to DCB. So carrying on banging my head against a wall here is just a waste of my time and sapping my morale. |
I agree with @joachim-n, drush command discovery is a mess (sorry). I would like to see a clear vision (or example) whats supported and whats not. I packaged my drush commands as composer package (e.g. https://github.com/webflo/config_file_import). The 2.x worked for Drush 9, but is completely broken in Drush 9.3 and 9.4. The instructions on https://docs.drush.org/en/master/commands/#global-drush-commands are not composer friendly because we are mixing custom (project specific) commands with "vendored" commands. I tried to add an additional folder to the discovery via "drush/drush.yml", but this does not as intended.
|
Here is a global command working with Drush 9.4.0 if that helps anyone. https://github.com/richardbporter/drush-users-commands |
Drush users-commands requires:
If different global command have different Composer installer requirements, then they won't work together. I agree that global commands are messed up right now. It would be good if someone could come up with a proposal and PR that worked in a consistent way & didn't involve too much deep directory searching. |
OK, regarding It seems that per #3566 (comment) (and per @richardbporter in #3615 (comment)), site-wide Drush commands (those that are part of a site, but not packaged with a module) do work, but only for commands I think there is nothing for it but to support the paths I am continuing this work in #3687 |
See #3610