generator-cg-gas
generator-cg-gas copied to clipboard
Making cg-gas generator work out-of-box
The gulp script does not work out-of-box. I made the modifications below so that it would work out of box. The changes are tested with the ui-router option selected.
Problems found
-
html not defined in config
-
Modified JS config to include all JS files other than test-results and bower files
-
added missing app.js to karma config
-
added code to app.js template so that $rootScope.$state and $rootScope.$stateParams are set when ui-router are selected
-
Modified partial/index.js line 52 to remove '/' concat after this.dir. This was cause double slashes '//' for ui-routers. Not sure if it is the same for angualr-router. (will be testing later)
-
Modified gulpfile.js to add () for cb at the end of test:unit. Otherwise the test:unit throws errors at the end of the test. Test complete but scripts exits with error
-
The template/html2js implementation was not working with karma and gulp serve task (out-of-box) Serve may have worked after running build:dist or html task. The following explains my solution to this problem it might be what it was intended to be but after these modification build,build:dist,test:unit,serve,server:dist all work fine.
Index.html references tmp/templates.js which does not work well with karma unit test. The karma server does not recognize the build directory as a resource. I personally like the philosophy of having all of the original files served on normal gulp serve and then have all the packed/minified sources served on serve:dist. It seems the html only runs on serve:dist anyways. Based on this idea I have made the following modifications.
- Modified the 'templates' task to uglify the the result template and put it directly into the build/dist/script folder
- Replaced script reference of tempalte.js the index.html with comment.
- Added code in the html task of the gulp script to replace the html comment with the location of the generated script file.
- Removed template module injection on app.js
- Added code in the html task to add the template module dependency back to app.js when does
Remaining Problem
I could not figure out why browswersync stops under the serve:dist task. The server stops as soon as test:unit is done with Karma. For the lack of a better solution I have removed the build:dist dependency so i can at least serve dist after manually running build:dist. I am new to the javascript/node.js scene so i don't know enough about this to fix it. Please let me know how so I can learn. Another question I have is if watch functionality should be implemented for build:dist.
Questionable scaffolding (Not sure if this should be accepted)
- Questionable scaffolding modified in partial/index.js. Running sub generator partial on modules creates file in app/modules/[module-name]/modules/partial/[partial-name] directory. I removed the extra modules so that the files are created in app/modules/[module-name]/partial/[partial-name] directory
Future effort
Based on reading google’s doc via https://docs.google.com/document/d/1XXMvReO8-Awi1EZXAXS4PzDzdNvV6pGcuaF4 Q9821Es/pub. It seems that this is not a word to word scaffolding implementation. I am thinking about extending this project to utilize the components and sub-section organization by adding component and sub-section sub-generators. I also plan to add -directive -factory -service -controller suffix to all file names that are generated through the sub generators.