├── .editorconfig ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .npmignore ├── .travis.yml ├── README.md ├── app ├── index.js └── templates │ ├── README.md │ ├── _bower.json │ ├── _gruntfile.js │ ├── _gulpfile.js │ ├── _package.json │ ├── editorconfig │ ├── gitattributes │ ├── gitignore │ ├── jshintrc │ ├── micro-tmpl.coffee │ ├── micro-tmpl.js │ ├── micro-tmpl.min.js │ ├── npmignore │ ├── test │ ├── jasmine.spec.coffee │ ├── jasmine.spec.js │ ├── karma.conf.coffee │ ├── karma.conf.js │ ├── mocha.spec.coffee │ └── mocha.spec.js │ ├── travis.yml │ └── umd ├── package.json └── test ├── mute.js ├── test-app-load.js └── test-creation.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # package managers # 2 | #################### 3 | node_modules/ 4 | npm-debug.log 5 | bower_components/ 6 | temp/ 7 | 8 | # generated files # 9 | ###################### 10 | .DS_Store 11 | .DS_Store? 12 | ._* 13 | .Trashes 14 | Icon? 15 | ehthumbs.db 16 | Thumbs.db 17 | .tmp 18 | .idea/ -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "white": true, 22 | "validthis": true, 23 | "globals": { 24 | "chai": false, 25 | "sinon": false, 26 | "assert": false, 27 | "describe": false, 28 | "it": false, 29 | "before": false, 30 | "after": false, 31 | "beforeEach": false, 32 | "afterEach": false, 33 | "suite": false, 34 | "test": false, 35 | "setup": false, 36 | "teardown": false, 37 | "expect": false, 38 | "spyOn": false, 39 | "xdescribe": false, 40 | "xit": false, 41 | "define": false 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.log 3 | bower_components/ 4 | temp/ 5 | .DS_Store 6 | .DS_Store? 7 | ._* 8 | .Trashes 9 | Icon? 10 | ehthumbs.db 11 | Thumbs.db 12 | .tmp 13 | .idea/ 14 | .gitignore 15 | .npmignore -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - '0.10' 5 | 6 | before_install: 7 | - currentfolder=${PWD##*/} 8 | - if [ "$currentfolder" != 'generator-microjs' ]; then cd .. && eval "mv $currentfolder generator-microjs" && cd generator-microjs; fi 9 | 10 | before_script: 11 | #- npm install -g codeclimate-test-reporter 12 | 13 | after_script: 14 | #- codeclimate < test/coverage/lcov.info 15 | 16 | notifications: 17 | # publish build status to IRC channel: #generator-microjs 18 | irc: 19 | channels: 20 | - chat.freenode.net#generator-microjs 21 | on_success: always 22 | on_failure: always 23 | template: 24 | - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}' 25 | - 'Change view : %{compare_url}' 26 | - 'Build details : %{build_url}' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-microjs 2 | [![Build Status][build-image]][build-url] 3 | [![Code GPA][gpa-image]][gpa-url] 4 | [![Dependency Status][depstat-image]][depstat-url] 5 | [![NPM Version][npm-image]][npm-url] 6 | [![IRC Channel][irc-image]][irc-url] 7 | [![Gitter][gitter-image]][gitter-url] 8 | [![GitTip][tip-image]][tip-url] 9 | 10 | ## About 11 | 12 | Quickly scaffold out a micro library or framework. 13 | 14 | ## Features 15 | 16 | * Pre-fills information using your GitHub account data. 17 | * Checks if your new project name is already taken on NPM. 18 | * Choose your preferred task runner framework. 19 | * [Gulp](http://gulpjs.com) 20 | * [Grunt](http://gruntjs.com) 21 | * Choose your preferred unit test framework. 22 | * [Jasmine](http://jasmine.github.io) 23 | * [Mocha](http://visionmedia.github.io/mocha) 24 | * [QUnit](http://qunitjs.com) (TODO) 25 | * Test coverage pre-configured to publish to code climate. 26 | * Micro library template is pre-configured for AMD, Node.js and browser support. 27 | * README file 28 | * Dynamic based on the project configurations. 29 | * Pre-configured badges for: 30 | * Travis Build Status: [![Build Status][build-image]][build-url] 31 | * Code Quality GPA: [![Code GPA][gpa-image]][gpa-url] 32 | * Dependency Status: [![Dependency Status][depstat-image]][depstat-url] 33 | * NPM Version: [![NPM Version][npm-image]][npm-url] 34 | * NPM Downloads: [![NPM Downloads][downloads-image]][downloads-url] 35 | * IRC Channel: [![IRC Channel][irc-image]][irc-url] 36 | * Gitter Chat Room: [![Gitter][gitter-image]][gitter-url] 37 | * GitTip: [![GitTip][tip-image]][tip-url] 38 | * [JSHint](https://www.npmjs.org/package/jshint) pre-configured to lint the source code and unit tests. 39 | * [Complexity Report](https://www.npmjs.org/package/complexity-report) pre-configured to analyze source code for maintainability. 40 | * [Karma](https://www.npmjs.org/package/karma) pre-configured to run unit tests in your chosen framework. 41 | * [Travis CI](https://travis-ci.org) configured for continuous integration. 42 | * pre-configured to publish build status to your project IRC channel and gitter chat room. 43 | * included `dot` files 44 | * .editorconfig 45 | * .gitattributes 46 | * .gitignore 47 | * .jshintrc 48 | * .npmignore 49 | * .travis.yml 50 | 51 | ## Setup 52 | 53 | You'll need Yeoman installed if you don't have it already. 54 | 55 | ```bash 56 | $ npm install -g yo 57 | ``` 58 | 59 | To install generator-microjs from npm, run: 60 | 61 | ```bash 62 | $ npm install -g generator-microjs 63 | ``` 64 | 65 | ## Scaffolding 66 | 67 | Go to your new project folder, run the generator and answer the prompts. The use `--coffee` flag is optional. 68 | 69 | ```bash 70 | $ yo microjs --coffee 71 | ``` 72 | 73 | ## Check List 74 | 75 | Step-by-step for creating a new micro-lib. A LOT will be done for you, but there are some things you should customize in your newly scaffolded micro-library. 76 | 77 | 1. Create an empty repository on [GitHub](https://github.com). 78 | 1. Clone it to your computer 79 | 1. Go to your new project folder, run the `microjs` generator and answer the prompts. 80 | 1. NPM 81 | 1. Update the description in your `package.json` file and add appropriate keywords. 82 | 1. Shrinkwrap your node.js modules using `npm shrinkwrap -dev` 83 | 1. Travis 84 | 1. enable any build status notifications you want published. 85 | 1. enable publishing test coverage to code climate. 86 | 1. Writing unit tests for your code. 87 | 1. Implement your micro library or framework. 88 | 1. Activate the repository in [Travis](https://travis-ci.org). 89 | 1. Push you *initial commit* to GitHub. 90 | 1. Activate the repository on [CodeClimate](https://codeclimate.com). 91 | 1. Create a new release of your code on GitHub. 92 | 1. Publish version to NPM with `npm publish`. 93 | 1. Register your framework with [Bower](http://bower.io/). 94 | 95 | ## Options 96 | 97 | * `--skip-install` 98 | 99 | Defaults to `true`. Skips the automatic execution of `bower` and `npm` after scaffolding has finished. 100 | 101 | * `--coffee` 102 | 103 | Defaults to `true`. Add support for [CoffeeScript](http://coffeescript.org/). 104 | 105 | ## Updating 106 | 107 | Use the following command to update to the latest version of generator-microjs. 108 | 109 | ```bash 110 | $ npm update -g generator-microjs 111 | ``` 112 | 113 | ## Contributing 114 | 115 | Pull requests welcome :) 116 | 117 | ### TODO List 118 | 119 | * add option for sass / css 120 | * add option for creating a demo page 121 | 122 | ### Testing 123 | 124 | Unit tests for this generator are written in [Mocha](http://visionmedia.github.io/mocha) and can be run using `npm test`. 125 | 126 | ## License 127 | 128 | (The MIT License) 129 | 130 | Copyright (c) 2014 Daniel Lamb 131 | 132 | Permission is hereby granted, free of charge, to any person obtaining 133 | a copy of this software and associated documentation files (the 134 | 'Software'), to deal in the Software without restriction, including 135 | without limitation the rights to use, copy, modify, merge, publish, 136 | distribute, sublicense, and/or sell copies of the Software, and to 137 | permit persons to whom the Software is furnished to do so, subject to 138 | the following conditions: 139 | 140 | The above copyright notice and this permission notice shall be 141 | included in all copies or substantial portions of the Software. 142 | 143 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 144 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 145 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 146 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 147 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 148 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 149 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 150 | 151 | [build-url]: https://travis-ci.org/daniellmb/generator-microjs 152 | [build-image]: http://img.shields.io/travis/daniellmb/generator-microjs.png 153 | 154 | [gpa-url]: https://codeclimate.com/github/daniellmb/generator-microjs 155 | [gpa-image]: http://img.shields.io/codeclimate/github/daniellmb/generator-microjs.png 156 | 157 | [coverage-url]: https://codeclimate.com/github/daniellmb/generator-microjs/code?sort=covered_percent&sort_direction=desc 158 | [coverage-image]: http://img.shields.io/codeclimate/coverage/github/daniellmb/generator-microjs.png 159 | 160 | [depstat-url]: https://david-dm.org/daniellmb/generator-microjs 161 | [depstat-image]: https://david-dm.org/daniellmb/generator-microjs.png?theme=shields.io 162 | 163 | [issues-url]: https://github.com/daniellmb/generator-microjs/issues 164 | [issues-image]: http://img.shields.io/github/issues/daniellmb/generator-microjs.png 165 | 166 | [downloads-url]: https://www.npmjs.org/package/generator-microjs 167 | [downloads-image]: http://img.shields.io/npm/dm/underscore.png 168 | 169 | [npm-url]: https://www.npmjs.org/package/generator-microjs 170 | [npm-image]: https://badge.fury.io/js/generator-microjs.png 171 | 172 | [irc-url]: http://webchat.freenode.net/?channels=generator-microjs 173 | [irc-image]: http://img.shields.io/badge/irc-%23microjs-brightgreen.png 174 | 175 | [gitter-url]: https://gitter.im/daniellmb/generator-microjs 176 | [gitter-image]: http://img.shields.io/badge/gitter-daniellmb/generator--microjs-brightgreen.png 177 | 178 | [tip-url]: https://www.gittip.com/daniellmb 179 | [tip-image]: http://img.shields.io/gittip/daniellmb.png -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var url = require('url'); 4 | var path = require('path'); 5 | var yeoman = require('yeoman-generator'); 6 | var yosay = require('yosay'); 7 | var npmName = require('npm-name'); 8 | /* jshint -W106 */ 9 | var proxy = process.env.http_proxy || process.env.HTTP_PROXY || process.env.https_proxy || process.env.HTTPS_PROXY || null; 10 | /* jshint +W106 */ 11 | var githubOptions = { 12 | version: '3.0.0' 13 | }; 14 | 15 | if (proxy) { 16 | var proxyUrl = url.parse(proxy); 17 | githubOptions.proxy = { 18 | host: proxyUrl.hostname, 19 | port: proxyUrl.port 20 | }; 21 | } 22 | 23 | var GitHubApi = require('github'); 24 | var github = new GitHubApi(githubOptions); 25 | 26 | var extractProj = function (_, appname) { 27 | var slugged = _.slugify(appname); 28 | var match = slugged.match(/^generator-(.+)/); 29 | 30 | if (match && match.length === 2) { 31 | return match[1].toLowerCase(); 32 | } 33 | 34 | return slugged; 35 | }; 36 | 37 | var toCamelCase = function (input) { 38 | return input.toLowerCase().replace(/-(.)/g, function (match, group1) { 39 | return group1.toUpperCase(); 40 | }); 41 | }; 42 | 43 | var githubUserInfo = function (name, cb) { 44 | 45 | // handle bad data 46 | if (name === 'daniellmb') { 47 | /*jshint camelcase:false */ 48 | cb({ 49 | name: 'Daniel Lamb', 50 | email: 'dlamb.open.source@gmail.com', 51 | html_url: 'https://github.com/daniellmb' 52 | }); 53 | 54 | // exit 55 | return; 56 | } 57 | 58 | github.user.getFrom({ 59 | user: name 60 | }, function (err, res) { 61 | if (err) { 62 | throw new Error(err.message + '\n\nCannot fetch your github profile. Make sure you\'ve typed it correctly.'); 63 | } 64 | cb(JSON.parse(JSON.stringify(res))); 65 | }); 66 | }; 67 | 68 | var MicroJSGenerator = yeoman.generators.Base.extend({ 69 | init: function () { 70 | this.pkg = require('../package.json'); 71 | this.currentYear = (new Date()).getFullYear(); 72 | 73 | this.on('end', function () { 74 | if (!this.options['skip-install']) { 75 | this.installDependencies(); 76 | } 77 | }); 78 | }, 79 | 80 | welcome: function () { 81 | 82 | if (this.options['skip-welcome-message']) { 83 | return; 84 | } 85 | 86 | // Have Yeoman greet the user. 87 | this.log(yosay('Welcome to the marvelous MicroJS generator!')); 88 | 89 | }, 90 | 91 | askForUsername: function () { 92 | var done = this.async(); 93 | 94 | var prompts = [{ 95 | name: 'githubUser', 96 | message: 'Would you mind telling me your username on GitHub?', 97 | default: (process.env && process.env.USER !== undefined) ? process.env.USER : 'username' 98 | }]; 99 | 100 | this.prompt(prompts, function (props) { 101 | this.githubUser = props.githubUser; 102 | 103 | done(); 104 | }.bind(this)); 105 | }, 106 | 107 | askForProj: function () { 108 | var done = this.async(); 109 | var projName = extractProj(this._, this.appname); 110 | 111 | var prompts = [{ 112 | name: 'projName', 113 | message: 'What\'s the name of your project?', 114 | default: projName 115 | }, { 116 | type: 'confirm', 117 | name: 'pkgName', 118 | message: 'The name above already exists on npm, choose another?', 119 | default: true, 120 | when: function (answers) { 121 | var done = this.async(); 122 | var name = answers.projName; 123 | 124 | npmName(name, function (err, available) { 125 | if (!available) { 126 | done(true); 127 | } 128 | 129 | done(false); 130 | }); 131 | } 132 | }]; 133 | 134 | this.prompt(prompts, function (props) { 135 | if (props.pkgName) { 136 | return this.askForProj(); 137 | } 138 | 139 | this.projName = props.projName; 140 | this.baseFileName = path.basename(this.projName, path.extname(this.projName)); 141 | this.exportName = toCamelCase(this.baseFileName); 142 | 143 | done(); 144 | }.bind(this)); 145 | }, 146 | 147 | askForTaskFramework: function () { 148 | var done = this.async(); 149 | 150 | var prompts = [{ 151 | name: 'taskFramework', 152 | message: 'What task runner do you want to use?', 153 | type : 'list', 154 | choices : [ 155 | { name : 'Gulp', value : 'gulp' }, 156 | { name : 'Grunt', value : 'grunt' } 157 | ], 158 | default : 'gulp' 159 | }]; 160 | 161 | this.prompt(prompts, function (props) { 162 | this.taskFramework = props.taskFramework; 163 | 164 | done(); 165 | }.bind(this)); 166 | }, 167 | 168 | askForTestFramework: function () { 169 | var done = this.async(); 170 | 171 | var prompts = [{ 172 | name: 'testFramework', 173 | message: 'What test runner do you want to use?', 174 | type : 'list', 175 | choices : [ 176 | { name : 'Jasmine', value : 'jasmine' }, 177 | { name : 'Mocha', value : 'mocha' } 178 | ], 179 | default : 'jasmine' 180 | }]; 181 | 182 | this.prompt(prompts, function (props) { 183 | this.testFramework = props.testFramework; 184 | 185 | done(); 186 | }.bind(this)); 187 | }, 188 | 189 | askForLicType: function () { 190 | var done = this.async(); 191 | 192 | var prompts = [{ 193 | type: 'confirm', 194 | name: 'useMitOrg', 195 | message: 'Would you like to use mit-license.org?', 196 | default: true 197 | }]; 198 | 199 | this.prompt(prompts, function (props) { 200 | this.useMitOrg = props.useMitOrg; 201 | 202 | done(); 203 | }.bind(this)); 204 | }, 205 | 206 | userInfo: function () { 207 | var done = this.async(); 208 | 209 | githubUserInfo(this.githubUser, function (res) { 210 | /*jshint camelcase:false */ 211 | this.realname = res.name; 212 | this.email = res.email; 213 | this.githubUrl = res.html_url; 214 | done(); 215 | }.bind(this)); 216 | }, 217 | 218 | bower: function () { 219 | this.template('_bower.json', 'bower.json'); 220 | }, 221 | 222 | packageJSON: function () { 223 | this.template('_package.json', 'package.json'); 224 | }, 225 | 226 | git: function () { 227 | this.copy('gitattributes', '.gitattributes'); 228 | this.copy('gitignore', '.gitignore'); 229 | }, 230 | 231 | travis: function () { 232 | this.template('travis.yml', '.travis.yml'); 233 | }, 234 | 235 | taskRunner: function () { 236 | if (this.taskFramework === 'grunt') { 237 | this.template('_gruntfile.js', 'gruntfile.js'); 238 | } else { 239 | this.template('_gulpfile.js', 'gulpfile.js'); 240 | } 241 | }, 242 | 243 | projectFiles: function () { 244 | this.copy('editorconfig', '.editorconfig'); 245 | this.copy('npmignore', '.npmignore'); 246 | this.template('umd', '.umd'); 247 | 248 | // only copy over coffee if the option was set 249 | if (this.options.coffee) { 250 | this.template('micro-tmpl.coffee', this.baseFileName + '.coffee'); 251 | } 252 | this.template('micro-tmpl.js', this.baseFileName + '.js'); 253 | this.template('micro-tmpl.min.js', this.baseFileName + '.min.js'); 254 | this.template('README.md', 'README.md'); 255 | }, 256 | 257 | testConfig: function () { 258 | // only copy over coffee if the option was set 259 | if (this.options.coffee) { 260 | this.template('test/karma.conf.coffee', 'test/karma.conf.coffee'); 261 | } 262 | this.template('test/karma.conf.js', 'test/karma.conf.js'); 263 | }, 264 | 265 | jshint: function () { 266 | this.copy('jshintrc', '.jshintrc'); 267 | }, 268 | 269 | tests: function () { 270 | this.mkdir('test/spec'); 271 | // only copy over coffee if the option was set 272 | if (this.options.coffee) { 273 | this.template('test/' + this.testFramework + '.spec.coffee', 'test/spec/' + this.baseFileName + '.spec.coffee'); 274 | } 275 | this.template('test/' + this.testFramework + '.spec.js', 'test/spec/' + this.baseFileName + '.spec.js'); 276 | } 277 | }); 278 | 279 | module.exports = MicroJSGenerator; 280 | -------------------------------------------------------------------------------- /app/templates/README.md: -------------------------------------------------------------------------------- 1 | # <%= projName %> 2 | [![Build Status][build-image]][build-url] 3 | [![Code GPA][gpa-image]][gpa-url] 4 | [![Test Coverage][coverage-image]][coverage-url] 5 | [![Dependency Status][depstat-image]][depstat-url] 6 | [![Bower Version][bower-image]][bower-url] 7 | [![NPM version][npm-image]][npm-url] 8 | [![IRC Channel][irc-image]][irc-url] 9 | [![Gitter][gitter-image]][gitter-url] 10 | [![GitTip][tip-image]][tip-url] 11 | 12 | ## About 13 | 14 | All about how amazing the <%= projName %> micro-library is. 15 | 16 | This repository was scaffolded with [<%= pkg.name %>](https://github.com/daniellmb/generator-microjs). 17 | 18 | ## Examples 19 | 20 | ### JavaScript 21 | 22 | ```JavaScript 23 | // TODO 24 | ``` 25 | <% if (options.coffee) { %> 26 | ### CoffeeScript 27 | 28 | ```CoffeeScript 29 | # TODO 30 | ``` 31 | <% } %> 32 | ## Install Choices 33 | - `bower install <%= projName %>` 34 | - [download the zip](https://github.com/<%= githubUser %>/<%= projName %>/archive/master.zip) 35 | 36 | ## Tasks 37 | 38 | All tasks can be run by simply running `<%= taskFramework %>` or with the `npm test` command, or individually: 39 | 40 | * `<%= taskFramework %> lint` will lint source code for syntax errors and anti-patterns. 41 | * `<%= taskFramework %> gpa` will analyze source code against complexity thresholds. 42 | * `<%= taskFramework %> test` will run the <%= testFramework %> unit tests against the source code.<% if (options.coffee) { %> 43 | * `<%= taskFramework %> test-coffee` will run the <%= testFramework %> unit tests against the CoffeeScript source code.<% } %> 44 | * `<%= taskFramework %> test-min` will run the <%= testFramework %> unit tests against the minified code. 45 | 46 | ## License 47 | 48 | (The MIT License) 49 | 50 | Copyright (c) <%= currentYear %> <%= realname %> <%= email %> 51 | 52 | Permission is hereby granted, free of charge, to any person obtaining 53 | a copy of this software and associated documentation files (the 54 | 'Software'), to deal in the Software without restriction, including 55 | without limitation the rights to use, copy, modify, merge, publish, 56 | distribute, sublicense, and/or sell copies of the Software, and to 57 | permit persons to whom the Software is furnished to do so, subject to 58 | the following conditions: 59 | 60 | The above copyright notice and this permission notice shall be 61 | included in all copies or substantial portions of the Software. 62 | 63 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 64 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 65 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 66 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 67 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 68 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 69 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 70 | 71 | 72 | 73 | [build-url]: https://travis-ci.org/<%= githubUser %>/<%= projName %> 74 | [build-image]: http://img.shields.io/travis/<%= githubUser %>/<%= projName %>.png 75 | 76 | [gpa-url]: https://codeclimate.com/github/<%= githubUser %>/<%= projName %> 77 | [gpa-image]: https://codeclimate.com/github/<%= githubUser %>/<%= projName %>.png 78 | 79 | [coverage-url]: https://codeclimate.com/github/<%= githubUser %>/<%= projName %>/code?sort=covered_percent&sort_direction=desc 80 | [coverage-image]: https://codeclimate.com/github/<%= githubUser %>/<%= projName %>/coverage.png 81 | 82 | [depstat-url]: https://david-dm.org/<%= githubUser %>/<%= projName %> 83 | [depstat-image]: https://david-dm.org/<%= githubUser %>/<%= projName %>.png?theme=shields.io 84 | 85 | [issues-url]: https://github.com/<%= githubUser %>/<%= projName %>/issues 86 | [issues-image]: http://img.shields.io/github/issues/<%= githubUser %>/<%= projName %>.png 87 | 88 | [bower-url]: http://bower.io/search/?q=<%= projName %> 89 | [bower-image]: https://badge.fury.io/bo/<%= projName %>.png 90 | 91 | [downloads-url]: https://www.npmjs.org/package/<%= projName %> 92 | [downloads-image]: http://img.shields.io/npm/dm/<%= projName %>.png 93 | 94 | [npm-url]: https://www.npmjs.org/package/<%= projName %> 95 | [npm-image]: https://badge.fury.io/js/<%= projName %>.png 96 | 97 | [irc-url]: http://webchat.freenode.net/?channels=<%= projName %> 98 | [irc-image]: http://img.shields.io/badge/irc-%23<%= projName %>-brightgreen.png 99 | 100 | [gitter-url]: https://gitter.im/<%= githubUser %>/<%= projName %> 101 | [gitter-image]: http://img.shields.io/badge/gitter-<%= githubUser %>/<%= projName %>-brightgreen.png 102 | 103 | [tip-url]: https://www.gittip.com/<%= githubUser %> 104 | [tip-image]: http://img.shields.io/gittip/<%= githubUser %>.png -------------------------------------------------------------------------------- /app/templates/_bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= projName %>", 3 | "version": "0.1.0", 4 | "main": "<%= baseFileName %>.js", 5 | "ignore": [ 6 | ".editorconfig", 7 | ".gitattributes", 8 | ".gitignore", 9 | ".jshintrc", 10 | ".npmignore", 11 | ".travis.yml", 12 | ".umd", 13 | "gulpfile.js", 14 | "npm-shrinkwrap.json", 15 | "package.json" 16 | ], 17 | "dependencies": { 18 | 19 | }, 20 | "devDependencies": { 21 | 22 | } 23 | } -------------------------------------------------------------------------------- /app/templates/_gruntfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * ### Responsibilities 5 | * - automate common tasks using grunt 6 | * 7 | * Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | * 9 | * @author <%= realname %> <<%= email %>> 10 | */ 11 | 'use strict'; 12 | 13 | module.exports = function (grunt) { 14 | var config = { 15 | app: '.', 16 | dist: '.' 17 | }; 18 | 19 | grunt.initConfig({ 20 | config: config, 21 | jshint: { 22 | options: { 23 | jshintrc: '.jshintrc' 24 | }, 25 | all: [ 26 | 'gruntfile.js', 27 | '<%%= config.app %>/{,*/}*.js', 28 | 'test/spec/{,*/}*.js' 29 | ] 30 | }, 31 | karma: { 32 | unit: { 33 | configFile: 'karma.conf.js' 34 | } 35 | } 36 | }); 37 | 38 | grunt.registerTask('test', [ 39 | 'karma:unit' 40 | ]); 41 | 42 | grunt.registerTask('build', [ 43 | 'uglify' 44 | ]); 45 | 46 | grunt.registerTask('default', [ 47 | 'jshint', 48 | 'test', 49 | 'build' 50 | ]); 51 | }; -------------------------------------------------------------------------------- /app/templates/_gulpfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * ### Responsibilities 5 | * - automate common tasks using gulp 6 | * 7 | * Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | * 9 | * @author <%= realname %> <<%= email %>> 10 | */ 11 | 'use strict'; 12 | 13 | var gulp = require('gulp'), 14 | jshint = require('gulp-jshint'), 15 | complexity = require('gulp-complexity'), 16 | uglify = require('gulp-uglify'), 17 | rename = require('gulp-rename'), 18 | replace = require('gulp-replace'), 19 | karma = require('gulp-karma'), 20 | fs = require('fs'), 21 | source = '<%= baseFileName %>.js', 22 | sourceMin = '<%= baseFileName %>.min.js', 23 | specs = 'test/spec/*.spec.js', 24 | karmaConf = 'test/karma.conf', 25 | umdWrapper = fs.readFileSync('./.umd'); 26 | 27 | gulp.task('lint', function () { 28 | return gulp.src([source, specs]) 29 | .pipe(jshint()) 30 | .pipe(jshint.reporter('default')) 31 | .pipe(jshint.reporter('fail')); 32 | }); 33 | 34 | gulp.task('gpa', function () { 35 | return gulp.src([source, specs]) 36 | .pipe(complexity({ 37 | cyclomatic: [8], 38 | halstead: [9], 39 | maintainability: [100] 40 | })); 41 | }); 42 | 43 | gulp.task('test', function () { 44 | return gulp.src([source, specs]) 45 | .pipe(karma({ 46 | configFile: karmaConf + '.js' 47 | })); 48 | }); 49 | 50 | gulp.task('min', function () { 51 | return gulp.src(source) 52 | .pipe(rename(sourceMin)) 53 | .pipe(uglify({ 54 | outSourceMap: true 55 | })) 56 | .pipe(replace(/(.*)/, umdWrapper)) 57 | .pipe(gulp.dest('.')); 58 | }); 59 | <% if (options.coffee) { %> 60 | gulp.task('test-coffee', function () { 61 | return gulp.src(['<%= baseFileName %>.coffee', 'test/spec/*.spec.coffee']) 62 | .pipe(karma({ 63 | configFile: karmaConf + '.coffee' 64 | })); 65 | });<% } %> 66 | 67 | gulp.task('test-min', ['min'], function () { 68 | return gulp.src([sourceMin, specs]) 69 | .pipe(karma({ 70 | configFile: karmaConf + '.js', 71 | reporters: ['dots'] 72 | })); 73 | }); 74 | 75 | gulp.task('default', ['lint', 'gpa', 'test',<% if (options.coffee) { %> 'test-coffee',<% } %> 'test-min']); -------------------------------------------------------------------------------- /app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= projName %>", 3 | "version": "0.1.0", 4 | "description": "<%= projName %> scaffolded with <%= pkg.name %> v<%= pkg.version %>.", 5 | "author": { 6 | "name": "<%= realname %>", 7 | "email": "<%= email %>", 8 | "url": "<%= githubUrl %>" 9 | }, 10 | "homepage": "<%= githubUrl %>/<%= projName %>", 11 | "bugs": { 12 | "url": "<%= githubUrl %>/<%= projName %>/issues" 13 | }, 14 | "licenses": [ 15 | { 16 | "type": "MIT"<% if (useMitOrg) { %>, 17 | "url": "http://<%= githubUser %>.mit-license.org"<% } %> 18 | } 19 | ], 20 | "maintainers": [], 21 | "contributors": [{ 22 | "name": "Daniel Lamb", 23 | "email": "dlamb.open.source@gmail.com", 24 | "url": "https://github.com/daniellmb" 25 | }], 26 | "repository": { 27 | "type": "git", 28 | "url": "git://github.com/<%= githubUser %>/<%= projName %>.git" 29 | }, 30 | "main": "<%= baseFileName %>.js", 31 | "scripts": { 32 | "test": "<%= taskFramework %>" 33 | }, 34 | "keywords": [ 35 | "micro", 36 | "framework", 37 | "library" 38 | ], 39 | "dependencies": { 40 | }, 41 | "devDependencies": {<% if (taskFramework === 'gulp') { %> 42 | "gulp": "*", 43 | "gulp-jshint": "*", 44 | "gulp-complexity": "*", 45 | "gulp-rename": "*", 46 | "gulp-replace": "*", 47 | "gulp-uglify": "*",<% if (options.coffee) { %> 48 | "gulp-coffee": "*",<% } %> 49 | "gulp-karma": "*",<% } %><% if (taskFramework === 'grunt') { %> 50 | "grunt": "*", 51 | "grunt-contrib-jshint": "*", 52 | "grunt-complexity": "*", 53 | "grunt-contrib-uglify": "*", 54 | "grunt-karma": "*",<% if (options.coffee) { %> 55 | "grunt-contrib-coffee": "*",<% } %><% } %><% if (testFramework === 'jasmine') { %> 56 | "karma-jasmine": "*",<% } %><% if (testFramework === 'mocha') { %> 57 | "mocha": "*", 58 | "karma-mocha": "*", 59 | "karma-chai": "*", 60 | "sinon-chai": "*", 61 | "karma-sinon": "*",<% } %><% if (options.coffee) { %> 62 | "coffee-script": "*", 63 | "karma-coffee-preprocessor": "*",<% } %> 64 | "karma-coverage": "*", 65 | "karma-phantomjs-launcher": "*" 66 | }, 67 | "engines": { 68 | "node": ">=0.10.0" 69 | } 70 | } -------------------------------------------------------------------------------- /app/templates/editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /app/templates/gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /app/templates/gitignore: -------------------------------------------------------------------------------- 1 | # package managers # 2 | #################### 3 | node_modules/ 4 | npm-debug.log 5 | bower_components/ 6 | 7 | # generated files # 8 | ###################### 9 | coverage/ 10 | .idea/ 11 | .DS_Store 12 | .DS_Store? 13 | ._* 14 | .Trashes 15 | Icon? 16 | ehthumbs.db 17 | Thumbs.db 18 | .tmp -------------------------------------------------------------------------------- /app/templates/jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 2, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "strict": false, 18 | "trailing": true, 19 | "smarttabs": true, 20 | "validthis": true, 21 | "white": true, 22 | "globals":{<% if (testFramework === 'mocha') { %> 23 | "chai": false, 24 | "sinon": false, 25 | "assert": false, 26 | "describe": false, 27 | "xdescribe": false, 28 | "it": false, 29 | "xit": false, 30 | "before": false, 31 | "after": false, 32 | "beforeEach": false, 33 | "afterEach": false, 34 | "suite": false, 35 | "test": false, 36 | "setup": false, 37 | "teardown": false, 38 | "expect": false,<% } %><% if (testFramework === 'jasmine') { %> 39 | "describe": false, 40 | "xdescribe": false, 41 | "it": false, 42 | "xit": false, 43 | "beforeEach": false, 44 | "afterEach": false, 45 | "expect": false, 46 | "spyOn": false,<% } %> 47 | "define": false 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/templates/micro-tmpl.coffee: -------------------------------------------------------------------------------- 1 | ###* 2 | @file <%= projName %> is micro-library. 3 | Scaffolded with <%= pkg.name %> 4 | @author <%= realname %> <<%= email %>> 5 | ### 6 | 7 | <%= exportName %> = -> 8 | # TODO: implement your micro framework or library. -------------------------------------------------------------------------------- /app/templates/micro-tmpl.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file <%= projName %> is micro-library. 3 | * Scaffolded with <%= pkg.name %> 4 | * @author <%= realname %> <<%= email %>> 5 | */ 6 | 7 | function <%= exportName %>() { 8 | // TODO: implement your micro framework or library. 9 | } -------------------------------------------------------------------------------- /app/templates/micro-tmpl.min.js: -------------------------------------------------------------------------------- 1 | // Run "<%= taskFramework %>" to generate this file -------------------------------------------------------------------------------- /app/templates/npmignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.log 3 | bower_components/ 4 | coverage/ 5 | .idea/ 6 | .DS_Store 7 | .DS_Store? 8 | ._* 9 | .Trashes 10 | Icon? 11 | ehthumbs.db 12 | Thumbs.db 13 | .tmp -------------------------------------------------------------------------------- /app/templates/test/jasmine.spec.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | @file 3 | 4 | ## Responsibilities 5 | - unit test <%= baseFileName %>.coffee 6 | 7 | Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | 9 | @author <%= realname %> <<%= email %>> 10 | ### 11 | 12 | describe '<%= baseFileName %>.coffee', -> 13 | beforeEach -> 14 | # add spies 15 | 16 | it 'should have a working test harness', -> 17 | # arrange 18 | # act 19 | # assert 20 | expect(true).not.toBe false 21 | 22 | it 'should exist', -> 23 | # arrange 24 | # act 25 | # assert 26 | expect(typeof <%= exportName %>).toBe 'function' 27 | 28 | it 'should return nothing', -> 29 | # arrange 30 | # act 31 | result = <%= exportName %>() 32 | # assert 33 | expect(result).toBeUndefined() -------------------------------------------------------------------------------- /app/templates/test/jasmine.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * ### Responsibilities 5 | * - unit test <%= baseFileName %>.js 6 | * 7 | * Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | * 9 | * @author <%= realname %> <<%= email %>> 10 | */ 11 | 'use strict'; 12 | 13 | /*global <%= exportName %>*/ 14 | describe('<%= baseFileName %>.js', function () { 15 | beforeEach(function () { 16 | // add spies 17 | }); 18 | 19 | it('should have a working test harness', function () { 20 | // arrange 21 | // act 22 | // assert 23 | expect(true).not.toBe(false); 24 | }); 25 | 26 | it('should exist', function () { 27 | // arrange 28 | // act 29 | // assert 30 | expect(typeof <%= exportName %>).toBe('function'); 31 | }); 32 | 33 | it('should return nothing', function () { 34 | // arrange 35 | // act 36 | var result = <%= exportName %>(); 37 | // assert 38 | expect(result).toBeUndefined(); 39 | }); 40 | 41 | }); -------------------------------------------------------------------------------- /app/templates/test/karma.conf.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | @file 3 | 4 | ## Responsibilities 5 | - configure karma for <%= testFramework %> testing 6 | 7 | Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | 9 | @author <%= realname %> <<%= email %>> 10 | ### 11 | 12 | module.exports = (config) -> 13 | config.set 14 | ### 15 | Path used to resolve file paths 16 | ### 17 | basePath: '../' 18 | 19 | ### 20 | Test results reporter to use: 21 | dots, progress, nyan, story, coverage etc. 22 | ### 23 | reporters: ['dots'] 24 | 25 | ### 26 | Test pre-processors 27 | ### 28 | preprocessors: 29 | '<%= baseFileName %>.coffee': ['coffee'] 30 | 'test/spec/*.spec.coffee': ['coffee'] 31 | 32 | ### 33 | Locally installed browsers 34 | Chrome, ChromeCanary, PhantomJS, Firefox, Opera, IE, Safari, iOS etc. 35 | ### 36 | browsers: ['PhantomJS'] 37 | 38 | ### 39 | Enable / disable watching file and executing tests whenever any file changes 40 | ### 41 | autoWatch: false 42 | 43 | ### 44 | Continuous Integration mode: if true, it capture browsers, run tests and exit 45 | ### 46 | singleRun: true 47 | 48 | ### 49 | Report slow running tests, time in ms 50 | ### 51 | reportSlowerThan: 250 52 | 53 | ### 54 | If browser does not capture in given timeout [ms], kill it 55 | Increasing timeout in case connection in Travis CI is slow 56 | ### 57 | captureTimeout: 100000 58 | 59 | ### 60 | Logging Level: 61 | DISABLE, ERROR, WARN, INFO, DEBUG 62 | ### 63 | logLevel: 'INFO' 64 | 65 | ### 66 | Test framework to use: 67 | jasmine, mocha, qunit etc. 68 | ### 69 | frameworks: ['<%= testFramework %>'<% if (testFramework === 'mocha') { %>, 'chai', 'sinon'<% } %>] -------------------------------------------------------------------------------- /app/templates/test/karma.conf.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * ### Responsibilities 5 | * - configure karma for <%= testFramework %> testing 6 | * 7 | * Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | * 9 | * @author <%= realname %> <<%= email %>> 10 | */ 11 | 'use strict'; 12 | 13 | module.exports = function (config) { 14 | config.set({ 15 | /* 16 | Path used to resolve file paths 17 | */ 18 | basePath : '../', 19 | 20 | /* 21 | Test results reporter to use: 22 | dots, progress, nyan, story, coverage etc. 23 | */ 24 | reporters: ['dots', 'coverage'], 25 | 26 | /* 27 | Test pre-processors 28 | */ 29 | preprocessors: { 30 | '<%= baseFileName %>.js': ['coverage'] 31 | }, 32 | 33 | /* 34 | Test coverage reporters: 35 | html, lcovonly, lcov, cobertura, text-summary, text, teamcity, clover etc. 36 | */ 37 | coverageReporter: { 38 | reporters: [{ 39 | type: 'text', 40 | dir: 'test/coverage' 41 | }, { 42 | type: 'lcov', 43 | dir: 'test/coverage' 44 | }] 45 | }, 46 | 47 | /* 48 | Locally installed browsers 49 | Chrome, ChromeCanary, PhantomJS, Firefox, Opera, IE, Safari, iOS etc. 50 | */ 51 | browsers: ['PhantomJS'], 52 | 53 | /* 54 | Enable / disable watching file and executing tests whenever any file changes 55 | */ 56 | autoWatch: false, 57 | 58 | /* 59 | Continuous Integration mode: if true, it capture browsers, run tests and exit 60 | */ 61 | singleRun: true, 62 | 63 | /* 64 | Report slow running tests, time in ms 65 | */ 66 | reportSlowerThan: 250, 67 | 68 | /* 69 | If browser does not capture in given timeout [ms], kill it 70 | Increasing timeout in case connection in Travis CI is slow 71 | */ 72 | captureTimeout: 100000, 73 | 74 | /* 75 | Logging Level: 76 | DISABLE, ERROR, WARN, INFO, DEBUG 77 | */ 78 | logLevel: 'INFO', 79 | 80 | /* 81 | Test framework to use: 82 | jasmine, mocha, qunit etc. 83 | */ 84 | frameworks: ['<%= testFramework %>'<% if (testFramework === 'mocha') { %>, 'chai', 'sinon'<% } %>] 85 | }); 86 | }; -------------------------------------------------------------------------------- /app/templates/test/mocha.spec.coffee: -------------------------------------------------------------------------------- 1 | ### 2 | @file 3 | 4 | ## Responsibilities 5 | - unit test <%= baseFileName %>.coffee 6 | 7 | Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | 9 | @author <%= realname %> <<%= email %>> 10 | ### 11 | 12 | describe '<%= baseFileName %>.coffee', -> 13 | sandbox = undefined 14 | beforeEach -> 15 | # create a sandbox 16 | sandbox = sinon.sandbox.create() 17 | 18 | # stub some methods 19 | afterEach -> 20 | # restore the environment as it was before 21 | sandbox.restore() 22 | 23 | it 'should have a working test harness', -> 24 | # arrange 25 | # act 26 | # assert 27 | expect(yes).to.not.equal no 28 | 29 | it 'should exist', -> 30 | # arrange 31 | # act 32 | # assert 33 | expect(typeof <%= exportName %>).to.equal 'function' 34 | 35 | it 'should return nothing', -> 36 | # arrange 37 | # act 38 | result = <%= exportName %>(); 39 | # assert 40 | expect(result).to.equal undefined -------------------------------------------------------------------------------- /app/templates/test/mocha.spec.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * 4 | * ### Responsibilities 5 | * - unit test <%= baseFileName %>.js 6 | * 7 | * Scaffolded with <%= pkg.name %> v<%= pkg.version %> 8 | * 9 | * @author <%= realname %> <<%= email %>> 10 | */ 11 | 'use strict'; 12 | 13 | /*global <%= exportName %>*/ 14 | describe('<%= baseFileName %>.js', function () { 15 | var sandbox; 16 | 17 | beforeEach(function () { 18 | // create a sandbox 19 | sandbox = sinon.sandbox.create(); 20 | 21 | // stub some methods 22 | }); 23 | 24 | afterEach(function () { 25 | // restore the environment as it was before 26 | sandbox.restore(); 27 | }); 28 | 29 | it('should have a working test harness', function () { 30 | // arrange 31 | // act 32 | // assert 33 | expect(true).to.not.equal(false); 34 | }); 35 | 36 | it('should exist', function () { 37 | // arrange 38 | // act 39 | // assert 40 | expect(typeof <%= exportName %>).to.equal('function'); 41 | }); 42 | 43 | it('should return nothing', function () { 44 | // arrange 45 | // act 46 | var result = <%= exportName %>(); 47 | // assert 48 | expect(result).to.equal(undefined); 49 | }); 50 | 51 | }); -------------------------------------------------------------------------------- /app/templates/travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - '0.10' 5 | 6 | before_script: 7 | #- npm install -g codeclimate-test-reporter 8 | 9 | after_script: 10 | #TODO: enable publishing code coverage reports 11 | #- codeclimate < test/coverage/**/lcov.info 12 | 13 | notifications: 14 | # publish build status to IRC channel: #<%= projName %> 15 | irc: 16 | channels: 17 | - chat.freenode.net#<%= projName %> 18 | on_success: always 19 | on_failure: always 20 | template: 21 | - '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}' 22 | - 'Change view : %{compare_url}' 23 | - 'Build details : %{build_url}' 24 | #TODO: enable publishing build status to gitter.im 25 | # publish build status to gitter chat room: https://gitter.im/<%= githubUser %>/<%= projName %> 26 | #webhooks: 27 | # urls: 28 | # - [REPLACE WITH YOUR WEBHOOK URL; https://webhooks.gitter.im/e/XXXXXXXXXXXXXXXX] 29 | # on_success: always 30 | # on_failure: always 31 | # on_start: false 32 | 33 | env: 34 | #- CODECLIMATE_REPO_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -------------------------------------------------------------------------------- /app/templates/umd: -------------------------------------------------------------------------------- 1 | (function (window, factory) { 2 | 'use strict'; 3 | if (typeof define === 'function' && define.amd) { 4 | // AMD 5 | define([], factory); 6 | } else if (typeof exports === 'object') { 7 | // Node.js 8 | module.exports = factory(); 9 | } else { 10 | // Browser 11 | window.<%= exportName %> = factory(); 12 | } 13 | }(this, function factory() { 14 | // public API 15 | return $1; 16 | })); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-microjs", 3 | "version": "0.1.2", 4 | "description": "Scaffold out a micro library or framework using yeoman.", 5 | "license": "MIT", 6 | "repository": "daniellmb/generator-microjs", 7 | "author": { 8 | "name": "Daniel Lamb", 9 | "email": "dlamb.open.source@gmail.com", 10 | "url": "https://github.com/daniellmb" 11 | }, 12 | "bugs": { 13 | "url": "https://github.com/daniellmb/generator-microjs/issues" 14 | }, 15 | "licenses": [ 16 | { 17 | "type": "MIT", 18 | "url": "http://daniellmb.mit-license.org" 19 | } 20 | ], 21 | "scripts": { 22 | "test": "mocha --reporter spec" 23 | }, 24 | "files": [ 25 | "app" 26 | ], 27 | "main": "app/index.js", 28 | "keywords": [ 29 | "micro", 30 | "library", 31 | "framework", 32 | "scaffold", 33 | "generator", 34 | "yeoman-generator", 35 | "web", 36 | "front-end", 37 | "gulp", 38 | "grunt" 39 | ], 40 | "dependencies": { 41 | "yeoman-generator": "~0.16.0", 42 | "chalk": "~0.5.1", 43 | "yosay": "^0.3.0", 44 | "npm-name": "~0.2.0", 45 | "github": "~0.2.0", 46 | "fixture-stdout": "~0.2.1" 47 | }, 48 | "devDependencies": { 49 | "mocha": "*", 50 | "underscore": "^1.6.0" 51 | }, 52 | "peerDependencies": { 53 | "yo": ">=1.0.0" 54 | }, 55 | "preferGlobal": true, 56 | "engines": { 57 | "node": ">=0.10.0", 58 | "npm": ">=1.2.10" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /test/mute.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Silence Yeoman during tests 3 | * uses github.com/balderdashy/fixture-stdout 4 | * 5 | * Usage: 6 | * ``` 7 | * // test-something.js 8 | * var Output = require('./mute'); 9 | * 10 | * // beforeEach() test: 11 | * this.app.on('start', Output.mute); 12 | * this.app.on('end', Output.unmute); 13 | * ``` 14 | */ 15 | 'use strict'; 16 | 17 | 18 | var Fixture = require('fixture-stdout'); 19 | var fixtureOut = new Fixture(); 20 | var fixtureErr = new Fixture({ stream: process.stderr }); 21 | 22 | var _writesOut = []; 23 | var _writesErr = []; 24 | 25 | 26 | // Mute 27 | module.exports.mute = function () { 28 | fixtureOut.capture(function onWrite(string) { 29 | _writesOut.push({ string : string }); 30 | 31 | // Prevent original write 32 | return false; 33 | }); 34 | 35 | 36 | fixtureErr.capture(function onWrite(string) { 37 | _writesErr.push({ string : string }); 38 | 39 | // Prevent original write 40 | return false; 41 | }); 42 | }; 43 | 44 | 45 | // Unmute 46 | module.exports.unmute = function () { 47 | fixtureOut.release(); 48 | fixtureErr.release(); 49 | }; 50 | 51 | 52 | // Return the output that was captured 53 | module.exports.getMutedWrites = function () { 54 | return { 55 | out: _writesOut, 56 | err: _writesErr 57 | }; 58 | }; -------------------------------------------------------------------------------- /test/test-app-load.js: -------------------------------------------------------------------------------- 1 | /*global describe, beforeEach, it*/ 2 | 'use strict'; 3 | var assert = require('assert'); 4 | 5 | describe('microjs generator load', function () { 6 | it('can be imported without blowing up', function () { 7 | var app = require('../app'); 8 | assert(app !== undefined); 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /test/test-creation.js: -------------------------------------------------------------------------------- 1 | /*global describe, beforeEach, it */ 2 | 'use strict'; 3 | var path = require('path'); 4 | var helpers = require('yeoman-generator').test; 5 | var _ = require('underscore'); 6 | var output = require('./mute'); 7 | 8 | global.YEOMAN_MUTE = true; 9 | 10 | describe('microjs generator', function () { 11 | 12 | var options, promptMocks, projName = 'test-proj', testDir = path.join(__dirname, 'temp'); 13 | 14 | function checkContents(file, contents) { 15 | return [file, new RegExp(contents)]; 16 | } 17 | 18 | beforeEach(function (done) { 19 | // mock command line options 20 | options = { 21 | 'skip-install-message': true, 22 | 'skip-install': true, 23 | 'skip-welcome-message': true, 24 | 'skip-message': true 25 | }; 26 | 27 | // mock generator prompts 28 | promptMocks = { 29 | 'githubUser': 'daniellmb', 30 | 'generatorName': 'temp', 31 | 'projName': projName, 32 | 'taskFramework': 'gulp', 33 | 'testFramework': 'jasmine' 34 | }; 35 | 36 | // create generator instance 37 | helpers.testDirectory(testDir, function (err) { 38 | if (err) { 39 | return done(err); 40 | } 41 | 42 | this.app = helpers.createGenerator('microjs:app', [ 43 | '../../app' 44 | ]); 45 | 46 | // mock generator prompts 47 | helpers.mockPrompt(this.app, promptMocks); 48 | 49 | // mock command line options 50 | _.extend(this.app.options, options); 51 | 52 | // Prevent Yeoman writes while the generator runs 53 | // then re-enable them when it's finished to see the test results 54 | this.app.on('start', output.mute); 55 | this.app.on('end', output.unmute); 56 | 57 | done(); 58 | 59 | }.bind(this)); 60 | }); 61 | 62 | describe('when using the default settings', function () { 63 | it('should create the expected files', function (done) { 64 | 65 | // the expected files should exist 66 | var expectedFiles = [ 67 | 'test/karma.conf.js', 68 | 'test/spec/' + projName + '.spec.js', 69 | '.editorconfig', 70 | '.gitattributes', 71 | '.gitignore', 72 | '.jshintrc', 73 | '.npmignore', 74 | '.travis.yml', 75 | '.umd', 76 | 'bower.json', 77 | 'gulpfile.js', 78 | 'package.json', 79 | 'README.md', 80 | projName + '.js', 81 | projName + '.min.js' 82 | ]; 83 | 84 | // the unexpected files should not exist 85 | var unexpectedFiles = [ 86 | 'gruntfile.js', 87 | projName + '.coffee', 88 | 'test/karma.conf.coffee', 89 | 'test/spec/' + projName + '.spec.coffee' 90 | ]; 91 | 92 | // run the generator 93 | this.app.run({}, function () { 94 | 95 | // check for expected files 96 | helpers.assertFile(expectedFiles); 97 | 98 | // check for unexpected files 99 | helpers.assertNoFile(unexpectedFiles); 100 | 101 | done(); 102 | }); 103 | }); 104 | 105 | describe('.jshintrc', function () { 106 | var file = '.jshintrc'; 107 | 108 | it('should contain the correct contents', function (done) { 109 | 110 | // the file should have the expected content 111 | var expectedContent = [ 112 | checkContents(file, 'expect'), 113 | checkContents(file, 'spyOn') 114 | ]; 115 | 116 | // the file should not have unexpected content 117 | var unexpectedContent = [ 118 | checkContents(file, 'setup'), 119 | checkContents(file, 'teardown') 120 | ]; 121 | 122 | // run the generator 123 | this.app.run({}, function () { 124 | 125 | // check for expected file contents 126 | helpers.assertFileContent(expectedContent); 127 | 128 | // check for unexpected file contents 129 | helpers.assertNoFileContent(unexpectedContent); 130 | 131 | done(); 132 | }); 133 | }); 134 | }); 135 | 136 | describe('bower.json', function () { 137 | var file = 'bower.json'; 138 | 139 | it('should contain the correct contents', function (done) { 140 | 141 | // the file should have the expected content 142 | var expectedContent = [ 143 | checkContents(file, '"name": "' + projName + '"') 144 | ]; 145 | 146 | // run the generator 147 | this.app.run({}, function () { 148 | 149 | // check for expected file contents 150 | helpers.assertFileContent(expectedContent); 151 | 152 | done(); 153 | }); 154 | }); 155 | }); 156 | 157 | describe('gulpfile.js', function () { 158 | var file = 'gulpfile.js'; 159 | 160 | it('should contain the correct contents', function (done) { 161 | 162 | // the file should have the expected content 163 | var expectedContent = [ 164 | checkContents(file, 'source = \'' + projName + '.js\''), 165 | checkContents(file, 'sourceMin = \'' + projName + '.min.js\''), 166 | checkContents(file, 'gulp.src\\(\\[source, specs\\]'), 167 | checkContents(file, 'pipe\\(rename\\(sourceMin') 168 | ]; 169 | 170 | // run the generator 171 | this.app.run({}, function () { 172 | 173 | // check for expected file contents 174 | helpers.assertFileContent(expectedContent); 175 | 176 | done(); 177 | }); 178 | }); 179 | }); 180 | 181 | describe('package.json', function () { 182 | var file = 'package.json'; 183 | 184 | it('should contain the correct contents', function (done) { 185 | 186 | // the file should have the expected content 187 | var expectedContent = [ 188 | checkContents(file, '"name": "' + projName + '"'), 189 | checkContents(file, 'gulp'), 190 | checkContents(file, 'jasmine') 191 | ]; 192 | 193 | // the file should not have unexpected content 194 | var unexpectedContent = [ 195 | checkContents(file, 'coffee'), 196 | checkContents(file, 'grunt'), 197 | checkContents(file, 'mocha') 198 | ]; 199 | 200 | // run the generator 201 | this.app.run({}, function () { 202 | 203 | // check for expected file contents 204 | helpers.assertFileContent(expectedContent); 205 | 206 | // check for unexpected file contents 207 | helpers.assertNoFileContent(unexpectedContent); 208 | 209 | done(); 210 | }); 211 | }); 212 | }); 213 | 214 | describe('README.md', function () { 215 | var file = 'README.md'; 216 | 217 | it('should contain the correct contents', function (done) { 218 | 219 | // the file should have the expected content 220 | var expectedContent = [ 221 | checkContents(file, '# ' + projName) 222 | ]; 223 | 224 | // the file should not have unexpected content 225 | var unexpectedContent = [ 226 | checkContents(file, 'CoffeeScript') 227 | ]; 228 | 229 | // run the generator 230 | this.app.run({}, function () { 231 | 232 | // check for expected file contents 233 | helpers.assertFileContent(expectedContent); 234 | 235 | // check for unexpected file contents 236 | helpers.assertNoFileContent(unexpectedContent); 237 | 238 | done(); 239 | }); 240 | }); 241 | }); 242 | 243 | describe(projName + '.js', function () { 244 | var file = projName + '.js'; 245 | 246 | it('should contain the correct contents', function (done) { 247 | 248 | // the file should have the expected content 249 | var expectedContent = [ 250 | checkContents(file, '@file ' + projName + ' is micro-library.'), 251 | checkContents(file, '@author Daniel Lamb ') 252 | ]; 253 | 254 | // run the generator 255 | this.app.run({}, function () { 256 | 257 | // check for expected file contents 258 | helpers.assertFileContent(expectedContent); 259 | 260 | done(); 261 | }); 262 | }); 263 | }); 264 | 265 | describe(projName + '.min.js', function () { 266 | var file = projName + '.min.js'; 267 | 268 | it('should contain the correct contents', function (done) { 269 | 270 | // the file should have the expected content 271 | var expectedContent = [ 272 | checkContents(file, '// Run "gulp" to generate this file') 273 | ]; 274 | 275 | // run the generator 276 | this.app.run({}, function () { 277 | 278 | // check for expected file contents 279 | helpers.assertFileContent(expectedContent); 280 | 281 | done(); 282 | }); 283 | }); 284 | }); 285 | }); 286 | 287 | describe('when taskFramework is grunt', function () { 288 | beforeEach(function () { 289 | // set use grunt task framework 290 | promptMocks.taskFramework = 'grunt'; 291 | // mock user prompts 292 | helpers.mockPrompt(this.app, promptMocks); 293 | }); 294 | 295 | it('should create the expected files', function (done) { 296 | // the expected files should exist 297 | var expectedFiles = [ 298 | 'gruntfile.js' 299 | ]; 300 | 301 | // run the generator 302 | this.app.run({}, function () { 303 | 304 | // check for expected files 305 | helpers.assertFile(expectedFiles); 306 | 307 | done(); 308 | }); 309 | }); 310 | 311 | describe('gruntfile.js', function () { 312 | var file = 'gruntfile.js'; 313 | 314 | it('should contain the correct contents', function (done) { 315 | 316 | // the file should have the expected content 317 | var expectedContent = [ 318 | checkContents(file, '@author Daniel Lamb ') 319 | ]; 320 | 321 | // run the generator 322 | this.app.run({}, function () { 323 | 324 | // check for expected file contents 325 | helpers.assertFileContent(expectedContent); 326 | 327 | done(); 328 | }); 329 | }); 330 | }); 331 | 332 | describe('package.json', function () { 333 | var file = 'package.json'; 334 | 335 | it('should contain the correct contents', function (done) { 336 | 337 | // the file should have the expected content 338 | var expectedContent = [ 339 | checkContents(file, 'grunt') 340 | ]; 341 | 342 | // the file should not have unexpected content 343 | var unexpectedContent = [ 344 | checkContents(file, 'gulp') 345 | ]; 346 | 347 | // run the generator 348 | this.app.run({}, function () { 349 | 350 | // check for expected file contents 351 | helpers.assertFileContent(expectedContent); 352 | 353 | // check for unexpected file contents 354 | helpers.assertNoFileContent(unexpectedContent); 355 | 356 | done(); 357 | }); 358 | }); 359 | }); 360 | 361 | }); 362 | 363 | describe('when testFramework is mocha', function () { 364 | beforeEach(function () { 365 | // set use mocha test framework 366 | promptMocks.testFramework = 'mocha'; 367 | // mock user prompts 368 | helpers.mockPrompt(this.app, promptMocks); 369 | }); 370 | 371 | describe('package.json', function () { 372 | var file = 'package.json'; 373 | 374 | it('should contain the correct contents', function (done) { 375 | 376 | // the file should have the expected content 377 | var expectedContent = [ 378 | checkContents(file, 'mocha') 379 | ]; 380 | 381 | // the file should not have unexpected content 382 | var unexpectedContent = [ 383 | checkContents(file, 'jasmine') 384 | ]; 385 | 386 | // run the generator 387 | this.app.run({}, function () { 388 | 389 | // check for expected file contents 390 | helpers.assertFileContent(expectedContent); 391 | 392 | // check for unexpected file contents 393 | helpers.assertNoFileContent(unexpectedContent); 394 | 395 | done(); 396 | }); 397 | }); 398 | }); 399 | }); 400 | 401 | describe('when --coffee is set', function () { 402 | beforeEach(function () { 403 | // set use coffee option 404 | this.app.options.coffee = true; 405 | }); 406 | 407 | it('should create the expected files', function (done) { 408 | // the expected files should exist 409 | var expectedFiles = [ 410 | projName + '.coffee', 411 | 'test/karma.conf.coffee', 412 | 'test/spec/' + projName + '.spec.coffee' 413 | ]; 414 | 415 | // run the generator 416 | this.app.run({}, function () { 417 | 418 | // check for expected files 419 | helpers.assertFile(expectedFiles); 420 | 421 | done(); 422 | }); 423 | }); 424 | 425 | describe('package.json', function () { 426 | var file = 'package.json'; 427 | 428 | it('should contain the correct contents', function (done) { 429 | 430 | // the file should have the expected content 431 | var expectedContent = [ 432 | checkContents(file, 'coffee') 433 | ]; 434 | 435 | // run the generator 436 | this.app.run({}, function () { 437 | 438 | // check for expected file contents 439 | helpers.assertFileContent(expectedContent); 440 | 441 | done(); 442 | }); 443 | }); 444 | }); 445 | 446 | describe(projName + '.coffee', function () { 447 | var file = projName + '.coffee'; 448 | 449 | it('should contain the correct contents', function (done) { 450 | 451 | // the file should have the expected content 452 | var expectedContent = [ 453 | checkContents(file, '@file ' + projName + ' is micro-library.'), 454 | checkContents(file, '@author Daniel Lamb ') 455 | ]; 456 | 457 | // run the generator 458 | this.app.run({}, function () { 459 | 460 | // check for expected file contents 461 | helpers.assertFileContent(expectedContent); 462 | 463 | done(); 464 | }); 465 | }); 466 | }); 467 | 468 | }); 469 | 470 | }); 471 | --------------------------------------------------------------------------------