├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .gitmodules ├── .npmrc ├── app └── index.js ├── license ├── package.json ├── readme.md ├── screenshot.png └── test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.yml] 11 | indent_style = space 12 | indent_size = 2 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | - push 4 | - pull_request 5 | jobs: 6 | test: 7 | name: Node.js ${{ matrix.node-version }} 8 | runs-on: ubuntu-latest 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | node-version: 13 | - 14 14 | - 12 15 | - 10 16 | - 8 17 | - 6 18 | - 4 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: actions/setup-node@v4 22 | with: 23 | node-version: ${{ matrix.node-version }} 24 | - run: npm install 25 | - run: npm test 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | yarn.lock 3 | /temp 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "app/templates"] 2 | path = app/templates 3 | url = git://github.com/sindresorhus/gulp-plugin-boilerplate 4 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const path = require('path'); 3 | const fs = require('fs'); 4 | const superb = require('superb'); 5 | const normalizeUrl = require('normalize-url'); 6 | const humanizeUrl = require('humanize-url'); 7 | const Generator = require('yeoman-generator'); 8 | const _s = require('underscore.string'); 9 | 10 | module.exports = class extends Generator { 11 | init() { 12 | return this.prompt([{ 13 | name: 'pluginName', 14 | message: 'What do you want to name your gulp plugin?', 15 | default: this.appname.replace(/\s/g, '-'), 16 | filter(val) { 17 | return _s.slugify(val.replace(/^gulp-/, '')); 18 | } 19 | }, { 20 | name: 'githubUsername', 21 | message: 'What is your GitHub username?', 22 | store: true, 23 | validate(val) { 24 | return val.length > 0 ? true : 'You have to provide a username'; 25 | } 26 | }, { 27 | name: 'website', 28 | message: 'What is the URL of your website?', 29 | store: true, 30 | validate(val) { 31 | return val.length > 0 ? true : 'You have to provide a website URL'; 32 | }, 33 | filter(val) { 34 | return normalizeUrl(val); 35 | } 36 | }]).then(props => { 37 | const tpl = { 38 | pluginName: props.pluginName, 39 | camelPluginName: _s.camelize(props.pluginName), 40 | githubUsername: props.githubUsername, 41 | name: this.user.git.name(), 42 | email: this.user.git.email(), 43 | website: props.website, 44 | humanizedWebsite: humanizeUrl(props.website), 45 | superb: superb() 46 | }; 47 | 48 | const mv = (from, to) => { 49 | this.fs.move(this.destinationPath(from), this.destinationPath(to)); 50 | }; 51 | 52 | // Workaround npm issue 53 | fs.writeFileSync(path.join(this.sourceRoot(), '.gitignore'), 'node_modules\n'); 54 | 55 | this.fs.copyTpl( 56 | [ 57 | `${this.templatePath()}/**`, 58 | `${this.templatePath()}/**/.*`, 59 | '!**/{readme.md,.git}' 60 | ], 61 | this.destinationPath(), 62 | tpl 63 | ); 64 | 65 | mv('_package.json', 'package.json'); 66 | mv('_readme.md', 'readme.md'); 67 | }); 68 | } 69 | 70 | install() { 71 | this.installDependencies({bower: false}); 72 | } 73 | }; 74 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (https://sindresorhus.com) 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-gulp-plugin-boilerplate", 3 | "version": "2.0.0", 4 | "description": "Scaffold out a gulp plugin boilerplate", 5 | "license": "MIT", 6 | "repository": "sindresorhus/generator-gulp-plugin-boilerplate", 7 | "funding": "https://github.com/sponsors/sindresorhus", 8 | "author": { 9 | "name": "Sindre Sorhus", 10 | "email": "sindresorhus@gmail.com", 11 | "url": "https://sindresorhus.com" 12 | }, 13 | "sideEffects": false, 14 | "engines": { 15 | "node": ">=4" 16 | }, 17 | "scripts": { 18 | "test": "xo && ava" 19 | }, 20 | "files": [ 21 | "app" 22 | ], 23 | "keywords": [ 24 | "yeoman-generator", 25 | "gulpfriendly", 26 | "gulp", 27 | "plugin", 28 | "boilerplate", 29 | "template" 30 | ], 31 | "dependencies": { 32 | "humanize-url": "^1.0.1", 33 | "normalize-url": "^2.0.1", 34 | "superb": "^2.0.0", 35 | "underscore.string": "^3.0.3", 36 | "yeoman-generator": "^2.0.2" 37 | }, 38 | "devDependencies": { 39 | "ava": "*", 40 | "pify": "^3.0.0", 41 | "xo": "*", 42 | "yeoman-assert": "^3.1.0", 43 | "yeoman-test": "^1.7.0" 44 | }, 45 | "ava": { 46 | "failWithoutAssertions": false 47 | }, 48 | "xo": { 49 | "ignores": [ 50 | "app/templates/**" 51 | ] 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # generator-gulp-plugin-boilerplate 2 | 3 | > Scaffold out a [Gulp plugin boilerplate](https://github.com/sindresorhus/gulp-plugin-boilerplate) 4 | 5 | ![](screenshot.png) 6 | 7 | ## Install 8 | 9 | ```sh 10 | npm install --global yo generator-gulp-plugin-boilerplate 11 | ``` 12 | 13 | ## Usage 14 | 15 | Run it with [`yo`](https://github.com/yeoman/yo): 16 | 17 | ```sh 18 | yo gulp-plugin-boilerplate 19 | ``` 20 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sindresorhus/generator-gulp-plugin-boilerplate/b09327d085beb37dd5e37189d98aa0721b0ee2c1/screenshot.png -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import test from 'ava'; 3 | import helpers from 'yeoman-test'; 4 | import assert from 'yeoman-assert'; 5 | import pify from 'pify'; 6 | 7 | let generator; 8 | 9 | test.beforeEach(async () => { 10 | await pify(helpers.testDirectory)(path.join(__dirname, 'temp')); 11 | generator = helpers.createGenerator('gulp-plugin-boilerplate:app', ['../app'], null, {skipInstall: true}); 12 | }); 13 | 14 | test.serial('generates expected files', async () => { 15 | helpers.mockPrompt(generator, { 16 | pluginName: 'test', 17 | githubUsername: 'test', 18 | website: 'test.com' 19 | }); 20 | 21 | await pify(generator.run.bind(generator))(); 22 | 23 | assert.file([ 24 | '.editorconfig', 25 | '.gitattributes', 26 | '.gitignore', 27 | '.travis.yml', 28 | 'index.js', 29 | 'license', 30 | 'package.json', 31 | 'readme.md', 32 | 'test.js' 33 | ]); 34 | }); 35 | --------------------------------------------------------------------------------