Skip to content

document public API #723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions core/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,31 @@ const patternlab_engine = function (config) {
}

return {
/**
* logs current version
*
* @returns {void} current patternlab-node version as defined in package.json, as console output
*/
version: function () {
return logVersion();
},

/**
* return current version
*
* @returns {string} current patternlab-node version as defined in package.json, as string
*/
v: function () {
return getVersion();
},

/**
* build patterns, copy assets, and construct ui
*
* @param {function} callback a function invoked when build is complete
* @param {object} options an object used to control build behavior
* @returns {Promise} a promise fulfilled when build is complete
*/
build: function (callback, options) {
if (patternlab && patternlab.isBusy) {
console.log('Pattern Lab is busy building a previous run - returning early.');
Expand Down Expand Up @@ -694,9 +713,23 @@ const patternlab_engine = function (config) {
callback();
});
},

/**
* logs usage
*
* @returns {void} pattern lab API usage, as console output
*/
help: function () {
help();
},

/**
* build patterns only, leaving existing public files intact
*
* @param {function} callback a function invoked when build is complete
* @param {object} options an object used to control build behavior
* @returns {Promise} a promise fulfilled when build is complete
*/
patternsonly: function (callback, options) {
if (patternlab && patternlab.isBusy) {
console.log('Pattern Lab is busy building a previous run - returning early.');
Expand All @@ -709,18 +742,53 @@ const patternlab_engine = function (config) {
callback();
});
},

/**
* fetches starterkit repos from pattern-lab github org that contain 'starterkit' in their name
*
* @returns {Promise} Returns an Array<{name,url}> for the starterkit repos
*/
liststarterkits: function () {
return listStarterkits();
},

/**
* load starterkit already available via `node_modules/`
*
* @param {string} starterkitName name of starterkit
* @param {boolean} clean whether or not to delete contents of source/ before load
* @returns {void}
*/
loadstarterkit: function (starterkitName, clean) {
loadStarterKit(starterkitName, clean);
},


/**
* install plugin already available via `node_modules/`
*
* @param {string} pluginName name of plugin
* @returns {void}
*/
installplugin: function (pluginName) {
installPlugin(pluginName);
},

/**
* returns all file extensions supported by installed PatternEngines
*
* @returns {Array<string>} all supported file extensions
*/
getSupportedTemplateExtensions: function () {
return getSupportedTemplateExtensions();
},

/**
* build patterns, copy assets, and construct ui, watch source files, and serve locally
*
* @param {object} options an object used to control build, copy, and serve behavior
* @returns {Promise} TODO: validate
*/
serve: function (options) {
options.watch = true;
return this.build(() => {}, options).then(function () {
Expand Down