-
Notifications
You must be signed in to change notification settings - Fork 277
Update generate:bundle for non-shared bundles and more #312
Conversation
@weaverryan thanks for your impressive work! Before reviewing the code of your commits, I have two questions:
|
@@ -39,7 +39,7 @@ protected function configure() | |||
new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'), | |||
new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name'), | |||
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'Use the format for configuration files (php, xml, yml, or annotation)'), | |||
new InputOption('structure', '', InputOption::VALUE_NONE, 'Whether to generate the whole directory structure'), | |||
new InputOption('shared', '', InputOption::VALUE_NONE, 'Are you planning on using/sharing this bundle across multiple applications?'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we simplify the question as follows?
Are you planning on sharing this bundle across multiple applications?
@weaverryan I've tested this command with all kinds of option combinations and it always worked great for me. |
@javiereguiluz One last thing. Do you agree that for non-shared bundles that we should continue generating a Thanks! |
@weaverryan I agree with importing the |
@@ -125,7 +125,7 @@ public function testExistingEmptyDirIsFine() | |||
{ | |||
$this->filesystem->mkdir($this->tmpDir.'/Foo/BarBundle'); | |||
|
|||
$this->getGenerator()->generate('Foo\BarBundle', 'FooBarBundle', $this->tmpDir, 'yml', false); | |||
$this->getGenerator()->generate('Foo\BarBundle', 'FooBarBundle', $this->tmpDir, 'yml', true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generateBundle
This is now ready for review! As I mentioned in #315, I think we should merge that in the short-term, then put this into a new version. I'd also like to update several of the other commands for that new version. The last change - other than a new Thanks! |
…ndor namespace (weaverryan) This PR was merged into the 2.4.x-dev branch. Discussion ---------- generate:bundle Allowing a namespace to be used without a vendor namespace Hey guys! This is a quick, BC version of #312, which has become a major update to the entire command. That's great, but it will break some BC and will need to be released as a new version. But right now, it's still impossible to generate a bundle without a vendor namespace. That was the original issue, and the fix is very simple. This fixes that in a BC way. If you *do* omit the vendor namespace, it even gives you a warning (in case someone accidentally says `Acme/FooBundle`, which looks like `AcmeFooBundle` to the system). I've tested both sides of the flow and it works fine. If someone else can double-check, that'll make Fabien's merge much easier. Screenshots Below! Thanks!   Commits ------- 6fe3188 Allowing a namespace to be used without a vendor namespace
Sorry about that, but this PR should be rebased as #321 removed the usage of the deprecated helpers. |
ping @weaverryan |
@weaverryan Can you rebase this PR? |
…en if they're passed to the command line (it simplifies the code a lot)
This is ready to go again! And I have tested all the different paths I can find. Highlights:
@javiereguiluz if you have a few minutes to try this, it would probably help Fabien have the confidence to merge (since the diff is too big to really study). Thanks! |
As there are some "BC breaks", I've bumped the version to 3.0: 176ea17 |
... which makes merging easier :) |
Thanks @weaverryan for working on this feature, this is much appreciated. |
…rafix, weaverryan) This PR was merged into the 3.0.x-dev branch. Discussion ---------- Update generate:bundle for non-shared bundles and more Hi guys! If you're reading this, please try this out and offer any feedback! There are so many different cases, it will make @fabpot's life much much easier (and that's always good). This replaces (adds to) @rafix's work on #299. The task ended up being a bit larger, because there are so many things we *could* change, and we need to communicate things well. Fortunately, the changes here alter the generation process very little - most changes are to *how* we ask the questions. Here are the highlights: * if a bundle is non-shared, we only ask for a bundle name, not a namespace * removed "generate full directory structure" functionality entirely. This added only a few extra files, which I don't think add value. * make `.yml` the service configuration format if you choose annotation format. If you're using annotation for routing, it's likely you're following the best practices are you might be surprised by XML :) * many small output changes BC breaks: * `BundleGenerator::generate` is now gone * The `structure` option was removed * You now get `services.yml` if you choose annotation as your format In #299, we asked the question "should a non-shared bundle have a `Resources/` directory?". I think it should. Why? I think the `AppBundle` is special - it's the one bundle that's truly coupled to your kernel (e.g. `app/` directory), which is why it's ok to store the templates in `app/`. If we also stored templates from other bundles in `app/`, it gets a crowded. If you had a `DefaultController` in 2 bundles, their templates would "want" to occupy the same space (e.g. `app/Resources/views/default/*`). So, I think it makes sense to have only one special bundle (per kernel) that you really *couple* to the kernel. *IF* you choose to add other bundles (which you don't need to do), I think you should organize them more along the lines of traditional bundle, at least for templates. ### TODOS * [x] Import services.xml/yml manually from config.yml for non-shared bundle * [x] Can we break BC in the ways described above? Or do I need to re-add somethings? * [x] Fix the GenerateBundleCommandTest * [x] Add more cases to BundleGeneratorTest for no DI directory * [x] Fix BundleGeneratorTest What does everyone think? /cc @javiereguiluz Thanks! Commits ------- e632cb8 Removing docs for now-gone option 712235e updating the test because we now ALWAYS ask questions, unless you pass --no-interactive 483ab4b Coding standards 1dd31e3 Removing an extra / in the target directory (was ok, but looked bad in messaging) 8ee423b Fixing a bug where we required the vendor namespace in the exact wrong situation a802785 Displaying path to AppKernel in messaging 2673bb4 Fixing wrong separator for namespace 079250f Not asking for the bundle if you're in non-shared mode - it was asking twice ae3db97 Fixing default value to be dependent on the "shared" value baab95e Cleaning some things up and changing the behavior to ask questions even if they're passed to the command line (it simplifies the code a lot) c5785e4 Trying to fix my rebase 89d3ee6 Fixing coding standards 5ae77db Fixing another test now that the Bundle object is being passed c66ed09 Fixing bad indentation (caught by tests!) de0c682 Fixing test by using new Bundle object 8a768ac Fixing bad base class for test cb4b1b9 Tweaking language based on comment from @samsonasik 7a41f5c Adding the ability to import a configuration file from app/config/config.yml 7a6033b Adding a Bundle model object to help centralize its metadata 48ced20 Removing an old, unused method 955fae6 Fixing code standards 5fa687a Fixing a number of tests! e7645da Improving error message on the validator - just a bit more helpful when I'm doing tests 5537e9c Revert "fixing a bug where we'd ask shared even if it were passed as false" e935050 fixing a bug where we'd ask shared even if it were passed as false e388b40 Fixing bug that caused paths to be missing a slash a55f65f Adding line breaks, but no changes bfd1916 Fixing coding standards f0d0b95 Tweaks thanks to @javiereguiluz ad28da8 Major overhaul of the interaction part of the generate:bundle command 42c32d4 Very minor code tweaks (no functional stuff) 4af1618 CS fix 3d65d3c better explanation for --shared option bc058c7 = false in generate method :) 1b5f7fb [WIP] optional vendor's name 8e4e023 shared option set to false by default 5f3233b droped shared element from parameters array in Generator/BundleGenerator.php 5f4d06c docs fixed 763e2f1 more on test 1d4600c [WIP] more on test f541d16 fix test errors in Tests/Command/GenerateBundleCommandTest.php ac39c7a patch applied 778caf2 [DX] Re-work generate:bundle for simple app bundles #290
It's in now, but if @javiereguiluz would test it thoroughly, that would be tremendously helpful (we can even tweak things as we are working on a version nobody is going to use before we decide to tag 3.0.0). |
Hi guys!
If you're reading this, please try this out and offer any feedback! There are so many different cases, it will make @fabpot's life much much easier (and that's always good).
This replaces (adds to) @rafix's work on #299. The task ended up being a bit larger, because there are so many things we could change, and we need to communicate things well.
Fortunately, the changes here alter the generation process very little - most changes are to how we ask the questions. Here are the highlights:
.yml
the service configuration format if you choose annotation format. If you're using annotation for routing, it's likely you're following the best practices are you might be surprised by XML :)BC breaks:
BundleGenerator::generate
is now gonestructure
option was removedservices.yml
if you choose annotation as your formatIn #299, we asked the question "should a non-shared bundle have a
Resources/
directory?". I think it should. Why? I think theAppBundle
is special - it's the one bundle that's truly coupled to your kernel (e.g.app/
directory), which is why it's ok to store the templates inapp/
. If we also stored templates from other bundles inapp/
, it gets a crowded. If you had aDefaultController
in 2 bundles, their templates would "want" to occupy the same space (e.g.app/Resources/views/default/*
). So, I think it makes sense to have only one special bundle (per kernel) that you really couple to the kernel. IF you choose to add other bundles (which you don't need to do), I think you should organize them more along the lines of traditional bundle, at least for templates.TODOS
What does everyone think? /cc @javiereguiluz
Thanks!