├── .editorconfig ├── .gitignore ├── .travis.yml ├── .yo-rc.json ├── generators └── plugin │ ├── USAGE │ ├── index.js │ └── templates │ ├── _package.json │ ├── _travis.yml │ ├── editorconfig │ ├── fixtures │ └── foo.js │ ├── gitignore │ ├── index.js │ ├── license │ ├── readme.md │ └── test │ ├── test-ava.js │ ├── test-jasmine.js │ ├── test-mocha.js │ └── test-tape.js ├── package.json ├── readme.md └── test └── test-plugin.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_size = 2 5 | indent_style = tab 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.{json,yml}] 12 | indent_style = space 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .DS_Store 3 | *.log 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 6 4 | - 4 5 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-generator": {} 3 | } -------------------------------------------------------------------------------- /generators/plugin/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Scaffold out a Taskr plugin 3 | 4 | Example: 5 | yo taskr plugin 6 | 7 | This will add the following files to your _current_ directory: 8 | - .editorconfig 9 | - .gitignore 10 | - .travis.yml 11 | - index.js 12 | - license 13 | - package.json 14 | - readme.md 15 | - test/index.js 16 | - test/fixtures/foo.js 17 | -------------------------------------------------------------------------------- /generators/plugin/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const yo = require('yeoman-generator'); 3 | const normlize = require('normalize-url'); 4 | const mkdirp = require('mkdirp'); 5 | const colors = require('clor'); 6 | const say = require('yosay'); 7 | 8 | const getSlugName = pluginName => pluginName.split('-').pop(); 9 | const properCase = word => word.charAt(0).toUpperCase() + word.slice(1); 10 | const createDir = dir => new Promise((resolve, reject) => { 11 | mkdirp(dir, err => err ? reject(err) : resolve()); 12 | }); 13 | 14 | const testCommands = { 15 | tape: 'tape test/*.js | tap-spec', 16 | jasmine: 'jasmine test', 17 | mocha: 'mocha test', 18 | ava: 'ava test' 19 | }; 20 | 21 | module.exports = yo.generators.Base.extend({ 22 | initializing() { 23 | this.log(say('Welcome to the ' + colors.cyan('Taskr Plugin Generator'))); 24 | }, 25 | 26 | prompting() { 27 | const done = this.async(); 28 | 29 | this.prompt([{ 30 | store: true, 31 | name: 'githubUserName', 32 | message: 'What is your GitHub username?', 33 | validate: val => val.length > 0 ? true : 'github needed' 34 | }, { 35 | store: true, 36 | name: 'website', 37 | message: 'What is your website URL', 38 | default: props => `https://github.com/${props.githubUserName}` 39 | }, { 40 | name: 'pluginName', 41 | message: 'What is your plugin name?', 42 | default: path.basename(process.cwd()) 43 | }, { 44 | name: 'description', 45 | message: 'Add a description', 46 | default: props => properCase(getSlugName(props.pluginName)) + ' plugin for Taskr.' 47 | }, { 48 | type: 'list', 49 | name: 'testTool', 50 | message: 'What testing tool would you like to use?', 51 | choices: ['tape', 'mocha', 'jasmine', 'ava'], 52 | default: 'tape' 53 | }, { 54 | type: 'confirm', 55 | name: 'gitinit', 56 | message: 'Initialize a Git repository?', 57 | store: true, 58 | default: true 59 | }], props => { 60 | this.props = props; 61 | done(); 62 | }); 63 | }, 64 | 65 | writing() { 66 | this.pluginName = this.props.pluginName; 67 | this.pluginSlugName = getSlugName(this.props.pluginName); 68 | this.pluginTitleName = properCase(this.pluginSlugName); 69 | this.description = this.props.description; 70 | this.testTool = this.props.testTool; 71 | this.githubUserName = this.props.githubUserName; 72 | this.name = this.user.git.name(); 73 | this.email = this.user.git.email(); 74 | this.website = normlize(this.props.website); 75 | 76 | const testDir = path.join(this.env.cwd, 'test'); 77 | const fixDir = path.join(testDir, 'fixtures'); 78 | 79 | createDir(testDir).then(() => { 80 | this.copy( 81 | path.join('test', 'test-' + this.testTool + '.js'), 82 | path.join('test', 'index.js') 83 | ); 84 | }).catch(err => this.log.error('Error while creating directory, error: ' + JSON.stringify(err))); 85 | 86 | createDir(fixDir).then(() => { 87 | this.copy( 88 | path.join('fixtures', 'foo.js'), 89 | path.join(fixDir, 'foo.js') 90 | ); 91 | }).catch(err => this.log.error('Error while creating directory, error: ' + JSON.stringify(err))); 92 | 93 | this.testCommand = testCommands[this.testTool]; 94 | 95 | this.template('_travis.yml', '.travis.yml'); 96 | this.template('editorconfig', '.editorconfig'); 97 | 98 | this.template('readme.md'); 99 | this.template('index.js'); 100 | this.template('license'); 101 | this.template('_package.json', 'package.json'); 102 | this.template('gitignore', '.gitignore'); 103 | }, 104 | 105 | install() { 106 | this.installDependencies({ bower:false }); 107 | }, 108 | 109 | end() { 110 | if (this.props.gitinit) { 111 | console.log('\n'); 112 | this.spawnCommand('git', ['init']).on('close', () => { 113 | this.spawnCommand('git', ['add', '--all']).on('close', () => { 114 | this.spawnCommand('git', ['commit', '-m', 'initial commit (via generator-taskr)']).on('close', () => console.log('\n')); 115 | }); 116 | }); 117 | } 118 | } 119 | }); 120 | -------------------------------------------------------------------------------- /generators/plugin/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= pluginName %>", 3 | "version": "0.0.0", 4 | "description": "<%= description %>", 5 | "repository": "https://github.com/<%= githubUserName %>/<%= pluginName %>", 6 | "main": "index.js", 7 | "license": "MIT", 8 | "files": [ 9 | "index.js" 10 | ], 11 | "keywords":[ 12 | "taskr", 13 | "taskr-plugin", 14 | "<%= pluginSlugName %>" 15 | ], 16 | "scripts": { 17 | "test": "xo && <%= testCommand %>" 18 | }, 19 | "author": { 20 | "name": "<%= name %>", 21 | "email": "<%= email %>", 22 | "url": "<%= website %>" 23 | }, 24 | "devDependencies": {<% if (testTool == 'tape') { %> 25 | "tap-spec": "^4.1.1", 26 | "tape": "^4.2.2",<% } else if (testTool == 'mocha') { %> 27 | "mocha": "^3.0.2",<% } else if (testTool == 'jasmine') { %> 28 | "jasmine": "^2.5.0",<% } else if (testTool == 'ava') { %> 29 | "ava": "^0.16.0",<% } %> 30 | "fly-clear": "^1.0.1", 31 | "taskr": "^0.9.0", 32 | "xo": "*" 33 | }, 34 | "engines": { 35 | "node": ">= 4.6" 36 | }, 37 | "xo": { 38 | "rules": { 39 | "generator-star-spacing": 0, 40 | "capitalized-comments": 0, 41 | "require-yield": 0 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /generators/plugin/templates/_travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 6 4 | - 4 5 | -------------------------------------------------------------------------------- /generators/plugin/templates/editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = tab 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.{json,yml}] 13 | indent_style = space 14 | -------------------------------------------------------------------------------- /generators/plugin/templates/fixtures/foo.js: -------------------------------------------------------------------------------- 1 | console.log('foo'); 2 | -------------------------------------------------------------------------------- /generators/plugin/templates/gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | *.log 4 | -------------------------------------------------------------------------------- /generators/plugin/templates/index.js: -------------------------------------------------------------------------------- 1 | const foo = require('foo'); 2 | 3 | /** 4 | * Documentation: Writing Plugins 5 | * @see https://github.com/lukeed/taskr#plugin 6 | * @see https://github.com/lukeed/taskr#external-plugins 7 | */ 8 | module.exports = function (task, utils) { 9 | // promisify before running else repeats per execution 10 | const render = utils.promisify(foo.bar); 11 | 12 | // Option #1 13 | task.plugin('<%= pluginSlugName %>', {/* every:true, files:true */}, function * (file, opts) { 14 | console.log('a single file object', file); //=> { base, dir, data } 15 | console.log('user-provided config', opts); //=> null || {} 16 | yield render(opts); 17 | }); 18 | 19 | // Option #2 20 | /* 21 | task.plugin({ 22 | name: '<%= pluginSlugName %>', 23 | every: true, 24 | files: true, 25 | *func(file, opts) { 26 | // ...same 27 | } 28 | }); 29 | */ 30 | }; 31 | -------------------------------------------------------------------------------- /generators/plugin/templates/license: -------------------------------------------------------------------------------- 1 | This software is released under the MIT license: 2 | 3 | Copyright (c) 2015 <%= name %> <<%= email %>> <%= website %> 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.)) 21 | -------------------------------------------------------------------------------- /generators/plugin/templates/readme.md: -------------------------------------------------------------------------------- 1 | # <%= pluginName %> 2 | 3 | > <%= pluginTitleName %> plugin for [Taskr](https://github.com/lukeed/taskr). 4 | 5 | [![npm package][npm-ver-link]][releases] 6 | [![][dl-badge]][npm-pkg-link] 7 | [![][travis-badge]][travis-link] 8 | 9 | ## Install 10 | 11 | ```sh 12 | npm install --save-dev <%= pluginName %> 13 | ``` 14 | 15 | ## Usage 16 | 17 | 18 | ```js 19 | exports.default = function * (task) { 20 | yield task.source('src/*.js').<%= pluginSlugName %>().target('dist') 21 | } 22 | ``` 23 | 24 | ## API 25 | 26 | ### .<%= pluginSlugName %>(input, options) 27 | 28 | > Check out the [documentation](PLUGIN_DOCUMENTATION) to see the available options. 29 | 30 | #### input 31 | 32 | Type: `string`
33 | Default: 'foobar' 34 | 35 | This is a description. 36 | 37 | #### options.foo 38 | 39 | Type: `boolean`
40 | Default: `false` 41 | 42 | This is a description. 43 | 44 | 45 | ## License 46 | 47 | MIT © [<%= name %>](<%= website %>) 48 | 49 | [releases]: https://github.com/<%= githubUserName %>/<%= pluginName %>/releases 50 | [npm-pkg-link]: https://www.npmjs.org/package/<%= pluginName %> 51 | [npm-ver-link]: https://img.shields.io/npm/v/<%= pluginName %>.svg?style=flat-square 52 | [dl-badge]: http://img.shields.io/npm/dm/<%= pluginName %>.svg?style=flat-square 53 | [travis-link]: https://travis-ci.org/<%= githubUserName %>/<%= pluginName %> 54 | [travis-badge]: http://img.shields.io/travis/<%= githubUserName %>/<%= pluginName %>.svg?style=flat-square 55 | -------------------------------------------------------------------------------- /generators/plugin/templates/test/test-ava.js: -------------------------------------------------------------------------------- 1 | const join = require('path').join; 2 | const Taskr = require('taskr'); 3 | const test = require('ava'); 4 | 5 | const dir = join(__dirname, 'fixtures'); 6 | const plugins = [require('fly-clear'), require('../')]; 7 | 8 | const tmpDir = str => join(__dirname, str); 9 | const create = tasks => new Taskr({ tasks, plugins }); 10 | 11 | test('attach `<%= pluginSlugName %>` plugin to instance', t => { 12 | const taskr = create(); 13 | t.ok('<%= pluginSlugName %>' in taskr.plugins); 14 | }); 15 | 16 | test('attach `<%= pluginSlugName %>` to Task instance', t => { 17 | create({ 18 | *foo(task) { 19 | t.ok('<%= pluginSlugName %>' in task); 20 | } 21 | }).start('foo'); 22 | }); 23 | 24 | test('example usage test', t => { 25 | create({ 26 | *foo(task) { 27 | const tmp = tmpDir('tmp1'); 28 | yield f.source(`${dir}/*.js`).target(tmp); 29 | const arr = yield f.$.expand(`${tmp}/*.js`); 30 | t.equal(arr.length, 1, 'copied one file to target tar'); 31 | yield f.clear(tmp); // cleanup 32 | } 33 | }).start('foo'); 34 | }); 35 | -------------------------------------------------------------------------------- /generators/plugin/templates/test/test-jasmine.js: -------------------------------------------------------------------------------- 1 | describe("<%= pluginName %>", () => { 2 | it("<%= pluginName %> works properly", done => done()); 3 | }); 4 | -------------------------------------------------------------------------------- /generators/plugin/templates/test/test-mocha.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | 3 | describe('<%= pluginName %>', () => { 4 | it('<%= pluginName %> works properly', () => { 5 | assert.ok(true); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /generators/plugin/templates/test/test-tape.js: -------------------------------------------------------------------------------- 1 | const join = require('path').join; 2 | const Taskr = require('taskr'); 3 | const test = require('tape'); 4 | 5 | const dir = join(__dirname, 'fixtures'); 6 | const plugins = [require('fly-clear'), require('../')]; 7 | 8 | const tmpDir = str => join(__dirname, str); 9 | const create = tasks => new Taskr({ tasks, plugins }); 10 | 11 | test('taskr-<%= pluginSlugName %>', t => { 12 | t.plan(3); 13 | const taskr = create({ 14 | *foo(task) { 15 | t.true('<%= pluginSlugName %>' in task, 'attach `<%= pluginSlugName %>` to Task instance'); 16 | t.true('<%= pluginSlugName %>' in taskr.plugins, 'attach `<%= pluginSlugName %>` plugin to instance'); 17 | // example usage test 18 | const tmp = tmpDir('tmp1'); 19 | yield f.source(`${dir}/*.js`).target(tmp); 20 | const arr = yield f.$.expand(`${tmp}/*.js`); 21 | t.equal(arr.length, 1, 'copied one file to target tar'); 22 | yield f.clear(tmp); // cleanup 23 | } 24 | }); 25 | taskr.start('foo'); 26 | }); 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-taskr", 3 | "version": "0.1.1", 4 | "description": "Official Yeoman generator for Taskr.", 5 | "repository": "lukeed/generator-taskr", 6 | "main": "generators/plugin/index.js", 7 | "license": "MIT", 8 | "author": { 9 | "name": "Luke Edwards", 10 | "email": "luke.edwards05@gmail.com", 11 | "url": "https://github.com/lukeed" 12 | }, 13 | "contributors": [ 14 | { 15 | "name": "Oleh Kuchuk", 16 | "email": "kuchuklehjs@gmail.com", 17 | "url": "https://github.com/hzlmn" 18 | } 19 | ], 20 | "scripts": { 21 | "test": "xo && mocha" 22 | }, 23 | "files": [ 24 | "generators" 25 | ], 26 | "keywords": [ 27 | "yeoman-generator", 28 | "template", 29 | "plugin", 30 | "taskr" 31 | ], 32 | "dependencies": { 33 | "clor": "^1.0.2", 34 | "mkdirp": "^0.5.1", 35 | "normalize-url": "^1.3.0", 36 | "yeoman-generator": "^0.19.2", 37 | "yosay": "^1.0.4" 38 | }, 39 | "devDependencies": { 40 | "mocha": "*", 41 | "xo": "^0.16.0" 42 | }, 43 | "engines": { 44 | "node": ">= 4.6" 45 | }, 46 | "xo": { 47 | "envs": [ 48 | "mocha", 49 | "node" 50 | ], 51 | "ignore": [ 52 | "generators/plugin/templates/**/*.js" 53 | ], 54 | "rules": { 55 | "babel/object-curly-spacing": 0, 56 | "no-loop-func": 0, 57 | "key-spacing": 0 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # generator-taskr [![Build Status](https://travis-ci.org/lukeed/generator-taskr.svg?branch=master)](https://travis-ci.org/lukeed/generator-taskr) 2 | 3 | > Official [Yeoman](http://yeoman.io/) generator for creating Taskr plugins. 4 | 5 | ## Install 6 | 7 | ```sh 8 | $ npm i -g generator-taskr 9 | ``` 10 | 11 | > **Note:** You need to install [Yeoman](http://yeoman.io/) to use this package. 12 | 13 | ## Usage 14 | 15 | ```sh 16 | $ mkdir taskr-cool-plugin 17 | $ cd taskr-cool-plugin 18 | $ yo taskr:plugin 19 | ``` 20 | 21 | > **Note**: This will run in your **current directory**! Please create & enter a new folder before running `yo taskr plugin`. 22 | 23 | ## Features 24 | 25 | - Choice of test runners: AVA, Jasmine, Mocha, Tape 26 | - Automatic Git Repo initialization 27 | - JavaScript Linting via XO 28 | - TravisCI config 29 | 30 | > :warning: Don't forget to add a [remote origin](https://help.github.com/articles/adding-a-remote/) to your repo! 31 | 32 | ## Output 33 | 34 | ``` 35 | |-- taskr-cool-plugin 36 | | |-- .editorconfig 37 | | |-- .gitignore 38 | | |-- .travis.yml 39 | | |-- index.js 40 | | |-- license 41 | | |-- package.json 42 | | |-- readme.md 43 | | |-- test 44 | | | |-- index.js 45 | | | |-- fixtures 46 | | | | |-- foo.js 47 | ``` 48 | 49 | ## License 50 | 51 | MIT © [Luke Edwards](https://lukeed.com) and [Oleh Kuchuk](https://github.com/hzlmn) 52 | -------------------------------------------------------------------------------- /test/test-plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const join = require('path').join; 4 | const yo = require('yeoman-generator'); 5 | 6 | const plugin = join(__dirname, '../generators/plugin'); 7 | 8 | describe('generator-taskr plugin', () => { 9 | before(done => yo.test.run(plugin).withOptions({ skipInstall:true }).on('end', done)); 10 | 11 | it('creates files', () => { 12 | yo.assert.file([ 13 | '.travis.yml', 14 | '.editorconfig', 15 | '.gitignore', 16 | 'index.js', 17 | 'license', 18 | 'package.json', 19 | 'readme.md', 20 | 'test/index.js', 21 | 'test/fixtures/foo.js' 22 | ]); 23 | }); 24 | }); 25 | --------------------------------------------------------------------------------