PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/readme.md

https://gitlab.com/javajamesb08/generator-angular-fullstack
Markdown | 403 lines | 282 code | 121 blank | 0 comment | 0 complexity | 2a254f8ab92e59b2cb25800597b319b9 MD5 | raw file
  1. # AngularJS Full-Stack generator [![Build Status](https://travis-ci.org/DaftMonk/generator-angular-fullstack.svg?branch=master)](http://travis-ci.org/DaftMonk/generator-angular-fullstack) [![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/DaftMonk/generator-angular-fullstack)
  2. > Yeoman generator for creating MEAN stack applications, using MongoDB, Express, AngularJS, and Node - lets you quickly set up a project following best practices.
  3. ## Example project
  4. Generated with defaults: http://fullstack-demo.herokuapp.com/.
  5. Source code: https://github.com/DaftMonk/fullstack-demo
  6. ## Usage
  7. Install `generator-angular-fullstack`:
  8. ```
  9. npm install -g generator-angular-fullstack
  10. ```
  11. Make a new directory, and `cd` into it:
  12. ```
  13. mkdir my-new-project && cd $_
  14. ```
  15. Run `yo angular-fullstack`, optionally passing an app name:
  16. ```
  17. yo angular-fullstack [app-name]
  18. ```
  19. Run `grunt` for building, `grunt serve` for preview, and `grunt serve:dist` for a preview of the built app.
  20. ## Prerequisites
  21. * MongoDB - Download and Install [MongoDB](http://www.mongodb.org/downloads) - If you plan on scaffolding your project with mongoose, you'll need mongoDB to be installed and have the `mongod` process running.
  22. ## Supported Configurations
  23. **Client**
  24. * Scripts: `JavaScript`, `CoffeeScript`
  25. * Markup: `HTML`, `Jade`
  26. * Stylesheets: `CSS`, `Stylus`, `Sass`, `Less`,
  27. * Angular Routers: `ngRoute`, `ui-router`
  28. **Server**
  29. * Database: `None`, `MongoDB`
  30. * Authentication boilerplate: `Yes`, `No`
  31. * oAuth integrations: `Facebook` `Twitter` `Google`
  32. * Socket.io integration: `Yes`, `No`
  33. ## Injection
  34. A grunt task looks for new files in your `client/app` and `client/components` folder and automatically injects them in the appropriate places based on an injection block.
  35. * `less` files into `client/app.less`
  36. * `scss` files into `client/app.scss`
  37. * `stylus` files into `client/app.styl`
  38. * `css` files into `client/index.html`
  39. * `js` files into `client/index.html`
  40. * `coffeescript` temp `js` files into `client/index.html`
  41. ## Generators
  42. Available generators:
  43. * App
  44. - [angular-fullstack](#app) (aka [angular-fullstack:app](#app))
  45. * Server Side
  46. - [angular-fullstack:endpoint](#endpoint)
  47. * Client Side
  48. - [angular-fullstack:route](#route)
  49. - [angular-fullstack:controller](#controller)
  50. - [angular-fullstack:filter](#filter)
  51. - [angular-fullstack:directive](#directive)
  52. - [angular-fullstack:service](#service)
  53. - [angular-fullstack:provider](#service)
  54. - [angular-fullstack:factory](#service)
  55. - [angular-fullstack:decorator](#decorator)
  56. * Deployment
  57. - [angular-fullstack:openshift](#openshift)
  58. - [angular-fullstack:heroku](#heroku)
  59. ### App
  60. Sets up a new AngularJS + Express app, generating all the boilerplate you need to get started.
  61. Example:
  62. ```bash
  63. yo angular-fullstack
  64. ```
  65. ### Endpoint
  66. Generates a new API endpoint.
  67. Example:
  68. ```bash
  69. yo angular-fullstack:endpoint message
  70. [?] What will the url of your endpoint to be? /api/messages
  71. ```
  72. Produces:
  73. server/api/message/index.js
  74. server/api/message/message.spec.js
  75. server/api/message/message.controller.js
  76. server/api/message/message.model.js (optional)
  77. server/api/message/message.socket.js (optional)
  78. ### Route
  79. Generates a new route.
  80. Example:
  81. ```bash
  82. yo angular-fullstack:route myroute
  83. [?] Where would you like to create this route? client/app/
  84. [?] What will the url of your route be? /myroute
  85. ```
  86. Produces:
  87. client/app/myroute/myroute.js
  88. client/app/myroute/myroute.controller.js
  89. client/app/myroute/myroute.controller.spec.js
  90. client/app/myroute/myroute.html
  91. client/app/myroute/myroute.scss
  92. ### Controller
  93. Generates a controller.
  94. Example:
  95. ```bash
  96. yo angular-fullstack:controller user
  97. [?] Where would you like to create this controller? client/app/
  98. ```
  99. Produces:
  100. client/app/user/user.controller.js
  101. client/app/user/user.controller.spec.js
  102. ### Directive
  103. Generates a directive.
  104. Example:
  105. ```bash
  106. yo angular-fullstack:directive myDirective
  107. [?] Where would you like to create this directive? client/app/
  108. [?] Does this directive need an external html file? Yes
  109. ```
  110. Produces:
  111. client/app/myDirective/myDirective.directive.js
  112. client/app/myDirective/myDirective.directive.spec.js
  113. client/app/myDirective/myDirective.html
  114. client/app/myDirective/myDirective.scss
  115. **Simple directive without an html file**
  116. Example:
  117. ```bash
  118. yo angular-fullstack:directive simple
  119. [?] Where would you like to create this directive? client/app/
  120. [?] Does this directive need an external html file? No
  121. ```
  122. Produces:
  123. client/app/simple/simple.directive.js
  124. client/app/simple/simple.directive.spec.js
  125. ### Filter
  126. Generates a filter.
  127. Example:
  128. ```bash
  129. yo angular-fullstack:filter myFilter
  130. [?] Where would you like to create this filter? client/app/
  131. ```
  132. Produces:
  133. client/app/myFilter/myFilter.filter.js
  134. client/app/myFilter/myFilter.filter.spec.js
  135. ### Service
  136. Generates an AngularJS service.
  137. Example:
  138. ```bash
  139. yo angular-fullstack:service myService
  140. [?] Where would you like to create this service? client/app/
  141. ```
  142. Produces:
  143. client/app/myService/myService.service.js
  144. client/app/myService/myService.service.spec.js
  145. You can also do `yo angular-fullstack:factory` and `yo angular-fullstack:provider` for other types of services.
  146. ### Decorator
  147. Generates an AngularJS service decorator.
  148. Example:
  149. ```bash
  150. yo angular-fullstack:decorator serviceName
  151. [?] Where would you like to create this decorator? client/app/
  152. ```
  153. Produces
  154. client/app/serviceName/serviceName.decorator.js
  155. ###Openshift
  156. Deploying to OpenShift can be done in just a few steps:
  157. yo angular-fullstack:openshift
  158. A live application URL will be available in the output.
  159. > **oAuth**
  160. >
  161. > If you're using any oAuth strategies, you must set environment variables for your selected oAuth. For example, if we're using Facebook oAuth we would do this :
  162. >
  163. > rhc set-env FACEBOOK_ID=id -a my-openshift-app
  164. > rhc set-env FACEBOOK_SECRET=secret -a my-openshift-app
  165. >
  166. > You will also need to set `DOMAIN` environment variable:
  167. >
  168. > rhc config:set DOMAIN=<your-openshift-app-name>.rhcloud.com
  169. >
  170. > # or (if you're using it):
  171. >
  172. > rhc config:set DOMAIN=<your-custom-domain>
  173. >
  174. > After you've set the required environment variables, restart the server:
  175. >
  176. > rhc app-restart -a my-openshift-app
  177. To make your deployment process easier consider using [grunt-build-control](https://github.com/robwierzbowski/grunt-build-control).
  178. **Pushing Updates**
  179. grunt
  180. Commit and push the resulting build, located in your dist folder:
  181. grunt buildcontrol:openshift
  182. ### Heroku
  183. Deploying to heroku only takes a few steps.
  184. yo angular-fullstack:heroku
  185. To work with your new heroku app using the command line, you will need to run any `heroku` commands from the `dist` folder.
  186. If you're using mongoDB you will need to add a database to your app:
  187. heroku addons:add mongohq
  188. Your app should now be live. To view it run `heroku open`.
  189. >
  190. > If you're using any oAuth strategies, you must set environment variables for your selected oAuth. For example, if we're using **Facebook** oAuth we would do this :
  191. >
  192. > heroku config:set FACEBOOK_ID=id
  193. > heroku config:set FACEBOOK_SECRET=secret
  194. >
  195. > You will also need to set `DOMAIN` environment variable:
  196. >
  197. > heroku config:set DOMAIN=<your-heroku-app-name>.herokuapp.com
  198. >
  199. > # or (if you're using it):
  200. >
  201. > heroku config:set DOMAIN=<your-custom-domain>
  202. >
  203. To make your deployment process easier consider using [grunt-build-control](https://github.com/robwierzbowski/grunt-build-control).
  204. #### Pushing Updates
  205. grunt
  206. Commit and push the resulting build, located in your dist folder:
  207. grunt buildcontrol:heroku
  208. ## Bower Components
  209. The following packages are always installed by the [app](#app) generator:
  210. * angular
  211. * angular-cookies
  212. * angular-mocks
  213. * angular-resource
  214. * angular-sanitize
  215. * angular-scenario
  216. * es5-shim
  217. * font-awesome
  218. * json3
  219. * jquery
  220. * lodash
  221. These packages are installed optionally depending on your configuration:
  222. * angular-route
  223. * angular-ui-router
  224. * angular-socket-io
  225. * angular-bootstrap
  226. * bootstrap
  227. All of these can be updated with `bower update` as new versions are released.
  228. ## Configuration
  229. Yeoman generated projects can be further tweaked according to your needs by modifying project files appropriately.
  230. A `.yo-rc` file is generated for helping you copy configuration across projects, and to allow you to keep track of your settings. You can change this as you see fit.
  231. ## Testing
  232. Running `grunt test` will run the client and server unit tests with karma and mocha.
  233. Use `grunt test:server` to only run server tests.
  234. Use `grunt test:client` to only run client tests.
  235. **Protractor tests**
  236. To setup protractor e2e tests, you must first run
  237. `npm run update-webdriver`
  238. Use `grunt test:e2e` to have protractor go through tests located in the `e2e` folder.
  239. ## Environment Variables
  240. Keeping your app secrets and other sensitive information in source control isn't a good idea. To have grunt launch your app with specific environment variables, add them to the git ignored environment config file: `server/config/local.env.js`.
  241. ## Project Structure
  242. Overview
  243. client
  244.    app - All of our app specific components go in here
  245.    assets - Custom assets: fonts, images, etc
  246.    components - Our reusable components, non-specific to to our app
  247. e2e - Our protractor end to end tests
  248. server
  249. api - Our apps server api
  250. auth - For handling authentication with different auth strategies
  251. components - Our reusable or app-wide components
  252. config - Where we do the bulk of our apps configuration
  253. local.env.js - Keep our environment variables out of source control
  254.    environment - Configuration specific to the node environment
  255. views - Server rendered views
  256. An example client component in `client/app`
  257. main
  258. main.js - Routes
  259. main.controller.js - Controller for our main route
  260. main.controller.spec.js - Test
  261. main.html - View
  262. main.less - Styles
  263. An example server component in `server/api`
  264. thing
  265. index.js - Routes
  266. thing.controller.js - Controller for our `thing` endpoint
  267. thing.model.js - Database model
  268. thing.socket.js - Register socket events
  269. thing.spec.js - Test
  270. ## Contribute
  271. See the [contributing docs](https://github.com/DaftMonk/generator-angular-fullstack/blob/master/contributing.md)
  272. This project has 2 main branches: `master` and `canary`. The `master` branch is where the current stable code lives and should be used for production setups. The `canary` branch is the main development branch, this is where PRs should be submitted to (backport fixes may be applied to `master`).
  273. By seperating the current stable code from the cutting-edge development we hope to provide a stable and efficient workflow for users and developers alike.
  274. When submitting an issue, please follow the [guidelines](https://github.com/yeoman/yeoman/blob/master/contributing.md#issue-submission). Especially important is to make sure Yeoman is up-to-date, and providing the command or commands that cause the issue.
  275. When submitting a PR, make sure that the commit messages match the [AngularJS conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/).
  276. When submitting a bugfix, try to write a test that exposes the bug and fails before applying your fix. Submit the test alongside the fix.
  277. When submitting a new feature, add tests that cover the feature.
  278. See the `travis.yml` for configuration required to run tests.
  279. ## License
  280. [BSD license](http://opensource.org/licenses/bsd-license.php)