Skip to content

Commit 593bf3d

Browse files
committed
Merge branch 'dev' into feature/uikit-refactor-and-enhancements
# Conflicts: # packages/uikit-workshop/dist/styleguide/js/patternlab-pattern.js # packages/uikit-workshop/dist/styleguide/js/patternlab-viewer.js
2 parents f7fabb3 + 561b523 commit 593bf3d

File tree

34 files changed

+83
-93
lines changed

34 files changed

+83
-93
lines changed

netlify.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[context.deploy-preview]
2+
command = "npm run preview:hbs"

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"test": "lerna run test",
3030
"clean": "git clean -dfx",
3131
"publish": "npx lerna publish -m \"[skip travis] chore(release): publish %s\"",
32-
"postpublish": "auto release"
32+
"postpublish": "auto release",
33+
"preview:hbs": "cd packages/development-edition-engine-handlebars && npx patternlab add --starterkits '@pattern-lab/starterkit-handlebars-vanilla' && npm run pl:build"
3334
},
3435
"nyc": {
3536
"exclude": [

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"name": "@pattern-lab/cli",
33
"description": "Command-line interface (CLI) for the @pattern-lab/core.",
4-
"version": "1.0.3",
4+
"version": "1.0.4",
55
"bin": {
66
"patternlab": "bin/patternlab.js"
77
},
88
"author": {
99
"name": "Raphael Okon"
1010
},
1111
"dependencies": {
12-
"@pattern-lab/core": "^3.0.4",
12+
"@pattern-lab/core": "^3.0.5",
1313
"@pattern-lab/live-server": "^1.3.4",
1414
"archiver": "2.1.1",
1515
"chalk": "2.4.1",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pattern-lab/core",
33
"description": "Create atomic design systems with Pattern Lab. This is the core API and orchestrator of the ecosystem.",
4-
"version": "3.0.4",
4+
"version": "3.0.5",
55
"main": "./src/index.js",
66
"dependencies": {
77
"@pattern-lab/engine-mustache": "^2.0.1",

packages/core/src/lib/object_factory.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Pattern = function(relPath, data, patternlab) {
3939

4040
// this is the unique name, subDir + fileName (sans extension)
4141
this.name = '';
42-
if (info.hasDir) {
42+
if (info.hasDir && info.dirLevel > 2) {
4343
let variant = '';
4444

4545
if (this.fileName.indexOf('~') !== -1) {
@@ -76,23 +76,24 @@ const Pattern = function(relPath, data, patternlab) {
7676
.trim(); //this is the display name for the ui. strip numeric + hyphen prefixes
7777

7878
//00-atoms if needed
79-
this.patternType = this.getDirLevel(0, info);
79+
this.patternType = this.getDirLevel(0);
8080

8181
// the top-level pattern group this pattern belongs to. 'atoms'
8282
this.patternGroup = this.patternType.replace(patternPrefixMatcher, '');
8383

8484
//00-colors if needed
85-
this.patternSubType = this.getDirLevel(1, info);
85+
this.patternSubType = this.getDirLevel(1);
8686

8787
// the sub-group this pattern belongs to.
8888
this.patternSubGroup = this.patternSubType.replace(patternPrefixMatcher, ''); // 'global'
8989

9090
// the joined pattern group and subgroup directory
91-
this.flatPatternPath = info.hasDir
92-
? this.subdir
93-
.replace(/[/\\]/g, '-')
94-
.replace(new RegExp('-' + info.dir + '$'), '')
95-
: this.subdir.replace(/[\/\\]/g, '-'); // '00-atoms-00-global'
91+
this.flatPatternPath =
92+
info.hasDir && info.dirLevel > 2
93+
? this.subdir
94+
.replace(/[/\\]/g, '-')
95+
.replace(new RegExp('-' + info.dir + '$'), '')
96+
: this.subdir.replace(/[\/\\]/g, '-'); // '00-atoms-00-global'
9697

9798
// calculated path from the root of the public directory to the generated
9899
// (rendered!) html file for this pattern, to be shown in the iframe
@@ -214,11 +215,8 @@ Pattern.prototype = {
214215
return this.engine.findPartial(partialString);
215216
},
216217

217-
getDirLevel: function(level, info) {
218+
getDirLevel: function(level) {
218219
const items = this.subdir.split(path.sep);
219-
if (info.hasDir) {
220-
items.pop();
221-
}
222220

223221
if (items[level]) {
224222
return items[level];

packages/core/src/lib/plugin_manager.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const plugin_manager = function() {
44
const path = require('path');
5-
const findModules = require('./findModules');
65
const logger = require('./log');
76

87
const pluginMatcher = /^plugin-(.*)$/;
@@ -38,25 +37,25 @@ const plugin_manager = function() {
3837
* @param {object} patternlab
3938
*/
4039
function initializePlugins(patternlab) {
41-
const nodeModulesPath = path.join(process.cwd(), 'node_modules');
42-
const foundPlugins = findModules(nodeModulesPath, isPlugin);
40+
const foundPlugins = Object.keys(patternlab.config.plugins || {});
4341
foundPlugins.forEach(plugin => {
44-
logger.info(`Found plugin: plugin-${plugin.name}`);
42+
logger.info(`Found plugin: ${plugin}`);
4543
logger.info(`Attempting to load and initialize plugin.`);
46-
const pluginModule = loadPlugin(plugin.modulePath);
44+
const pluginModule = loadPlugin(
45+
path.join(process.cwd(), 'node_modules', plugin)
46+
);
4747
pluginModule(patternlab);
4848
});
4949
}
5050

51-
async function raiseEvent(patternlab, eventName, ...args) {
51+
async function raiseEvent(patternlab, eventName, args) {
5252
patternlab.events.emit(eventName, args);
53-
5453
await (async function() {
5554
const hookHandlers = (patternlab.hooks[eventName] || []).map(h =>
5655
h(args)
5756
);
5857

59-
const results = await Promise.all(hookHandlers);
58+
await Promise.all(hookHandlers);
6059
})();
6160
}
6261

packages/core/test/object_factory_tests.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ tap.test('test Pattern capitalizes patternDisplayName correctly', function(
178178
test.end();
179179
});
180180

181-
tap.test('test Pattern get dir level no sepatated pattern directory', function(
181+
tap.test('test Pattern get dir level no separated pattern directory', function(
182182
test
183183
) {
184184
var p = new Pattern('00-atoms/00-global/00-colors-alt.mustache', { d: 123 });
@@ -198,24 +198,36 @@ tap.test('test Pattern get dir level no sepatated pattern directory', function(
198198
});
199199

200200
tap.test(
201-
'test Pattern get dir level with sepatated pattern directory',
201+
'test Pattern get dir level with separated pattern directory',
202202
function(test) {
203203
var p = new Pattern(
204204
'00-atoms/00-global/00-colors-alt/colors-alt.mustache',
205205
{ d: 123 }
206206
);
207207
test.equals(p.getDirLevel(0, { hasDir: true, dirLevel: 3 }), '00-atoms');
208208
test.equals(p.getDirLevel(1, { hasDir: true, dirLevel: 3 }), '00-global');
209-
test.equals(p.getDirLevel(3, { hasDir: true, dirLevel: 3 }), '');
209+
test.equals(
210+
p.getDirLevel(3, { hasDir: true, dirLevel: 3 }),
211+
'00-colors-alt'
212+
);
210213
var p = new Pattern('00-atoms/00-colors-alt/colors-alt.mustache', {
211214
d: 123,
212215
});
213216
test.equals(p.getDirLevel(0, { hasDir: true, dirLevel: 2 }), '00-atoms');
214-
test.equals(p.getDirLevel(1, { hasDir: true, dirLevel: 2 }), '00-atoms');
217+
test.equals(
218+
p.getDirLevel(1, { hasDir: true, dirLevel: 2 }),
219+
'00-colors-alt'
220+
);
215221
test.equals(p.getDirLevel(3, { hasDir: true, dirLevel: 2 }), '');
216222
var p = new Pattern('00-colors-alt/colors-alt.mustache', { d: 123 });
217-
test.equals(p.getDirLevel(0, { hasDir: true, dirLevel: 1 }), '');
218-
test.equals(p.getDirLevel(1, { hasDir: true, dirLevel: 1 }), '');
223+
test.equals(
224+
p.getDirLevel(0, { hasDir: true, dirLevel: 1 }),
225+
'00-colors-alt'
226+
);
227+
test.equals(
228+
p.getDirLevel(1, { hasDir: true, dirLevel: 1 }),
229+
'00-colors-alt'
230+
);
219231
test.equals(p.getDirLevel(3, { hasDir: true, dirLevel: 1 }), '');
220232
test.end();
221233
}

packages/create/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "create-pattern-lab",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "",
55
"bin": "index.js",
66
"main": "index.js",
77
"scripts": {},
88
"dependencies": {
9-
"@pattern-lab/cli": "^1.0.3"
9+
"@pattern-lab/cli": "^1.0.4"
1010
},
1111
"author": "",
1212
"license": "MIT",

packages/development-edition-engine-handlebars/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@pattern-lab/development-edition-engine-handlebars",
33
"private": true,
4-
"version": "0.1.6",
4+
"version": "0.1.7",
55
"description": "The tree of components we use to test, develop and validate the Handlebars engine",
66
"scripts": {
77
"pl:build": "patternlab build --config ./patternlab-config.json",
@@ -27,12 +27,12 @@
2727
"node": ">=10.0"
2828
},
2929
"dependencies": {
30-
"@pattern-lab/cli": "^1.0.3",
31-
"@pattern-lab/core": "^3.0.4",
30+
"@pattern-lab/cli": "^1.0.4",
31+
"@pattern-lab/core": "^3.0.5",
3232
"@pattern-lab/engine-handlebars": "^2.0.2",
3333
"@pattern-lab/engine-mustache": "^2.0.1",
34-
"@pattern-lab/plugin-tab": "^2.0.3",
34+
"@pattern-lab/plugin-tab": "^2.0.4",
3535
"@pattern-lab/starterkit-mustache-demo": "^5.0.0",
36-
"@pattern-lab/uikit-workshop": "^1.0.7"
36+
"@pattern-lab/uikit-workshop": "^1.0.8"
3737
}
3838
}

packages/development-edition-engine-handlebars/source/_patterns/atoms/swatches/swatch.hbs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)