Skip to content
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

Generate more derby apps #6

Closed
icaliman opened this issue Jul 9, 2014 · 10 comments
Closed

Generate more derby apps #6

icaliman opened this issue Jul 9, 2014 · 10 comments

Comments

@icaliman
Copy link

icaliman commented Jul 9, 2014

Feature request!

It would be greate to have an app generator, to generate more derby apps in same project.

@icaliman icaliman changed the title Generate new app Generate new derby app Jul 9, 2014
@icaliman icaliman changed the title Generate new derby app Generate more derby apps Jul 9, 2014
@minicuper
Copy link
Contributor

Ok, I will think how to implement this

@mattbrun
Copy link
Contributor

Hoping to help, I'll post here what I did to implement multiple apps by hand.
For example, wanting a boom app aside the app app I did the following:

  • add boom dir with index.js in src/, copied from src/app/index.js
  • add boom dir with index.css in styles/, copied from styles/app/index.css
  • add boom dir with index.html and home.html in views/, copied from views/app/*.html
  • replace the "app" word of src/boom/index.js with the "boom" word
  • change the path in the .get() route in src/boom/index.js
  • add require('./src/boom') in the apps array in server.js

And that was enough, at least for me.

Some considerations:

  • My guess is that the yeoman command might be yo derby:app
  • I think all the files to generate the app are already there, maybe they just need to be extrapolated in their own template directory
  • I'd be more than happy to help build this feature, but I never built a yeoman module (shouldn't be that hard starting from the existing one...), and I'm in a kind of super busy period, so don't expect that too soon... :(

@minicuper
Copy link
Contributor

I think about the issue too. And I'm going to split the generator internally into project-level generating and app-level generating. The two stuff will be still in yo derby.

If you start it inside an empty folder it generates a project with app. But if you start it inside an existing project it will create only a new app.

@mattbrun
Copy link
Contributor

@zag2art I didn't know you may split a single yeoman command into multiple commands which may be called one after another. That makes sense, and I really like you're ideas of splitting things up!

From what I understood there will be one commad which does multiple things in a smart way. But what if you actually put the app generation code in another command and then call it from the project generation command?
In this way when you call 'yo derby' it calls the project and the app generation code, when you call 'yo derby:app' it just can just generate the app.

In this way:

  • generator features are pretty straight forward to learn and there are no hidden things or side-effects like behaviours
  • we don't have to check for files in directories, or checking in which dir we are, or whatsoever...
  • each "module" does one thing, and you call the app module inside the project module
  • my guess is that the code would be simpler and easier to maintain

What do you think?

@minicuper
Copy link
Contributor

Unfortunately yo derby = yo derby:app in yeoman because app is a default generator. Look here. I tried to find the way to change the behavior (here the code) but at the moment didn't find the answer.

@mattbrun
Copy link
Contributor

Ok, I didn't know the alias story.
So, from my point of view, there might be two possibilities:

  • Following your idea of generating different things based on where we are. Maybe searching for the .yo-rc.json file might help, because it should be in the root of the project as stated here at the end. Howeever there might be a case corner: the first time we generate the project, which is in an empty dir;
  • accept an app name parameter for the yo derby command. In this way yo derby bootstrap the project in the current empty dir, and yo derby boom creates the boom app in the apps dir.

I'm not trying to avoid your original idea, I'm just trying to understand if there's a simpler way to do it :)

@mattbrun
Copy link
Contributor

Another possibile solution: accept a parameter name for bot the project or the app generation, but add a --app parameter to generate an app.

@minicuper
Copy link
Contributor

Hmm, I like the second suggestion. Think yo derby boom is quite expressive. Anyway we need to start somewhere.

@mattbrun
Copy link
Contributor

I agree

@minicuper
Copy link
Contributor

Add this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants