From 922124ca49c44c4c860b06c56dd81aa10b78a4ca Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 20 Jan 2015 18:21:52 +0800 Subject: [PATCH] use the latest yeoman-generator API --- .editorconfig | 5 ++- .jshintrc | 11 +----- .travis.yml | 1 - app/index.js | 49 +++++++++++++------------ license | 21 +++++++++++ package.json | 26 ++++--------- readme.md | 8 ++-- test/{test-file-creation.js => test.js} | 7 ++-- 8 files changed, 67 insertions(+), 61 deletions(-) create mode 100644 license rename test/{test-file-creation.js => test.js} (83%) diff --git a/.editorconfig b/.editorconfig index b0d7fd9..86c8f59 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,4 +1,3 @@ -# editorconfig.org root = true [*] @@ -8,5 +7,9 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true +[package.json] +indent_style = space +indent_size = 2 + [*.md] trim_trailing_whitespace = false diff --git a/.jshintrc b/.jshintrc index ac35c13..804f8af 100644 --- a/.jshintrc +++ b/.jshintrc @@ -4,17 +4,10 @@ "bitwise": true, "camelcase": true, "curly": true, - "eqeqeq": true, "immed": true, - "indent": 4, - "latedef": true, "newcap": true, "noarg": true, - "quotmark": "single", - "regexp": true, "undef": true, - "unused": true, - "strict": true, - "trailing": true, - "smarttabs": true + "unused": "vars", + "strict": true } diff --git a/.travis.yml b/.travis.yml index 2cdacaf..244b7e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ language: node_js node_js: - '0.10' - - '0.8' diff --git a/app/index.js b/app/index.js index 80eb00c..08206d6 100644 --- a/app/index.js +++ b/app/index.js @@ -1,31 +1,32 @@ 'use strict'; var path = require('path'); var chalk = require('chalk'); +var yeoman = require('yeoman-generator'); -var Generator = module.exports = function () { - var cb = this.async(); - var self = this; +module.exports = yeoman.generators.Base.extend({ + init: function () { + var cb = this.async(); + var self = this; - self.prompt([{ - type: 'checkbox', - name: 'modules', - message: 'What would you like?\n' + chalk.gray('Generates to a `pure` subfolder'), - choices:[ - 'Buttons', - 'Forms', - 'Grids', - 'Menus', - 'Tables' - ] - }], function (data) { - var pattern = path.join('src', '{' + data.modules.join(',') + ',}', 'css', '*.css'); + self.prompt([{ + type: 'checkbox', + name: 'modules', + message: 'What would you like?\n' + chalk.gray('Generates to a `pure` subfolder'), + choices:[ + 'Buttons', + 'Forms', + 'Grids', + 'Menus', + 'Tables' + ] + }], function (data) { + var pattern = path.join('src', '{' + data.modules.join(',') + ',}', 'css', '*.css'); - self.expandFiles(pattern, {cwd: self.sourceRoot(), nocase: true}).forEach(function (el) { - self.copy(el, path.join('pure', path.basename(el))); - }); - - cb(); - }); -}; + self.expandFiles(pattern, {cwd: self.sourceRoot(), nocase: true}).forEach(function (el) { + self.copy(el, path.join('pure', path.basename(el))); + }); -Generator.name = 'YUI Pure'; + cb(); + }); + } +}); diff --git a/license b/license new file mode 100644 index 0000000..654d0bf --- /dev/null +++ b/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/package.json b/package.json index 46405e7..abe86f4 100644 --- a/package.json +++ b/package.json @@ -9,39 +9,27 @@ "template", "framework" ], - "homepage": "https://github.com/sindresorhus/generator-pure", - "bugs": "https://github.com/sindresorhus/generator-pure/issues", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" + "url": "sindresorhus.com" }, "main": "app/index.js", - "repository": { - "type": "git", - "url": "git://github.com/sindresorhus/generator-pure.git" - }, + "repository": "sindresorhus/generator-pure", "scripts": { "test": "mocha" }, "dependencies": { - "yeoman-generator": "~0.13.4", - "chalk": "~0.2.1" - }, - "peerDependencies": { - "yo": ">=1.0.0-rc.1.1" + "chalk": "^0.5.1", + "yeoman-generator": "^0.18.6" }, "devDependencies": { - "mocha": "~1.13.0" + "mocha": "*" }, "engines": { - "node": ">=0.8.0" + "node": ">=0.10.0" }, - "licenses": [ - { - "type": "MIT" - } - ], + "license": "MIT", "files": [ "app" ] diff --git a/readme.md b/readme.md index 1a64f9c..2f045e9 100644 --- a/readme.md +++ b/readme.md @@ -2,12 +2,12 @@ > Scaffolds out [YUI Pure](https://github.com/yui/pure) -![screenshot](screenshot.png) +![](screenshot.png) ## Install -```bash +``` $ npm install --global generator-pure ``` @@ -16,11 +16,11 @@ $ npm install --global generator-pure Run it with [yo](https://github.com/yeoman/yo): -```bash +``` $ yo pure ``` ## License -[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/test/test-file-creation.js b/test/test.js similarity index 83% rename from test/test-file-creation.js rename to test/test.js index 1b40175..3cdd99f 100644 --- a/test/test-file-creation.js +++ b/test/test.js @@ -9,7 +9,8 @@ describe('Pure generator', function () { helpers.testDirectory(path.join(__dirname, 'temp'), function (err) { if (err) { - return cb(err); + cb(err); + return; } this.gen = helpers.createGenerator('pure:app', deps); @@ -20,10 +21,10 @@ describe('Pure generator', function () { it('generates expected files', function (cb) { var expected = [path.join('pure', 'buttons.css')]; - helpers.mockPrompt(this.gen, { modules: ['Buttons'] }); + helpers.mockPrompt(this.gen, {modules: ['Buttons']}); this.gen.run({}, function () { - helpers.assertFiles(expected); + helpers.assertFile(expected); cb(); }); });