-
-
Notifications
You must be signed in to change notification settings - Fork 628
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
Feature: Generators for React/Redux files #245
Comments
We certainly could @aaronvb. Give it a try if you like! However, even more important would be to move over the latest in the https://github.com/shakacode/react-webpack-rails-tutorial/ over to the generators. Specifically, the switch to CSS modules. |
@jbhatab I'm down to pair up or talk about this. Lmk when there's good time to talk about this over Slack. |
@jbhatab posted this to a merged PR @justin808 @samnang @robwise @alexfedoseev As you would normally expect from me, I have to disagree with the 'rails way' here :P. I think for rails it may make sense, but for gems it doesn't. Popular gemshttps://github.com/plataformatec/simple_form. Simple form doesn't automatically include bootstrap and then allow you not include it. https://github.com/plataformatec/devise Devise doesn't automatically setup users for you when you install it and then allow you remove it after. https://github.com/thoughtbot/paperclip#installation Paperclip simply shows you instructions how to set things up and has their installer as a second class citizen. http://activeadmin.info/docs/documentation.html Active admin follows the devise pattern of having two separate installers. The most popular gems I know have generic installers that are simple and then sometimes have options that are second class citizens. And sometimes they even use the readme as the core of things. Similar gemsNow more relevant to what our gem is, here are some good counterparts. EMBERhttps://github.com/emberjs/ember-rails. This is a very similar to gem to what this gem is. They install ember within your rails app. They have one generic installer and 4 options. --ember-path or -d # custom ember path These are very non intrusive options imo compared to what we are doing. Like for us the equivilents would be choosing the custom folder name, skipping git, coffee or es6, and a custom app name. I like those options and they actually stack very well. BACKBONEhttps://github.com/codebrew/backbone-rails This one take an interesting approach I really like. They actually have one default generator and then they have secondary generators for models. Now I could see us having the default generator and then having a secondary generator for redux 'apps' and they can run it repeatedly. That's interesting actually. https://github.com/meleyal/backbone-on-rails Now this one is closer to us in terms of options but they are secondary to the other backbone one, which I imagine played a part in this. Simialrly to ember js though, there options are much more stackable and are much more 'option' like. They are things like names of the folder, app name, coffee vs es6. I'm fine with as many options as we want for this but hello worlds, bootstrap, and to some extent hot reload doesnt fit in this paradigm. This one does do the same thing as the other backbone gem where they have a repeatable second generator. POLYMERhttps://github.com/alchapone/polymer-rails Polymer follows the same pattern of a simple single generator and then a secondary repeatable generator. After looking at these I'm actually in support of doing a single simple generator for just the bare minimum files and then having a secondary generator to generate bundles. Then we have a redux or default option for that. Then with that generator we can add more options like flux or alt. I think this approach is the most fitting. Would love to hear all of your thoughts on this. |
@jbhatab I'd like you to take a first crack at how you'd change the generators such that there's 2 generator commands:
Some needed options for 1) are:
@aaronvb @jbhatab Ball is in your court now. Let me know what you think. |
I agree with @jbhatab on making the generators more simple and and adding a secondary generator for the bundles. I think when we first started the generators, we wanted to show people how react_on_rails worked by generating the hello_world bundles for them. It allowed someone to start a project right away with the way we used react_on_rails. Looking forward I don't think there's anything wrong with that approach for people starting with a blank rails app, but for an existing project, I think it could cause more harm(or confusion) than good. I'm a fan of how devise handles the generators. They provide a base generator install to setup the initializer, and basic structure to integrate devise in a new or existing app, and another generator to create the devise models.
@justin808 I think that's a great approach, let's do it. @jbhatab We could also add to that with simple generators that can create components, etc. ie: |
@justin808 @aaronvb I still want to address some points before we start coding. I think that just attacking it could lead to some wasted efforts. Here are my thoughts on what we could do. Would love input and feedback on this.
|
@jbhatab, I'm not following you on removing what's working. What's the issue with npm-shrinkwrap? |
@justin808 I main issues are maintenance, simplicity, and scope in relation to the generators. It has already been complicated to maintain the single installer and adding a component generator compounds that much more. To be able to adapt and keep all of our documentation consistant with ease it would help to remove a lot of these concepts. We can write blogs on a lot of these concepts that show you how to launch react_on_rails with bootstrap, heroku, linters, etc but I think they should be removed from the installer. |
Hi @jbhatab. Thanks for the help. Here’s some examples that show the differences between generator runs: https://github.com/shakacode/react_on_rails-generator-results (sorry about some diff noise) I’m all in favor of the change to make a new bundle generator. How about if we just do that, as that will be useful to both existing and new installs. We can discuss removing things later. So long as you can generate the full basic install, and then run the bundle generator, we’re OK. Maybe create a fresh PR, pushing an empty branch, and we can put down the changes to the README first and agree on that for the new generator. Please consider creating a simple repo that shows exactly what you want to generate from a given set of options to the bundle generator. That's the best to show this. |
Getting webpack and rails to work nicely together is the main goal of people coming to this repo. Watching Blaine try and teach this stuff to people when he screencasts, I'm noticing that it's really difficult for developers to understand what is going on with the amount of stuff we generate that is tangential to just getting started. Also, there's an appreciable maintenance cost to all of it—a cost which is getting increasingly difficult to pay given how busy we are with internal projects. This is why when I originally made the generators I purposely wrote the code in a way that would make it trivial to remove bootstrap and the linters, with the hopes that one day we would. One thing missing from Blaine's list is removing the express server code. On an internal project, we tried doing the development on the express server first and then porting it over to the rails server, and it didn't work very well at all. Any changes to the Rails application layout must be duplicated to the express server's jade file to ensure styles will work correctly in both environments. There is a huge amount of code to add in order to get the express server to work, including an entirely fake API that can easily get out of sync with the Rails API (assuming it was ever in sync in the first place). |
Thanks for creating this awesome project.
I agree with @jbhatab and @robwise on the removals. I've pulled out everything except bootstrap and hot reloading to make it easier to understand how everything works. Speaking of screencasts, how about a paid screencast series? It could fund some of the work and would probably bring more contributors because the learning curve would be reduced. Side note: I wonder if it would be helpful to add a second bundle to the tutorial code mostly to show how bundles could interact and how react-router would be configured. |
@jbhatab and I discussed this. He's going to create some sample PRs for his upcoming tutorial in terms of what he'd like the generators to do. This will give us a possible idea of how this should work. Here's a simple example: https://github.com/shakacode/react_on_rails-generator-results/pull/227/files. This repo clearly shows what the different options do: https://github.com/shakacode/react_on_rails-generator-results |
@jbhatab also asked me to chime in on this with some of the things I discussed on Slack. It seems like this discussion is going in the right direction, but I'll try to summarize:
Sorry this is very hand-wavy and idealistic for someone who doesn't intend to pitch in and make it better, but HTH anyway :) -- Chad |
@thewoolleyman Did you find the https://github.com/shakacode/react_on_rails-generator-results repo helpful? |
I skimmed them, that looks good and a lot like what I suggested! However, it's still only certain combinations. E.g., skip bootstrap but with server side rendering is not shown. And I know it was discussed above, but it would be great to see examples without the added complexity of hot reloading. I also notice some "spurious" changes in the comparison branches - e.g. bumping the rails version when it's unrelated to the generator option. Seems like this should be automate-able? Just have a script that runs through the generator with everything turned off, then commits that to a clean repo on master branch. Then, iterate for each individual option enabled, and commit the changes to a branch, then resetting back to master and repeat. Then, when done, force push all the branches up to an existing or new repo. And, perhaps one more set of iterations that progressively adds each option in on top of the previous, to catch incompatibilities (at least when options are added in that specific order). That would also be a great integration test of the generator to ensure it doesn't rot. And also, a lot of work to implement and maintain. Again, I'm full of suggestions but not time to implement them. -- Chad |
Chad, we have automated this: https://github.com/shakacode/react-on-rails-generator-results-automation. You've always had the commit bit here. 😸 And regarding tests, we have an amazing system that actually runs the generators and runs specs the generated apps. What's frustrating about this is that @robwise and I did a huge amount of work to get this all going, and we're more than happy to guide somebody to help us, but nobody is volunteering the time to get this done. @yorzi had also helped in the past and did an incredible job. And of course @aaronvb did the initial implementation. So what we have is extremely solid, but it mainly needs the update of the new recommended way of handling CSS using CSS modules, which also includes hot reloading Rails in dev mode. Any ideas on how we can fund the development of this? I'm happy to donate ShakaCode's time in doing the code reviews, etc. Plus, this is a great way for new people to get involved in open source. |
Wow, you already have it automated. I had assume it wasn't since some of the branches had pending pull requests (?) We should put a link to that automation repo in the results repo readme (I would but I'm not positive if the generation of the readme itself is automated?) Yes, the new CSS approach seems to be the crux of a lot of my confusion as well, at least when I was trying to get Jasmine or Karma working. Also, I think that the "basic" version basis for comparison should be considered to be the absolute minimum "everything turned off", even things that are on by default like bootstrap. That is the least amount of confusion (I opened an issue for this ) As for helping paint the fence, I must continue to be selfishly focused on my current hack project, because that's all I have time for on the side (and not enough of that). But hopefully later this year I may have it to the point I want, and then I will try to consider helping move react_on_rails forward. I think it's very solid and has tons of potential. Once I can focus on it and dig in to finally grok the details (and looking at these generator diffs is a great approach), I can be of more use besides pedantic pontificating. |
Sorry for the slow responses. Similar to @thewoolleyman, the time I'm volunteering is also between my side project and day-to-day work. A complete rewrite of the generators might be more than my bandwidth can allow, but I want to see this through and will volunteer as much help as I can. Also, I have some other features I want to see in react_on_rails (like react-stdio as an alternative to therubyracer/execjs) that I want to prioritize as well. |
@aaronvb I agree with you that the react-stdio is much more important. |
@jbhatab I think we could accomplish your goals with the following as an interim step:
With just those small changes you'll be able to create a simple Rails app, and you can rely on the asset pipeline for assets (css, css images, etc.). Let me know what you think of that. I will later change the bootstrap option to bootstrap-loader and use the new Rails hot reloading. |
@justin808 I think making things optional is great. The only remaining issue would be multi options support. If we add the component generator and it needs to support server rendering, client rendering, bootstrap, hot reloading, and linting as options then it will have to have a ton of options that will be hard to maintain. Also, what do you think about moving things like the hot reloader and bootstrap setup to a blog or wiki? That way it doesn't need to be so precise and people can adapt it to their needs. |
Having worked intensely on this:
I don't see any need to throw it away. It needs to be updated to the latest. On the to-do list. |
@justin808 I respect and appreciate the previous work but I want to make sure that looking forward we can make the most pragmatic decisions to make the gem the best experience for the people using it. I don't think we need to throw it away but it is very difficult and time consuming to keep them in. If you keep things like the hot loader and bootstrap in the default generator as options then you need to have those corresponding options on the component generator. It also makes maintaining the giant blogs, tutorials, and examples quite difficult. If we just had modular blogs, we may not even need to update them all as we transition through various versions of the gem. The core of them would still be the same and people would figure out how to apply them to their projects as needed. It also opens up flexibility for us to have other small blogs like integration of foundation 6 or material into react_on_rails without having to change the core of the gem. |
I made some example generators for the installer and component generator. https://github.com/jbhatab/react_on_rails-generators. They are in the pull requests if anyone wants to look it over. |
I agree with @jbhatab. If the default generator includes bootstrap as options, then people will look forward to adding other libraries as options like Materialize, Foundation, etc. I think it's expensive to keep the hot reloader in the default generator. it'd be worth lowering the high maintenance bar with reducing several options. |
@seoyoochan Let me know if you want an invite to our slack room. We're looking for more code contributors! |
@justin808 sure. invite me with supergnee@gmail.com |
Curious on something with this. Love the idea of generators for react & redux files, but im wondering if the install generator this has now should keep the hello world components. It's great to have examples, but can be a lot to cleanup/rename as well. |
@agmcleod we are slowly building towards this. Right now we are stripping the main installer down of options so the component generator will be more manageable. We'll be removing the hello world component in the installer generator when we add this in. |
@agmcleod yeah, ideally, the hello world examples should be easily named by the name argument that user passed in when he activated the install generator. |
Awesome, love to hear it. Very cool project so far, as i'm digging through it. Hats off to you all :) |
@seoyoochan @agmcleod feel free to message me on the shakacode slack. My username is blaine. |
Love where this project is heading. Agree with one of the earlier comments about the difficulty of bringing this in to an existing project, particularly the introduction of all the HelloWorld items. I appreciate why it is done but not great for existing projects IMO. Also fond of the idea of including generators for creating components & redux actions. Keep up the good work!! |
Hi @patrickgordon, we've got a plan for breaking up the current generator into something more suited to both existing and new projects. Personally, I've been focused on the core functionality. @jbhatab is helping with the generator work. For anybody interested in helping, we're always super happy to have more join the party! |
Cool @justin808 I'd offer to help but I'm a bit of a hobbyist programmer and would probably hinder more than help 😄 |
Hi, I was looking for generators to generate bundles. Seems I was a bit late to the game with the idea to make some generators. I totally feel like the approach mentioned by @justin808 in issuecomment-186682640 seems like a good idea, but wouldn't it be good to put the generators in a separate gem? A lot of people (purists? 😄) don't like to use generators, but if you want to build - say - a quick MVP, you could optionally install the We could use the Comments example here as a starting point: https://github.com/shakacode/react-webpack-rails-tutorial for I know I'm repeating stuff that was already mentioned here, but for the sake of clarity I hope. Either way, great stuff here, thank you. And happy to help develop some basic generator gem to start with. |
@foxycoder Interesting to move it to a separate gem... Is this a common practice? I'd be interested in some other examples if you know of any. |
@foxycoder @patrickgordon Stay tuned. @jbhatab and I are actively working on this. |
@jbhatab is actively working on this. Should we leave this open for now? |
To improve the React experience for many people it could be nice to have a Again, happy to help with this. :) |
@jbhatab @foxycoder @patrickgordon Let's get the next stage of the generator going. Should we close this issue, as it's a lot of scrolling at this point. I'm thinking a new issue where we build off of what's in V6 would be better. |
@jbhatab Any update? |
@jbhatab @foxycoder @patrickgordon, please see #584 where we're updating the redux example. |
Let's make this a PR! |
Are there any plans to implement generators for React components, stores, routes, actions, and Redux reducers, etc?
Similar to how rails generators work for controllers, models, mails, etc.
The text was updated successfully, but these errors were encountered: