├── fixtures ├── a.js ├── b.js └── c.js ├── .gitattributes ├── .travis.yml ├── .gitignore ├── .jshintrc ├── .editorconfig ├── gulpfile.js ├── LICENSE ├── package.json ├── index.js ├── .verb.md ├── README.md └── test.js /fixtures/a.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/b.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fixtures/c.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Enforce Unix newlines 2 | * text eol=lf 3 | 4 | # binaries 5 | *.ai binary 6 | *.psd binary 7 | *.jpg binary 8 | *.gif binary 9 | *.png binary 10 | *.jpeg binary 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - "0.10" 5 | - "0.12" 6 | - "0.13" 7 | - "iojs" 8 | matrix: 9 | fast_finish: true 10 | allow_failures: 11 | - node_js: "0.13" 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.sublime-* 3 | _gh_pages 4 | bower_components 5 | node_modules 6 | npm-debug.log 7 | actual 8 | test/actual 9 | temp 10 | tmp 11 | TODO.md 12 | vendor 13 | .idea 14 | benchmark 15 | coverage 16 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "asi": false, 3 | "boss": true, 4 | "curly": true, 5 | "eqeqeq": true, 6 | "eqnull": true, 7 | "esnext": true, 8 | "immed": true, 9 | "latedef": false, 10 | "laxbreak": true, 11 | "laxcomma": false, 12 | "mocha": true, 13 | "newcap": true, 14 | "noarg": true, 15 | "node": true, 16 | "sub": true, 17 | "undef": true, 18 | "unused": true 19 | } 20 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | end_of_line = lf 7 | charset = utf-8 8 | indent_size = 2 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | insert_final_newline = false 15 | 16 | [{,test/}{actual,fixtures}/**] 17 | trim_trailing_whitespace = false 18 | insert_final_newline = false 19 | 20 | [templates/**] 21 | trim_trailing_whitespace = false 22 | insert_final_newline = false 23 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var mocha = require('gulp-mocha'); 3 | var istanbul = require('gulp-istanbul'); 4 | var jshint = require('gulp-jshint'); 5 | var del = require('rimraf'); 6 | require('jshint-stylish'); 7 | 8 | gulp.task('coverage', function () { 9 | return gulp.src(['index.js']) 10 | .pipe(istanbul()) 11 | .pipe(istanbul.hookRequire()); 12 | }); 13 | 14 | gulp.task('coverage:clean', function (cb) { 15 | del('coverage', cb); 16 | }); 17 | 18 | gulp.task('mocha', ['coverage'], function () { 19 | return gulp.src('test.js') 20 | .pipe(mocha({reporter: 'spec'})) 21 | .pipe(istanbul.writeReports()); 22 | }); 23 | 24 | gulp.task('jshint', function () { 25 | return gulp.src(['index.js']) 26 | .pipe(jshint()) 27 | .pipe(jshint.reporter('jshint-stylish')) 28 | .pipe(jshint.reporter('fail')); 29 | }); 30 | 31 | gulp.task('default', ['mocha', 'jshint']); 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015, Jon Schlinkert. 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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assemble-scaffold", 3 | "description": "Generate project scaffolds with assemble and Scaffold.", 4 | "version": "0.1.0", 5 | "homepage": "https://github.com/jonschlinkert/assemble-scaffold", 6 | "author": "Jon Schlinkert (https://github.com/jonschlinkert)", 7 | "repository": "jonschlinkert/assemble-scaffold", 8 | "bugs": { 9 | "url": "https://github.com/jonschlinkert/assemble-scaffold/issues" 10 | }, 11 | "license": "MIT", 12 | "files": [ 13 | "index.js" 14 | ], 15 | "main": "index.js", 16 | "engines": { 17 | "node": ">=0.10.0" 18 | }, 19 | "scripts": { 20 | "test": "mocha" 21 | }, 22 | "dependencies": { 23 | "is-scaffold": "^0.1.0", 24 | "scaffold": "^0.1.1" 25 | }, 26 | "devDependencies": { 27 | "assemble": "assemble/assemble#dev", 28 | "gulp": "^3.9.0", 29 | "gulp-istanbul": "^0.10.0", 30 | "gulp-jshint": "^1.11.2", 31 | "gulp-mocha": "^2.1.3", 32 | "jshint-stylish": "^2.0.1", 33 | "mocha": "*", 34 | "rimraf": "^2.4.3", 35 | "should": "*" 36 | }, 37 | "keywords": [ 38 | "assemble", 39 | "boilerplate", 40 | "config", 41 | "configuration", 42 | "create", 43 | "generate", 44 | "init", 45 | "project", 46 | "scaffold", 47 | "scaffolds", 48 | "templates" 49 | ], 50 | "verb": { 51 | "related": { 52 | "list": [ 53 | "scaffold", 54 | "assemble", 55 | "expand-config", 56 | "expand-files" 57 | ] 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * assemble-scaffold 3 | * 4 | * Copyright (c) 2015, Jon Schlinkert. 5 | * Licensed under the MIT License. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | var isScaffold = require('is-scaffold'); 11 | 12 | module.exports = function assembleScaffold(options) { 13 | options = options || {}; 14 | options.expand = true; 15 | 16 | return function (app) { 17 | if (!app || !isApp(app)) { 18 | throw new Error('expected an instance of an assemble-compatible application.'); 19 | } 20 | 21 | app.define('scaffold', function (name, config) { 22 | if (!config && typeof name === 'string') { 23 | var res = this.scaffolds[name]; 24 | if (typeof res === 'function') { 25 | return res; 26 | } 27 | return res; 28 | } 29 | 30 | if (typeof config === 'function') { 31 | this.scaffolds[name] = config.bind(this); 32 | return this; 33 | } 34 | 35 | var Scaffold = options.Scaffold || this.get('Scaffold') || require('scaffold'); 36 | config.expand = true; 37 | 38 | var scaffold = new Scaffold(name, config); 39 | 40 | scaffold.use = function (fn) { 41 | fn.call(this, this); 42 | return this; 43 | }; 44 | 45 | scaffold.generate = function (dest/*, cb*/) { 46 | var args = [].slice.call(arguments); 47 | if (typeof dest === 'string') { 48 | dest = args.shift(); 49 | this.options.dest = dest; 50 | } 51 | args.unshift(this); 52 | return app.generate.apply(app, args); 53 | }; 54 | 55 | this.scaffolds[name] = scaffold; 56 | return this; 57 | }); 58 | }; 59 | }; 60 | 61 | function isApp(val) { 62 | return ('extendView' in val) 63 | && ('extendViews' in val) 64 | && ('viewTypes' in val); 65 | } 66 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | # {%= name %} {%= badge("fury") %} 2 | 3 | > {%= description %} 4 | 5 | ## Install 6 | {%= include("install-npm", {save: true}) %} 7 | 8 | ## Usage 9 | 10 | ```js 11 | var assemble = require('assemble'); 12 | var scaffold = require('{%= name %}'); 13 | 14 | // register the plugin, add options if needed 15 | var app = assemble() 16 | .use(scaffold({cwd: 'scaffolds/'})) 17 | ``` 18 | 19 | **Register scaffolds** 20 | 21 | Uses [scaffold][] to create normalize configuration objects: 22 | 23 | ```js 24 | app.scaffold('ejs', { 25 | src: ['templates/ejs/*.ejs'], 26 | dest: 'src/templates' 27 | }); 28 | ``` 29 | 30 | The created configuration object looks something like: 31 | 32 | ```js 33 | [ { src: [ 'templates/ejs/foo.ejs', 'templates/ejs/bar.ejs' ], 34 | dest: 'src/templates', 35 | options: { cwd: 'scaffolds' }, 36 | name: 'ejs' } ] 37 | ``` 38 | 39 | **Generate scaffold** 40 | 41 | Which can easily be generated by calling the scaffold's generate method: 42 | 43 | ```js 44 | scaffold('ejs') 45 | // destination base is optional 46 | .generate('dest/', function(err) { 47 | if (err) console.error(err); 48 | }); 49 | ``` 50 | 51 | **Plugins** 52 | 53 | Plugins may also be used by passing them to the `.use()` method on the scaffold instance. It's also chainable. 54 | 55 | ```js 56 | scaffold('ejs') 57 | // plugins 58 | .use(function(config) { 59 | config.files.forEach(function(file) { 60 | // do something to `file` 61 | }); 62 | }) 63 | .use(function(config) { 64 | config.dest = 'foo/' + config.dest; 65 | }) 66 | .generate(function(err) { 67 | if (err) console.error(err); 68 | }); 69 | ``` 70 | 71 | 72 | 73 | ## Related projects 74 | {%= related(verb.related.list) %} 75 | 76 | ## Running tests 77 | {%= include("tests") %} 78 | 79 | ## Contributing 80 | {%= include("contributing") %} 81 | 82 | ## Author 83 | {%= include("author") %} 84 | 85 | ## License 86 | {%= copyright() %} 87 | {%= license() %} 88 | 89 | *** 90 | 91 | {%= include("footer") %} 92 | 93 | {%= reflinks(verb.related.list) %} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # assemble-scaffold [![NPM version](https://badge.fury.io/js/assemble-scaffold.svg)](http://badge.fury.io/js/assemble-scaffold) 2 | 3 | > Generate project scaffolds with assemble and Scaffold. 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/) 8 | 9 | ```sh 10 | $ npm i assemble-scaffold --save 11 | ``` 12 | 13 | ## Usage 14 | 15 | ```js 16 | var assemble = require('assemble'); 17 | var scaffold = require('assemble-scaffold'); 18 | 19 | // register the plugin, add options if needed 20 | var app = assemble() 21 | .use(scaffold({cwd: 'scaffolds/'})) 22 | ``` 23 | 24 | **Register scaffolds** 25 | 26 | Uses [scaffold](https://github.com/jonschlinkert/scaffold) to create normalize configuration objects: 27 | 28 | ```js 29 | app.scaffold('ejs', { 30 | src: ['templates/ejs/*.ejs'], 31 | dest: 'src/templates' 32 | }); 33 | ``` 34 | 35 | The created configuration object looks something like: 36 | 37 | ```js 38 | [ { src: [ 'templates/ejs/foo.ejs', 'templates/ejs/bar.ejs' ], 39 | dest: 'src/templates', 40 | options: { cwd: 'scaffolds' }, 41 | name: 'ejs' } ] 42 | ``` 43 | 44 | **Generate scaffold** 45 | 46 | Which can easily be generated by calling the scaffold's generate method: 47 | 48 | ```js 49 | scaffold('ejs') 50 | // destination base is optional 51 | .generate('dest/', function(err) { 52 | if (err) console.error(err); 53 | }); 54 | ``` 55 | 56 | **Plugins** 57 | 58 | Plugins may also be used by passing them to the `.use()` method on the scaffold instance. It's also chainable. 59 | 60 | ```js 61 | scaffold('ejs') 62 | // plugins 63 | .use(function(config) { 64 | config.files.forEach(function(file) { 65 | // do something to `file` 66 | }); 67 | }) 68 | .use(function(config) { 69 | config.dest = 'foo/' + config.dest; 70 | }) 71 | .generate(function(err) { 72 | if (err) console.error(err); 73 | }); 74 | ``` 75 | 76 | ## Related projects 77 | 78 | * [assemble](https://www.npmjs.com/package/assemble): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](https://www.npmjs.com/package/assemble) | [homepage](http://assemble.io) 79 | * [expand-config](https://www.npmjs.com/package/expand-config): Expand tasks, targets and files in a declarative configuration. | [homepage](https://github.com/jonschlinkert/expand-config) 80 | * [expand-files](https://www.npmjs.com/package/expand-files): Expand glob patterns in a declarative configuration into src-dest mappings. | [homepage](https://github.com/jonschlinkert/expand-files) 81 | * [scaffold](https://www.npmjs.com/package/scaffold): Conventions and API for creating scaffolds that can by used by any build system or… [more](https://www.npmjs.com/package/scaffold) | [homepage](https://github.com/jonschlinkert/scaffold) 82 | 83 | ## Running tests 84 | 85 | Install dev dependencies: 86 | 87 | ```sh 88 | $ npm i -d && npm test 89 | ``` 90 | 91 | ## Contributing 92 | 93 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/assemble-scaffold/issues/new). 94 | 95 | ## Author 96 | 97 | **Jon Schlinkert** 98 | 99 | + [github/jonschlinkert](https://github.com/jonschlinkert) 100 | + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) 101 | 102 | ## License 103 | 104 | Copyright © 2015 Jon Schlinkert 105 | Released under the MIT license. 106 | 107 | *** 108 | 109 | _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 13, 2015._ 110 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * assemble-scaffold 3 | * 4 | * Copyright (c) 2015 . 5 | * Licensed under the MIT license. 6 | */ 7 | 8 | 'use strict'; 9 | 10 | /* deps:mocha */ 11 | var assert = require('assert'); 12 | var should = require('should'); 13 | var Scaffold = require('scaffold'); 14 | var assemble = require('assemble'); 15 | var scaffold = require('./'); 16 | 17 | describe('scaffold', function () { 18 | it('should work as a plugin with assemble:', function () { 19 | var app = assemble() 20 | .use(scaffold()) 21 | assert(typeof app.scaffold === 'function'); 22 | }); 23 | 24 | it('should register scaffolds on `app.scaffolds`:', function () { 25 | var app = assemble() 26 | .use(scaffold()) 27 | 28 | app.scaffold('foo', { 29 | src: ['*.js'], 30 | dest: 'actual' 31 | }); 32 | 33 | assert(typeof app.scaffold === 'function'); 34 | assert(typeof app.scaffolds === 'object'); 35 | assert(typeof app.scaffolds.foo === 'object'); 36 | assert(Array.isArray(app.scaffolds.foo.files)); 37 | }); 38 | 39 | it('should take an instance of Scaffold:', function () { 40 | var app = assemble() 41 | .use(scaffold()) 42 | 43 | var config = new Scaffold({ 44 | src: ['*.js'], 45 | dest: 'actual' 46 | }); 47 | 48 | app.scaffold('foo', config); 49 | 50 | assert(typeof app.scaffold === 'function'); 51 | assert(typeof app.scaffolds === 'object'); 52 | assert(typeof app.scaffolds.foo === 'object'); 53 | assert(Array.isArray(app.scaffolds.foo.files)); 54 | }); 55 | 56 | it('should decorate a `generate` method onto registered scaffolds:', function () { 57 | var app = assemble() 58 | .use(scaffold()) 59 | 60 | app.scaffold('bar', { 61 | src: ['*.js'], 62 | dest: 'actual' 63 | }); 64 | 65 | assert(typeof app.scaffolds.bar === 'object'); 66 | assert(typeof app.scaffolds.bar.generate === 'function'); 67 | }); 68 | 69 | it('should support registering a scaffold as a function:', function () { 70 | var app = assemble() 71 | .use(scaffold()) 72 | 73 | app.scaffold('bar', function(options) { 74 | return new Scaffold({ 75 | options: options || {}, 76 | src: ['*.js'], 77 | dest: 'actual' 78 | }) 79 | }); 80 | 81 | assert(typeof app.scaffolds.bar === 'function'); 82 | var config = app.scaffold('bar')({cwd: 'fixtures'}); 83 | assert(Array.isArray(config.files)); 84 | }); 85 | 86 | it('should get a registered scaffold when one arg is passed:', function () { 87 | var app = assemble() 88 | .use(scaffold()) 89 | 90 | app.scaffold('bar', { 91 | src: ['*.js'], 92 | dest: 'actual' 93 | }); 94 | 95 | var config = app.scaffold('bar'); 96 | 97 | assert(typeof config === 'object'); 98 | assert(typeof config.generate === 'function'); 99 | }); 100 | 101 | it.skip('should generate a scaffold:', function () { 102 | var app = assemble() 103 | .use(scaffold()) 104 | 105 | app.scaffold('bar', { 106 | src: ['*.js'], 107 | dest: 'actual' 108 | }); 109 | 110 | app.scaffold('bar') 111 | .generate('dist/', function (err) { 112 | console.log(arguments) 113 | }); 114 | 115 | assert(typeof config === 'object'); 116 | assert(typeof config.generate === 'function'); 117 | }); 118 | 119 | it.skip('should decorate a `use` method onto registered scaffolds:', function () { 120 | var app = assemble() 121 | .use(scaffold()) 122 | 123 | app.scaffold('bar', { 124 | src: ['*.js'], 125 | dest: 'actual' 126 | }); 127 | 128 | app.scaffold('bar') 129 | .use(function (config) { 130 | console.log(config); 131 | }) 132 | .generate('dist/', function (err) { 133 | console.log(arguments) 134 | }); 135 | 136 | assert(typeof app.scaffolds.bar === 'object'); 137 | assert(typeof app.scaffolds.bar.generate === 'function'); 138 | }); 139 | 140 | it('should throw an error on invalid arguments:', function () { 141 | (function () { 142 | scaffold()(); 143 | }).should.throw('expected an instance of an assemble-compatible application.'); 144 | (function () { 145 | scaffold({})(); 146 | }).should.throw('expected an instance of an assemble-compatible application.'); 147 | (function () { 148 | scaffold({})({}); 149 | }).should.throw('expected an instance of an assemble-compatible application.'); 150 | }); 151 | }); 152 | --------------------------------------------------------------------------------