[make:*] interactivly install composer dependencies#1466
[make:*] interactivly install composer dependencies#1466jrushlow wants to merge 4 commits intosymfony:1.xfrom
Conversation
| * Interface that all maker commands must implement. | ||
| * | ||
| * @method static string getCommandDescription() | ||
| * @method void configureComposerDependencies(DependencyManager $dependencyManager) |
There was a problem hiding this comment.
Not a fan of touching the interface... better ideas are welcome..
| * | ||
| * @internal | ||
| */ | ||
| abstract class AbstractClassDependency |
There was a problem hiding this comment.
Originally went with a single class that had bool $isRequired to determine if the dependency was required or optional. I went with an abstract base model and a RequiredClassDependency && OptionalClassDependency for better DX / code review readability... Atleast that was the intent..
| { | ||
| // @TODO - do we deprecate this method in favor of the one above. then remove in 2.x | ||
| // @TODO - still have plenty of work todo to determine if thats possible or a good idea... | ||
| } |
There was a problem hiding this comment.
Not a fan of touching the abstraction - but it keeps BC in check w/ the interface change. (see note on that below)
| // @TODO - with the dependencyManager in `Command` -> we can't use it outside of configure dependencies..... | ||
| $this->dependencyManager->installOptionalDependencies(); |
There was a problem hiding this comment.
Not sure how to go about using the manager in other maker methods (aside from configureDepends...) Gonna play around with this a bit more. but other ideas are welcome.. Thought about some sort of setter in AbstractMaker or a constructor param in the individual makers that needs this...
7f19dfe to
0b215ad
Compare
| } | ||
|
|
||
| public function configureDependencies(DependencyBuilder $dependencies): void | ||
| public function configureComposerDependencies(DependencyManager $dependencyManager): void |
There was a problem hiding this comment.
I'm wondering if we can simplify. A few things:
- Could we keep
DependencyBuilder? It already records the required dependencies, which allows us to know if we need to throw an error. Now we're just going to use this to runcomposer requireinstead of throwing an error. - In
DependencyBuilder, we have this idea of an "optional dependency". I'm wondering if we can scrap that. It seems rarely used and the usages look questionable. For example, inMakeForm, we markvalidatoras optional. We should be more opinionated: validation is required. We also markormas optional inMakeForm. That probably should be optional. But why record that as an optional dependency at all? I'd just not mention it or handle it at all.
The tl;dr is
A) Can we keep using DependencyBuilder but not worry about this optional dependencies idea anymore?
B) For packages that we discover that we need only during the interactive phase (e.g. ux-live-component after answering the "live" question), could we just make some new service available (that maker commands could DI into their constructor) that allows you to trigger the install? e.g.
if ($input->getOption('live')) {
$this->dependencyDownloader->installPackage('symfony/ux-live-component', $io);
}This could interactively ask them if they want to install and do it. Else throw an exception to exit the command. Or maybe we go further and just composer require packages that are needed and just notify the user as we're doing it.
$isLiveComponentbutux-live-componentisn't installed, let's ask if they want us to run composer for them...On Success (keep it clean with no output from the process):
On Failure (we dump composer output):
fixes: #1277