IdanCo / ng1bs4

AngularJS with Bootstrap 4
https://idanco.github.io/ng1bs4
38 stars 13 forks source link

yeoman generator for components #41

Closed IdanCo closed 7 years ago

IdanCo commented 7 years ago

Add some awesome sauce to the project by harnessing the powers of yeoman to scaffold new components with a single click.

simply install yeoman, and inside the project folder type

yo ./generators/component

And follow the on-screen instructions.

@langdonx - if you get a chance, you're welcome to take it for a spin

langdonx commented 7 years ago

This is great! I was able to create a test component. The only change I'd say that should definitely be made is to use backticks in component-name-demo.md for the default value. Is the escaping necessary there too, I wonder?

I don't have any experience with Yeoman, but is there no way for it to modify library.module.js, docs.module.js, and docs.html or to at least call to some external .js file that can do it? It shouldn't be too hard to script those changes. The other alternative is to write a babel plugin that generates the module based on the all the sub-directories (I do have experience with this).

langdonx commented 7 years ago

Ah, component-name-demo.md also needs the ngbs- prefix on the first line.

## ngbs-<%- componentName %>
IdanCo commented 7 years ago

Thanks! fixed issues.

I do wish yeoman could change the existing files. Unfortunately yeoman recommends other libraries for this parts, or even some manual node.js. I don't have any experience with that, so i'll be happy for help if it's up your alley - no pressure. It's not blocking me from merging.

The babel option could be nice, but i'm reluctant to set dependencies during build and not hard-coded. I feel it obscures the app structure.

langdonx commented 7 years ago

Brittle, but functional:

And then just remove the reminders in the this.log statements.

It's brittle because there's no error checking and it expects specific line breaks and indentation. We could make more liberal use of regular expressions to make it less brittle, but it might be OK for now. I'm not sure how to throw errors from Yeoman though, if we were to add error checking.