Permalink
Browse files

feat(generator): create basic MEAN stack generator

  • Loading branch information...
1 parent 3d2ee63 commit 1290e5d7c18aea46621c915929e1e32d18aabb26 @iki iki committed Nov 21, 2013
Showing with 2,139 additions and 2 deletions.
  1. +10 −0 .editorconfig
  2. +3 −0 .gitignore
  3. +19 −0 .jshintrc
  4. +8 −0 .travis.yml
  5. +92 −0 Gruntfile.js
  6. +4 −0 LICENSE.md
  7. +169 −2 README.md
  8. +71 −0 app/index.js
  9. +308 −0 app/templates/_Gruntfile.js
  10. +11 −0 app/templates/_app.js
  11. +7 −0 app/templates/_app_grunt.js
  12. +17 −0 app/templates/_bower.json
  13. +3 −0 app/templates/_bowerrc
  14. +10 −0 app/templates/_editorconfig
  15. +6 −0 app/templates/_gitignore
  16. +24 −0 app/templates/_jshintrc
  17. +51 −0 app/templates/_karma-e2e.conf.js
  18. +56 −0 app/templates/_karma.conf.js
  19. +46 −0 app/templates/_package.json
  20. +5 −0 app/templates/_server.js
  21. +1 −0 app/templates/app/.buildignore
  22. +544 −0 app/templates/app/.htaccess
  23. +157 −0 app/templates/app/404.html
  24. BIN app/templates/app/favicon.ico
  25. +54 −0 app/templates/app/index.html
  26. +3 −0 app/templates/app/robots.txt
  27. +13 −0 app/templates/app/scripts/app.js
  28. +10 −0 app/templates/app/scripts/controllers/main.js
  29. +22 −0 app/templates/app/styles/main.css
  30. +9 −0 app/templates/app/views/main.html
  31. +28 −0 app/templates/config/environments/development.js
  32. +4 −0 app/templates/config/environments/index.js
  33. +19 −0 app/templates/config/environments/production.js
  34. +8 −0 app/templates/public/stylesheets/style.css
  35. +7 −0 app/templates/routes/index.js
  36. +10 −0 app/templates/test/runner.html
  37. +22 −0 app/templates/test/spec/controllers/main.js
  38. +21 −0 app/templates/views/index.ejs
  39. +5 −0 docs/about.md
  40. +20 −0 docs/contributing.md
  41. +31 −0 docs/features.md
  42. +17 −0 docs/getting-started.md
  43. +42 −0 docs/options.md
  44. +41 −0 docs/roadmap.md
  45. +2 −0 docs/usage.md
  46. +80 −0 package.json
  47. +38 −0 test/test-creation.js
  48. +11 −0 test/test-load.js
