Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian committed Feb 20, 2021
2 parents 6b4a6fb + baf5bdf commit 6431987
Show file tree
Hide file tree
Showing 59 changed files with 350 additions and 286 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.14.1](https://github.com/pattern-lab/patternlab-node/compare/v5.14.0...v5.14.1) (2021-02-19)


### Bug Fixes

* **demopage:** switched to HTTPS URLs for image placeholders ([#1289](https://github.com/pattern-lab/patternlab-node/issues/1289)) ([e09bf6a](https://github.com/pattern-lab/patternlab-node/commit/e09bf6aae9bad99365b5a01381e0df6de9ddeafe))





# [5.14.0](https://github.com/pattern-lab/patternlab-node/compare/v5.13.3...v5.14.0) (2021-01-12)

**Note:** Version bump only for package patternlab-node
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ If you'd like to see what a front-end project built with Pattern Lab looks like,
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![node (scoped)](https://img.shields.io/node/v/@pattern-lab/core.svg)]()
[![Join the chat at Gitter](https://badges.gitter.im/pattern-lab/node.svg)](https://gitter.im/pattern-lab/node)
[![Join the chat at Discord](https://img.shields.io/badge/Chat-Discord-informational.svg)](https://discord.gg/WPPFAaETQC)

Docs @ [![Netlify Status](https://api.netlify.com/api/v1/badges/d454dbde-02c5-4bd4-8393-4ab75e862b03/deploy-status)](https://app.netlify.com/sites/patternlab-docs-preview/deploys)

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "3.11.0",
"version": "5.14.0",
"version": "5.14.1",
"packages": [
"packages/*"
],
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.14.1](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/v5.14.0...v5.14.1) (2021-02-19)

**Note:** Version bump only for package @pattern-lab/cli






# [5.14.0](https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli/compare/v5.13.3...v5.14.0) (2021-01-12)

**Note:** Version bump only for package @pattern-lab/cli
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@pattern-lab/cli",
"description": "Command-line interface (CLI) for the @pattern-lab/core.",
"version": "5.14.0",
"version": "5.14.1",
"bin": {
"patternlab": "bin/patternlab.js"
},
"author": {
"name": "Patternlab contributors"
},
"dependencies": {
"@pattern-lab/core": "^5.14.0",
"@pattern-lab/core": "^5.14.1",
"@pattern-lab/live-server": "^5.13.0",
"@pattern-lab/starterkit-mustache-base": "3.0.3",
"archiver": "2.1.1",
Expand Down
8 changes: 8 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.14.1](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/v5.14.0...v5.14.1) (2021-02-19)

**Note:** Version bump only for package @pattern-lab/core





# [5.14.0](https://github.com/pattern-lab/patternlab-node/tree/master/packages/core/compare/v5.13.3...v5.14.0) (2021-01-12)

**Note:** Version bump only for package @pattern-lab/core
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@pattern-lab/core",
"description": "Create atomic design systems with Pattern Lab. This is the core API and orchestrator of the ecosystem.",
"version": "5.14.0",
"version": "5.14.1",
"main": "./src/index.js",
"dependencies": {
"@pattern-lab/engine-mustache": "^5.14.0",
Expand All @@ -16,7 +16,7 @@
"js-yaml": "3.13.1",
"lodash": "4.17.20",
"markdown-it": "6.0.1",
"node-fetch": "1.6.0",
"node-fetch": "2.6.1",
"recursive-copy": "2.0.8",
"update-notifier": "2.2.0"
},
Expand Down
11 changes: 9 additions & 2 deletions packages/core/src/lib/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const parseLink = require('./parseLink');
const render = require('./render');
const uikitExcludePattern = require('./uikitExcludePattern');
const pm = require('./plugin_manager');
const dataMerger = require('./dataMerger');
const pluginManager = new pm();

const Pattern = require('./object_factory').Pattern;
Expand Down Expand Up @@ -56,8 +57,14 @@ module.exports = async function(pattern, patternlab) {
'listitems.json + any pattern listitems.json'
);

allData = _.merge({}, patternlab.data, pattern.jsonFileData);
allData = _.merge({}, allData, allListItems);
allData = dataMerger(
patternlab.data,
pattern.jsonFileData,
patternlab.config
);
// _.merge({}, patternlab.data, pattern.jsonFileData);
allData = dataMerger(allData, allListItems, patternlab.config);
// _.merge({}, allData, allListItems);
allData.cacheBuster = patternlab.cacheBuster;
allData.patternPartial = pattern.patternPartial;

Expand Down
32 changes: 32 additions & 0 deletions packages/core/src/lib/dataMerger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const _ = require('lodash');

/**
* Merges two objects depending on the configuration and will either merge
* arrays and only replaces items on the index or replace the entire
* collection of the different parameters
*
* @param {*} dataObject the object that contains the main data
* @param {*} dataToMergeWithObject the object that should be merged with the original data
* @param {*} patternlabConfig the patternlab configuration object
*/
module.exports = function(dataObject, dataToMergeWithObject, patternlabConfig) {
return _.mergeWith(
{},
dataObject,
dataToMergeWithObject,
(objValue, srcValue) => {
if (
_.isArray(objValue) &&
// If the parameter is not available after updating pattern lab but
// not the patternlab-config it should not override arrays.
patternlabConfig.hasOwnProperty('patternMergeVariantArrays') &&
!patternlabConfig.patternMergeVariantArrays
) {
return srcValue;
}
// Lodash will only check for "undefined" and eslint needs a consistent
// return so do not remove
return undefined;
}
);
};
13 changes: 12 additions & 1 deletion packages/core/src/lib/object_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,19 @@ const Pattern = function(
this.patternGroupData.order = info.patternSubgroupOrder;
}

// TODO: Remove the following when ordering by file prefix gets obsolete
if (prefixMatcherDeprecationCheckOrder.test(this.fileName)) {
if (this.fileName.indexOf('~') === -1) {
this.order = this.setPatternOrderDataForInfo(this.fileName);
} else {
this.variantOrder = this.setPatternOrderDataForInfo(this.fileName);
}
}

/**
* Determines if this pattern needs to be recompiled.
*
* @ee {@link CompileState}*/
* @see {@link CompileState}*/
this.compileState = null;

/**
Expand Down Expand Up @@ -371,12 +380,14 @@ Pattern.prototype = {
.split(/\/|\\/, 2)
.map((o, i) => {
if (i === 0) {
// TODO: Remove when prefix gets deprecated
info.patternGroupOrder = Pattern.prototype.setPatternOrderDataForInfo(
o
);
}

if (i === 1) {
// TODO: Remove when prefix gets deprecated
info.patternSubgroupOrder = Pattern.prototype.setPatternOrderDataForInfo(
o
);
Expand Down
19 changes: 3 additions & 16 deletions packages/core/src/lib/pseudopattern_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const readDocumentation = require('./readDocumentation');
const lineage_hunter = new lh();
const changes_hunter = new ch();
const yaml = require('js-yaml');
const dataMerger = require('./dataMerger');

const pseudopattern_hunter = function() {};

Expand Down Expand Up @@ -60,24 +61,10 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
}

//extend any existing data with variant data
variantFileData = _.mergeWith(
{},
variantFileData = dataMerger(
currentPattern.jsonFileData,
variantFileData,
(objValue, srcValue) => {
if (
_.isArray(objValue) &&
// If the parameter is not available after updating pattern lab but
// not the patternlab-config it should not override arrays.
patternlab.config.hasOwnProperty('patternMergeVariantArrays') &&
!patternlab.config.patternMergeVariantArrays
) {
return srcValue;
}
// Lodash will only check for "undefined" and eslint needs a consistent
// return so do not remove
return undefined;
}
patternlab.config
);

const variantName = pseudoPatterns[i]
Expand Down
10 changes: 6 additions & 4 deletions packages/core/src/lib/readDocumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = function(pattern, patternlab, isVariant) {
if (markdownObject.order) {
pattern[isVariant ? 'variantOrder' : 'order'] = markdownObject.order;
}
if (markdownObject.hidden) {
if (markdownObject.hasOwnProperty('hidden')) {
pattern.hidden = markdownObject.hidden;
}
if (markdownObject.excludeFromStyleguide) {
Expand Down Expand Up @@ -83,9 +83,10 @@ module.exports = function(pattern, patternlab, isVariant) {
// Read Documentation for Pattern-Group
// Use this approach, since pattern lab is a pattern driven software
try {
const groupRelPath = pattern.relPath.split(path.sep);
const markdownFileNameGroup = path.resolve(
patternlab.config.paths.source.patterns,
path.parse(pattern.subdir).dir || pattern.subdir,
groupRelPath[0] || pattern.subdir,
GROUP_DOC_PREFIX + pattern.patternGroup + FILE_EXTENSION
);
const markdownFileContentsGroup = fs.readFileSync(
Expand Down Expand Up @@ -115,10 +116,11 @@ module.exports = function(pattern, patternlab, isVariant) {

// Read Documentation for Pattern-Subgroup
try {
const subgroupRelPath = pattern.relPath.split(path.sep);
const markdownFileNameSubgroup = path.resolve(
patternlab.config.paths.source.patterns,
path.parse(pattern.subdir).dir,
path.parse(pattern.subdir).base,
subgroupRelPath[0],
subgroupRelPath[1],
GROUP_DOC_PREFIX + pattern.patternSubgroup + FILE_EXTENSION
);
const markdownFileContentsSubgroup = fs.readFileSync(
Expand Down
3 changes: 3 additions & 0 deletions packages/core/test/files/_patterns/orderTest/_orderTest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
order: 1
---
Empty file.
3 changes: 3 additions & 0 deletions packages/core/test/files/_patterns/orderTest/b/_b.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
order: 2
---
Empty file.
3 changes: 3 additions & 0 deletions packages/core/test/files/_patterns/orderTest/c/_c.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
order: -1
---
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions packages/core/test/files/_patterns/orderTest/orderTest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
order: 1
---
62 changes: 62 additions & 0 deletions packages/core/test/loadPattern_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,65 @@ tap.test(
test.end();
}
);

tap.test(
'loadPattern - group and subgroup ordering will be taken from markdown files',
test => {
//arrange
const patternlab = util.fakePatternLab(patterns_dir);

const basePatternAPath = path.join('orderTest', 'a', 'a-test.mustache');
const basePatternBPath = path.join('orderTest', 'b', 'b-test.mustache');
const basePatternCPath = path.join(
'orderTest',
'c',
'subfolder',
'subfolder.mustache'
);

//act
const resultPatternA = loadPattern(basePatternAPath, patternlab);
const resultPatternB = loadPattern(basePatternBPath, patternlab);
const resultPatternC = loadPattern(basePatternCPath, patternlab);

//assert
console.log(resultPatternA.patternGroupData.order);
test.same(
resultPatternA.patternGroupData.order,
1,
'Pattern group should be loaded as 1'
);
console.log(resultPatternA.patternSubgroupData.order || 0);
test.same(
resultPatternA.patternSubgroupData.order || 0,
0,
'Pattern Subgroup not be availabe and default to 0'
);

console.log(resultPatternB.patternGroupData.order);
test.same(
resultPatternB.patternGroupData.order,
1,
'Pattern group should be loaded as 1'
);
console.log(resultPatternB.patternSubgroupData.order);
test.same(
resultPatternB.patternSubgroupData.order,
2,
'Pattern Subgroup should be loaded as 2'
);

test.same(
resultPatternC.patternGroupData.order,
1,
'Pattern group should be loaded as 1'
);
test.same(
resultPatternC.patternSubgroupData.order,
-1,
'Pattern Subgroup should be loaded as -1'
);

test.end();
}
);
8 changes: 8 additions & 0 deletions packages/create/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.14.1](https://github.com/pattern-lab/patternlab-node/compare/v5.14.0...v5.14.1) (2021-02-19)

**Note:** Version bump only for package create-pattern-lab





# [5.14.0](https://github.com/pattern-lab/patternlab-node/compare/v5.13.3...v5.14.0) (2021-01-12)

**Note:** Version bump only for package create-pattern-lab
Expand Down
4 changes: 2 additions & 2 deletions packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "create-pattern-lab",
"version": "5.14.0",
"version": "5.14.1",
"description": "",
"bin": "index.js",
"main": "index.js",
"scripts": {},
"dependencies": {
"@pattern-lab/cli": "^5.14.0"
"@pattern-lab/cli": "^5.14.1"
},
"author": "",
"license": "MIT",
Expand Down
8 changes: 8 additions & 0 deletions packages/development-edition-engine-handlebars/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [5.14.1](https://github.com/pattern-lab/patternlab-node/compare/v5.14.0...v5.14.1) (2021-02-19)

**Note:** Version bump only for package @pattern-lab/development-edition-engine-handlebars





# [5.14.0](https://github.com/pattern-lab/patternlab-node/compare/v5.13.3...v5.14.0) (2021-01-12)

**Note:** Version bump only for package @pattern-lab/development-edition-engine-handlebars
Expand Down
Loading

0 comments on commit 6431987

Please sign in to comment.