Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Init

  • Loading branch information...
commit b75cbf94e1878ccda47b66a8c637872012229c6b 0 parents
@jrcryer authored
Showing with 888 additions and 0 deletions.
  1. BIN  .DS_Store
  2. +13 −0 .editorconfig
  3. +1 −0  .gitattributes
  4. +2 −0  .gitignore
  5. +21 −0 .jshintrc
  6. +4 −0 .travis.yml
  7. +20 −0 LICENSE
  8. +53 −0 README.md
  9. BIN  app/.DS_Store
  10. +113 −0 app/index.js
  11. BIN  app/templates/.DS_Store
  12. +24 −0 app/templates/_bower.json
  13. +81 −0 app/templates/_gruntfile.js
  14. +41 −0 app/templates/_package.json
  15. +52 −0 app/templates/_server.js
  16. BIN  app/templates/app/.DS_Store
  17. +13 −0 app/templates/app/controllers/index.js
  18. BIN  app/templates/app/models/.DS_Store
  19. BIN  app/templates/app/views/.DS_Store
  20. +13 −0 app/templates/app/views/404.jade
  21. +12 −0 app/templates/app/views/500.jade
  22. +25 −0 app/templates/app/views/includes/foot.jade
  23. +26 −0 app/templates/app/views/includes/head.jade
  24. +4 −0 app/templates/app/views/index.jade
  25. +9 −0 app/templates/app/views/layouts/default.jade
  26. +7 −0 app/templates/config/config.js
  27. +8 −0 app/templates/config/env/all.js
  28. +6 −0 app/templates/config/env/development.json
  29. +6 −0 app/templates/config/env/production.json
  30. +7 −0 app/templates/config/env/test.json
  31. +7 −0 app/templates/config/env/travis.json
  32. +87 −0 app/templates/config/express.js
  33. +8 −0 app/templates/config/routes.js
  34. +13 −0 app/templates/editorconfig
  35. +5 −0 app/templates/gitignore
  36. +40 −0 app/templates/jshintrc
  37. BIN  app/templates/public/.DS_Store
  38. +15 −0 app/templates/public/humans.txt
  39. BIN  app/templates/public/js/.DS_Store
  40. +3 −0  app/templates/public/js/app.js
  41. +19 −0 app/templates/public/js/config.js
  42. +3 −0  app/templates/public/js/controllers/index.js
  43. 0  app/templates/public/js/directives.js
  44. 0  app/templates/public/js/filters.js
  45. +15 −0 app/templates/public/js/init.js
  46. +3 −0  app/templates/public/robots.txt
  47. BIN  app/templates/public/views/.DS_Store
  48. +12 −0 app/templates/public/views/index.html
  49. +7 −0 app/templates/travis.yml
  50. +41 −0 package.json
  51. +38 −0 test/test-creation.js
  52. +11 −0 test/test-load.js