View
@@ -0,0 +1,10 @@
+# http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_size = 2
+end_of_line = lf
+indent_style = space
+insert_final_newline = true
+trim_trailing_whitespace = true
View
@@ -0,0 +1,3 @@
+node_modules
+npm-debug.log
+test/temp/
View
@@ -0,0 +1,19 @@
+{
+ "strict": true,
+ "camelcase": true,
+ "indent": 2,
+ "undef": true,
+ "quotmark": "single",
+ "maxlen": 100,
+ "trailing": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "sub": true,
+ "boss": true,
+ "eqnull": true,
+ "node": true
+}
View
@@ -0,0 +1,8 @@
+language: node_js
+node_js:
+ - '0.8'
+ - '0.10'
+before_script:
+ - currentfolder=${PWD##*/}
+ - if [ "$currentfolder" != 'generator-salsa' ]; then cd .. && eval "mv $currentfolder generator-salsa" && cd generator-salsa; fi
+ - npm install -g grunt-cli
View
@@ -0,0 +1,92 @@
+/*
+ * generator-salsa
+ * https://github.com/salsita/generator-salsa
+ *
+ * Copyright (c) 2013 Salsita Software
+ * Licensed under the MIT license.
+ */
+
+'use strict';
+
+module.exports = function (grunt) {
+ // load all npm grunt tasks
+ require('load-grunt-tasks')(grunt);
+
+ // Project configuration.
+ grunt.initConfig({
+ // Read package info.
+ pkg: grunt.file.readJSON('package.json'),
+
+ // Concatenate README.md.
+ concat: {
+ readme: {
+ src: [
+ 'docs/about.md',
+ 'docs/features.md',
+ 'docs/getting-started.md',
+ 'docs/usage.md',
+ 'docs/options.md',
+ 'docs/contributing.md',
+ 'docs/roadmap.md',
+ 'CHANGELOG.md',
+ 'LICENSE.md',
+ ],
+ dest: 'README.md',
+ },
+ },
+
+ // Lint sources.
+ jshint: {
+ all: [
+ 'Gruntfile.js',
+ 'app/*.js',
+ 'test/**/*.js',
+ ],
+ options: {
+ jshintrc: '.jshintrc',
+ reporter: require('jshint-stylish'),
+ },
+ },
+
+ // Before generating any new files, remove any previously-created files.
+ clean: {
+ tests: ['test/temp'],
+ },
+
+ // Unit tests.
+ mochaTest: {
+ options: {
+ reporter: 'spec',
+ },
+ src: ['test/**/*.js'],
+ },
+
+ // Watch sources and run tests.
+ delta: {
+ js: {
+ files: ['test/**', 'app/*.js', 'Gruntfile.js'],
+ tasks: ['jshint', 'test'],
+ },
+ jshintrc: {
+ files: ['.jshintrc'],
+ tasks: ['jshint'],
+ },
+ readme: {
+ files: ['docs/**.md', 'LICENSE.md', 'CHANGELOG.md'],
+ tasks: ['concat:readme'],
+ },
+
+ },
+ });
+
+ // By default, lint and run all tests.
+ grunt.registerTask('default', ['jshint', 'test', 'concat']);
+
+ // On watch, run both default and delta (original watch).
+ grunt.renameTask('watch', 'delta');
+ grunt.registerTask('watch', ['default', 'delta']);
+
+ // On test, do cleanup and then run Mocha tests.
+ grunt.registerTask('test', ['clean', 'mochaTest']);
+
+};
View
@@ -0,0 +1,4 @@
+
+## License
+
+Copyright 2013 [Salsita Software](http://salsitasoft.com). Licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
View
171 README.md
@@ -1,2 +1,169 @@
-generator-salsa
-===============
+# AngularJS salsa <a href='https://github.com/salsita'><img align='right' title='Salsita' src='https://www.google.com/a/cpanel/salsitasoft.com/images/logo.gif?alpha=1' _src='https://1.gravatar.com/avatar/d413290a5fe1385efcf5a344d4a0b588?s=50' /></a>
+
+> Mixes a tasteful AngularJS salsa for web/mobile apps and browser extensions using JS/Coffee, Jade/HTML5, Node.js, Express and MongoDB.
+
+<a href='https://npmjs.org/package/generator-salsa'><img align='right' alt='npm' title='npm info' src='https://nodei.co/npm/generator-salsa.png?compact=true' /></a>&nbsp;[![build](https://secure.travis-ci.org/salsita/generator-salsa.png?branch=master)](https://travis-ci.org/salsita/generator-salsa) [![dependencies](https://david-dm.org/salsita/generator-salsa.png)](https://david-dm.org/salsita/generator-salsa) [![dev-dependencies](https://david-dm.org/salsita/generator-salsa/dev-status.png)](https://david-dm.org/salsita/generator-salsa#info=devDependencies)
+
+
+## Features (coming soon)
+
+Salsa type:
+- Single-page web/mobile applications based on [AngularJS](http://angularjs.org), [Grunt](http://gruntjs.com) and [Bower](http://bower.io),
+- RESTful web/mobile applications with backend based on [MEAN stack](http://mean.io):
+ + client:
+ [AngularJS](http://angularjs.org),
+ [RestAngular](https://github.com/mgonto/restangular),
+ [UI-Bootstrap](http://angular-ui.github.io/bootstrap)/[Twitter Bootstrap](http://getbootstrap.com),
+ + server:
+ [Node.js](http://nodejs.org),
+ [Express](http://expressjs.com),
+ [Passport](http://passportjs.org),
+ [MonGoose](http://mongoosejs.com),
+ [mongoDB](http://mongodb.org),
+- [Google Chrome AngularJS extensions](https://github.com/salsita/chrome-angular-skeleton).
+
+Available spices:
+- [CoffeeScript](http://coffeescript.org)/[CS2](https://github.com/michaelficarra/CoffeeScriptRedux)/[ECMAScript 3](http://en.wikipedia.org/wiki/ECMAScript#Version_correspondence)/[ES5-shim](https://github.com/kriskowal/es5-shim)/[ES5](http://en.wikipedia.org/wiki/ECMAScript#ECMAScript.2C_5th_Edition)/[ES6](http://en.wikipedia.org/wiki/ECMAScript#ECMAScript_Harmony_.286th_Edition.29)/[Traceur](https://github.com/google/traceur-compiler),
+- [Jade](http://jade-lang.com)/[HTML](http://www.w3.org/html),
+ [LESS](http://lesscss.org),
+ [UI-Bootstrap](http://angular-ui.github.io/bootstrap)/[Twitter Bootstrap](http://getbootstrap.com),
+ [UI-Router](https://github.com/angular-ui/ui-router),
+- [Karma](http://karma-runner.github.io),
+ [Jasmine](http://pivotal.github.io/jasmine)/[Mocha](http://visionmedia.github.io/mocha)+[Chai](http://chaijs.com)+[as-promised](https://github.com/domenic/chai-as-promised)+[Sinon](http://sinonjs.org),
+ [Istanbul](https://github.com/gotwarlost/istanbul),
+- [Browserify](http://browserify.org),
+ [ngmin](https://github.com/btford/ngmin).
+
+Inspired by [AngularJS generator](https://github.com/yeoman/generator-angular), [ngBoilerplate](http://joshdmiller.github.io/ng-boilerplate), and [MEAN stack generator](https://github.com/wlepinski/generator-meanstack). Served by [Yeoman](http://yeoman.io).
+
+
+## Getting Started
+
+Install `yeoman` and `generator-salsa`:
+ ```
+ npm install -g yo generator-salsa
+ ```
+
+Make a new directory, and `cd` into it:
+ ```
+ mkdir my-new-project && cd $_
+ ```
+
+Run `yo salsa`, optionally passing any options, and/or an app name:
+ ```
+ yo salsa [options] [app-name]
+ ```
+
+
+## Usage
+
+
+### Options (coming soon)
+
+```shell
+--spa Generate a single page Angular application.
+--mean Generate a browser/server Mongo+Angular+Express+Node application.
+--chrome Generate a Google Chrome Angular extension.
+
+--coffee Compile CoffeeScript.
+--coffee2 Compile CoffeeScript 2 (beta).
+--es3 Use ECMA Script 3 (legacy).
+--es5shim Add shim to emulate ECMA Script 5 methods on ES3.
+ May be combined with --coffee, or --coffee2.
+--es5 Use ECMA Script 5 (IE9+, FF4+, Sf5.1+, Ch7+, Op12+).
+--es6 Use ECMA Script 6 (upcoming).
+--es6to5 Compile ES6 code to ES5 using Traceur (experimental).
+
+--jade Compile Jade to HTML.
+--html Use HTML.
+
+--browserify
+ Concatenate scripts with Browserify (--no-concat to disable).
+--(no-)concat
+ Concatenate scripts with Grunt concat task.
+--(no-)minsafe
+ Prepare scripts for safe minification with ngmin.
+--(no-)release
+ Bump versions and generate changelog with Grunt release task.
+
+--(no-)ui-router
+ Use UI Router to handle client-side routing.
+
+--(no-)demo
+ Create demo application files (`yo salsa:demo`).
+
+--quiet Do not prompt for options, use passed ones and defaults.
+```
+
+Default options:
+```shell
+--spa --coffee --jade --browserify --ui-router --minsafe --release
+```
+
+
+## Contributing
+
+Welcome to the project. Choose a way that suits you. You'll need a [GitHub account](https://github.com/signup/free).
+
+### Submit a bug, or feature request
+
+* Search [existing issues](https://github.com/salsita/generator-salsa/issues) to avoid duplicities.
+* [Submit an issue](https://github.com/salsita/generator-salsa/issues/new) with label `bug`, or `enhancement`.
+* For a bug, include any relevant information, e.g. task output, installed OS/Node.js/Grunt/generator-salsa versions, and steps to reproduce.
+
+### Submit a pull request
+
+* [Fork the repository](https://github.com/salsita/generator-salsa/fork) ([help](https://help.github.com/articles/fork-a-repo)) and checkout new branch with `<type>-` prefix in name, where type may be feature, fix, docs, or chore.
+* [Use](https://github.com/salsita/generator-salsa/blob/master/.jshintrc) the [popular JavaScript style convention](http://sideeffect.kr/popularconvention#javascript) and [winning JavaScript style](http://seravo.fi/2013/javascript-the-winning-style) with exception of 100 characters per line. In short, use 2 spaces indent, camelCase names, trailing comma, single quotes, semicolons, sparse spacing, and no trailing whitespace.
+* For bugfix, write a test that exposes the bug and fails without the fix. Submit the test alongside.
+* For a new feature, add tests that cover the feature.
+* Lint and test your code with `grunt`, or `grunt watch` to watch sources and run tests on any change.
+* Use commit messages that follow [Karma/Angular commit message convention](https://github.com/karma-runner/karma/blob/master/docs/dev/04-git-commit-msg.md) ([docs](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#)). In short, use `<type>(<scope>): <subject>` header in imperative present tense, message body describing motivation/differences, and footer referencing related issues and breaking changes.
+* [Create a pull request](https://github.com/salsita/generator-salsa/compare) to [generator-salsa](https://github.com/salsita/generator-salsa) [master](https://github.com/salsita/generator-salsa/branches) branch ([help](https://help.github.com/articles/creating-a-pull-request)).
+
+
+## Roadmap
+
+- **Base:**
+ + Add the yeoman generator option parser and .salsarc
+ + Add bump/npm/changelog/release tasks
+ + Add reliable concurrent(watch-notest, karma:watch)
+ + Add concat/minify/sourcemaps/filerev/userev
+
+- **Demo application and tests:**
+ + Add demo application
+ + Add Karma tests
+ + Add Protractor tests
+ + Add best practices and componentization guide
+
+- **Spices:**
+ + Add Browserify support and demo
+ + Add UI-Router support and demo
+ + Add UI-Bootstrap support and demo
+ + Add CoffeeScript2 beta support
+
+- **Subgenerators:**
+ + Add subgenerator for feature,
+ including route, controller and template
+ + Add subgenerator for feature/common filter
+ + Add subgenerator for feature/common service
+ + Add subgenerator for feature/common directive
+
+- **Google Chrome extensions:**
+ + Add Google Chrome extension support
+ + Extend demo application to Google Chrome extension
+
+- **ECMAScript 5/6 targets:**
+ + Add ES5-shim support
+ + Add ES5 support
+ + Add ES6 Harmony support
+ + Add Traceur (ES6 draft -> ES5 compiler) support
+
+
+<a name="changelog"></a>
+## Changelog
+
+
+## License
+
+Copyright 2013 [Salsita Software](http://salsitasoft.com). Licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
View
@@ -0,0 +1,71 @@
+'use strict';
+var util = require('util');
+var path = require('path');
+var yeoman = require('yeoman-generator');
+
+
+var SalsaGenerator = module.exports = function SalsaGenerator(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(SalsaGenerator, yeoman.generators.Base);
+
+SalsaGenerator.prototype.askFor = function askFor() {
+ var cb = this.async();
+
+ // have Yeoman greet the user.
+ console.log(this.yeoman);
+
+ cb();
+};
+
+SalsaGenerator.prototype.app = function app() {
+ this.mkdir('public');
+ this.mkdir('public/images');
+ this.mkdir('public/javascripts');
+ this.mkdir('public/stylesheets');
+ this.mkdir('config');
+ this.mkdir('config/environments');
+ this.mkdir('routes');
+ this.mkdir('views');
+
+ this.directory('public');
+ this.directory('routes');
+ this.directory('views');
+ this.directory('config');
+
+ this.mkdir('app');
+ this.mkdir('app/scripts');
+ this.mkdir('app/styles');
+ this.mkdir('app/views');
+ this.directory('app');
+ this.mkdir('test');
+ this.mkdir('test/spec');
+ this.mkdir('test/spec/controllers');
+ this.directory('test');
+};
+
+SalsaGenerator.prototype.projectfiles = function projectfiles() {
+ // Config
+ this.copy('_bowerrc', '.bowerrc');
+ this.copy('_editorconfig', '.editorconfig');
+ this.copy('_jshintrc', '.jshintrc');
+ this.copy('_package.json', 'package.json');
+
+ // Client
+ this.copy('_bower.json', 'bower.json');
+ this.copy('_Gruntfile.js', 'Gruntfile.js');
+ this.copy('_karma-e2e.conf.js', 'karma-e2e.conf.js');
+ this.copy('_karma.conf.js', 'karma.conf.js');
+
+ // Server
+ this.copy('_app.js', 'app.js');
+ this.copy('_app_grunt.js', 'app_grunt.js');
+ this.copy('_server.js', 'server.js');
+};
Oops, something went wrong.

0 comments on commit 1290e5d

Please sign in to comment.