npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scaffold

v0.2.13

Published

Conventions and API for creating declarative configuration objects for project scaffolds - similar in format to a grunt task, but more portable, generic and can be used by any build system or generator - even gulp.

Downloads

969

Readme

scaffold NPM version NPM downloads Build Status

Conventions and API for creating declarative configuration objects for project scaffolds - similar in format to a grunt task, but more portable, generic and can be used by any build system or generator - even gulp.

Install

Install with npm:

$ npm install --save scaffold

What is a scaffold? | gulp-scaffold-example

What is a scaffold?

There are many definitions for the word "scaffold", here a scaffold is defined as: a declarative configuration for one or more templates or source files, which are intended to serve as a "temporary support structure" to be used for initializing a new project, providing ad-hoc "components" throughout the duration of a project, and so on.

A typical scaffold configuration might include:

  • paths or glob patterns for source files or templates
  • destination paths or directories to use for generated files
  • data for rendering templates
  • options

See the comparison table for more information.

Example scaffold

The following scaffold configuration expands into an object that can be passed to gulp, grunt, assemble, metalsmith, yeoman or any other build system for scaffolding out various parts of a blog or site:

var Scaffold = require('scaffold');
var scaffold = new Scaffold({
  posts: {
    src: 'templates/post.md',
    dest: 'blog/' 
  },
  components: {
    cwd: 'content',
    src: ['templates/*.hbs'],
    dest: 'blog/'
  }  
});

Example result

The above scaffold might expand into something like the following:

{
  options: {},
  blog: {
    options: {cwd: 'blog'},
    files: [
      {
        src: ['content/post.md', 'content/about.md'],
        dest: 'src/posts/'
      },
      {
        src: ['data/ipsum.json'],
        dest: 'src/data/'
      }
    ]
  },
  components: {
    options: {cwd: 'ui'},
    files: [
      {
        options: {cwd: 'templates/layouts'},
        src: ['default.hbs', '3-column.hbs'],
        dest: 'src/templates/layouts'
      },
      {
        options: {cwd: 'templates/components'},
        src: ['button.hbs', 'modal.hbs', 'navbar.hbs'],
        dest: 'src/templates/partials'
      },
      {
        src: ['scripts/button.js'],
        dest: 'src/assets/js/'
      },
      {
        src: ['data/ipsum.json'],
        dest: 'src/assets/data/'
      }
    ]
  }
}

Since we're just creating an object (with zero application logic), anything can obviously be extended, overridden, etc.

Install

Install with npm:

$ npm install --save scaffold

Usage

Create an instance of scaffold:

var Scaffold = require('scaffold');
var foo = new Scaffold({
  // config/options here  
});

Scaffold uses expand-target and expand-files as dependencies. Visit those projects for the full range of available features and options:

Examples

The following are just a few random examples of what a scaffold could be, but there are many more use cases.

Blog posts

Create a scaffold for adding blog posts to a project:

var blog = new Scaffold({
  post: {
    cwd: 'content',
    src: 'content/post.md', 
    dest: 'src/posts/'
  }
});

UI components

Create a scaffold for adding UI components to a project:

var components = new Scaffold({
  foo: {
    options: {cwd: 'scaffolds'},
    files: [
      {src: 'templates/component.hbs', dest: 'src/templates/'},
      {src: 'scripts/component.js', dest: 'src/scripts/'},
      {src: 'styles/component.css', dest: 'src/styles/'},
    ]
  }
});

API

Scaffold

Create a new Scaffold with the given options

Params

  • options {Object}

Example

var scaffold = new Scaffold({cwd: 'src'});
scaffold.addTargets({
  site: {src: ['*.hbs']},
  blog: {src: ['*.md']}
});

.isScaffold

Static method, returns true if the given value is an instance of Scaffold or appears to be a valid scaffold configuration object.

Params

  • val {Object}: The value to check
  • returns {Boolean}

Example

Scaffold.isScaffold({});
//=> false

var blog = new Scaffold({
  post: {
    src: 'content/post.md',
    dest: 'src/posts/'
  }
});
Scaffold.isScaffold(blog);
//=> true

.addTargets

Add targets to the scaffold, while also normalizing src-dest mappings and expanding glob patterns in each target.

Params

  • targets {Object}: Object of targets, options, or arbitrary properties.
  • returns {Object}

Example

scaffold.addTargets({
  site: {src: '*.hbs', dest: 'templates/'},
  docs: {src: '*.md', dest: 'content/'}
});

.addTarget

Add a single target to the scaffold, while also normalizing src-dest mappings and expanding glob patterns in the target.

Params

  • name {String}
  • config {Object}
  • returns {Object}

Example

scaffold.addTarget('foo', {
  src: 'templates/*.hbs',
  dest: 'site'
});

// other configurations are possible
scaffold.addTarget('foo', {
  options: {cwd: 'templates'}
  files: [
    {src: '*.hbs', dest: 'site'},
    {src: '*.md', dest: 'site'}
  ]
});

.Target

Getter/setter for the Target constructor to use for creating new targets.

  • returns {Function}: Returns the Target constructor to use for creating new targets.

Example

var Target = scaffold.get('Target');
var target = new Target();

.name

Getter/setter for scaffold.name. The name property can be set on the options or directly on the instance.

  • returns {Function}: Returns the Target constructor to use for creating new targets.

Example

var scaffold = new Scaffold({name: 'foo'});
console.log(scaffold.name);
//=> 'foo'

// or
var scaffold = new Scaffold();
scaffold.options.name = 'bar';
console.log(scaffold.name);
//=> 'bar'

// or
var scaffold = new Scaffold();
scaffold.name = 'baz';
console.log(scaffold.name);
//=> 'baz'

Comparison table

Many definitions exist for the terms "boilerplate", "scaffold" and "template". The following definitions describe these concepts as it relates to this project.

| type | description | | --- | --- | | template | Resuable file, code or content which contains "placeholder" values that will eventually be replaced with real values by a rendering (template) engine | | scaffold | Consists of one or more templates or source files and serves as a "temporary support structure" that may be used to initialize a new project, or to provide ad-hoc "components" throughout the duration of a project. | | boilerplate | Boilerplates consist of all of the necessary files required to initialize a complete project. |

History

v0.3.0

  • breaking change: targets are now stored on the targets object
  • feature: now emits files when a files object is expanded.

Related projects

You might also be interested in these projects:

  • assemble: Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… more | homepage
  • boilerplate: Tools and conventions for authoring and publishing boilerplates that can be generated by any build… more | homepage
  • generate: The Santa Claus machine for GitHub projects. Scaffolds out new projects, or creates any kind… more | homepage
  • templates: System for creating and managing template collections, and rendering templates with any node.js template engine… more | homepage
  • update: Easily keep anything in your project up-to-date by installing the updaters you want to use… more | homepage
  • verb: Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… more | homepage

Contributing

This document was generated by verb-readme-generator (a verb generator), please don't edit directly. Any changes to the readme must be made in .verb.md. See Building Docs.

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Or visit the verb-readme-generator project to submit bug reports or pull requests for the readme layout template.

Building docs

(This document was generated by verb-readme-generator (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

Generate readme and API documentation with verb:

$ npm install -g verb verb-readme-generator && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on June 30, 2016.