Skip to content

Commit 4693676

Browse files
Merge pull request #635 from pattern-lab/dev
Pattern Lab Node Core 2.8.0
2 parents bc8636b + ae79e03 commit 4693676

File tree

6 files changed

+55
-18
lines changed

6 files changed

+55
-18
lines changed

Diff for: core/lib/patternlab.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v2.7.2 - 2017
2+
* patternlab-node - v2.8.0 - 2017
33
*
44
* Brian Muenzenmeyer, Geoff Pursell, Raphael Okon, tburny and the web community.
55
* Licensed under the MIT license.
@@ -99,6 +99,8 @@ function checkConfiguration(patternlab) {
9999
* Finds and calls the main method of any found plugins.
100100
* @param patternlab - global data store
101101
*/
102+
103+
//todo, move this to plugin_manager
102104
function initializePlugins(patternlab) {
103105

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

183+
function getSupportedTemplateExtensions(){
184+
return patternlab.engines.getSupportedFileExtensions();
185+
}
186+
181187
function help() {
182188

183189
console.log('');
@@ -627,6 +633,9 @@ var patternlab_engine = function (config) {
627633
},
628634
installplugin: function (pluginName) {
629635
installPlugin(pluginName);
636+
},
637+
getSupportedTemplateExtensions: function () {
638+
return getSupportedTemplateExtensions();
630639
}
631640
};
632641
};

Diff for: core/lib/plugin_manager.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,23 @@ var plugin_manager = function (config, configPath) {
4242
if (!diskConfig.plugins) {
4343
diskConfig.plugins = {};
4444
}
45-
diskConfig.plugins[pluginName] = {
46-
enabled: true,
47-
initialized: false
48-
};
45+
46+
if (!diskConfig.plugins[pluginName]) {
47+
diskConfig.plugins[pluginName] = {
48+
enabled: true,
49+
initialized: false
50+
};
51+
}
52+
53+
const pluginPathConfig = path.resolve(pluginPath, 'config.json');
54+
try {
55+
var pluginConfigJSON = require(pluginPathConfig);
56+
if (!diskConfig.plugins[pluginName].options) {
57+
diskConfig.plugins[pluginName].options = pluginConfigJSON;
58+
}
59+
} catch (ex) {
60+
//a config.json file is not required at this time
61+
}
4962

5063
//write config entry back
5164
fs.outputFileSync(path.resolve(configPath), JSON.stringify(diskConfig, null, 2));

Diff for: core/lib/starterkit_manager.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@ var starterkit_manager = function (config) {
3636
console.log('Overwriting contents of', paths.source.root, 'during starterkit load.');
3737
}
3838

39-
fs.copy(kitPath, paths.source.root, function (ex) {
40-
if (ex) {
41-
console.error(ex);
42-
}
43-
util.debug('starterkit ' + starterkitName + ' loaded successfully.');
44-
});
39+
try {
40+
fs.copySync(kitPath, paths.source.root);
41+
} catch (ex) {
42+
util.error(ex);
43+
return;
44+
}
45+
util.debug('starterkit ' + starterkitName + ' loaded successfully.');
4546
}
4647
} catch (ex) {
4748
console.log(ex);

Diff for: core/lib/ui_builder.js

+17-4
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ var ui_builder = function () {
8282
}
8383

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

486486
var p;
487-
var typePatterns = [];
488-
var styleGuideExcludes = patternlab.config.styleGuideExcludes;
487+
var typePatterns = [], styleguideTypePatterns = [];
488+
var styleGuideExcludes = patternlab.config.styleGuideExcludes || patternlab.config.styleguideExcludes;
489489

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

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

511+
//determine if we should omit this subpatterntype completely from the viewall page
512+
var omitPatternType = styleGuideExcludes && styleGuideExcludes.length
513+
&& _.some(styleGuideExcludes, function (exclude) {
514+
return exclude === patternType + '/' + patternSubtype;
515+
});
516+
if (omitPatternType) {
517+
if (patternlab.config.debug) {
518+
console.log('Omitting ' + patternType + '/' + patternSubtype + ' from building a viewall page because its patternSubGroup is specified in styleguideExcludes.');
519+
}
520+
} else {
521+
styleguideTypePatterns = styleguideTypePatterns.concat(subtypePatterns);
522+
}
523+
511524
typePatterns = typePatterns.concat(subtypePatterns);
512525

513526
var viewAllHTML = buildViewAllHTML(patternlab, subtypePatterns, patternPartial);
@@ -544,7 +557,7 @@ var ui_builder = function () {
544557
console.log('Omitting ' + patternType + ' from building a viewall page because its patternGroup is specified in styleguideExcludes.');
545558
}
546559
} else {
547-
patterns = patterns.concat(typePatterns);
560+
patterns = patterns.concat(styleguideTypePatterns);
548561
}
549562
});
550563
return patterns;

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "patternlab-node",
33
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
4-
"version": "2.7.2",
4+
"version": "2.8.0",
55
"main": "./core/lib/patternlab.js",
66
"dependencies": {
77
"chalk": "^1.1.3",

Diff for: test/ui_builder_tests.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var eol = require('os').EOL;
77
var Pattern = require('../core/lib/object_factory').Pattern;
88
var extend = require('util')._extend;
99
var uiModule = rewire('../core/lib/ui_builder');
10+
var path = require('path');
1011

1112
//set up a global mocks - we don't want to be writing/rendering any files right now
1213
var fsMock = {
@@ -80,7 +81,7 @@ tap.test('isPatternExcluded - returns true when pattern within underscored direc
8081
//arrange
8182
var patternlab = createFakePatternLab({});
8283
var pattern = Pattern.createEmpty({
83-
relPath: '_hidden/patternsubtype/foo.mustache',
84+
relPath: path.sep + '_hidden' + path.sep + 'patternsubtype' + path.sep + 'foo.mustache',
8485
isPattern: true,
8586
fileName : 'foo.mustache',
8687
patternPartial: 'hidden-foo'
@@ -98,7 +99,7 @@ tap.test('isPatternExcluded - returns true when pattern within underscored direc
9899
//arrange
99100
var patternlab = createFakePatternLab({});
100101
var pattern = Pattern.createEmpty({
101-
relPath: 'shown/_patternsubtype/foo.mustache',
102+
relPath: 'shown' + path.sep + '_patternsubtype' + path.sep + 'foo.mustache',
102103
isPattern: true,
103104
fileName : 'foo.mustache',
104105
patternPartial: 'shown-foo'

0 commit comments

Comments
 (0)