generator-moonraft-boilerplate
A Yeoman gulp-angular generator for Moonraft Innovation Labs boilerplate
Build on top of generator-gulp-angular
Usage
Create your project
Install the required tools: yo
, gulp
, bower
npm install -g yo gulp bower
Install generator-moonraft-boilerplate
:
npm install -g generator-moonraft-boilerplate
Make a new directory, and cd
into it:
mkdir my-new-project && cd $_
Run yo moonraft-boilerplate
, optionally passing an app name:
yo moonraft-boilerplate [app-name]
Yo options
yo moonraft-boilerplate --help
or yo moonraft-boilerplate -h
for help. All options are not required. If not provided, default values will be used.
--app-path='src'
customize Angular's app folder, relative to cwd, default is src
--dist-path='dist'
customize build target folder, relative to cwd, default is dist
--e2e-path='e2e'
customize e2e test specs folder, relative to cwd, default is e2e
--tmp-path='.tmp'
customize pre-processing temp folder, relative to cwd, default is .tmp
--skip-install
do not run bower install
and npm install
after generating the app, default is false
(not skip)--skip-welcome-message
skip yo welcome messages, default is false
(not skip)--skip-message
skip install messages, default is false
(not skip)--default
use default configurations, default is false
--advanced
prompt for advanced additional features, default is false
Paths configuration are stored in gulpfile.js
. Change options.(src|dist|tmp|e2e)
in gulpfile.js
if you want to config paths after the app is generated.
Warning: The paths are also written in the index.html
for the build with useref. If you want to change these paths, you also have to change the paths there in order to have the build task working.
Use Gulp tasks
gulp
or gulp build
to build an optimized version of your application in /dist
gulp serve:mock-backend
to launch a browser sync server on your source files with yor mocked data using wiremockgulp serve:live
to launch a browser sync server on your source files with live servergulp serve:dist
to launch a server on your optimized applicationgulp test
to launch your unit tests with Karmagulp test:auto
to launch your unit tests with Karma in watch modegulp protractor
to launch your e2e tests with Protractorgulp protractor:dist
to launch your e2e tests with Protractor on the dist filesgulp scripts
to check js files for any eslint errorsgulp scss-lint
to check scss files for any errorsgulp html-lint
to check HTML files for any errors
More information on the gulp tasks in the User Guide.
Directory structure
Best Practice Recommendations for Angular App Structure
The root directory generated with default paths configuration for application with name gulpAngular
:
├── bower_components/
├── e2e/
├── gulp/
├── nodes_modules/
│
├── src/
│ ├── app/
│ │ ├── components/
│ │ │ └── githubContributor/
│ │ │ │ └── githubContributor.service.js
│ │ │ │
│ │ │ └── malarkey/
│ │ │ │ ├── malarkey.directive.js
│ │ │ │ └── malarkey.(scss|styl|less|css)
│ │ │ │
│ │ │ └── navbar/
│ │ │ │ ├── navbar.directive.(js|ts|coffee)
│ │ │ │ ├── navbar.html
│ │ │ │ └── navbar.(scss|styl|less|css)
│ │ │ │
│ │ │ └── webDevTec/
│ │ │ └── webDevTec.service.js
│ │ │
│ │ ├── main/
│ │ │ ├── main.controller.(js|ts|coffee)
│ │ │ ├── main.controller.spec.js
│ │ │ └── main.html
│ │ │
│ │ └── index.config.(js|ts|coffee)
│ │ └── index.constants.(js|ts|coffee)
│ │ └── index.module.(js|ts|coffee)
│ │ └── index.route.(js|ts|coffee)
│ │ └── index.run.(js|ts|coffee)
│ │ └── index.(scss|styl|less|css)
| |
│ ├── assets/
│ │ └── images/
│ ├── favico.ico
│ └── index.html
│
├── .bowerrc
├── .editorconfig
├── .gitignore
├── .eslintrc
└── .htmlhintrc
├── bower.json
├── gulpfile.js
├── karma.conf.js
├── package.json
└── protractor.conf.js
└── sonar-project.properties
There is none at the generation but you can add .jade
, .haml
or .hbs
(dependent of your HTML pre-processor choice) anywhere in the src
folder and it will be compiled automatically. Warning, the first file of a type in a folder is often missed by the Gulp watch, try to relaunch Gulp if it happens.
Features included in the gulpfile
- useref : allow configuration of your files in comments of your HTML file
- ngAnnotate : convert simple injection to complete syntax to be minification proof
- uglify : optimize all your JavaScript
- csso : optimize all your CSS
- autoprefixer : add vendor prefixes to CSS
- rev : add a hash in the file names to prevent browser cache problems
- watch : watch your source files and recompile them automatically
- eslint : The pluggable linting utility for JavaScript
- scss-lint : linting utility for scss
- html-lint : linting utility for HTML
- imagemin : all your images will be optimized at build
- Unit test (karma) : out of the box unit test configuration with karma
- e2e test (protractor) : out of the box e2e test configuration with protractor
- browser sync : full-featured development web server with livereload and devices sync
- angular-templatecache : all HTML partials will be converted to JS to be bundled in the application
- TODO lazy : don't process files which haven't changed when possible
Questions the generator will ask
- jQuery: jQuery 1.x, 2.x, Zepto, none
- Angular modules: animate, cookies, touch, sanitize
- Resource handler: ngResource, Restangular, none
- Router: ngRoute, UI Router, none
- UI Framework: Bootstrap, Foundation, Angular Material, Material Design Lite, none (depends on the chosen CSS preprocessor)
- UI directives : UI Bootstrap, Angular Strap, official Bootstrap JavaScript, Angular Foundation, official Foundation JavaScript, none (depends on the UI framework)
- CSS pre-processor: Less, Sass with Ruby and Node, Stylus, none
- JS preprocessor: CoffeeScript, TypeScript, ECMAScript 6 (Traceur and Babel), none
- HTML preprocessor: Jade, Haml, Handlebars, none
- TODO Script loader: Require, Webpack, none
- TODO Test framework: Jasmine, Mocha, Qunit
- TODO Prompts for Sonar and Wiremock Settings
- TODO CLI for file creations