BIN  .DS_Store
Binary file not shown
13 .editorconfig
@@ -0,0 +1,13 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
1  .gitattributes
@@ -0,0 +1 @@
+* text=auto
2  .gitignore
@@ -0,0 +1,2 @@
+node_modules/
+temp/
21 .jshintrc
@@ -0,0 +1,21 @@
+{
+ "node": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 4,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "strict": true,
+ "trailing": true,
+ "smarttabs": true,
+ "white": true
+}
4 .travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - '0.8'
+ - '0.10'
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright 2013 James Cryer
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
53 README.md
@@ -0,0 +1,53 @@
+# generator-mean [![Build Status](https://secure.travis-ci.org/jrcryer/generator-mean.png?branch=master)](https://travis-ci.org/jrcryer/generator-mean)
+
+A generator for [Yeoman](http://yeoman.io).
+
+
+## Getting Started
+
+### What is Yeoman?
+
+Trick question. It's not a thing. It's this guy:
+
+![](http://i.imgur.com/JHaAlBJ.png)
+
+Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create.
+
+Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.*
+
+```
+$ npm install -g yo
+```
+
+### Yeoman Generators
+
+Yeoman travels light. He didn't pack any generators when he moved in. You can think of a generator like a plug-in. You get to choose what type of application you wish to create, such as a Backbone application or even a Chrome extension.
+
+To install generator-mean from npm, run:
+
+```
+$ npm install -g generator-mean
+```
+
+Finally, initiate the generator:
+
+```
+$ yo mean
+```
+
+To start your server:
+
+```
+$ grunt
+```
+
+### Getting To Know Yeoman
+
+Yeoman has a heart of gold. He's a person with feelings and opinions, but he's very easy to work with. If you think he's too opinionated, he can be easily convinced.
+
+If you'd like to get to know Yeoman better and meet some of his friends, [Grunt](http://gruntjs.com) and [Bower](http://bower.io), check out the complete [Getting Started Guide](https://github.com/yeoman/yeoman/wiki/Getting-Started).
+
+
+## License
+
+[MIT License](http://en.wikipedia.org/wiki/MIT_License)
BIN  app/.DS_Store
Binary file not shown
113 app/index.js
@@ -0,0 +1,113 @@
+'use strict';
+var util = require('util');
+var path = require('path');
+var yeoman = require('yeoman-generator');
+
+
+var MeanGenerator = module.exports = function MeanGenerator(args, options, config) {
+ yeoman.generators.Base.apply(this, arguments);
+
+ this.on('end', function () {
+ this.installDependencies({ skipInstall: options['skip-install'] });
+ });
+
+ this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
+};
+
+util.inherits(MeanGenerator, yeoman.generators.Base);
+
+MeanGenerator.prototype.grunt = function grunt() {
+ this.copy('_gruntfile.js', 'gruntfile.js');
+};
+
+MeanGenerator.prototype.bower = function bower() {
+ this.copy('_bower.json', 'bower.json');
+};
+
+MeanGenerator.prototype.jshint = function jshint() {
+ this.copy('jshintrc', '.jshintrc');
+};
+
+MeanGenerator.prototype.travis = function travis() {
+ this.copy('travis.yml', '.travis.yml');
+};
+
+MeanGenerator.prototype.editorConfig = function editorConfig() {
+ this.copy('editorconfig', '.editorconfig');
+};
+
+MeanGenerator.prototype.git = function git() {
+ this.copy('gitignore', '.gitignore');
+};
+
+MeanGenerator.prototype.packageJSON = function packageJSON() {
+ this.copy('_package.json', 'package.json');
+};
+
+MeanGenerator.prototype.app = function app() {
+ this.mkdir('app');
+ this.mkdir('app/controllers');
+ this.mkdir('app/models');
+ this.mkdir('app/views');
+ this.mkdir('app/views/includes');
+ this.mkdir('app/views/layouts');
+
+ this.copy('app/controllers/index.js', 'app/controllers/index.js');
+
+ this.copy('app/views/includes/foot.jade', 'app/views/includes/foot.jade');
+ this.copy('app/views/includes/head.jade', 'app/views/includes/head.jade');
+
+ this.copy('app/views/layouts/default.jade', 'app/views/layouts/default.jade');
+
+ this.copy('app/views/404.jade', 'app/views/404.jade');
+ this.copy('app/views/500.jade', 'app/views/500.jade');
+ this.copy('app/views/index.jade', 'app/views/index.jade');
+};
+
+MeanGenerator.prototype.configSetup = function configSetup() {
+ this.mkdir('config');
+ this.mkdir('config/env');
+ this.mkdir('config/middlewares');
+
+ this.copy('config/env/all.js', 'config/env/all.js');
+ this.copy('config/env/development.json', 'config/env/development.json');
+ this.copy('config/env/production.json', 'config/env/production.json');
+ this.copy('config/env/test.json', 'config/env/test.json');
+ this.copy('config/env/travis.json', 'config/env/travis.json');
+
+ this.copy('config/config.js', 'config/config.js');
+ this.copy('config/express.js', 'config/express.js');
+ this.copy('config/routes.js', 'config/routes.js');
+};
+
+MeanGenerator.prototype.publicSetup = function publicSetup() {
+
+ this.mkdir('public');
+ this.mkdir('public/js');
+ this.mkdir('public/js/controllers');
+ this.mkdir('public/js/services');
+ this.mkdir('public/views');
+};
+
+MeanGenerator.prototype.angularSetup = function angularSetup() {
+
+ this.copy('public/js/controllers/index.js', 'public/js/controllers/index.js');
+ this.copy('public/js/app.js', 'public/js/app.js');
+ this.copy('public/js/config.js', 'public/js/config.js');
+ this.copy('public/js/directives.js', 'public/js/directives.js');
+ this.copy('public/js/filters.js', 'public/js/filters.js');
+ this.copy('public/js/init.js', 'public/js/init.js');
+};
+
+MeanGenerator.prototype.templateSetup = function templateSetup() {
+
+ this.copy('public/views/index.html', 'public/views/index.html');
+
+ this.copy('public/humans.txt', 'public/humans.txt');
+ this.copy('public/robots.txt', 'public/robots.txt');
+};
+
+MeanGenerator.prototype.serverSetup = function serverSetup() {
+ this.copy('_server.js', 'server.js');
+};
+
BIN  app/templates/.DS_Store
Binary file not shown
24 app/templates/_bower.json
@@ -0,0 +1,24 @@
+{
+ "name": "mean",
+ "version": "1.0.0",
+ "dependencies": {
+ "jquery": "~1.9.1",
+ "bootstrap": "~2.3.2",
+ "angular": "~1.0.6",
+ "angular-resource": "~1.0.6",
+ "angular-cookies": "~1.0.6",
+ "angular-bootstrap": "~0.4.0",
+ "angular-ui-utils": "0.0.4",
+ "json3": "~3.2.4"
+ },
+ "exportsOverride": {
+ "bootstrap": {
+ "css": "docs/assets/css/bootstrap*.css",
+ "js": "docs/assets/js/bootstrap.js",
+ "img": "docs/assets/img/glyphicons-halflings*.png"
+ },
+ "angular-ui-utils": {
+ "modules": "modules/route/route.js"
+ }
+ }
+}
81 app/templates/_gruntfile.js
@@ -0,0 +1,81 @@
+module.exports = function(grunt) {
+ // Project Configuration
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ watch: {
+ jade: {
+ files: ['app/views/**'],
+ options: {
+ livereload: true,
+ },
+ },
+ js: {
+ files: ['public/js/**', 'app/**/*.js'],
+ tasks: ['jshint'],
+ options: {
+ livereload: true,
+ },
+ },
+ html: {
+ files: ['public/views/**'],
+ options: {
+ livereload: true,
+ },
+ },
+ css: {
+ files: ['public/css/**'],
+ options: {
+ livereload: true
+ }
+ }
+ },
+ jshint: {
+ all: ['gruntfile.js', 'public/js/**/*.js', 'test/**/*.js', 'app/**/*.js']
+ },
+ nodemon: {
+ dev: {
+ options: {
+ file: 'server.js',
+ args: [],
+ ignoredFiles: ['README.md', 'node_modules/**', '.DS_Store'],
+ watchedExtensions: ['js'],
+ watchedFolders: ['app', 'config'],
+ debug: true,
+ delayTime: 1,
+ env: {
+ PORT: 3000
+ },
+ cwd: __dirname
+ }
+ }
+ },
+ concurrent: {
+ tasks: ['nodemon', 'watch'],
+ options: {
+ logConcurrentOutput: true
+ }
+ },
+ mochaTest: {
+ options: {
+ reporter: 'spec'
+ },
+ src: ['test/**/*.js']
+ }
+ });
+
+ //Load NPM tasks
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-mocha-test');
+ grunt.loadNpmTasks('grunt-nodemon');
+ grunt.loadNpmTasks('grunt-concurrent');
+
+ //Making grunt default to force in order not to break the project.
+ grunt.option('force', true);
+
+ //Default task(s).
+ grunt.registerTask('default', ['jshint', 'concurrent']);
+
+ //Test task.
+ grunt.registerTask('test', ['mochaTest']);
+};
41 app/templates/_package.json
@@ -0,0 +1,41 @@
+{
+ "name": "mean",
+ "description": "MEAN - A Modern Stack: MongoDB, ExpressJS, AngularJS, NodeJS. (BONUS: Passport User Support).",
+ "version": "1.0.0",
+ "private": false,
+ "author": "Amos Haviv",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/linnovate/mean.git"
+ },
+ "engines": {
+ "node": "0.10.x",
+ "npm": "1.2.x"
+ },
+ "scripts": {
+ "start": "node node_modules/grunt-cli/bin/grunt",
+ "test": "node node_modules/grunt-cli/bin/grunt test"
+ },
+ "dependencies": {
+ "express": "latest",
+ "jade": "latest",
+ "mongoose": "latest",
+ "connect-mongo": "latest",
+ "connect-flash": "latest",
+ "underscore": "latest",
+ "async": "latest",
+ "view-helpers": "latest",
+ "forever": "latest",
+ "grunt": "latest",
+ "grunt-cli": "latest"
+ },
+ "devDependencies": {
+ "supertest": "latest",
+ "should": "latest",
+ "grunt-contrib-watch": "latest",
+ "grunt-contrib-jshint": "latest",
+ "grunt-nodemon": "latest",
+ "grunt-concurrent": "latest",
+ "grunt-mocha-test": "latest"
+ }
+}
52 app/templates/_server.js
@@ -0,0 +1,52 @@
+/**
+ * Module dependencies.
+ */
+var express = require('express'),
+ fs = require('fs');
+
+/**
+ * Main application entry file.
+ * Please note that the order of loading is important.
+ */
+
+//Load configurations
+//if test env, load example file
+var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development',
+ config = require('./config/config'),
+ mongoose = require('mongoose');
+
+//Bootstrap db connection
+var db = mongoose.connect(config.db);
+
+//Bootstrap models
+var models_path = __dirname + '/app/models';
+var walk = function(path) {
+ fs.readdirSync(path).forEach(function(file) {
+ var newPath = path + '/' + file;
+ var stat = fs.statSync(newPath);
+ if (stat.isFile()) {
+ if (/(.*)\.(js|coffee)/.test(file)) {
+ require(newPath);
+ }
+ } else if (stat.isDirectory()) {
+ walk(newPath);
+ }
+ });
+};
+walk(models_path);
+
+var app = express();
+
+//express settings
+require('./config/express')(app);
+
+//Bootstrap routes
+require('./config/routes')(app);
+
+//Start the app by listening on <port>
+var port = config.port;
+app.listen(port);
+console.log('Express app started on port ' + port);
+
+//expose app
+exports = module.exports = app;
BIN  app/templates/app/.DS_Store
Binary file not shown
13 app/templates/app/controllers/index.js
@@ -0,0 +1,13 @@
+/**
+ * Module dependencies.
+ */
+var mongoose = require('mongoose'),
+ async = require('async'),
+ _ = require('underscore');
+
+
+exports.render = function(req, res) {
+ res.render('index', {
+ user: req.user ? JSON.stringify(req.user) : "null"
+ });
+};
BIN  app/templates/app/models/.DS_Store
Binary file not shown
BIN  app/templates/app/views/.DS_Store
Binary file not shown
13 app/templates/app/views/404.jade
@@ -0,0 +1,13 @@
+extends layouts/default
+
+block main
+ h1 Oops something went wrong
+ br
+ span 404
+
+block content
+ #error-message-box
+ #error-stack-trace
+ pre
+ code!= error
+
12 app/templates/app/views/500.jade
@@ -0,0 +1,12 @@
+extends layouts/default
+
+block main
+ h1 Oops something went wrong
+ br
+ span 500
+
+block content
+ #error-message-box
+ #error-stack-trace
+ pre
+ code!= error
25 app/templates/app/views/includes/foot.jade
@@ -0,0 +1,25 @@
+script(type='text/javascript', src='/lib/jquery/jquery.js')
+
+//Bootstrap
+script(type='text/javascript', src='/lib/bootstrap/docs/assets/js/bootstrap.js')
+
+//AngularJS
+script(type='text/javascript', src='/lib/angular/angular.js')
+script(type='text/javascript', src='/lib/angular-cookies/angular-cookies.js')
+script(type='text/javascript', src='/lib/angular-resource/angular-resource.js')
+
+//Angular UI
+script(type='text/javascript', src='/lib/angular-bootstrap/ui-bootstrap-tpls.js')
+script(type='text/javascript', src='/lib/angular-ui-utils/modules/route/route.js')
+
+//Application Init
+script(type='text/javascript', src='/js/app.js')
+script(type='text/javascript', src='/js/config.js')
+script(type='text/javascript', src='/js/directives.js')
+script(type='text/javascript', src='/js/filters.js')
+
+//Application Services
+
+//Application Controllers
+script(type='text/javascript', src='/js/controllers/index.js')
+script(type='text/javascript', src='/js/init.js')
26 app/templates/app/views/includes/head.jade
@@ -0,0 +1,26 @@
+head
+ meta(charset='utf-8')
+ meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
+ meta(name='viewport', content='width=device-width,initial-scale=1')
+
+ title= appName+' - '+title
+ meta(http-equiv='Content-type', content='text/html;charset=UTF-8')
+ meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs")
+ meta(name="description", content="MEAN - A Modern Stack: MongoDB, ExpressJS, AngularJS, NodeJS. (BONUS: Passport User Support).")
+
+ link(href='/img/icons/favicon.ico', rel='shortcut icon', type='image/x-icon')
+
+ meta(property='fb:app_id', content='APP_ID')
+ meta(property='og:title', content='#{appName} - #{title}')
+ meta(property='og:description', content='MEAN - A Modern Stack: MongoDB, ExpressJS, AngularJS, NodeJS. (BONUS: Passport User Support).')
+ meta(property='og:type', content='website')
+ meta(property='og:url', content='APP_URL')
+ meta(property='og:image', content='APP_LOGO')
+ meta(property='og:site_name', content='MEAN - A Modern Stack')
+ meta(property='fb:admins', content='APP_ADMIN')
+
+ link(rel='stylesheet', href='/lib/bootstrap/docs/assets/css/bootstrap.css')
+ link(rel='stylesheet', href='/lib/bootstrap/docs/assets/css/bootstrap-responsive.css')
+
+ //if lt IE 9
+ script(src='http://html5shim.googlecode.com/svn/trunk/html5.js')
4 app/templates/app/views/index.jade
@@ -0,0 +1,4 @@
+extends layouts/default
+
+block content
+ section(data-ng-view)
9 app/templates/app/views/layouts/default.jade
@@ -0,0 +1,9 @@
+!!! 5
+html(lang='en', xmlns='http://www.w3.org/1999/xhtml', xmlns:fb='https://www.facebook.com/2008/fbml', itemscope='itemscope', itemtype='http://schema.org/Product')
+ include ../includes/head
+ body
+ header.navbar.navbar-fixed-top.navbar-inverse(data-ng-include="'views/header.html'")
+ section.content
+ section.container
+ block content
+ include ../includes/foot
7 app/templates/config/config.js
@@ -0,0 +1,7 @@
+var _ = require('underscore');
+
+// Load app configuration
+
+module.exports = _.extend(
+ require(__dirname + '/../config/env/all.js'),
+ require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.json') || {});
8 app/templates/config/env/all.js
@@ -0,0 +1,8 @@
+var path = require('path'),
+rootPath = path.normalize(__dirname + '/../..');
+
+module.exports = {
+ root: rootPath,
+ port: process.env.PORT || 3000,
+ db: process.env.MONGOHQ_URL
+}
6 app/templates/config/env/development.json
@@ -0,0 +1,6 @@
+{
+ "db": "mongodb://localhost/mean-dev",
+ "app": {
+ "name": "MEAN - A Modern Stack - Development"
+ }
+}
6 app/templates/config/env/production.json
@@ -0,0 +1,6 @@
+{
+ "db": "mongodb://localhost/mean",
+ "app": {
+ "name": "MEAN - A Modern Stack - Production"
+ }
+}
7 app/templates/config/env/test.json
@@ -0,0 +1,7 @@
+{
+ "db": "mongodb://localhost/mean-test",
+ "port": 3001,
+ "app": {
+ "name": "MEAN - A Modern Stack - Test"
+ }
+}
7 app/templates/config/env/travis.json
@@ -0,0 +1,7 @@
+{
+ "db": "mongodb://localhost/mean-travis",
+ "port": 3001,
+ "app": {
+ "name": "MEAN - A Modern Stack - Test on travis"
+ }
+}
87 app/templates/config/express.js
@@ -0,0 +1,87 @@
+/**
+ * Module dependencies.
+ */
+var express = require('express'),
+ mongoStore = require('connect-mongo')(express),
+ flash = require('connect-flash'),
+ helpers = require('view-helpers'),
+ config = require('./config');
+
+module.exports = function(app) {
+ app.set('showStackError', true);
+
+ //Should be placed before express.static
+ app.use(express.compress({
+ filter: function(req, res) {
+ return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
+ },
+ level: 9
+ }));
+
+ //Setting the fav icon and static folder
+ app.use(express.favicon());
+ app.use(express.static(config.root + '/public'));
+ app.use('/lib', express.static(config.root + '/app/components'));
+
+ //Don't use logger for test env
+ if (process.env.NODE_ENV !== 'test') {
+ app.use(express.logger('dev'));
+ }
+
+ //Set views path, template engine and default layout
+ app.set('views', config.root + '/app/views');
+ app.set('view engine', 'jade');
+
+ //Enable jsonp
+ app.enable("jsonp callback");
+
+ app.configure(function() {
+ //cookieParser should be above session
+ app.use(express.cookieParser());
+
+ //bodyParser should be above methodOverride
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+
+ //express/mongo session storage
+ app.use(express.session({
+ secret: 'MEAN',
+ store: new mongoStore({
+ url: config.db,
+ collection: 'sessions'
+ })
+ }));
+
+ //connect flash for flash messages
+ app.use(flash());
+
+ //dynamic helpers
+ app.use(helpers(config.app.name));
+
+ //routes should be at the last
+ app.use(app.router);
+
+ //Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc.
+ app.use(function(err, req, res, next) {
+ //Treat as 404
+ if (~err.message.indexOf('not found')) return next();
+
+ //Log it
+ console.error(err.stack);
+
+ //Error page
+ res.status(500).render('500', {
+ error: err.stack
+ });
+ });
+
+ //Assume 404 since no middleware responded
+ app.use(function(req, res, next) {
+ res.status(404).render('404', {
+ url: req.originalUrl,
+ error: 'Not found'
+ });
+ });
+
+ });
+};
8 app/templates/config/routes.js
@@ -0,0 +1,8 @@
+var async = require('async');
+
+module.exports = function(app) {
+
+ //Home route
+ var index = require('../app/controllers/index');
+ app.get('/', index.render);
+};
13 app/templates/editorconfig
@@ -0,0 +1,13 @@
+# http://editorconfig.org
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
5 app/templates/gitignore
@@ -0,0 +1,5 @@
+.DS_Store
+.nodemonignore
+.sass-cache/
+node_modules/
+public/lib
40 app/templates/jshintrc
@@ -0,0 +1,40 @@
+{
+ "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
+ "browser": true, // Standard browser globals e.g. `window`, `document`.
+ "es5": true, // Allow EcmaScript 5 syntax.
+ "esnext": true, // Allow ES.next specific features such as `const` and `let`.
+ "bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
+ "camelcase": false, // Permit only camelcase for `var` and `object indexes`.
+ "curly": false, // Require {} for every new block or scope.
+ "eqeqeq": true, // Require triple equals i.e. `===`.
+ "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
+ "latedef": true, // Prohibit variable use before definition.
+ "newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
+ "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
+ "quotmark": "single", // Define quotes to string values.
+ "regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
+ "undef": true, // Require all non-global variables be declared before they are used.
+ "unused": true, // Warn unused variables.
+ "strict": false, // Require `use strict` pragma in every file.
+ "trailing": true, // Prohibit trailing whitespaces.
+ "smarttabs": false, // Suppresses warnings about mixed tabs and spaces
+ "globals": { // Globals variables.
+ "angular": true
+ },
+ "predef": [ // Extra globals.
+ "define",
+ "require",
+ "exports",
+ "module",
+ "describe",
+ "before",
+ "beforeEach",
+ "after",
+ "afterEach",
+ "it"
+ ],
+ "indent": 4, // Specify indentation spacing
+ "maxlen": 120, // Max line lenght
+ "devel": false, // Allow development statements e.g. `console.log();`.
+ "noempty": true // Prohibit use of empty blocks.
+}
BIN  app/templates/public/.DS_Store
Binary file not shown
15 app/templates/public/humans.txt
@@ -0,0 +1,15 @@
+# humanstxt.org/
+# The humans responsible & technology colophon
+
+# TEAM
+
+ <name> -- <role> -- <twitter>
+
+# THANKS
+
+ <name>
+
+# TECHNOLOGY COLOPHON
+
+ HTML5, CSS3
+ jQuery, Modernizr
BIN  app/templates/public/js/.DS_Store
Binary file not shown
3  app/templates/public/js/app.js
@@ -0,0 +1,3 @@
+window.app = angular.module('mean', ['ngCookies', 'ngResource', 'ui.bootstrap', 'ui.route', 'mean.system']);
+
+angular.module('mean.system', []);
19 app/templates/public/js/config.js
@@ -0,0 +1,19 @@
+//Setting up route
+window.app.config(['$routeProvider',
+ function($routeProvider) {
+ $routeProvider.
+ when('/', {
+ templateUrl: 'views/index.html'
+ }).
+ otherwise({
+ redirectTo: '/'
+ });
+ }
+]);
+
+//Setting HTML5 Location Mode
+window.app.config(['$locationProvider',
+ function($locationProvider) {
+ $locationProvider.hashPrefix("!");
+ }
+]);
3  app/templates/public/js/controllers/index.js
@@ -0,0 +1,3 @@
+angular.module('mean.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) {
+ $scope.global = Global;
+}]);
0  app/templates/public/js/directives.js
No changes.
0  app/templates/public/js/filters.js
No changes.
15 app/templates/public/js/init.js
@@ -0,0 +1,15 @@
+window.bootstrap = function() {
+ angular.bootstrap(document, ['mean']);
+};
+
+window.init = function() {
+ window.bootstrap();
+};
+
+$(document).ready(function() {
+ //Fixing facebook bug with redirect
+ if (window.location.hash == "#_=_") window.location.hash = "";
+
+ //Then init the app
+ window.init();
+});
3  app/templates/public/robots.txt
@@ -0,0 +1,3 @@
+# robotstxt.org/
+
+User-agent: *
BIN  app/templates/public/views/.DS_Store
Binary file not shown
12 app/templates/public/views/index.html
@@ -0,0 +1,12 @@
+<section data-ng-controller="IndexController">
+ <div class="hero-unit">
+ <h1>'Allo, 'Allo!</h1>
+ <p>You now have</p>
+ <ul>
+ <li>Mongoose</li>
+ <li>Express</li>
+ <li>Angular</li>
+ <li>Node</li>
+ </ul>
+ </div>
+</section>
7 app/templates/travis.yml
@@ -0,0 +1,7 @@
+language: node_js
+node_js:
+ - '0.10'
+env:
+ - NODE_ENV=travis
+services:
+ - mongodb
41 package.json
@@ -0,0 +1,41 @@
+{
+ "name": "generator-mean",
+ "version": "0.0.1",
+ "description": "A Yeoman generator for MEAN stack, inspired by mean.io",
+ "keywords": [
+ "yeoman-generator"
+ ],
+ "homepage": "https://github.com/jrcryer/generator-mean",
+ "bugs": "https://github.com/jrcryer/generator-mean/issues",
+ "author": {
+ "name": "James Cryer",
+ "email": "chat@jamescryer.com",
+ "url": "https://github.com/jrcryer"
+ },
+ "main": "app/index.js",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jrcryer/generator-mean.git"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "dependencies": {
+ "yeoman-generator": "~0.13.0"
+ },
+ "devDependencies": {
+ "mocha": "~1.12.0"
+ },
+ "peerDependencies": {
+ "yo": ">=1.0.0-rc.1"
+ },
+ "engines": {
+ "node": ">=0.8.0",
+ "npm": ">=1.2.10"
+ },
+ "licenses": [
+ {
+ "type": "MIT"
+ }
+ ]
+}
38 test/test-creation.js
@@ -0,0 +1,38 @@
+/*global describe, beforeEach, it*/
+'use strict';
+
+var path = require('path');
+var helpers = require('yeoman-generator').test;
+
+
+describe('mean generator', function () {
+ beforeEach(function (done) {
+ helpers.testDirectory(path.join(__dirname, 'temp'), function (err) {
+ if (err) {
+ return done(err);
+ }
+
+ this.app = helpers.createGenerator('mean:app', [
+ '../../app'
+ ]);
+ done();
+ }.bind(this));
+ });
+
+ it('creates expected files', function (done) {
+ var expected = [
+ // add files you expect to exist here.
+ '.jshintrc',
+ '.editorconfig'
+ ];
+
+ helpers.mockPrompt(this.app, {
+ 'someOption': true
+ });
+ this.app.options['skip-install'] = true;
+ this.app.run({}, function () {
+ helpers.assertFiles(expected);
+ done();
+ });
+ });
+});
11 test/test-load.js
@@ -0,0 +1,11 @@
+/*global describe, beforeEach, it*/
+'use strict';
+
+var assert = require('assert');
+
+describe('mean generator', function () {
+ it('can be imported without blowing up', function () {
+ var app = require('../app');
+ assert(app !== undefined);
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.