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

Remove pattern states #620

Merged
merged 3 commits into from
Mar 21, 2017
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
20 changes: 0 additions & 20 deletions core/lib/pattern_assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,7 @@ var pattern_assembler = function () {
}
}

/*
* Deprecated in favor of .md 'status' frontmatter inside a pattern. Still used for unit tests at this time.
* Will be removed in future versions
*/
function setState(pattern, patternlab, displayDeprecatedWarning) {
if (patternlab.config.patternStates && patternlab.config.patternStates[pattern.patternPartial]) {

if (displayDeprecatedWarning) {
plutils.error("Deprecation Warning: Using patternlab-config.json patternStates object will be deprecated in favor of the state frontmatter key associated with individual pattern markdown files.");
console.log("This feature will still work in it's current form this release (but still be overridden by the new parsing method), and will be removed in the future.");
}

pattern.patternState = patternlab.config.patternStates[pattern.patternPartial];
}
}

function addPattern(pattern, patternlab) {

Expand Down Expand Up @@ -313,9 +299,6 @@ var pattern_assembler = function () {
return currentPattern;
}

//see if this file has a state
setState(currentPattern, patternlab, true);

//look for a json file for this template
try {
var jsonFilename = path.resolve(patternsPath, currentPattern.subdir, currentPattern.fileName + ".json");
Expand Down Expand Up @@ -571,9 +554,6 @@ var pattern_assembler = function () {
find_list_items: function (pattern) {
return pattern.findListItems();
},
setPatternState: function (pattern, patternlab, displayDeprecatedWarning) {
setState(pattern, patternlab, displayDeprecatedWarning);
},
addPattern: function (pattern, patternlab) {
addPattern(pattern, patternlab);
},
Expand Down
2 changes: 2 additions & 0 deletions core/lib/patternlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ function checkConfiguration(patternlab) {
* Finds and calls the main method of any found plugins.
* @param patternlab - global data store
*/

//todo, move this to plugin_manager
function initializePlugins(patternlab) {

if (!patternlab.config.plugins) { return; }
Expand Down
23 changes: 19 additions & 4 deletions core/lib/plugin_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,25 @@ var plugin_manager = function (config, configPath) {
if (!diskConfig.plugins) {
diskConfig.plugins = {};
}
diskConfig.plugins[pluginName] = {
enabled: true,
initialized: false
};

if (!diskConfig.plugins[pluginName]) {
diskConfig.plugins[pluginName] = {
enabled: true,
initialized: false,
options: {}
};
}

const pluginPathConfig = path.resolve(pluginPath, 'config.json');
try {
var pluginConfigJSON = require(pluginPathConfig);
if (!diskConfig.plugins[pluginName].options) {

diskConfig.plugins[pluginName].options = pluginConfigJSON;
}
} catch (ex) {
//a config.json file is not required at this time
}

//write config entry back
fs.outputFileSync(path.resolve(configPath), JSON.stringify(diskConfig, null, 2));
Expand Down
2 changes: 0 additions & 2 deletions patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
"ishMinimum": "240",
"ishMaximum": "2600",
"patternStateCascade": ["inprogress", "inreview", "complete"],
"patternStates": {
},
"patternExportPatternPartials": [],
"patternExportDirectory": "./pattern_exports/",
"cacheBust": true,
Expand Down
43 changes: 0 additions & 43 deletions test/pattern_assembler_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,49 +456,6 @@ tap.test('processPatternRecursive - ensure deep-nesting works', function(test) {
test.end();
});

tap.test('setState - applies any patternState matching the pattern', function(test) {
//arrange
var pa = require('../core/lib/pattern_assembler');
var pattern_assembler = new pa();
var patternlab = {};
patternlab.config = {};
patternlab.config.patternStates = {};
patternlab.config.patternStates["pages-homepage-emergency"] = "inprogress";

var pattern = {
patternPartial: "pages-homepage-emergency"
};

//act
pattern_assembler.setPatternState(pattern, patternlab);

//assert
test.equals(pattern.patternState, "inprogress");
test.end();
});

tap.test('setState - does not apply any patternState if nothing matches the pattern', function(test) {
//arrange
var pa = require('../core/lib/pattern_assembler');
var pattern_assembler = new pa();
var patternlab = {};
patternlab.config = {};
patternlab.config.patternStates = {};
patternlab.config.patternStates["pages-homepage-emergency"] = "inprogress";

var pattern = {
key: "pages-homepage",
patternState: ""
};

//act
pattern_assembler.setPatternState(pattern, patternlab);

//assert
test.equals(pattern.patternState, "");
test.end();
});

tap.test('parseDataLinks - replaces found link.* data for their expanded links', function(test) {
//arrange
var diveSync = require('diveSync');
Expand Down