├── .gitattributes ├── .gitignore ├── app ├── templates │ ├── gitignore │ ├── travis.yml │ ├── bower.json │ ├── src │ │ ├── jshintrc │ │ └── name.js │ ├── editorconfig │ ├── jshintrc │ ├── test │ │ ├── jshintrc │ │ ├── name.html │ │ └── name_test.js │ ├── readme.md │ ├── _package.json │ ├── contributing.md │ └── Gruntfile.js └── index.js ├── .travis.yml ├── .jshintrc ├── test ├── test-load.js └── test-creation.js ├── .editorconfig ├── readme.md ├── package.json └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | temp 3 | -------------------------------------------------------------------------------- /app/templates/gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /bower_components/ 3 | dist 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - 'iojs' 5 | - '0.12' 6 | - '0.10' 7 | -------------------------------------------------------------------------------- /app/templates/travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - 'iojs' 5 | - '0.12' 6 | - '0.10' 7 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "esnext": true, 4 | "bitwise": true, 5 | "camelcase": true, 6 | "curly": true, 7 | "immed": true, 8 | "newcap": true, 9 | "noarg": true, 10 | "undef": true, 11 | "unused": "vars", 12 | "strict": true 13 | } 14 | -------------------------------------------------------------------------------- /test/test-load.js: -------------------------------------------------------------------------------- 1 | /*global describe, it */ 2 | 'use strict'; 3 | var assert = require('assert'); 4 | 5 | describe('jquery generator', function () { 6 | it('can be imported without blowing up', function () { 7 | assert(require('../app') !== undefined); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /app/templates/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= slugname %>", 3 | "version": "<%= props.version %>", 4 | "dependencies": {}, 5 | "devDependencies": { 6 | "qunit": "~1.12.0", 7 | "jquery": "<%= props.jquery_version ? '~' + props.jquery_version : 'latest' %>" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [package.json] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /app/templates/src/jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "unused": true, 11 | "boss": true, 12 | "eqnull": true, 13 | "browser": true, 14 | "predef": ["jQuery"] 15 | } 16 | -------------------------------------------------------------------------------- /app/templates/editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [package.json] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /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 | "undef": true, 16 | "unused": true, 17 | "strict": true 18 | } 19 | -------------------------------------------------------------------------------- /app/templates/test/jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "unused": true, 11 | "boss": true, 12 | "eqnull": true, 13 | "browser": true, 14 | "node": true, 15 | "predef": [ 16 | "jQuery", 17 | "QUnit", 18 | "module", 19 | "test", 20 | "asyncTest", 21 | "expect", 22 | "start", 23 | "stop", 24 | "ok", 25 | "equal", 26 | "notEqual", 27 | "deepEqual", 28 | "notDeepEqual", 29 | "strictEqual", 30 | "notStrictEqual", 31 | "throws" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ------- 2 | 3 | > [!CAUTION] 4 | > **This repository is archived and no longer actively maintained.** 5 | > 6 | > We are no longer accepting issues, feature requests, or pull requests. 7 | > For additional support or questions, please visit the [Maintenance Reboot plan](https://github.com/yeoman/yeoman/issues/1779). 8 | 9 | ------- 10 | 11 | 12 | # generator-jquery [![Build Status](https://travis-ci.org/yeoman/generator-jquery.svg?branch=master)](https://travis-ci.org/yeoman/generator-jquery) 13 | 14 | > Generate a jQuery plugin 15 | 16 | 17 | ## Install 18 | 19 | ``` 20 | $ npm install --global generator-jquery 21 | ``` 22 | 23 | 24 | ## Usage 25 | 26 | ``` 27 | $ yo jquery 28 | ``` 29 | 30 | 31 | ## License 32 | 33 | MIT © Yeoman 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-jquery", 3 | "version": "1.2.3", 4 | "description": "Generate a jQuery plugin", 5 | "keywords": [ 6 | "yeoman-generator", 7 | "scaffold", 8 | "jquery" 9 | ], 10 | "author": "Yeoman", 11 | "main": "app/index.js", 12 | "repository": "yeoman/generator-jquery", 13 | "scripts": { 14 | "test": "mocha --timeout 20000" 15 | }, 16 | "dependencies": { 17 | "compare-version": "^0.1.2", 18 | "is-online": "^3.1.0", 19 | "multiline": "^1.0.1", 20 | "pkg-name": "^1.0.0", 21 | "yeoman-generator": "^0.18.9" 22 | }, 23 | "devDependencies": { 24 | "mocha": "*" 25 | }, 26 | "engines": { 27 | "node": ">=0.10.0" 28 | }, 29 | "files": [ 30 | "app" 31 | ], 32 | "license": "MIT" 33 | } 34 | -------------------------------------------------------------------------------- /app/templates/readme.md: -------------------------------------------------------------------------------- 1 | # <%= props.title || props.name %> 2 | 3 | > <%= props.description %> 4 | 5 | 6 | ## Getting Started 7 | 8 | Download the [production version][min] or the [development version][max]. 9 | 10 | [min]: https://raw.githubusercontent.com/<%= props.github_username %>/jquery-<%= slugname %>/master/dist/jquery.<%= slugname %>.min.js 11 | [max]: https://raw.githubusercontent.com/<%= props.github_username %>/jquery-<%= slugname %>/master/dist/jquery.<%= slugname %>.js 12 | 13 | In your web page: 14 | 15 | ```html 16 | 17 | 18 | 23 | ``` 24 | 25 | 26 | ## License 27 | 28 | <%= props.license %> © <%= props.author_name %> 29 | -------------------------------------------------------------------------------- /app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= slugname %>", 3 | "version": "<%= props.version %>", 4 | "description": "<%= props.title %>", 5 | "keywords": [ 6 | "jquery-plugin" 7 | ], 8 | "author": { 9 | "name": "<%= props.author_name %>", 10 | "email": "<%= props.author_email %>", 11 | "url": "https://github.com/<%= props.github_username %>" 12 | }, 13 | "repository": "<%= props.github_username %>/<%= slugname %>", 14 | "license": "<%= props.license %>", 15 | "scripts": { 16 | "test": "grunt", 17 | "install": "bower install" 18 | }, 19 | "devDependencies": { 20 | "bower": "^1.4.1", 21 | "grunt": "^0.4.5", 22 | "grunt-cli": "^0.1.13", 23 | "grunt-contrib-clean": "^0.6.0", 24 | "grunt-contrib-concat": "^0.5.0", 25 | "grunt-contrib-connect": "^0.9.0", 26 | "grunt-contrib-jshint": "^0.10.0", 27 | "grunt-contrib-qunit": "^0.5.1", 28 | "grunt-contrib-uglify": "^0.7.0", 29 | "grunt-contrib-watch": "^0.6.1", 30 | "jshint-stylish": "^1.0.0", 31 | "load-grunt-tasks": "^2.0.0", 32 | "time-grunt": "^1.0.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/templates/src/name.js: -------------------------------------------------------------------------------- 1 | /* 2 | * <%= props.name %> 3 | * <%= props.homepage %> 4 | * 5 | * Copyright (c) <%= currentYear %> <%= props.author_name %> 6 | * Licensed under the <%= props.license %> license. 7 | */ 8 | (function ($) { 9 | <% if (props.kind === 'collection_method') { %>$.fn.<%= camelname %> = function () { 10 | return this.each(function (i) { 11 | // Do something to each selected element. 12 | $(this).html('<%= camelname %>' + i); 13 | }); 14 | };<% } if (props.kind === 'static_method') { %>$.<%= camelname %> = function (options) { 15 | // Override default options with passed-in options. 16 | options = $.extend({}, $.<%= camelname %>.options, options); 17 | // Return the name of your plugin plus a punctuation character. 18 | return '<%= camelname %>' + options.punctuation; 19 | }; 20 | 21 | // Default options. 22 | $.<%= camelname %>.options = { 23 | punctuation: '.' 24 | };<% } if (props.kind === 'custom_selector') { %> 25 | $.expr[':'].<%= camelname %> = function (el) { 26 | return $(el).text() === 'awesome test markup'; 27 | };<% } %> 28 | }(jQuery)); 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Yeoman team 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/templates/test/name.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= props.title || props.name %> Test Suite 6 | <% if (props.jquery_version && compareVersion(props.jquery_version, '1.11.0') === -1) { %> 7 | <% } else { %> 8 | <% } %> 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 20 | 21 |
22 |
23 | lame test markup 24 | normal test markup 25 | awesome test markup 26 |
27 | 28 | 29 | -------------------------------------------------------------------------------- /app/templates/test/name_test.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | <% if (props.kind === 'collection_method') { %>module('jQuery#<%= camelname %>', { 3 | setup: function () { 4 | this.elems = $('#qunit-fixture').children(); 5 | } 6 | }); 7 | 8 | test('is chainable', function () { 9 | expect(1); 10 | strictEqual(this.elems.<%= camelname %>(), this.elems, 'should be chainable'); 11 | }); 12 | 13 | test('is <%= camelname %>', function () { 14 | expect(1); 15 | strictEqual(this.elems.<%= camelname %>().text(), '<%= camelname %>0<%= camelname %>1<%= camelname %>2', 'should be <%= camelname %>'); 16 | }); 17 | <% } if (props.kind === 'static_method') { %>module('jQuery.<%= camelname %>'); 18 | 19 | test('is <%= camelname %>', function () { 20 | expect(2); 21 | strictEqual($.<%= camelname %>(), '<%= camelname %>.', 'should be <%= camelname %>'); 22 | strictEqual($.<%= camelname %>({punctuation: '!'}), '<%= camelname %>!', 'should be thoroughly <%= camelname %>'); 23 | }); 24 | <% } if (props.kind === 'custom_selector') { %>module(':<%= camelname %> selector', { 25 | setup: function () { 26 | this.elems = $('#qunit-fixture').children(); 27 | } 28 | }); 29 | 30 | test('is <%= camelname %>', function () { 31 | expect(1); 32 | deepEqual(this.elems.filter(':<%= camelname %>').get(), this.elems.last().get()); 33 | });<% } %> 34 | }(jQuery)); 35 | -------------------------------------------------------------------------------- /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 | 6 | describe('jquery generator', function () { 7 | beforeEach(function (done) { 8 | helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { 9 | if (err) { 10 | done(err); 11 | return; 12 | } 13 | 14 | this.app = helpers.createGenerator('jquery:app', [ 15 | '../../app' 16 | ]); 17 | this.app.options['skip-install'] = true; 18 | done(); 19 | }.bind(this)); 20 | }); 21 | 22 | it('creates expected files', function (done) { 23 | var expected = [ 24 | '.jshintrc', 25 | '.editorconfig', 26 | 'bower.json' 27 | ]; 28 | 29 | helpers.mockPrompt(this.app, { 30 | 'name': 'myplugin', 31 | 'title': 'a jquery plugin', 32 | 'description': 'awesome plugin', 33 | 'version': '1.0.0', 34 | 'repository': 'http://github.com', 35 | 'bugs': 'http://jira.com', 36 | 'license': 'MIT', 37 | 'github_username': 'octocat', 38 | 'author_name': 'Octo Cat', 39 | 'author_email': 'octo@example.com', 40 | 'jquery_version': '1.9.1' 41 | }); 42 | 43 | this.app.run(function () { 44 | helpers.assertFile(expected); 45 | helpers.assertFileContent('package.json', /"name": "myplugin"/); 46 | done(); 47 | }); 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /app/templates/contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Important notes 4 | Please don't edit files in the `dist` subdirectory as they are generated via Grunt. You'll find source code in the `src` subdirectory! 5 | 6 | ### Code style 7 | Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.** 8 | 9 | ### PhantomJS 10 | While Grunt can run the included unit tests via [PhantomJS](http://phantomjs.org/), this shouldn't be considered a substitute for the real thing. Please be sure to test the `test/*.html` unit test file(s) in _actual_ browsers. 11 | 12 | ## Modifying the code 13 | First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed. 14 | 15 | Test that Grunt's CLI and Bower are installed by running `grunt --version` and `bower --version`. If the commands aren't found, run `npm install -g grunt-cli bower`. For more information about installing the tools, see the [getting started with Grunt guide](http://gruntjs.com/getting-started) or [bower.io](http://bower.io/) respectively. 16 | 17 | 1. Fork and clone the repo. 18 | 1. Run `npm install` to install all build dependencies (including Grunt). 19 | 1. Run `bower install` to install the front-end dependencies. 20 | 1. Run `grunt` to grunt this project. 21 | 22 | Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken. 23 | 24 | ## Submitting pull requests 25 | 26 | 1. Create a new branch, please don't work in your `master` branch directly. 27 | 1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail. 28 | 1. Fix stuff. 29 | 1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done. 30 | 1. Open `test/*.html` unit test file(s) in actual browser to ensure tests pass everywhere. 31 | 1. Update the documentation to reflect any changes. 32 | 1. Push to your fork and submit a pull request. 33 | -------------------------------------------------------------------------------- /app/templates/Gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | module.exports = function (grunt) { 3 | // Load all grunt tasks 4 | require('load-grunt-tasks')(grunt); 5 | // Show elapsed time at the end 6 | require('time-grunt')(grunt); 7 | 8 | // Project configuration. 9 | grunt.initConfig({ 10 | // Metadata. 11 | pkg: grunt.file.readJSON('package.json'), 12 | banner: '/*! <%%= pkg.name %> - v<%%= pkg.version %> - ' + 13 | '<%%= grunt.template.today("yyyy-mm-dd") %>\n' + 14 | '<%%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + 15 | '* Copyright (c) <%%= grunt.template.today("yyyy") %> <%%= pkg.author.name %>;' + 16 | ' Licensed <%= props.license %> */\n', 17 | // Task configuration. 18 | clean: { 19 | files: ['dist'] 20 | }, 21 | concat: { 22 | options: { 23 | banner: '<%%= banner %>', 24 | stripBanners: true 25 | }, 26 | dist: { 27 | src: ['src/<%%= pkg.name %>.js'], 28 | dest: 'dist/jquery.<%%= pkg.name %>.js' 29 | } 30 | }, 31 | uglify: { 32 | options: { 33 | banner: '<%%= banner %>' 34 | }, 35 | dist: { 36 | src: '<%%= concat.dist.dest %>', 37 | dest: 'dist/jquery.<%%= pkg.name %>.min.js' 38 | } 39 | }, 40 | qunit: { 41 | all: { 42 | options: { 43 | urls: ['http://localhost:9000/test/<%%= pkg.name %>.html'] 44 | } 45 | } 46 | }, 47 | jshint: { 48 | options: { 49 | reporter: require('jshint-stylish') 50 | }, 51 | gruntfile: { 52 | options: { 53 | jshintrc: '.jshintrc' 54 | }, 55 | src: 'Gruntfile.js' 56 | }, 57 | src: { 58 | options: { 59 | jshintrc: 'src/.jshintrc' 60 | }, 61 | src: ['src/**/*.js'] 62 | }, 63 | test: { 64 | options: { 65 | jshintrc: 'test/.jshintrc' 66 | }, 67 | src: ['test/**/*.js'] 68 | } 69 | }, 70 | watch: { 71 | gruntfile: { 72 | files: '<%%= jshint.gruntfile.src %>', 73 | tasks: ['jshint:gruntfile'] 74 | }, 75 | src: { 76 | files: '<%%= jshint.src.src %>', 77 | tasks: ['jshint:src', 'qunit'] 78 | }, 79 | test: { 80 | files: '<%%= jshint.test.src %>', 81 | tasks: ['jshint:test', 'qunit'] 82 | } 83 | }, 84 | connect: { 85 | server: { 86 | options: { 87 | hostname: '*', 88 | port: 9000 89 | } 90 | } 91 | } 92 | }); 93 | 94 | // Default task. 95 | grunt.registerTask('default', ['jshint', 'connect', 'qunit', 'clean', 'concat', 'uglify']); 96 | grunt.registerTask('server', function () { 97 | grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); 98 | grunt.task.run(['serve']); 99 | }); 100 | grunt.registerTask('serve', ['connect', 'watch']); 101 | grunt.registerTask('test', ['jshint', 'connect', 'qunit']); 102 | }; 103 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var compareVersion = require('compare-version'); 3 | var yeoman = require('yeoman-generator'); 4 | var isOnline = require('is-online'); 5 | var pkgName = require('pkg-name'); 6 | 7 | module.exports = yeoman.generators.Base.extend({ 8 | initializing: function () { 9 | this.pkg = require('../package.json'); 10 | this.compareVersion = compareVersion; 11 | }, 12 | 13 | promptingName: function () { 14 | var cb = this.async(); 15 | 16 | var prompts = [{ 17 | name: 'name', 18 | message: 'Project Name', 19 | default: this.appname, 20 | }, { 21 | type: 'confirm', 22 | name: 'pkgName', 23 | message: 'The name above already exists on npm or Bower, choose another?', 24 | default: true, 25 | when: function (answers) { 26 | var done = this.async(); 27 | 28 | isOnline(function (error, online) { 29 | if (!online) { 30 | done(false); 31 | return; 32 | } 33 | 34 | pkgName(answers.name, function (err, available) { 35 | if (!available.npm || !available.bower) { 36 | done(true); 37 | } 38 | 39 | done(false); 40 | }); 41 | }); 42 | } 43 | }]; 44 | 45 | this.prompt(prompts, function (props) { 46 | if (props.pkgName) { 47 | return this.promptingName(); 48 | } 49 | 50 | // For easier access in the templates. 51 | this.slugname = this._.slugify(props.name); 52 | this.camelname = this._.camelize(props.name); 53 | 54 | cb(); 55 | }.bind(this)); 56 | }, 57 | 58 | prompting: function () { 59 | var cb = this.async(); 60 | 61 | var prompts = [{ 62 | name: 'title', 63 | default: 'Awesome jQuery plugin' 64 | }, { 65 | name: 'description', 66 | default: 'The best jQuery plugin ever.' 67 | }, { 68 | name: 'version' 69 | }, { 70 | name: 'repository' 71 | }, { 72 | name: 'license', 73 | default: 'MIT' 74 | }, { 75 | name: 'github_username', 76 | store: true 77 | }, { 78 | name: 'author_name', 79 | store: true 80 | }, { 81 | name: 'author_email', 82 | store: true 83 | }, { 84 | name: 'jquery_version', 85 | message: 'jQuery Version' 86 | }, { 87 | type: 'list', 88 | name: 'kind', 89 | message: 'What kind of jQuery plugin would you like to create?', 90 | choices: [{ 91 | name: 'Collection method', 92 | value: 'collection_method' 93 | }, { 94 | name: 'Static method', 95 | value: 'static_method' 96 | }, { 97 | name: 'Custom selector', 98 | value: 'custom_selector' 99 | }] 100 | }]; 101 | 102 | var nameToMessage = function (name) { 103 | return name.split('_').map( 104 | function (x) { 105 | return this._.capitalize(x); 106 | }.bind(this) 107 | ).join(' ') + ':'; 108 | }.bind(this); 109 | 110 | // Generate prompt messages if only the name is defined. 111 | prompts.map(function (entry) { 112 | if (entry.message === undefined) { 113 | entry.message = nameToMessage(entry.name); 114 | } 115 | return entry; 116 | }.bind(this)); 117 | 118 | this.currentYear = (new Date()).getFullYear(); 119 | 120 | this.prompt(prompts, function (props) { 121 | this.props = props; 122 | cb(); 123 | }.bind(this)); 124 | }, 125 | 126 | configuration: function () { 127 | this.copy('editorconfig', '.editorconfig'); 128 | this.copy('jshintrc', '.jshintrc'); 129 | this.copy('gitignore', '.gitignore'); 130 | this.copy('travis.yml', '.travis.yml'); 131 | this.template('_package.json', 'package.json'); 132 | this.template('bower.json', 'bower.json'); 133 | }, 134 | 135 | source: function () { 136 | this.mkdir('src'); 137 | this.copy('src/jshintrc', 'src/.jshintrc'); 138 | this.template('src/name.js', 'src/' + this.slugname + '.js'); 139 | }, 140 | 141 | test: function () { 142 | this.mkdir('test'); 143 | this.copy('test/jshintrc', 'test/.jshintrc'); 144 | this.template('test/name_test.js', 'test/' + this.slugname + '_test.js'); 145 | this.template('test/name.html', 'test/' + this.slugname + '.html'); 146 | }, 147 | 148 | writing: function () { 149 | this.template('readme.md'); 150 | this.template('Gruntfile.js'); 151 | this.copy('contributing.md', 'contributing.md'); 152 | }, 153 | 154 | install: function () { 155 | this.installDependencies({ 156 | skipInstall: this.options['skip-install'] 157 | }); 158 | } 159 | }); 160 | --------------------------------------------------------------------------------