Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion core/lib/patternlab.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* patternlab-node - v2.7.2 - 2017
* patternlab-node - v2.8.0 - 2017
*
* Brian Muenzenmeyer, Geoff Pursell, Raphael Okon, tburny and the web community.
* Licensed under the MIT license.
Expand Down Expand Up @@ -99,6 +99,8 @@ function checkConfiguration(patternlab) {
* Finds and calls the main method of any found plugins.
* @param patternlab - global data store
*/

//todo, move this to plugin_manager
function initializePlugins(patternlab) {

if (!patternlab.config.plugins) { return; }
Expand Down Expand Up @@ -178,6 +180,10 @@ var patternlab_engine = function (config) {
console.log(patternlab.package.version);
}

function getSupportedTemplateExtensions(){
return patternlab.engines.getSupportedFileExtensions();
}

function help() {

console.log('');
Expand Down Expand Up @@ -627,6 +633,9 @@ var patternlab_engine = function (config) {
},
installplugin: function (pluginName) {
installPlugin(pluginName);
},
getSupportedTemplateExtensions: function () {
return getSupportedTemplateExtensions();
}
};
};
Expand Down
21 changes: 17 additions & 4 deletions core/lib/plugin_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,23 @@ var plugin_manager = function (config, configPath) {
if (!diskConfig.plugins) {
diskConfig.plugins = {};
}
diskConfig.plugins[pluginName] = {
enabled: true,
initialized: false
};

if (!diskConfig.plugins[pluginName]) {
diskConfig.plugins[pluginName] = {
enabled: true,
initialized: false
};
}

const pluginPathConfig = path.resolve(pluginPath, 'config.json');
try {
var pluginConfigJSON = require(pluginPathConfig);
if (!diskConfig.plugins[pluginName].options) {
diskConfig.plugins[pluginName].options = pluginConfigJSON;
}
} catch (ex) {
//a config.json file is not required at this time
}

//write config entry back
fs.outputFileSync(path.resolve(configPath), JSON.stringify(diskConfig, null, 2));
Expand Down
13 changes: 7 additions & 6 deletions core/lib/starterkit_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ var starterkit_manager = function (config) {
console.log('Overwriting contents of', paths.source.root, 'during starterkit load.');
}

fs.copy(kitPath, paths.source.root, function (ex) {
if (ex) {
console.error(ex);
}
util.debug('starterkit ' + starterkitName + ' loaded successfully.');
});
try {
fs.copySync(kitPath, paths.source.root);
} catch (ex) {
util.error(ex);
return;
}
util.debug('starterkit ' + starterkitName + ' loaded successfully.');
}
} catch (ex) {
console.log(ex);
Expand Down
21 changes: 17 additions & 4 deletions core/lib/ui_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var ui_builder = function () {
}

//this pattern is contained with a directory prefixed with an underscore (a handy way to hide whole directories from the nav
isOmitted = pattern.relPath.charAt(0) === '_' || pattern.relPath.indexOf('/_') > -1;
isOmitted = pattern.relPath.charAt(0) === '_' || pattern.relPath.indexOf(path.sep + '_') > -1;
if (isOmitted) {
if (patternlab.config.debug) {
console.log('Omitting ' + pattern.patternPartial + ' from styleguide patterns because its contained within an underscored directory.');
Expand Down Expand Up @@ -484,8 +484,8 @@ var ui_builder = function () {
_.forEach(styleguidePatterns.patternGroups, function (patternTypeObj, patternType) {

var p;
var typePatterns = [];
var styleGuideExcludes = patternlab.config.styleGuideExcludes;
var typePatterns = [], styleguideTypePatterns = [];
var styleGuideExcludes = patternlab.config.styleGuideExcludes || patternlab.config.styleguideExcludes;

_.forOwn(patternTypeObj, function (patternSubtypes, patternSubtype) {

Expand All @@ -508,6 +508,19 @@ var ui_builder = function () {
return pat.isDocPattern;
});

//determine if we should omit this subpatterntype completely from the viewall page
var omitPatternType = styleGuideExcludes && styleGuideExcludes.length
&& _.some(styleGuideExcludes, function (exclude) {
return exclude === patternType + '/' + patternSubtype;
});
if (omitPatternType) {
if (patternlab.config.debug) {
console.log('Omitting ' + patternType + '/' + patternSubtype + ' from building a viewall page because its patternSubGroup is specified in styleguideExcludes.');
}
} else {
styleguideTypePatterns = styleguideTypePatterns.concat(subtypePatterns);
}

typePatterns = typePatterns.concat(subtypePatterns);

var viewAllHTML = buildViewAllHTML(patternlab, subtypePatterns, patternPartial);
Expand Down Expand Up @@ -544,7 +557,7 @@ var ui_builder = function () {
console.log('Omitting ' + patternType + ' from building a viewall page because its patternGroup is specified in styleguideExcludes.');
}
} else {
patterns = patterns.concat(typePatterns);
patterns = patterns.concat(styleguideTypePatterns);
}
});
return patterns;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "patternlab-node",
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
"version": "2.7.2",
"version": "2.8.0",
"main": "./core/lib/patternlab.js",
"dependencies": {
"chalk": "^1.1.3",
Expand Down
5 changes: 3 additions & 2 deletions test/ui_builder_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var eol = require('os').EOL;
var Pattern = require('../core/lib/object_factory').Pattern;
var extend = require('util')._extend;
var uiModule = rewire('../core/lib/ui_builder');
var path = require('path');

//set up a global mocks - we don't want to be writing/rendering any files right now
var fsMock = {
Expand Down Expand Up @@ -80,7 +81,7 @@ tap.test('isPatternExcluded - returns true when pattern within underscored direc
//arrange
var patternlab = createFakePatternLab({});
var pattern = Pattern.createEmpty({
relPath: '_hidden/patternsubtype/foo.mustache',
relPath: path.sep + '_hidden' + path.sep + 'patternsubtype' + path.sep + 'foo.mustache',
isPattern: true,
fileName : 'foo.mustache',
patternPartial: 'hidden-foo'
Expand All @@ -98,7 +99,7 @@ tap.test('isPatternExcluded - returns true when pattern within underscored direc
//arrange
var patternlab = createFakePatternLab({});
var pattern = Pattern.createEmpty({
relPath: 'shown/_patternsubtype/foo.mustache',
relPath: 'shown' + path.sep + '_patternsubtype' + path.sep + 'foo.mustache',
isPattern: true,
fileName : 'foo.mustache',
patternPartial: 'shown-foo'
Expand Down