Skip to content
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

BREAKING-CHANGE: Deprecate ordering by file-prefix ##- #1238

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ packages/**/annotations.js
*.json
*.md
*.scss

**/_head.*
**/_foot.*
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"private": true,
"scripts": {
"postinstall": "lerna run postbootstrap",
"postinstall": "lerna run postbootstrap && lerna link --force-local",
"setup": "yarn",
"build:uikit": "cd packages/uikit-workshop && npm run build",
"precommit": "pretty-quick --staged",
Expand All @@ -41,7 +41,7 @@
"publish": "npx lerna publish -m \"[skip travis] chore(release): publish %s\"",
"postpublish": "auto release",
"preview:docs": "cd packages/docs && yarn production",
"preview:hbs": "cd packages/development-edition-engine-handlebars && npx patternlab add --starterkits @pattern-lab/starterkit-handlebars-vanilla && npm run pl:build"
"preview:hbs": "cd packages/development-edition-engine-handlebars && npx patternlab add --starterkits @pattern-lab/starterkit-handlebars-demo && npm run pl:build"
},
"nyc": {
"exclude": [
Expand All @@ -50,5 +50,6 @@
"packages/core/test",
"packages/live-server"
]
}
},
"name": "patternlab-node-main"
}
4 changes: 2 additions & 2 deletions packages/cli/test/fixtures/patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"node_modules/@pattern-lab/uikit-workshop/views/partials/general-footer.mustache",
"patternSection":
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSection.mustache",
"patternSectionSubtype":
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSectionSubtype.mustache",
"patternSectionSubgroup":
"node_modules/@pattern-lab/uikit-workshop/views/partials/patternSectionSubgroup.mustache",
"viewall":
"node_modules/@pattern-lab/uikit-workshop/views/viewall.mustache"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/docs/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Emitted after patterns are iterated over to gather data about them. Right before

#### `EVENTS~PATTERNLAB_BUILD_GLOBAL_DATA_END`

Emitted after global `data.json` and `listitems.json` are read, and the supporting Pattern Lab templates are loaded into memory (header, footer, patternSection, patternSectionSubType, viewall). Right before patterns are iterated over to gather data about them.
Emitted after global `data.json` and `listitems.json` are read, and the supporting Pattern Lab templates are loaded into memory (header, footer, patternSection, patternSectionSubgroup, viewall). Right before patterns are iterated over to gather data about them.

