Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Pattern Lab Node API

Join the chat at Gitter

Usage

patternlab-node can be required within any Node environment, taking in a configuration file at instantiation.

const config = require('./patternlab-config.json');
const patternlab = require('patternlab-node')(config);

Events

Pattern Lab emits numerous events.

Functions

Many of these functions are exposed to users within Editions, but direct consumption is also encouraged.

getDefaultConfig()object

Returns the standardized default config used to run Pattern Lab. This method can be called statically or after instantiation.

Returns: object - Returns the object representation of the patternlab-config.json

version()void

Logs current version to standard output

Returns: void - current patternlab-node version as defined in package.json

v()string

Returns current version

Returns: string - current patternlab-node version as defined in package.json, as string

build(options)Promise

Builds patterns, copies assets, and constructs user interface

Returns: Promise - a promise fulfilled when build is complete

Param Type Description
options object an object used to control build behavior
options.cleanPublic bool whether or not to delete the configured output location (usually public/) before build
options.data object additional data to be merged with global data prior to build
options.watch bool whether or not Pattern Lab should watch configured source/ directories for changes to rebuild

getDefaultConfig()object

Returns the standardized default config used to run Pattern Lab. This method can be called statically or after instantiation.

Returns: object - Returns the object representation of the patternlab-config.json

getSupportedTemplateExtensions()Array.<string>

Returns all file extensions supported by installed PatternEngines

Returns: Array.<string> - all supported file extensions

help()void

Logs usage to standard output

Returns: void - pattern lab API usage, as console output

installplugin(pluginName)void

Installs plugin already available via node_modules/

Param Type Description
pluginName string name of plugin

liststarterkits()Promise

Fetches starterkit repositories from pattern-lab github org that contain 'starterkit' in their name

Returns: Promise - Returns an Array<{name,url}> for the starterkit repos

loadstarterkit(starterkitName, clean)void

Loads starterkit already available via node_modules/

Param Type Description
starterkitName string name of starterkit
clean boolean whether or not to delete contents of source/ before load

patternsonly(options)Promise

Builds patterns only, leaving existing user interface files intact

Returns: Promise - a promise fulfilled when build is complete

Param Type Description
options object an object used to control build behavior
options.cleanPublic bool whether or not to delete the configured output location (usually public/) before build
options.data object additional data to be merged with global data prior to build

serve(options)Promise

Build patterns, copies assets, and constructs user interface. Watches configured source/ directories, and serves all output locally

Returns: Promise - a promise fulfilled when build is complete

Param Type Description
options object an object used to control build behavior
options.cleanPublic bool whether or not to delete the configured output location (usually public/) before build
options.data object additional data to be merged with global data prior to build
options.watch bool ALWAYS OVERRIDDEN to true whether or not Pattern Lab should watch configured source/ directories for changes to rebuild

Pattern Lab Node is MIT Licensed