Skip to content

Major UIKit Refactor Updates #1008

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 15 commits into from
Aug 20, 2019
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
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 2017,
"sourceType": "module"
},
"globals": {},
Expand Down
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
language: node_js

addons:
chrome: stable

before_install:
- phantomjs --version

Expand All @@ -13,6 +16,8 @@ before_script:
- lerna add @pattern-lab/engine-twig --scope=@pattern-lab/core
- lerna add @pattern-lab/engine-react --scope=@pattern-lab/core

script: travis_wait npm run test

branches:
only:
- master
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/lib/annotation_exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ const annotations_exporter = function(pl) {
);
} catch (ex) {
logger.debug(
`annotations.js file missing from ${
paths.source.annotations
}. This may be expected if you do not use annotations or are using markdown.`
`annotations.js file missing from ${paths.source.annotations}. This may be expected if you do not use annotations or are using markdown.`
);
return [];
}
Expand All @@ -39,9 +37,7 @@ const annotations_exporter = function(pl) {
return oldAnnotationsJSON.comments;
} catch (ex) {
logger.error(
`There was an error parsing JSON for ${
paths.source.annotations
}annotations.js`
`There was an error parsing JSON for ${paths.source.annotations}annotations.js`
);
return [];
}
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/lib/buildPatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ module.exports = (deletePatternDir, patternlab, additionalData) => {
}
//render all patterns last, so lineageR works
const allPatternsPromise = patternsToBuild.map(pattern =>
compose(pattern, patternlab)
compose(
pattern,
patternlab
)
);
//copy non-pattern files like JavaScript
const allJS = patternsToBuild.map(pattern => {
Expand Down
6 changes: 1 addition & 5 deletions packages/core/src/lib/expandPartials.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ module.exports = function(currentPattern, patternlab) {

//this is what we came here for
logger.debug(
`within ${
currentPattern.patternPartial
}, replacing extendedTemplate partial ${foundPartial} with ${
cleanPartialPattern.patternPartial
}'s extendedTemplate`
`within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate`
);

currentPattern.extendedTemplate = currentPattern.extendedTemplate.replace(
Expand Down
8 changes: 1 addition & 7 deletions packages/core/src/lib/lineage_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,7 @@ const lineage_hunter = function() {
? '<<blank>>'
: lineageRPattern.patternState;
logger.info(
`Found a lower common denominator pattern state: ${
pattern.patternState
} on ${
pattern.patternPartial
}. Setting reverse lineage pattern ${
lineageRPattern.patternPartial
} from ${oldState}`
`Found a lower common denominator pattern state: ${pattern.patternState} on ${pattern.patternPartial}. Setting reverse lineage pattern ${lineageRPattern.patternPartial} from ${oldState}`
);

lineageRPattern.patternState = pattern.patternState;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/list_item_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const list_item_hunter = function() {
return matches.reduce((previousMatchPromise, liMatchStart) => {
return previousMatchPromise.then(() => {
logger.debug(
`found listItem of size ${liMatchStart} inside ${
pattern.patternPartial
}`
`found listItem of size ${liMatchStart} inside ${pattern.patternPartial}`
);

//we found a listitem match
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/lib/loadPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,14 @@ module.exports = function(relPath, patternlab) {

if (listItemsData) {
logger.debug(
`found pattern-specific listitems data for ${
currentPattern.patternPartial
}`
`found pattern-specific listitems data for ${currentPattern.patternPartial}`
);
currentPattern.listitems = listItemsData;
buildListItems(currentPattern);
}
} catch (err) {
logger.warning(
`There was an error parsing sibling listitem JSON for ${
currentPattern.relPath
}`
`There was an error parsing sibling listitem JSON for ${currentPattern.relPath}`
);
logger.warning(err);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/loaduikits.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ module.exports = patternlab => {

if (!configEntry) {
logger.warning(
`Could not find uikit with name uikit-${
kit.name
} defined within patternlab-config.json, or it is not enabled.`
`Could not find uikit with name uikit-${kit.name} defined within patternlab-config.json, or it is not enabled.`
);
return;
}
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/lib/markModifiedPatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ module.exports = function(lastModified, patternlab) {
array.forEach(func);
}
};
const modifiedOrNot = _.groupBy(
patternlab.patterns,
p =>
changes_hunter.needsRebuild(lastModified, p) ? 'modified' : 'notModified'
const modifiedOrNot = _.groupBy(patternlab.patterns, p =>
changes_hunter.needsRebuild(lastModified, p) ? 'modified' : 'notModified'
);

// For all unmodified patterns load their rendered template output
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/lib/object_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ const Pattern = function(relPath, data, patternlab) {
// (rendered!) html file for this pattern, to be shown in the iframe
this.patternLink = this.patternSectionSubtype
? `$${this.name}/index.html`
: patternlab ? this.getPatternLink(patternlab, 'rendered') : null;
: patternlab
? this.getPatternLink(patternlab, 'rendered')
: null;

// The canonical "key" by which this pattern is known. This is the callable
// name of the pattern. UPDATE: this.key is now known as this.patternPartial
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ module.exports = class PatternLab {
if (typeof patternlab.config.paths.source.patternlabFiles === 'string') {
logger.warning('');
logger.warning(
`Configuration key [paths.source.patternlabFiles] inside patternlab-config.json was found as the string '${
patternlab.config.paths.source.patternlabFiles
}'`
`Configuration key [paths.source.patternlabFiles] inside patternlab-config.json was found as the string '${patternlab.config.paths.source.patternlabFiles}'`
);
logger.warning(
'Since Pattern Lab Node Core 3.0.0 this key is an object. Suggest you update this key following this issue: https://github.com/pattern-lab/patternlab-node/issues/683.'
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/processMetaPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ module.exports = function(fileName, metaType, patternlab) {
})
.catch(reason => {
logger.warning(
`Could not find the user-editable template ${fileName}, currently configured to be at ${
patternlab.config.paths.source.meta
}. Your configured path may be incorrect (check paths.source.meta in your config file), the file may have been deleted, or it may have been left in the wrong place during a migration or update.`
`Could not find the user-editable template ${fileName}, currently configured to be at ${patternlab.config.paths.source.meta}. Your configured path may be incorrect (check paths.source.meta in your config file), the file may have been deleted, or it may have been left in the wrong place during a migration or update.`
);
logger.warning(reason);
});
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/pseudopattern_hunter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
);
} catch (err) {
logger.warning(
`There was an error parsing pseudopattern JSON for ${
currentPattern.relPath
}`
`There was an error parsing pseudopattern JSON for ${currentPattern.relPath}`
);
logger.warning(err);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/readDocumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ module.exports = function(pattern, patternlab) {
// do nothing when file not found
if (err.code !== 'ENOENT') {
logger.warning(
`'there was an error setting pattern keys after markdown parsing of the companion file for pattern ${
pattern.patternPartial
}`
`'there was an error setting pattern keys after markdown parsing of the companion file for pattern ${pattern.patternPartial}`
);
logger.warning(err);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ const server = patternlab => {
setTimeout(() => {
try {
liveServer.start(liveServerConfig);
resolveMsg = `Pattern Lab is being served from http://127.0.0.1:${
liveServerConfig.port
}`;
resolveMsg = `Pattern Lab is being served from http://127.0.0.1:${liveServerConfig.port}`;
logger.info(resolveMsg);
} catch (e) {
const err = `Pattern Lab serve failed to start: ${e}`;
Expand Down
8 changes: 2 additions & 6 deletions packages/core/src/lib/starterkit_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,12 @@ const starterkit_manager = function(config) {
if (kitPathDirExists) {
if (clean) {
logger.info(
`Deleting contents of ${
paths.source.root
} prior to starterkit load.`
`Deleting contents of ${paths.source.root} prior to starterkit load.`
);
fs.emptyDirSync(paths.source.root);
} else {
logger.info(
`Overwriting contents of ${
paths.source.root
} during starterkit load.`
`Overwriting contents of ${paths.source.root} during starterkit load.`
);
}

Expand Down
38 changes: 9 additions & 29 deletions packages/core/src/lib/ui_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ const ui_builder = function() {
isOmitted = uikitExcludePattern(pattern, uikit);
if (isOmitted) {
logger.info(
`Omitting ${
pattern.patternPartial
} from styleguide patterns because its pattern state or tag is excluded within ${
uikit.name
}.`
`Omitting ${pattern.patternPartial} from styleguide patterns because its pattern state or tag is excluded within ${uikit.name}.`
);
return true;
}
Expand All @@ -88,9 +84,7 @@ const ui_builder = function() {
isOmitted = pattern.isPattern && pattern.fileName.charAt(0) === '_';
if (isOmitted) {
logger.info(
`Omitting ${
pattern.patternPartial
} from styleguide patterns because it has an underscore prefix.`
`Omitting ${pattern.patternPartial} from styleguide patterns because it has an underscore prefix.`
);
return true;
}
Expand All @@ -99,9 +93,7 @@ const ui_builder = function() {
isOmitted = pattern.patternPartial === patternlab.config.defaultPattern;
if (isOmitted) {
logger.info(
`Omitting ${
pattern.patternPartial
} from styleguide patterns because it is defined as a defaultPattern.`
`Omitting ${pattern.patternPartial} from styleguide patterns because it is defined as a defaultPattern.`
);
patternlab.defaultPattern = pattern;
return true;
Expand All @@ -113,9 +105,7 @@ const ui_builder = function() {
pattern.relPath.indexOf(path.sep + '_') > -1;
if (isOmitted) {
logger.info(
`Omitting ${
pattern.patternPartial
} from styleguide patterns because its contained within an underscored directory.`
`Omitting ${pattern.patternPartial} from styleguide patterns because its contained within an underscored directory.`
);
return true;
}
Expand All @@ -124,9 +114,7 @@ const ui_builder = function() {
isOmitted = pattern.isMetaPattern;
if (isOmitted) {
logger.info(
`Omitting ${
pattern.patternPartial
} from styleguide patterns because its a meta pattern.`
`Omitting ${pattern.patternPartial} from styleguide patterns because its a meta pattern.`
);
return true;
}
Expand Down Expand Up @@ -212,9 +200,7 @@ const ui_builder = function() {

if (!patternType) {
logger.error(
`Could not find patternType ${
pattern.patternType
}. This is a critical error.`
`Could not find patternType ${pattern.patternType}. This is a critical error.`
);
}

Expand All @@ -236,9 +222,7 @@ const ui_builder = function() {

if (!patternSubType) {
logger.error(
`Could not find patternType ${pattern.patternType}-${
pattern.patternType
}. This is a critical error.`
`Could not find patternType ${pattern.patternType}-${pattern.patternType}. This is a critical error.`
);
}

Expand Down Expand Up @@ -348,9 +332,7 @@ const ui_builder = function() {
const patternType = getPatternType(patternlab, pattern);
if (!patternType) {
logger.error(
`Could not find patternType ${
pattern.patternType
}. This is a critical error.`
`Could not find patternType ${pattern.patternType}. This is a critical error.`
);
}

Expand Down Expand Up @@ -867,9 +849,7 @@ const ui_builder = function() {
);
} catch (err) {
logger.error(
`Could not load one or more styleguidekit assets from ${
paths.source.styleguide
}`
`Could not load one or more styleguidekit assets from ${paths.source.styleguide}`
);
}
fs.outputFileSync(
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/lib/watchPatternLabFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ const watchPatternLabFiles = (
});

logger.info(
`Pattern Lab is watching for changes to files under ${
assetDirectories.source.root
}`
`Pattern Lab is watching for changes to files under ${assetDirectories.source.root}`
);
return Promise.resolve();
};
Expand Down
5 changes: 5 additions & 0 deletions packages/edition-twig/.patternlabrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
buildDir: __dirname + '/public',
wwwDir: __dirname + '/public/',
publicPath: '/public/styleguide/',
};
1 change: 1 addition & 0 deletions packages/edition-twig/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
],
"main": "patternlab-config.json",
"scripts": {
"build:uikit": "npm run build --prefix node_modules/@pattern-lab/uikit-workshop -- --patternlabrc $INIT_CWD/.patternlabrc.js",
"build": "patternlab build --config ./patternlab-config.json",
"help": "patternlab --help",
"install": "patternlab install --config ./patternlab-config.json",
Expand Down
Loading