Swiip/generator-gulp-angular — pull request #148 by marani (2014-12-02 06:40:48+00:00)
Title: Add appPath for customizing angular folder name (In Progress, not ready for merge)

**Problem**
Currently the root folder of Angular app is fixed at `src`. Problem arises when I try to use this generator on top of the base Laravel app, to create Laravel's similar folder named `public`. It is true that we can change Laravel config to point to `src` but since it's not Laravel's default folder, Laravel or its 3rd party packages might silently break due to this, so it's safer to customize the frontend instead. Also other frameworks like Express, Rails, Django, Joomla, Wordpress... might have the same problem.

This is one of the improvements to make the generator achieve higher composability. I am trying to build a Laravel yeoman generator (basically the clone of Laravel base with some Angular-specific configs) to compose it with this generator, and this will make it easier.
Also we could possibly just use sub-generator from generator-angular directly by making the two share the same app path out of the box.

The same feature has also landed on generator-angular earlier this year, and still quite unstable.

**Solution**
So the plan is to either add a question (like I have implemented at this point), or as an argument. It can support multiple level like `path/to/src` This means changes to: generator's main scripts file, templates & tests.
Also to support easier folder change after app is generated, I am trying make all path definition in gulp files more flexible (similar to yeoman.appPath in grunt workflow) so that we only need to change one variable instead of manually.

So the patch is in progress. I would like to post it here for code review & discussion.

**Progress**
Question changes
- [x] prompts.json: json -> js, add appPath question, add when for bootstrap
- [x] index.js: remove when for bootstrap
- [x] package.json: add slash
- [ ] unit test for appPath validatiors

Generator Changes:
- [x] files.json: change dictionary structure
- [x] format.js, write.js: add appPath, move all copy operations into writes.js
- [ ] update test for file creation & options, check missing props variable in template
- [ ] improve comments

Template Changes:
Gulp
- [ ] moves all static 'src' into `gulp/config/path.js`

Everywhere else
- [ ] find & replace` 'src/` with `<%= props.appPath + '/` & `%>`, look for bower_component conflicts in every `../../` escape path.

Generator Tests
- [ ] find & replace` 'src/` with `props.appPath + '/'`.

The major changes are still ahead. Even generator-angular still has minor issues with this feature. Overall, composability is still new to yeoman. So please review & suggest improvement before I can make further changes.

Some problems & ideas:
- The relative path of `bower_components` to `index.html` might make things difficult to compute (source map, font path..). I have read about the topic that led to the change of `bower_components` from `src` back to root folder, but I have some arguments against that, will discuss below.
- Should it be a question or a prompt, or an argument, or both?
- format.js & write.js are growing, and they are sharing some common variables that I had to put into `this`, which is quite ugly.
- I am not really sure about the execution order of methods defined inside index.js, is there any documentation for that. For example, I couldn't find out why `askQuestions`, `formatProps` & `writeFiles` are executed in the right order... I couldn't find these methods in the doc.