generator-mean-stack
v0.4.0
Published
An other Yeoman Generator for MEAN (MongoDB, ExpressJS, AngularJS, NodeJS) applications
Downloads
9
Maintainers
Readme
Yeoman generator for MEAN stack projects
Introduction
MEAN stack defines application using MongoDB, ExpressJS, AngularJS and NodeJS for a full Javascript development. This generator will help you to start with a solid base, which permits you to code faster. Some usual tasks are handled in sub-generators too.
Prerequisites
To use the generator, you need some prerequisites :
- Node.js with NPM
- MongoDB (only needed if you want to use a local database, you could use a MongoDB web service like Mongolab too, but for development purpose it could be useful to have a local database)
- Yo - This package manage all Yeoman's generators
$ npm install -g yo
- Bower - Bower will manage your frontend dependencies
$ npm install -g bower
- Grunt - Grunt will automate some tasks to build your app or check if there's no error in your code.
$ npm install -g grunt-cli
Please make sure to read the documentation of these packages before starting your MEAN project. You also need to know basics about Express, AngularJS, Mongoose and Passport.
Installation
Install the generator
$ npm install -g generator-mean-stack
Make a new directory and cd into it
$ mkdir -p mean-project && cd $_
Scaffold a new MEAN stack project
yo mean-stack
Note: If you want to test user authentication in the new generated project, you need to leave ngRoute, ngCookies and nodemailer
You also need Bootstrap and Font Awesome to get the good demo project style
Generators
Available generators:
- mean-stack (or mean-stack:app)
- mean-stack:bRoute
- mean-stack:bModel (coming soon)
- mean-stack:fRoute (coming soon)
Note: Generators are to be run from the app root directory
App
Sets up a new MEAN stack app, generating all the boilerplate you need to get started.
Example:
$ yo mean-stack
bRoute
Sets up a new route in Express router (located in app/backend/router/routes
dir).
You can choose if the route has a restricted access (only for users) and if you want a ready CRUD template.
Example:
$ yo mean-stack:bRoute
Note: CRUD will create a route AND start the bModel sub-generator to set up a new Mongoose model
If you want to skip bModel generator, use the --skip-model
option.
$ yo mean-stack:bRoute --skip-model
bModel
Create a new Mongoose model (located in app/backend/models
dir).
Suggestion: If you have to make a new route too, use yo mean-stack:bRoute
instead
Example:
$ yo mean-stack:bModel
Serve and build
The generator makes a gruntfile configuration, so building your app becomes easy.
Build a fresh new distribution :
$ grunt
Run the app server in development mode :
$ grunt serve
You can define a production
target to serve in production mode :
grunt serve:production
Note: this last command builds automatically a new distribution before serving.
Deployment
Make sure to test your final distribution with Grunt :
$ grunt serve:production
The final distribution is located in /build
directory.
$ cd build
Everything you need is here, you can init a git repo here and push your build :
git init && git remote add origin pathToYourProductionServer && git commit -am "Build 1.0.0" && git push origin master
Note: Make sure to configure your .gitignore file inside /build directory to match with your production server specifications.
Note2: .git folder and .gitignore file won't be overwritten during new build, but you can add other files too in Gruntfile.js configuration.
MEAN-Stack Example
Coming soon...