**Kind**: inner property of [<code>EVENTS</code>](#exp_module_Events--EVENTS)
**Properties**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"views/partials/general-footer.mustache",
"patternSection":
"views/partials/patternSection.mustache",
"patternSectionSubtype":
"views/partials/patternSectionSubtype.mustache",
"patternSectionSubgroup":
"views/partials/patternSectionSubgroup.mustache",
"viewall":
"views/viewall.mustache"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/buildFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let render = require('./render'); //eslint-disable-line prefer-const
/**
* Builds footer HTML from the general footer and user-defined footer
* @param patternlab - global data store
* @param patternPartial - the partial key to build this for, either viewall-patternPartial or a viewall-patternType-all
* @param patternPartial - the partial key to build this for, either viewall-patternPartial or a viewall-patternGroup-all
* @returns A promise which resolves with the HTML
*/
module.exports = function(patternlab, patternPartial, uikit) {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/buildPatterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => {
//perhaps we can check for a convention like [uikitname]_00-head.mustache, and if found, add them to patternlab.uikits[uikitname].userFoot
//then, if present, use those during compose()
const headPatternPromise = processMetaPattern(
`_00-head.${patternlab.config.patternExtension}`,
`_head.${patternlab.config.patternExtension}`,
'userHead',
patternlab
);
const footPatternPromise = processMetaPattern(
`_01-foot.${patternlab.config.patternExtension}`,
`_foot.${patternlab.config.patternExtension}`,
'userFoot',
patternlab
);
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/lib/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const parseLink = require('./parseLink');
const render = require('./render');
const uikitExcludePattern = require('./uikitExcludePattern');
const pm = require('./plugin_manager');
const pluginMananger = new pm();
const pluginManager = new pm();

const Pattern = require('./object_factory').Pattern;
const CompileState = require('./object_factory').CompileState;
Expand All @@ -32,7 +32,7 @@ module.exports = async function(pattern, patternlab) {
pattern.patternLineageEExists =
pattern.patternLineageExists || pattern.patternLineageRExists;

await pluginMananger.raiseEvent(
await pluginManager.raiseEvent(
patternlab,
events.PATTERNLAB_PATTERN_BEFORE_DATA_MERGE,
patternlab,
Expand Down Expand Up @@ -116,13 +116,13 @@ module.exports = async function(pattern, patternlab) {
pattern.patternLineageExists || pattern.patternLineageRExists,
patternDesc: pattern.patternDescExists ? pattern.patternDesc : '',
patternBreadcrumb:
pattern.patternGroup === pattern.patternSubGroup
pattern.patternGroup === pattern.patternSubgroup
? {
patternType: pattern.patternGroup,
patternGroup: pattern.patternGroup,
}
: {
patternType: pattern.patternGroup,
patternSubtype: pattern.patternSubGroup,
patternGroup: pattern.patternGroup,
patternSubgroup: pattern.patternSubgroup,
},
patternExtension: pattern.fileExtension.substr(1), //remove the dot because styleguide asset default adds it for us
patternName: pattern.patternName,
Expand Down Expand Up @@ -175,7 +175,7 @@ module.exports = async function(pattern, patternlab) {
///////////////
// WRITE FILES
///////////////
await pluginMananger.raiseEvent(
await pluginManager.raiseEvent(
patternlab,
events.PATTERNLAB_PATTERN_WRITE_BEGIN,
patternlab,
Expand All @@ -190,7 +190,7 @@ module.exports = async function(pattern, patternlab) {
uikit.outputDir
);

await pluginMananger.raiseEvent(
await pluginManager.raiseEvent(
patternlab,
events.PATTERNLAB_PATTERN_WRITE_END,
patternlab,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const EVENTS = Object.freeze({
PATTERNLAB_PATTERN_ITERATION_END: 'patternlab-pattern-iteration-end',

/**
* @desc Emitted after global `data.json` and `listitems.json` are read, and the supporting Pattern Lab templates are loaded into memory (header, footer, patternSection, patternSectionSubType, viewall). Right before patterns are iterated over to gather data about them.
* @desc Emitted after global `data.json` and `listitems.json` are read, and the supporting Pattern Lab templates are loaded into memory (header, footer, patternSection, patternSectionSubgroup, viewall). Right before patterns are iterated over to gather data about them.
* @property {object} patternlab - global data store
*/
PATTERNLAB_BUILD_GLOBAL_DATA_END: 'patternlab-build-global-data-end',
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/exportData.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ module.exports = function(patternlab) {

//navItems
output +=
'var navItems = {"patternTypes": ' +
JSON.stringify(patternlab.patternTypes) +
'var navItems = {"patternGroups": ' +
JSON.stringify(patternlab.patternGroups) +
', "ishControlsHide": ' +
JSON.stringify(patternlab.config.ishControlsHide) +
'};' +
Expand Down
83 changes: 42 additions & 41 deletions packages/core/src/lib/loadPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ module.exports = function(relPath, patternlab) {
"It's strongly suggested to not deviate from the following structure under _patterns/"
);
logger.warning(
'[patternType]/[patternSubtype]/[patternName].[patternExtension]'
'[patternGroup]/[patternSubgroup]/[patternName].[patternExtension]'
);
logger.warning('or');
logger.warning(
'[patternType]/[patternSubtype]/[patternName]/[patternName].[patternExtension]'
'[patternGroup]/[patternSubgroup]/[patternName]/[patternName].[patternExtension]'
);
logger.warning('');
logger.warning(
Expand All @@ -53,46 +53,47 @@ module.exports = function(relPath, patternlab) {
logger.warning('');
}

//check if the found file is a top-level markdown file
const fileObject = path.parse(relPath);
if (fileObject.ext === '.md') {
try {
const proposedDirectory = path.resolve(
patternlab.config.paths.source.patterns,
fileObject.dir,
fileObject.name
);
const proposedDirectoryStats = fs.statSync(proposedDirectory);
if (proposedDirectoryStats.isDirectory()) {
const subTypeMarkdownFileContents = fs.readFileSync(
proposedDirectory + '.md',
'utf8'
);
const subTypeMarkdown = markdown_parser.parse(
subTypeMarkdownFileContents
);
const subTypePattern = new Pattern(relPath, null, patternlab);
subTypePattern.patternSectionSubtype = true;
subTypePattern.patternDesc = subTypeMarkdown
? subTypeMarkdown.markdown
: '';
subTypePattern.flatPatternPath =
subTypePattern.flatPatternPath + '-' + subTypePattern.fileName;
subTypePattern.isPattern = false;
subTypePattern.engine = null;
patternlab.subtypePatterns[
subTypePattern.patternPartial
] = subTypePattern;

return subTypePattern;
}
} catch (err) {
// no file exists, meaning it's a pattern markdown file
if (err.code !== 'ENOENT') {
logger.warning(err);
}
}
}
// Check if the found file is a top-level markdown file
// TODO: Rethink this stuff
// if (fileObject.ext === '.md') {
// try {
// const proposedDirectory = path.resolve(
// patternlab.config.paths.source.patterns,
// fileObject.dir,
// fileObject.name
// );
// const proposedDirectoryStats = fs.statSync(proposedDirectory);
// if (proposedDirectoryStats.isDirectory()) {
// const subgroupMarkdownFileContents = fs.readFileSync(
// proposedDirectory + '.md',
// 'utf8'
// );
// const subgroupMarkdown = markdown_parser.parse(
// subgroupMarkdownFileContents
// );
// const subgroupPattern = new Pattern(relPath, null, patternlab);
// subgroupPattern.patternSectionSubgroup = true;
// subgroupPattern.patternDesc = subgroupMarkdown
// ? subgroupMarkdown.markdown
// : '';
// subgroupPattern.flatPatternPath =
// subgroupPattern.flatPatternPath + '-' + subgroupPattern.fileName;
// subgroupPattern.isPattern = false;
// subgroupPattern.engine = null;
// patternlab.subgroupPatterns[
// subgroupPattern.patternPartial
// ] = subgroupPattern;

// return subgroupPattern;
// }
// } catch (err) {
// // no file exists, meaning it's a pattern markdown file
// if (err.code !== 'ENOENT') {
// logger.warning(err);
// }
// }
// }

//extract some information
const filename = fileObject.base;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/loaduikits.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ module.exports = patternlab => {
kit,
paths.source.patternlabFiles.patternSection
),
patternSectionSubType: readModuleFile(
patternSectionSubgroup: readModuleFile(
kit,
paths.source.patternlabFiles.patternSectionSubtype
paths.source.patternlabFiles.patternSectionSubgroup
),
viewAll: readModuleFile(kit, paths.source.patternlabFiles.viewall),
}; // [4]
Expand Down