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

skivvy-factory

v0.1.3

Published

Create Skivvy tasks from Factory templates

Downloads

10

Readme

skivvy-factory

npm version Stability Build Status

Create Skivvy tasks from Factory templates

Overview

Skivvy is a modular task runner for reusable build systems, and Factory provides a quick and easy template scaffolding tool for Node. skivvy-factory unites the two, allowing you to turn your Factory templates into reusable Skivvy tasks.

Installation

npm install skivvy-factory --save-dev

Example

As a local Skivvy task:

var skivvyFactory = require('skivvy-factory');

module.exports = skivvyFactory({
	description: 'Create a component',
	template: 'templates/component',
	placeholders: [
		{
			name: 'name',
			message: 'Component name'
		},
		{
			name: 'author',
			message: 'Author',
			default: '<%= project.author %>'
		}
	],
	options: {
		destination: '<%= environment.paths.components %>',
		overwrite: true
	},
	context: {
		license: '<%= project.license %>'
	}
});

After saving this to your skivvy_tasks folder, you can launch your template by running the following commands (where create-component.js is the filename of the task):

# Configure the task
skivvy config --config.paths.components=src/components

# Create a new component
skivvy run create-component

# Create another new component, hard-coding the
# "name" value and preventing accidental overwrite:
skivvy run create-component --config.context.name=foo --config.options.overwrite=false

Within a Skivvy task package:

var skivvyFactory = require('skivvy-factory');

var path = require('path');

exports.tasks = {
	'create-component': skivvyFactory({
		description: 'Create a component',
		template: path.join(__dirname, 'templates/component'),
		placeholders: [
			{
				name: 'name',
				message: 'Component name'
			},
			{
				name: 'author',
				message: 'Author',
				default: '<%= package.author %>'
			}
		],
		options: {
			destination: '<%= package.paths.components %>',
			overwrite: true
		},
		context: {,
			license: '<%= package.license %>'
		}
	}),
	'create-service': skivvyFactory({
		description: 'Create a service',
		template: path.join(__dirname, 'templates/service'),
		placeholders: [
			{
				name: 'name',
				message: 'Service name'
			},
			{
				name: 'author',
				message: 'Author',
				default: '<%= package.author %>'
			}
		],
		options: {
			destination: '<%= package.paths.services %>',
			overwrite: true
		},
		context: {
			license: '<%= package.license %>'
		}
	})
};

exports.defaults = {
	paths: {
		component: null,
		service: null
	},
	author: '<%= project.author %>',
	license: '<%= project.license %>'
}

After installing this package, you can launch your templates by running the following commands, where PACKAGE_NAME is the name of the package:

# Configure the package
skivvy config --package=PACKAGE_NAME --config.paths.components=src/components --config.paths.services=src/services

# Create a new component
skivvy run create-component

# Create a service
skivvy run create-service

# Create another new component, hard-coding the
# "name" value and preventing accidental overwrite:
skivvy run create-component --config.context.name=foo --config.options.overwrite=false

Usage

skivvyFactory(options)

Create a Skivvy task from a Factory template

Options:

| Name | Type | Required | Default | Description | | ---- | ---- | -------- | ------- | ----------- | | template | string | Yes | N/A | Path to the Factory template folder | | options | object | Yes | N/A | Factory copy options | | options.destination | string | Yes | N/A | Destination directory for output files | | options.overwrite | boolean | No | false | Whether to overwrite existing files | | placeholders | Array | No | [] | Array of inquirer prompts used to gather data for injecting into templates | | context | object | No | {} | Preset template placeholder values | | getContext | function | No | null | Function that transforms placeholder values before they are passed to the template | | description | string | No | null | Skivvy task description |

Notes:
  • Values within the options, placeholders and context option values can use Skivvy task config placeholder values.

  • getContext has the following signature:

    function(context)
    Arguments:

    | Name | Type | Description | | ---- | ---- | ----------- | | context | object | Key/value object containing placeholder values, gathered from factory context and template placeholders |

    Returns:

    object Key/value object containing transformed context placeholder for use in templates

Returns:

function Skivvy task